optimized-react-component-library-xyz123 3.3.2 → 3.4.1
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.js +247 -245
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +245 -243
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -377,7 +377,188 @@ var PreviewCheckboxGroup = ({
|
|
|
377
377
|
};
|
|
378
378
|
|
|
379
379
|
// src/components/input-components/TextAreaStandard/TextAreaStandard.tsx
|
|
380
|
+
var import_react7 = require("react");
|
|
381
|
+
|
|
382
|
+
// src/hooks/useCookieConsent/useCookieConsent.ts
|
|
380
383
|
var import_react3 = require("react");
|
|
384
|
+
|
|
385
|
+
// src/helpers/cookieHandler/cookieHandler.ts
|
|
386
|
+
var getCookie = (name) => {
|
|
387
|
+
const match = document.cookie.match(new RegExp("(^| )" + name + "=([^;]+)"));
|
|
388
|
+
return match ? match[2] : null;
|
|
389
|
+
};
|
|
390
|
+
var setCookie = (name, value, expirationDate) => {
|
|
391
|
+
let cookieString = `${name}=${value}; path=/; SameSite=Strict`;
|
|
392
|
+
if (expirationDate) {
|
|
393
|
+
cookieString += `; expires=${expirationDate.toUTCString()}`;
|
|
394
|
+
}
|
|
395
|
+
if (window.location.protocol === "https:") {
|
|
396
|
+
cookieString += "; Secure";
|
|
397
|
+
}
|
|
398
|
+
document.cookie = cookieString;
|
|
399
|
+
};
|
|
400
|
+
var removeCookie = (name) => {
|
|
401
|
+
const pastDate = /* @__PURE__ */ new Date(0);
|
|
402
|
+
setCookie(name, "", pastDate);
|
|
403
|
+
};
|
|
404
|
+
var createCookieConsent = (config) => {
|
|
405
|
+
const { cookieName, choiceKey, expiryYears = 1 } = config;
|
|
406
|
+
const acceptCookies = () => {
|
|
407
|
+
const expires = /* @__PURE__ */ new Date();
|
|
408
|
+
expires.setFullYear(expires.getFullYear() + expiryYears);
|
|
409
|
+
setCookie(cookieName, "true", expires);
|
|
410
|
+
localStorage.setItem(cookieName, "true");
|
|
411
|
+
};
|
|
412
|
+
const rejectCookies = () => {
|
|
413
|
+
removeCookie(cookieName);
|
|
414
|
+
localStorage.removeItem(cookieName);
|
|
415
|
+
sessionStorage.setItem(choiceKey, "true");
|
|
416
|
+
};
|
|
417
|
+
const areCookiesAccepted = () => getCookie(cookieName) === "true";
|
|
418
|
+
const hasChoiceBeenMade = () => sessionStorage.getItem(choiceKey) === "true";
|
|
419
|
+
const clearChoiceFromSession = () => sessionStorage.removeItem(choiceKey);
|
|
420
|
+
return {
|
|
421
|
+
acceptCookies,
|
|
422
|
+
rejectCookies,
|
|
423
|
+
areCookiesAccepted,
|
|
424
|
+
hasChoiceBeenMade,
|
|
425
|
+
clearChoiceFromSession
|
|
426
|
+
};
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
// src/hooks/useCookieConsent/useCookieConsent.ts
|
|
430
|
+
var useCookieConsent = ({
|
|
431
|
+
cookieName,
|
|
432
|
+
choiceKey,
|
|
433
|
+
expiryYears = 1,
|
|
434
|
+
onConsentChange
|
|
435
|
+
}) => {
|
|
436
|
+
const {
|
|
437
|
+
acceptCookies,
|
|
438
|
+
rejectCookies,
|
|
439
|
+
areCookiesAccepted,
|
|
440
|
+
hasChoiceBeenMade,
|
|
441
|
+
clearChoiceFromSession
|
|
442
|
+
} = (0, import_react3.useMemo)(
|
|
443
|
+
() => createCookieConsent({
|
|
444
|
+
cookieName,
|
|
445
|
+
choiceKey,
|
|
446
|
+
expiryYears
|
|
447
|
+
}),
|
|
448
|
+
[cookieName, choiceKey, expiryYears]
|
|
449
|
+
);
|
|
450
|
+
const [showBanner, setShowBanner] = (0, import_react3.useState)(false);
|
|
451
|
+
const handleCookieStateChange = (0, import_react3.useCallback)(() => {
|
|
452
|
+
const cookiesNowAccepted = areCookiesAccepted();
|
|
453
|
+
if (onConsentChange) {
|
|
454
|
+
onConsentChange(cookiesNowAccepted);
|
|
455
|
+
}
|
|
456
|
+
setShowBanner(false);
|
|
457
|
+
}, [areCookiesAccepted, onConsentChange]);
|
|
458
|
+
(0, import_react3.useEffect)(() => {
|
|
459
|
+
const cookiesAccepted = areCookiesAccepted();
|
|
460
|
+
const choiceMade = hasChoiceBeenMade();
|
|
461
|
+
setShowBanner(!cookiesAccepted && !choiceMade);
|
|
462
|
+
if (cookiesAccepted && onConsentChange) {
|
|
463
|
+
onConsentChange(true);
|
|
464
|
+
}
|
|
465
|
+
const handleShowBannerEvent = () => {
|
|
466
|
+
clearChoiceFromSession();
|
|
467
|
+
setShowBanner(true);
|
|
468
|
+
};
|
|
469
|
+
window.addEventListener("showCookieBanner", handleShowBannerEvent);
|
|
470
|
+
return () => {
|
|
471
|
+
window.removeEventListener("showCookieBanner", handleShowBannerEvent);
|
|
472
|
+
};
|
|
473
|
+
}, [areCookiesAccepted, hasChoiceBeenMade, clearChoiceFromSession, onConsentChange]);
|
|
474
|
+
return {
|
|
475
|
+
showBanner,
|
|
476
|
+
handleCookieStateChange,
|
|
477
|
+
acceptCookies,
|
|
478
|
+
rejectCookies
|
|
479
|
+
};
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
// src/hooks/useDebouncedValue/useDebouncedValue.ts
|
|
483
|
+
var import_react4 = require("react");
|
|
484
|
+
var useDebouncedValue = (value, delay) => {
|
|
485
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react4.useState)(value);
|
|
486
|
+
(0, import_react4.useEffect)(() => {
|
|
487
|
+
const timeoutId = window.setTimeout(() => {
|
|
488
|
+
setDebouncedValue(value);
|
|
489
|
+
}, delay);
|
|
490
|
+
return () => window.clearTimeout(timeoutId);
|
|
491
|
+
}, [value, delay]);
|
|
492
|
+
return debouncedValue;
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
// src/hooks/useFormStatusModal/useFormStatusModal.ts
|
|
496
|
+
var React = __toESM(require("react"));
|
|
497
|
+
var useFormStatusModal = (formStatus, handleModalOpen, handleModalClose, mainSelector = "#main-content") => {
|
|
498
|
+
React.useEffect(() => {
|
|
499
|
+
if (formStatus === "loading") {
|
|
500
|
+
handleModalOpen();
|
|
501
|
+
}
|
|
502
|
+
if (formStatus === "success" || formStatus === "failed") {
|
|
503
|
+
setTimeout(() => {
|
|
504
|
+
handleModalClose();
|
|
505
|
+
}, 1050);
|
|
506
|
+
const main = document.querySelector(mainSelector);
|
|
507
|
+
if (main) main.focus();
|
|
508
|
+
}
|
|
509
|
+
}, [formStatus, handleModalOpen, handleModalClose, mainSelector]);
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
// src/hooks/useInputMethodDetection/useInputMethodDetection.ts
|
|
513
|
+
var import_react5 = require("react");
|
|
514
|
+
var useInputMethodDetection = ({
|
|
515
|
+
mouseClassName = "using-mouse",
|
|
516
|
+
keyboardToggleKey = "Tab"
|
|
517
|
+
} = {}) => {
|
|
518
|
+
(0, import_react5.useEffect)(() => {
|
|
519
|
+
const handleMouseDown = () => {
|
|
520
|
+
document.body.classList.add(mouseClassName);
|
|
521
|
+
};
|
|
522
|
+
const handleKeyDown = (event) => {
|
|
523
|
+
if (event.key === keyboardToggleKey) {
|
|
524
|
+
document.body.classList.remove(mouseClassName);
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
document.addEventListener("mousedown", handleMouseDown);
|
|
528
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
529
|
+
return () => {
|
|
530
|
+
document.removeEventListener("mousedown", handleMouseDown);
|
|
531
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
532
|
+
};
|
|
533
|
+
}, [mouseClassName, keyboardToggleKey]);
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
// src/hooks/usePTSPageTitle/usePTSPageTitle.ts
|
|
537
|
+
var import_react6 = require("react");
|
|
538
|
+
var usePTSPageTitle = ({
|
|
539
|
+
formStatus,
|
|
540
|
+
activeStep,
|
|
541
|
+
applicationContent,
|
|
542
|
+
thankYouBlock,
|
|
543
|
+
steps,
|
|
544
|
+
fallbackTitle = "PTS e-tj\xE4nst"
|
|
545
|
+
}) => {
|
|
546
|
+
const computedTitle = (0, import_react6.useMemo)(() => {
|
|
547
|
+
var _a, _b, _c, _d;
|
|
548
|
+
const baseTitle = (_a = applicationContent == null ? void 0 : applicationContent.pageTitle) != null ? _a : "";
|
|
549
|
+
const thankYouPageTitle = (_b = thankYouBlock == null ? void 0 : thankYouBlock.pageTitle) != null ? _b : "";
|
|
550
|
+
const stepTitle = (_d = (_c = steps == null ? void 0 : steps[Math.max(0, activeStep - 1)]) == null ? void 0 : _c.pageTitle) != null ? _d : "";
|
|
551
|
+
if (formStatus === "success" && thankYouPageTitle) return thankYouPageTitle;
|
|
552
|
+
if (activeStep === 0 && baseTitle) return baseTitle;
|
|
553
|
+
return stepTitle || baseTitle || fallbackTitle;
|
|
554
|
+
}, [formStatus, activeStep, applicationContent, thankYouBlock, steps, fallbackTitle]);
|
|
555
|
+
(0, import_react6.useEffect)(() => {
|
|
556
|
+
document.title = computedTitle;
|
|
557
|
+
}, [computedTitle]);
|
|
558
|
+
return computedTitle;
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
// src/components/input-components/TextAreaStandard/TextAreaStandard.tsx
|
|
381
562
|
var import_dompurify = __toESM(require("dompurify"));
|
|
382
563
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
383
564
|
var InputTextarea = ({
|
|
@@ -386,31 +567,27 @@ var InputTextarea = ({
|
|
|
386
567
|
showPreview = false,
|
|
387
568
|
activatedLanguage
|
|
388
569
|
}) => {
|
|
389
|
-
var _a, _b, _c, _d, _e
|
|
570
|
+
var _a, _b, _c, _d, _e;
|
|
390
571
|
const questionId = `question-${question.id}`;
|
|
391
572
|
const inputId = `textarea-${question.id}`;
|
|
392
573
|
const aboutId = `about-${question.id}`;
|
|
393
574
|
const errorId = `error-${question.id}`;
|
|
394
|
-
const
|
|
395
|
-
const
|
|
396
|
-
(0,
|
|
575
|
+
const counterLiveRegionId = `counter-live-${question.id}`;
|
|
576
|
+
const [localAnswer, setLocalAnswer] = (0, import_react7.useState)((_a = question.answer) != null ? _a : "");
|
|
577
|
+
(0, import_react7.useEffect)(() => {
|
|
397
578
|
var _a2;
|
|
398
|
-
|
|
399
|
-
if (incomingFromRedux !== lastSyncedAnswer.current) {
|
|
400
|
-
setLocalAnswer(incomingFromRedux);
|
|
401
|
-
lastSyncedAnswer.current = incomingFromRedux;
|
|
402
|
-
}
|
|
579
|
+
setLocalAnswer((_a2 = question.answer) != null ? _a2 : "");
|
|
403
580
|
}, [question.answer]);
|
|
581
|
+
const debouncedAnswer = useDebouncedValue(localAnswer, 1e3);
|
|
404
582
|
const defaultMaxLength = 1e3;
|
|
405
|
-
const answerLength =
|
|
406
|
-
const
|
|
583
|
+
const answerLength = localAnswer.length;
|
|
584
|
+
const debouncedAnswerLength = debouncedAnswer.length;
|
|
585
|
+
const maxLength = (_c = (_b = question.questionExtraAttribute) == null ? void 0 : _b.answerMaxLength) != null ? _c : defaultMaxLength;
|
|
407
586
|
const isTooLong = answerLength > maxLength;
|
|
408
|
-
const
|
|
587
|
+
const visibleCounterText = activatedLanguage === "en" ? `${answerLength} of ${maxLength} characters` : `${answerLength} av ${maxLength} tecken`;
|
|
588
|
+
const screenReaderCounterText = activatedLanguage === "en" ? `${debouncedAnswerLength} of ${maxLength} characters` : `${debouncedAnswerLength} av ${maxLength} tecken`;
|
|
409
589
|
const maxLengthErrorText = activatedLanguage === "en" ? `The text must be ${maxLength} characters or less` : `Texten f\xE5r inte vara l\xE4ngre \xE4n ${maxLength} tecken`;
|
|
410
|
-
const
|
|
411
|
-
const value = e.target.value;
|
|
412
|
-
setLocalAnswer(value);
|
|
413
|
-
lastSyncedAnswer.current = value;
|
|
590
|
+
const onChange = (e) => {
|
|
414
591
|
handleQuestionInputChange(e, question);
|
|
415
592
|
};
|
|
416
593
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
@@ -439,8 +616,8 @@ var InputTextarea = ({
|
|
|
439
616
|
"textarea",
|
|
440
617
|
{
|
|
441
618
|
className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0,
|
|
442
|
-
onChange:
|
|
443
|
-
value:
|
|
619
|
+
onChange: (e) => onChange(e),
|
|
620
|
+
value: question.answer,
|
|
444
621
|
required: question.isQuestionMandatory,
|
|
445
622
|
"aria-required": question.isQuestionMandatory,
|
|
446
623
|
"aria-invalid": question.hasValidationError,
|
|
@@ -449,13 +626,16 @@ var InputTextarea = ({
|
|
|
449
626
|
}
|
|
450
627
|
),
|
|
451
628
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "pts-textarea-counter-error-container", children: [
|
|
452
|
-
!((
|
|
629
|
+
!((_d = question.questionExtraAttribute) == null ? void 0 : _d.hideTextCounter) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
630
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { "aria-hidden": "true", className: `pts-character-counter`, children: visibleCounterText }),
|
|
631
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { id: counterLiveRegionId, "aria-live": "polite", className: "sr-only", children: screenReaderCounterText })
|
|
632
|
+
] }),
|
|
453
633
|
!isTooLong && question.hasValidationError && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
454
634
|
ValidationMessage_default,
|
|
455
635
|
{
|
|
456
636
|
showValidationMessage: true,
|
|
457
637
|
validationId: errorId,
|
|
458
|
-
validationMessesege: (
|
|
638
|
+
validationMessesege: (_e = question.validationDefaultMessesege) != null ? _e : "",
|
|
459
639
|
activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv"
|
|
460
640
|
}
|
|
461
641
|
),
|
|
@@ -496,7 +676,6 @@ var PreviewTextarea = ({
|
|
|
496
676
|
};
|
|
497
677
|
|
|
498
678
|
// src/components/input-components/TextFieldStandard/TextFieldStandard.tsx
|
|
499
|
-
var import_react4 = require("react");
|
|
500
679
|
var import_dompurify2 = __toESM(require("dompurify"));
|
|
501
680
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
502
681
|
var TextFieldStandard = ({
|
|
@@ -505,29 +684,16 @@ var TextFieldStandard = ({
|
|
|
505
684
|
showPreview = false,
|
|
506
685
|
activatedLanguage
|
|
507
686
|
}) => {
|
|
508
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o
|
|
687
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
509
688
|
const questionId = `question-${question.id}`;
|
|
510
689
|
const inputId = `textField-${question.id}`;
|
|
511
690
|
const aboutId = `about-${question.id}`;
|
|
512
691
|
const errorId = `error-${question.id}`;
|
|
513
|
-
const
|
|
514
|
-
const lastSyncedAnswer = (0, import_react4.useRef)((_b = question.answer) != null ? _b : "");
|
|
515
|
-
(0, import_react4.useEffect)(() => {
|
|
516
|
-
var _a2;
|
|
517
|
-
const incomingFromRedux = (_a2 = question.answer) != null ? _a2 : "";
|
|
518
|
-
if (incomingFromRedux !== lastSyncedAnswer.current) {
|
|
519
|
-
setLocalAnswer(incomingFromRedux);
|
|
520
|
-
lastSyncedAnswer.current = incomingFromRedux;
|
|
521
|
-
}
|
|
522
|
-
}, [question.answer]);
|
|
523
|
-
const answerLength = (_c = localAnswer == null ? void 0 : localAnswer.length) != null ? _c : 0;
|
|
692
|
+
const answerLength = (_b = (_a = question.answer) == null ? void 0 : _a.length) != null ? _b : 0;
|
|
524
693
|
const maxLength = 100;
|
|
525
694
|
const isTooLong = answerLength > maxLength;
|
|
526
695
|
const maxLengthErrorText = activatedLanguage === "en" ? `The text must be ${maxLength} characters or less` : `Texten f\xE5r inte vara l\xE4ngre \xE4n ${maxLength} tecken`;
|
|
527
696
|
const handleOnChange = (e) => {
|
|
528
|
-
const value = e.target.value;
|
|
529
|
-
setLocalAnswer(value);
|
|
530
|
-
lastSyncedAnswer.current = value;
|
|
531
697
|
handleQuestionInputChange(e, question);
|
|
532
698
|
};
|
|
533
699
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
@@ -535,7 +701,7 @@ var TextFieldStandard = ({
|
|
|
535
701
|
"div",
|
|
536
702
|
{
|
|
537
703
|
id: questionId,
|
|
538
|
-
className: `pts-root-question pts-textField-container ${((
|
|
704
|
+
className: `pts-root-question pts-textField-container ${((_c = question.questionExtraAttribute) == null ? void 0 : _c.disabled) ? " pts-textField-disabled" : ""}${question.aboutText ? " pts-question-hasAbout" : ""}`.trim(),
|
|
539
705
|
children: [
|
|
540
706
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { htmlFor: inputId, children: [
|
|
541
707
|
question.questionLabel,
|
|
@@ -555,21 +721,21 @@ var TextFieldStandard = ({
|
|
|
555
721
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
556
722
|
"input",
|
|
557
723
|
{
|
|
558
|
-
type: (
|
|
559
|
-
autoComplete: (
|
|
560
|
-
inputMode: (
|
|
724
|
+
type: (_e = (_d = question.questionExtraAttribute) == null ? void 0 : _d.inputType) != null ? _e : "text",
|
|
725
|
+
autoComplete: (_g = (_f = question.questionExtraAttribute) == null ? void 0 : _f.autoComplete) != null ? _g : void 0,
|
|
726
|
+
inputMode: (_i = (_h = question.questionExtraAttribute) == null ? void 0 : _h.inputMode) != null ? _i : void 0,
|
|
561
727
|
name: `question-name-${question.id}`,
|
|
562
728
|
className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0,
|
|
563
729
|
onChange: handleOnChange,
|
|
564
|
-
value:
|
|
730
|
+
value: question.answer,
|
|
565
731
|
id: inputId,
|
|
566
|
-
disabled: (
|
|
732
|
+
disabled: (_j = question.questionExtraAttribute) == null ? void 0 : _j.disabled,
|
|
567
733
|
required: question.isQuestionMandatory,
|
|
568
734
|
"aria-required": question.isQuestionMandatory,
|
|
569
735
|
"aria-describedby": [question.aboutText ? aboutId : null, question.hasValidationError ? errorId : null].filter(Boolean).join(" ") || void 0,
|
|
570
736
|
"aria-invalid": question.hasValidationError,
|
|
571
|
-
spellCheck: (
|
|
572
|
-
autoCapitalize: (
|
|
737
|
+
spellCheck: (_l = (_k = question.questionExtraAttribute) == null ? void 0 : _k.spellCheck) != null ? _l : void 0,
|
|
738
|
+
autoCapitalize: (_n = (_m = question.questionExtraAttribute) == null ? void 0 : _m.autoCapitalize) != null ? _n : void 0
|
|
573
739
|
}
|
|
574
740
|
),
|
|
575
741
|
!isTooLong && question.hasValidationError && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -577,7 +743,7 @@ var TextFieldStandard = ({
|
|
|
577
743
|
{
|
|
578
744
|
showValidationMessage: true,
|
|
579
745
|
validationId: errorId,
|
|
580
|
-
validationMessesege: (
|
|
746
|
+
validationMessesege: (_o = question.validationDefaultMessesege) != null ? _o : "",
|
|
581
747
|
activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv"
|
|
582
748
|
}
|
|
583
749
|
),
|
|
@@ -617,7 +783,7 @@ var PreviewTextField = ({
|
|
|
617
783
|
};
|
|
618
784
|
|
|
619
785
|
// src/components/input-components/AddFilesStandard/AddFilesStandard.tsx
|
|
620
|
-
var
|
|
786
|
+
var import_react12 = require("react");
|
|
621
787
|
var import_clsx3 = __toESM(require("clsx"));
|
|
622
788
|
|
|
623
789
|
// src/components/input-components/AddFilesStandard/DropFilesStandard.tsx
|
|
@@ -669,19 +835,19 @@ var DropFiles = ({ FilesSelected, DropFilesText = "Dra och sl\xE4pp dina filer h
|
|
|
669
835
|
var DropFilesStandard_default = DropFiles;
|
|
670
836
|
|
|
671
837
|
// src/components/input-components/AddFilesStandard/ExploreFilesStandard.tsx
|
|
672
|
-
var
|
|
838
|
+
var import_react9 = require("react");
|
|
673
839
|
var import_clsx = __toESM(require("clsx"));
|
|
674
840
|
|
|
675
841
|
// src/components/input-components/AddFilesStandard/ScreenReaderErrors.tsx
|
|
676
|
-
var
|
|
842
|
+
var import_react8 = __toESM(require("react"));
|
|
677
843
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
678
844
|
var ScreenReaderErrors = ({
|
|
679
845
|
errorMessageAddingFile,
|
|
680
846
|
activatedLanguage
|
|
681
847
|
}) => {
|
|
682
|
-
const [activateErrorMessagesForScreenReader, setActivateErrorMessagesForScreenReader] =
|
|
683
|
-
const [errorMessagesForScreenReader, setErrorMessagesForScreenReader] =
|
|
684
|
-
|
|
848
|
+
const [activateErrorMessagesForScreenReader, setActivateErrorMessagesForScreenReader] = import_react8.default.useState(false);
|
|
849
|
+
const [errorMessagesForScreenReader, setErrorMessagesForScreenReader] = import_react8.default.useState("");
|
|
850
|
+
import_react8.default.useEffect(() => {
|
|
685
851
|
if (errorMessageAddingFile.length > 0) {
|
|
686
852
|
let errorMessages = "";
|
|
687
853
|
errorMessages += errorMessageAddingFile.length;
|
|
@@ -712,8 +878,8 @@ var ExploreFiles = ({
|
|
|
712
878
|
showErrors,
|
|
713
879
|
errorMessageAddingFile
|
|
714
880
|
}) => {
|
|
715
|
-
const fileInputRef = (0,
|
|
716
|
-
const buttonInputRef = (0,
|
|
881
|
+
const fileInputRef = (0, import_react9.useRef)(null);
|
|
882
|
+
const buttonInputRef = (0, import_react9.useRef)(null);
|
|
717
883
|
const handleFiles = (event) => {
|
|
718
884
|
const files = Array.from(event.target.files || []);
|
|
719
885
|
FilesSelected(files);
|
|
@@ -781,16 +947,16 @@ var ExploreFiles = ({
|
|
|
781
947
|
var ExploreFilesStandard_default = ExploreFiles;
|
|
782
948
|
|
|
783
949
|
// src/components/input-components/AddFilesStandard/SelectedFilesStandard.tsx
|
|
784
|
-
var
|
|
950
|
+
var import_react11 = __toESM(require("react"));
|
|
785
951
|
var import_react_bootstrap = require("react-bootstrap");
|
|
786
952
|
|
|
787
953
|
// src/components/input-components/AddFilesStandard/IndicatorStandard.tsx
|
|
788
|
-
var
|
|
954
|
+
var import_react10 = require("react");
|
|
789
955
|
var import_clsx2 = __toESM(require("clsx"));
|
|
790
956
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
791
957
|
var Indicator = (filename) => {
|
|
792
|
-
const [uploadPercentage, setUploadPercentage] = (0,
|
|
793
|
-
const [uploadDone, setUploadDone] = (0,
|
|
958
|
+
const [uploadPercentage, setUploadPercentage] = (0, import_react10.useState)(0);
|
|
959
|
+
const [uploadDone, setUploadDone] = (0, import_react10.useState)(false);
|
|
794
960
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: (0, import_clsx2.default)("uploadIndicator", "uploadDone") }) });
|
|
795
961
|
};
|
|
796
962
|
var IndicatorStandard_default = Indicator;
|
|
@@ -809,7 +975,7 @@ var SelectedFiles = ({
|
|
|
809
975
|
setNumberOfFiles,
|
|
810
976
|
removeUploadErrors
|
|
811
977
|
}) => {
|
|
812
|
-
const theDiv = (0,
|
|
978
|
+
const theDiv = (0, import_react11.useRef)(null);
|
|
813
979
|
const remove = (file) => {
|
|
814
980
|
let newFiles = questionObject.files.filter((f) => f !== file);
|
|
815
981
|
const newCountOfFiles = newFiles.length;
|
|
@@ -821,8 +987,8 @@ var SelectedFiles = ({
|
|
|
821
987
|
removeFile(newCountOfFiles);
|
|
822
988
|
};
|
|
823
989
|
const useWindowWidth = () => {
|
|
824
|
-
const [windowWidth2, setWindowWidth] = (0,
|
|
825
|
-
(0,
|
|
990
|
+
const [windowWidth2, setWindowWidth] = (0, import_react11.useState)(window.innerWidth);
|
|
991
|
+
(0, import_react11.useEffect)(() => {
|
|
826
992
|
const handleResize = () => {
|
|
827
993
|
setWindowWidth(window.innerWidth);
|
|
828
994
|
};
|
|
@@ -845,7 +1011,7 @@ var SelectedFiles = ({
|
|
|
845
1011
|
mobileFirstFileName = mobileFirstFileName.length > 8 ? mobileFirstFileName.substring(0, 8) + ".." : mobileFirstFileName;
|
|
846
1012
|
const fileType = errorObj.FileName.split(".").pop();
|
|
847
1013
|
mobileFirstFileName = mobileFirstFileName + "." + fileType;
|
|
848
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1014
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react11.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "fileInListContainer", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "fileInList", children: [
|
|
849
1015
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_bootstrap.Row, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_bootstrap.Col, { children: windowWidth < 768 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "mobileFirstFileName", children: mobileFirstFileName }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "desktopFileName", children: errorObj.FileName }) }) }),
|
|
850
1016
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_bootstrap.Row, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
851
1017
|
import_react_bootstrap.Col,
|
|
@@ -898,7 +1064,7 @@ var SelectedFiles = ({
|
|
|
898
1064
|
mobileFirstFileName = mobileFirstFileName.length > 8 ? mobileFirstFileName.substring(0, 8) + ".." : mobileFirstFileName;
|
|
899
1065
|
const fileType = file.FileName.split(".").pop();
|
|
900
1066
|
mobileFirstFileName = mobileFirstFileName + "." + fileType;
|
|
901
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1067
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react11.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "fileInListContainer", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "fileInList", children: [
|
|
902
1068
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "fileItem", children: [
|
|
903
1069
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_bootstrap.Col, { style: { maxWidth: "30px" }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { "aria-hidden": "true", className: "uploadedDot", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
904
1070
|
"svg",
|
|
@@ -991,24 +1157,24 @@ var AddFiles = ({
|
|
|
991
1157
|
const errorId = `error-${questionObject.id}`;
|
|
992
1158
|
const labelId = `label-${questionObject.id}`;
|
|
993
1159
|
const maxSizeMB = Math.round(allowedTotalFileSize / 1048576);
|
|
994
|
-
const [numberOfFiles, setNumberOfFiles] = (0,
|
|
995
|
-
const [totalFileSize, setTotalFileSize] = (0,
|
|
996
|
-
const [errorMessageAddingFile, setErrorMessageAddingFile] = (0,
|
|
997
|
-
const [newFiles, setNewFiles] = (0,
|
|
998
|
-
const [dropFilesText, setDropFilesText] = (0,
|
|
999
|
-
(0,
|
|
1160
|
+
const [numberOfFiles, setNumberOfFiles] = (0, import_react12.useState)(0);
|
|
1161
|
+
const [totalFileSize, setTotalFileSize] = (0, import_react12.useState)(0);
|
|
1162
|
+
const [errorMessageAddingFile, setErrorMessageAddingFile] = (0, import_react12.useState)([]);
|
|
1163
|
+
const [newFiles, setNewFiles] = (0, import_react12.useState)([]);
|
|
1164
|
+
const [dropFilesText, setDropFilesText] = (0, import_react12.useState)("Dra och sl\xE4pp dina filer h\xE4r");
|
|
1165
|
+
(0, import_react12.useEffect)(() => {
|
|
1000
1166
|
if (activatedLanguage === "sv") {
|
|
1001
1167
|
setDropFilesText("Dra och sl\xE4pp dina filer h\xE4r");
|
|
1002
1168
|
} else {
|
|
1003
1169
|
setDropFilesText("Drag and drop your files here");
|
|
1004
1170
|
}
|
|
1005
1171
|
}, [activatedLanguage]);
|
|
1006
|
-
(0,
|
|
1172
|
+
(0, import_react12.useEffect)(() => {
|
|
1007
1173
|
if (questionObject.files && questionObject.files.length > 0) {
|
|
1008
1174
|
setNumberOfFiles(questionObject.files.length);
|
|
1009
1175
|
}
|
|
1010
1176
|
}, []);
|
|
1011
|
-
const onDrop = (0,
|
|
1177
|
+
const onDrop = (0, import_react12.useCallback)(
|
|
1012
1178
|
(acceptedFiles) => {
|
|
1013
1179
|
var _a2, _b2, _c;
|
|
1014
1180
|
const validationErrors = [];
|
|
@@ -1098,7 +1264,7 @@ var AddFiles = ({
|
|
|
1098
1264
|
reader.readAsDataURL(file);
|
|
1099
1265
|
});
|
|
1100
1266
|
};
|
|
1101
|
-
(0,
|
|
1267
|
+
(0, import_react12.useEffect)(() => {
|
|
1102
1268
|
if (newFiles.length > 0) {
|
|
1103
1269
|
const currentFiles = questionObject.files ? questionObject.files : [];
|
|
1104
1270
|
const e = {
|
|
@@ -1218,7 +1384,7 @@ var PreviewAddFiles = ({
|
|
|
1218
1384
|
};
|
|
1219
1385
|
|
|
1220
1386
|
// src/components/input-components/SingleCheckboxStandard/SingleCheckboxStandard.tsx
|
|
1221
|
-
var
|
|
1387
|
+
var import_react13 = require("react");
|
|
1222
1388
|
var import_dompurify3 = __toESM(require("dompurify"));
|
|
1223
1389
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1224
1390
|
var SingleCheckbox = ({
|
|
@@ -1232,8 +1398,8 @@ var SingleCheckbox = ({
|
|
|
1232
1398
|
const inputId = `checkbox-${question.id}`;
|
|
1233
1399
|
const aboutId = `about-${question.id}`;
|
|
1234
1400
|
const errorId = `error-${question.id}`;
|
|
1235
|
-
const [checked, setChecked] = (0,
|
|
1236
|
-
(0,
|
|
1401
|
+
const [checked, setChecked] = (0, import_react13.useState)(false);
|
|
1402
|
+
(0, import_react13.useEffect)(() => {
|
|
1237
1403
|
if (question.answer && question.answer === "true") {
|
|
1238
1404
|
setChecked(true);
|
|
1239
1405
|
} else {
|
|
@@ -1309,7 +1475,7 @@ var PreviewSingleCheckbox = ({
|
|
|
1309
1475
|
};
|
|
1310
1476
|
|
|
1311
1477
|
// src/components/text-blocks/TextHeadlineAndBodyStandard/TextHeadlineAndBodyStandard.tsx
|
|
1312
|
-
var
|
|
1478
|
+
var import_react14 = require("react");
|
|
1313
1479
|
var import_dompurify4 = __toESM(require("dompurify"));
|
|
1314
1480
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1315
1481
|
var TextHeadlineAndBody = ({ data, headlineType = "h2" }) => {
|
|
@@ -1318,7 +1484,7 @@ var TextHeadlineAndBody = ({ data, headlineType = "h2" }) => {
|
|
|
1318
1484
|
{
|
|
1319
1485
|
className: "pts-textHeadlineAndBody-container",
|
|
1320
1486
|
children: [
|
|
1321
|
-
data.headline && (0,
|
|
1487
|
+
data.headline && (0, import_react14.createElement)(headlineType, { id: "textHeadlineAndBody-headline" }, data.headline),
|
|
1322
1488
|
data.body && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { dangerouslySetInnerHTML: { __html: import_dompurify4.default.sanitize(data.body) } }),
|
|
1323
1489
|
data.linksForMoreInfo && data.linksForMoreInfo.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("ul", { className: "pts-moreinfo-list", children: data.linksForMoreInfo.map((link, index) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("li", { className: index > 0 ? "notFirstInList" : "", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1324
1490
|
"a",
|
|
@@ -2161,10 +2327,10 @@ var InputInfoOnly = ({
|
|
|
2161
2327
|
var InfoOnlyStandard_default = InputInfoOnly;
|
|
2162
2328
|
|
|
2163
2329
|
// src/components/input-components/RadioMultipleWithInfoStandard/RadioMultipleWithInfoStandard.tsx
|
|
2164
|
-
var
|
|
2330
|
+
var import_react16 = __toESM(require("react"));
|
|
2165
2331
|
|
|
2166
2332
|
// src/components/input-components/RadioMultipleWithInfoStandard/RadioCollapseItem.tsx
|
|
2167
|
-
var
|
|
2333
|
+
var import_react15 = require("react");
|
|
2168
2334
|
var import_dompurify7 = __toESM(require("dompurify"));
|
|
2169
2335
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2170
2336
|
var RadioCollapseItem = ({
|
|
@@ -2180,13 +2346,13 @@ var RadioCollapseItem = ({
|
|
|
2180
2346
|
activatedLanguage = "sv",
|
|
2181
2347
|
initialOpen = false
|
|
2182
2348
|
}) => {
|
|
2183
|
-
const [isOpen, setIsOpen] = (0,
|
|
2349
|
+
const [isOpen, setIsOpen] = (0, import_react15.useState)(initialOpen);
|
|
2184
2350
|
const contentId = `${questionId}-content-${index}`;
|
|
2185
2351
|
const buttonId = `${questionId}-button-${index}`;
|
|
2186
2352
|
const openLabel = activatedLanguage === "sv" ? "Visa mer information om" : "Show more information about";
|
|
2187
2353
|
const closeLabel = activatedLanguage === "sv" ? "D\xF6lj mer information om" : "Hide more information about";
|
|
2188
2354
|
const buttonLabel = `${isOpen ? closeLabel : openLabel} "${label}"`;
|
|
2189
|
-
(0,
|
|
2355
|
+
(0, import_react15.useEffect)(() => {
|
|
2190
2356
|
if (questionAnswer === value) {
|
|
2191
2357
|
setIsOpen(true);
|
|
2192
2358
|
} else {
|
|
@@ -2296,7 +2462,7 @@ var RadioWithInfo = ({
|
|
|
2296
2462
|
groupedOptionArray.map((group, g_index) => {
|
|
2297
2463
|
var _a2;
|
|
2298
2464
|
let subId = "subheading-" + g_index;
|
|
2299
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_react16.default.Fragment, { children: [
|
|
2300
2466
|
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("legend", { className: "pts-radioWithInfo-sub-headline", id: subId, children: group.category }),
|
|
2301
2467
|
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { role: "group", "aria-labelledby": subId, children: (_a2 = group.items) == null ? void 0 : _a2.map((option, o_index) => {
|
|
2302
2468
|
var _a3, _b2, _c2, _d, _e;
|
|
@@ -3022,50 +3188,6 @@ var makeFormSelectors = (selectSlice) => {
|
|
|
3022
3188
|
};
|
|
3023
3189
|
};
|
|
3024
3190
|
|
|
3025
|
-
// src/helpers/cookieHandler/cookieHandler.ts
|
|
3026
|
-
var getCookie = (name) => {
|
|
3027
|
-
const match = document.cookie.match(new RegExp("(^| )" + name + "=([^;]+)"));
|
|
3028
|
-
return match ? match[2] : null;
|
|
3029
|
-
};
|
|
3030
|
-
var setCookie = (name, value, expirationDate) => {
|
|
3031
|
-
let cookieString = `${name}=${value}; path=/; SameSite=Strict`;
|
|
3032
|
-
if (expirationDate) {
|
|
3033
|
-
cookieString += `; expires=${expirationDate.toUTCString()}`;
|
|
3034
|
-
}
|
|
3035
|
-
if (window.location.protocol === "https:") {
|
|
3036
|
-
cookieString += "; Secure";
|
|
3037
|
-
}
|
|
3038
|
-
document.cookie = cookieString;
|
|
3039
|
-
};
|
|
3040
|
-
var removeCookie = (name) => {
|
|
3041
|
-
const pastDate = /* @__PURE__ */ new Date(0);
|
|
3042
|
-
setCookie(name, "", pastDate);
|
|
3043
|
-
};
|
|
3044
|
-
var createCookieConsent = (config) => {
|
|
3045
|
-
const { cookieName, choiceKey, expiryYears = 1 } = config;
|
|
3046
|
-
const acceptCookies = () => {
|
|
3047
|
-
const expires = /* @__PURE__ */ new Date();
|
|
3048
|
-
expires.setFullYear(expires.getFullYear() + expiryYears);
|
|
3049
|
-
setCookie(cookieName, "true", expires);
|
|
3050
|
-
localStorage.setItem(cookieName, "true");
|
|
3051
|
-
};
|
|
3052
|
-
const rejectCookies = () => {
|
|
3053
|
-
removeCookie(cookieName);
|
|
3054
|
-
localStorage.removeItem(cookieName);
|
|
3055
|
-
sessionStorage.setItem(choiceKey, "true");
|
|
3056
|
-
};
|
|
3057
|
-
const areCookiesAccepted = () => getCookie(cookieName) === "true";
|
|
3058
|
-
const hasChoiceBeenMade = () => sessionStorage.getItem(choiceKey) === "true";
|
|
3059
|
-
const clearChoiceFromSession = () => sessionStorage.removeItem(choiceKey);
|
|
3060
|
-
return {
|
|
3061
|
-
acceptCookies,
|
|
3062
|
-
rejectCookies,
|
|
3063
|
-
areCookiesAccepted,
|
|
3064
|
-
hasChoiceBeenMade,
|
|
3065
|
-
clearChoiceFromSession
|
|
3066
|
-
};
|
|
3067
|
-
};
|
|
3068
|
-
|
|
3069
3191
|
// src/helpers/scriptHandler/scriptHandler.ts
|
|
3070
3192
|
var toggleScriptByConsent = (consent, options) => {
|
|
3071
3193
|
if (typeof document === "undefined") return;
|
|
@@ -3118,126 +3240,6 @@ var getGroupCheckIds = (validationType) => {
|
|
|
3118
3240
|
};
|
|
3119
3241
|
var getGroupCheckIds_default = getGroupCheckIds;
|
|
3120
3242
|
|
|
3121
|
-
// src/hooks/useFormStatusModal/useFormStatusModal.ts
|
|
3122
|
-
var React10 = __toESM(require("react"));
|
|
3123
|
-
var useFormStatusModal = (formStatus, handleModalOpen, handleModalClose, mainSelector = "#main-content") => {
|
|
3124
|
-
React10.useEffect(() => {
|
|
3125
|
-
if (formStatus === "loading") {
|
|
3126
|
-
handleModalOpen();
|
|
3127
|
-
}
|
|
3128
|
-
if (formStatus === "success" || formStatus === "failed") {
|
|
3129
|
-
setTimeout(() => {
|
|
3130
|
-
handleModalClose();
|
|
3131
|
-
}, 1050);
|
|
3132
|
-
const main = document.querySelector(mainSelector);
|
|
3133
|
-
if (main) main.focus();
|
|
3134
|
-
}
|
|
3135
|
-
}, [formStatus, handleModalOpen, handleModalClose, mainSelector]);
|
|
3136
|
-
};
|
|
3137
|
-
|
|
3138
|
-
// src/hooks/usePTSPageTitle/usePTSPageTitle.ts
|
|
3139
|
-
var import_react14 = require("react");
|
|
3140
|
-
var usePTSPageTitle = ({
|
|
3141
|
-
formStatus,
|
|
3142
|
-
activeStep,
|
|
3143
|
-
applicationContent,
|
|
3144
|
-
thankYouBlock,
|
|
3145
|
-
steps,
|
|
3146
|
-
fallbackTitle = "PTS e-tj\xE4nst"
|
|
3147
|
-
}) => {
|
|
3148
|
-
const computedTitle = (0, import_react14.useMemo)(() => {
|
|
3149
|
-
var _a, _b, _c, _d;
|
|
3150
|
-
const baseTitle = (_a = applicationContent == null ? void 0 : applicationContent.pageTitle) != null ? _a : "";
|
|
3151
|
-
const thankYouPageTitle = (_b = thankYouBlock == null ? void 0 : thankYouBlock.pageTitle) != null ? _b : "";
|
|
3152
|
-
const stepTitle = (_d = (_c = steps == null ? void 0 : steps[Math.max(0, activeStep - 1)]) == null ? void 0 : _c.pageTitle) != null ? _d : "";
|
|
3153
|
-
if (formStatus === "success" && thankYouPageTitle) return thankYouPageTitle;
|
|
3154
|
-
if (activeStep === 0 && baseTitle) return baseTitle;
|
|
3155
|
-
return stepTitle || baseTitle || fallbackTitle;
|
|
3156
|
-
}, [formStatus, activeStep, applicationContent, thankYouBlock, steps, fallbackTitle]);
|
|
3157
|
-
(0, import_react14.useEffect)(() => {
|
|
3158
|
-
document.title = computedTitle;
|
|
3159
|
-
}, [computedTitle]);
|
|
3160
|
-
return computedTitle;
|
|
3161
|
-
};
|
|
3162
|
-
|
|
3163
|
-
// src/hooks/useInputMethodDetection/useInputMethodDetection.ts
|
|
3164
|
-
var import_react15 = require("react");
|
|
3165
|
-
var useInputMethodDetection = ({
|
|
3166
|
-
mouseClassName = "using-mouse",
|
|
3167
|
-
keyboardToggleKey = "Tab"
|
|
3168
|
-
} = {}) => {
|
|
3169
|
-
(0, import_react15.useEffect)(() => {
|
|
3170
|
-
const handleMouseDown = () => {
|
|
3171
|
-
document.body.classList.add(mouseClassName);
|
|
3172
|
-
};
|
|
3173
|
-
const handleKeyDown = (event) => {
|
|
3174
|
-
if (event.key === keyboardToggleKey) {
|
|
3175
|
-
document.body.classList.remove(mouseClassName);
|
|
3176
|
-
}
|
|
3177
|
-
};
|
|
3178
|
-
document.addEventListener("mousedown", handleMouseDown);
|
|
3179
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
3180
|
-
return () => {
|
|
3181
|
-
document.removeEventListener("mousedown", handleMouseDown);
|
|
3182
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
3183
|
-
};
|
|
3184
|
-
}, [mouseClassName, keyboardToggleKey]);
|
|
3185
|
-
};
|
|
3186
|
-
|
|
3187
|
-
// src/hooks/useCookieConsent/useCookieConsent.ts
|
|
3188
|
-
var import_react16 = require("react");
|
|
3189
|
-
var useCookieConsent = ({
|
|
3190
|
-
cookieName,
|
|
3191
|
-
choiceKey,
|
|
3192
|
-
expiryYears = 1,
|
|
3193
|
-
onConsentChange
|
|
3194
|
-
}) => {
|
|
3195
|
-
const {
|
|
3196
|
-
acceptCookies,
|
|
3197
|
-
rejectCookies,
|
|
3198
|
-
areCookiesAccepted,
|
|
3199
|
-
hasChoiceBeenMade,
|
|
3200
|
-
clearChoiceFromSession
|
|
3201
|
-
} = (0, import_react16.useMemo)(
|
|
3202
|
-
() => createCookieConsent({
|
|
3203
|
-
cookieName,
|
|
3204
|
-
choiceKey,
|
|
3205
|
-
expiryYears
|
|
3206
|
-
}),
|
|
3207
|
-
[cookieName, choiceKey, expiryYears]
|
|
3208
|
-
);
|
|
3209
|
-
const [showBanner, setShowBanner] = (0, import_react16.useState)(false);
|
|
3210
|
-
const handleCookieStateChange = (0, import_react16.useCallback)(() => {
|
|
3211
|
-
const cookiesNowAccepted = areCookiesAccepted();
|
|
3212
|
-
if (onConsentChange) {
|
|
3213
|
-
onConsentChange(cookiesNowAccepted);
|
|
3214
|
-
}
|
|
3215
|
-
setShowBanner(false);
|
|
3216
|
-
}, [areCookiesAccepted, onConsentChange]);
|
|
3217
|
-
(0, import_react16.useEffect)(() => {
|
|
3218
|
-
const cookiesAccepted = areCookiesAccepted();
|
|
3219
|
-
const choiceMade = hasChoiceBeenMade();
|
|
3220
|
-
setShowBanner(!cookiesAccepted && !choiceMade);
|
|
3221
|
-
if (cookiesAccepted && onConsentChange) {
|
|
3222
|
-
onConsentChange(true);
|
|
3223
|
-
}
|
|
3224
|
-
const handleShowBannerEvent = () => {
|
|
3225
|
-
clearChoiceFromSession();
|
|
3226
|
-
setShowBanner(true);
|
|
3227
|
-
};
|
|
3228
|
-
window.addEventListener("showCookieBanner", handleShowBannerEvent);
|
|
3229
|
-
return () => {
|
|
3230
|
-
window.removeEventListener("showCookieBanner", handleShowBannerEvent);
|
|
3231
|
-
};
|
|
3232
|
-
}, [areCookiesAccepted, hasChoiceBeenMade, clearChoiceFromSession, onConsentChange]);
|
|
3233
|
-
return {
|
|
3234
|
-
showBanner,
|
|
3235
|
-
handleCookieStateChange,
|
|
3236
|
-
acceptCookies,
|
|
3237
|
-
rejectCookies
|
|
3238
|
-
};
|
|
3239
|
-
};
|
|
3240
|
-
|
|
3241
3243
|
// src/components/question-rendering/QuestionRenderer/QuestionRenderer.tsx
|
|
3242
3244
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
3243
3245
|
var QuestionRenderer = ({
|