optimized-react-component-library-xyz123 3.0.2 → 3.0.3
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 +14 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -397,7 +397,7 @@ var PreviewTextarea = ({
|
|
|
397
397
|
};
|
|
398
398
|
|
|
399
399
|
// src/components/input-components/TextFieldStandard/TextFieldStandard.tsx
|
|
400
|
-
import { useState as useState4 } from "react";
|
|
400
|
+
import { useState as useState4, useRef, useEffect as useEffect3 } from "react";
|
|
401
401
|
import DOMPurify2 from "dompurify";
|
|
402
402
|
import { Fragment as Fragment5, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
403
403
|
var TextFieldStandard = ({
|
|
@@ -411,13 +411,22 @@ var TextFieldStandard = ({
|
|
|
411
411
|
const inputId = `textField-${question.id}`;
|
|
412
412
|
const aboutId = `about-${question.id}`;
|
|
413
413
|
const errorId = `error-${question.id}`;
|
|
414
|
-
const [localAnswer, setLocalAnswer] = useState4(question.answer);
|
|
415
|
-
const
|
|
414
|
+
const [localAnswer, setLocalAnswer] = useState4((_a = question.answer) != null ? _a : "");
|
|
415
|
+
const lastSyncedAnswer = useRef(question.answer);
|
|
416
|
+
useEffect3(() => {
|
|
417
|
+
if (question.answer && question.answer !== lastSyncedAnswer.current) {
|
|
418
|
+
setLocalAnswer(question.answer);
|
|
419
|
+
lastSyncedAnswer.current = question.answer;
|
|
420
|
+
}
|
|
421
|
+
}, [question.answer]);
|
|
422
|
+
const answerLength = (_b = localAnswer == null ? void 0 : localAnswer.length) != null ? _b : 0;
|
|
416
423
|
const maxLength = 100;
|
|
417
424
|
const isTooLong = answerLength > maxLength;
|
|
418
425
|
const maxLengthErrorText = activatedLanguage === "en" ? `The text must be ${maxLength} characters or less` : `Texten f\xE5r inte vara l\xE4ngre \xE4n ${maxLength} tecken`;
|
|
419
|
-
const
|
|
420
|
-
|
|
426
|
+
const handleOnChange = (e) => {
|
|
427
|
+
const value = e.target.value;
|
|
428
|
+
setLocalAnswer(value);
|
|
429
|
+
lastSyncedAnswer.current = value;
|
|
421
430
|
handleQuestionInputChange(e, question);
|
|
422
431
|
};
|
|
423
432
|
return /* @__PURE__ */ jsxs6(Fragment5, { children: [
|
|
@@ -450,7 +459,7 @@ var TextFieldStandard = ({
|
|
|
450
459
|
inputMode: (_i = (_h = question.questionExtraAttribute) == null ? void 0 : _h.inputMode) != null ? _i : void 0,
|
|
451
460
|
name: `question-name-${question.id}`,
|
|
452
461
|
className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0,
|
|
453
|
-
onChange:
|
|
462
|
+
onChange: handleOnChange,
|
|
454
463
|
value: localAnswer,
|
|
455
464
|
id: inputId,
|
|
456
465
|
disabled: (_j = question.questionExtraAttribute) == null ? void 0 : _j.disabled,
|
|
@@ -507,7 +516,7 @@ var PreviewTextField = ({
|
|
|
507
516
|
};
|
|
508
517
|
|
|
509
518
|
// src/components/input-components/AddFilesStandard/AddFilesStandard.tsx
|
|
510
|
-
import { useCallback, useEffect as
|
|
519
|
+
import { useCallback, useEffect as useEffect6, useState as useState7 } from "react";
|
|
511
520
|
import clsx3 from "clsx";
|
|
512
521
|
|
|
513
522
|
// src/components/input-components/AddFilesStandard/DropFilesStandard.tsx
|
|
@@ -559,7 +568,7 @@ var DropFiles = ({ FilesSelected, DropFilesText = "Dra och sl\xE4pp dina filer h
|
|
|
559
568
|
var DropFilesStandard_default = DropFiles;
|
|
560
569
|
|
|
561
570
|
// src/components/input-components/AddFilesStandard/ExploreFilesStandard.tsx
|
|
562
|
-
import { useRef } from "react";
|
|
571
|
+
import { useRef as useRef2 } from "react";
|
|
563
572
|
import clsx from "clsx";
|
|
564
573
|
|
|
565
574
|
// src/components/input-components/AddFilesStandard/ScreenReaderErrors.tsx
|
|
@@ -602,8 +611,8 @@ var ExploreFiles = ({
|
|
|
602
611
|
showErrors,
|
|
603
612
|
errorMessageAddingFile
|
|
604
613
|
}) => {
|
|
605
|
-
const fileInputRef =
|
|
606
|
-
const buttonInputRef =
|
|
614
|
+
const fileInputRef = useRef2(null);
|
|
615
|
+
const buttonInputRef = useRef2(null);
|
|
607
616
|
const handleFiles = (event) => {
|
|
608
617
|
const files = Array.from(event.target.files || []);
|
|
609
618
|
FilesSelected(files);
|
|
@@ -671,7 +680,7 @@ var ExploreFiles = ({
|
|
|
671
680
|
var ExploreFilesStandard_default = ExploreFiles;
|
|
672
681
|
|
|
673
682
|
// src/components/input-components/AddFilesStandard/SelectedFilesStandard.tsx
|
|
674
|
-
import React6, { useEffect as
|
|
683
|
+
import React6, { useEffect as useEffect5, useState as useState6, useRef as useRef3 } from "react";
|
|
675
684
|
import { Col, Row } from "react-bootstrap";
|
|
676
685
|
|
|
677
686
|
// src/components/input-components/AddFilesStandard/IndicatorStandard.tsx
|
|
@@ -699,7 +708,7 @@ var SelectedFiles = ({
|
|
|
699
708
|
setNumberOfFiles,
|
|
700
709
|
removeUploadErrors
|
|
701
710
|
}) => {
|
|
702
|
-
const theDiv =
|
|
711
|
+
const theDiv = useRef3(null);
|
|
703
712
|
const remove = (file) => {
|
|
704
713
|
let newFiles = questionObject.files.filter((f) => f !== file);
|
|
705
714
|
const newCountOfFiles = newFiles.length;
|
|
@@ -712,7 +721,7 @@ var SelectedFiles = ({
|
|
|
712
721
|
};
|
|
713
722
|
const useWindowWidth = () => {
|
|
714
723
|
const [windowWidth2, setWindowWidth] = useState6(window.innerWidth);
|
|
715
|
-
|
|
724
|
+
useEffect5(() => {
|
|
716
725
|
const handleResize = () => {
|
|
717
726
|
setWindowWidth(window.innerWidth);
|
|
718
727
|
};
|
|
@@ -886,14 +895,14 @@ var AddFiles = ({
|
|
|
886
895
|
const [errorMessageAddingFile, setErrorMessageAddingFile] = useState7([]);
|
|
887
896
|
const [newFiles, setNewFiles] = useState7([]);
|
|
888
897
|
const [dropFilesText, setDropFilesText] = useState7("Dra och sl\xE4pp dina filer h\xE4r");
|
|
889
|
-
|
|
898
|
+
useEffect6(() => {
|
|
890
899
|
if (activatedLanguage === "sv") {
|
|
891
900
|
setDropFilesText("Dra och sl\xE4pp dina filer h\xE4r");
|
|
892
901
|
} else {
|
|
893
902
|
setDropFilesText("Drag and drop your files here");
|
|
894
903
|
}
|
|
895
904
|
}, [activatedLanguage]);
|
|
896
|
-
|
|
905
|
+
useEffect6(() => {
|
|
897
906
|
if (questionObject.files && questionObject.files.length > 0) {
|
|
898
907
|
setNumberOfFiles(questionObject.files.length);
|
|
899
908
|
}
|
|
@@ -988,7 +997,7 @@ var AddFiles = ({
|
|
|
988
997
|
reader.readAsDataURL(file);
|
|
989
998
|
});
|
|
990
999
|
};
|
|
991
|
-
|
|
1000
|
+
useEffect6(() => {
|
|
992
1001
|
if (newFiles.length > 0) {
|
|
993
1002
|
const currentFiles = questionObject.files ? questionObject.files : [];
|
|
994
1003
|
const e = {
|
|
@@ -1108,7 +1117,7 @@ var PreviewAddFiles = ({
|
|
|
1108
1117
|
};
|
|
1109
1118
|
|
|
1110
1119
|
// src/components/input-components/SingleCheckboxStandard/SingleCheckboxStandard.tsx
|
|
1111
|
-
import { useEffect as
|
|
1120
|
+
import { useEffect as useEffect7, useState as useState8 } from "react";
|
|
1112
1121
|
import DOMPurify3 from "dompurify";
|
|
1113
1122
|
import { Fragment as Fragment12, jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1114
1123
|
var SingleCheckbox = ({
|
|
@@ -1123,7 +1132,7 @@ var SingleCheckbox = ({
|
|
|
1123
1132
|
const aboutId = `about-${question.id}`;
|
|
1124
1133
|
const errorId = `error-${question.id}`;
|
|
1125
1134
|
const [checked, setChecked] = useState8(false);
|
|
1126
|
-
|
|
1135
|
+
useEffect7(() => {
|
|
1127
1136
|
if (question.answer && question.answer === "true") {
|
|
1128
1137
|
setChecked(true);
|
|
1129
1138
|
} else {
|
|
@@ -2054,7 +2063,7 @@ var InfoOnlyStandard_default = InputInfoOnly;
|
|
|
2054
2063
|
import React9 from "react";
|
|
2055
2064
|
|
|
2056
2065
|
// src/components/input-components/RadioMultipleWithInfoStandard/RadioCollapseItem.tsx
|
|
2057
|
-
import { useEffect as
|
|
2066
|
+
import { useEffect as useEffect8, useState as useState9 } from "react";
|
|
2058
2067
|
import DOMPurify7 from "dompurify";
|
|
2059
2068
|
import { jsx as jsx20, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2060
2069
|
var RadioCollapseItem = ({
|
|
@@ -2076,7 +2085,7 @@ var RadioCollapseItem = ({
|
|
|
2076
2085
|
const openLabel = activatedLanguage === "sv" ? "Visa mer information om" : "Show more information about";
|
|
2077
2086
|
const closeLabel = activatedLanguage === "sv" ? "D\xF6lj mer information om" : "Hide more information about";
|
|
2078
2087
|
const buttonLabel = `${isOpen ? closeLabel : openLabel} "${label}"`;
|
|
2079
|
-
|
|
2088
|
+
useEffect8(() => {
|
|
2080
2089
|
if (questionAnswer === value) {
|
|
2081
2090
|
setIsOpen(true);
|
|
2082
2091
|
} else {
|
|
@@ -3029,7 +3038,7 @@ var useFormStatusModal = (formStatus, handleModalOpen, handleModalClose, mainSel
|
|
|
3029
3038
|
};
|
|
3030
3039
|
|
|
3031
3040
|
// src/hooks/usePTSPageTitle/usePTSPageTitle.ts
|
|
3032
|
-
import { useMemo, useEffect as
|
|
3041
|
+
import { useMemo, useEffect as useEffect10 } from "react";
|
|
3033
3042
|
var usePTSPageTitle = ({
|
|
3034
3043
|
formStatus,
|
|
3035
3044
|
activeStep,
|
|
@@ -3047,19 +3056,19 @@ var usePTSPageTitle = ({
|
|
|
3047
3056
|
if (activeStep === 0 && baseTitle) return baseTitle;
|
|
3048
3057
|
return stepTitle || baseTitle || fallbackTitle;
|
|
3049
3058
|
}, [formStatus, activeStep, applicationContent, thankYouBlock, steps, fallbackTitle]);
|
|
3050
|
-
|
|
3059
|
+
useEffect10(() => {
|
|
3051
3060
|
document.title = computedTitle;
|
|
3052
3061
|
}, [computedTitle]);
|
|
3053
3062
|
return computedTitle;
|
|
3054
3063
|
};
|
|
3055
3064
|
|
|
3056
3065
|
// src/hooks/useInputMethodDetection/useInputMethodDetection.ts
|
|
3057
|
-
import { useEffect as
|
|
3066
|
+
import { useEffect as useEffect11 } from "react";
|
|
3058
3067
|
var useInputMethodDetection = ({
|
|
3059
3068
|
mouseClassName = "using-mouse",
|
|
3060
3069
|
keyboardToggleKey = "Tab"
|
|
3061
3070
|
} = {}) => {
|
|
3062
|
-
|
|
3071
|
+
useEffect11(() => {
|
|
3063
3072
|
const handleMouseDown = () => {
|
|
3064
3073
|
document.body.classList.add(mouseClassName);
|
|
3065
3074
|
};
|
|
@@ -3078,7 +3087,7 @@ var useInputMethodDetection = ({
|
|
|
3078
3087
|
};
|
|
3079
3088
|
|
|
3080
3089
|
// src/hooks/useCookieConsent/useCookieConsent.ts
|
|
3081
|
-
import { useCallback as useCallback2, useEffect as
|
|
3090
|
+
import { useCallback as useCallback2, useEffect as useEffect12, useMemo as useMemo2, useState as useState10 } from "react";
|
|
3082
3091
|
var useCookieConsent = ({
|
|
3083
3092
|
cookieName,
|
|
3084
3093
|
choiceKey,
|
|
@@ -3107,7 +3116,7 @@ var useCookieConsent = ({
|
|
|
3107
3116
|
}
|
|
3108
3117
|
setShowBanner(false);
|
|
3109
3118
|
}, [areCookiesAccepted, onConsentChange]);
|
|
3110
|
-
|
|
3119
|
+
useEffect12(() => {
|
|
3111
3120
|
const cookiesAccepted = areCookiesAccepted();
|
|
3112
3121
|
const choiceMade = hasChoiceBeenMade();
|
|
3113
3122
|
setShowBanner(!cookiesAccepted && !choiceMade);
|
|
@@ -3236,7 +3245,7 @@ var QuestionRenderer = ({
|
|
|
3236
3245
|
var QuestionRenderer_default = QuestionRenderer;
|
|
3237
3246
|
|
|
3238
3247
|
// src/components/question-rendering/QuestionGroup/QuestionGroup.tsx
|
|
3239
|
-
import { useEffect as
|
|
3248
|
+
import { useEffect as useEffect13, Fragment as Fragment18 } from "react";
|
|
3240
3249
|
import { Fragment as Fragment19, jsx as jsx25, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
3241
3250
|
var QuestionGroup = ({
|
|
3242
3251
|
questions,
|
|
@@ -3256,7 +3265,7 @@ var QuestionGroup = ({
|
|
|
3256
3265
|
const groupMandatory = (_a = firstQuestion.validationType) == null ? void 0 : _a.find(
|
|
3257
3266
|
(e) => e.startsWith("groupCheck-")
|
|
3258
3267
|
);
|
|
3259
|
-
|
|
3268
|
+
useEffect13(() => {
|
|
3260
3269
|
questions.forEach((question) => {
|
|
3261
3270
|
if (question.visible && !question.isDisplayed) {
|
|
3262
3271
|
markQuestionAsDisplayed(question);
|
|
@@ -3935,10 +3944,10 @@ var Header = ({
|
|
|
3935
3944
|
var HeaderStandard_default = Header;
|
|
3936
3945
|
|
|
3937
3946
|
// src/components/layout/NavigationHeaderStandard/NavigationHeaderStandard.tsx
|
|
3938
|
-
import { useRef as
|
|
3947
|
+
import { useRef as useRef5, useState as useState13 } from "react";
|
|
3939
3948
|
|
|
3940
3949
|
// src/components/layout/NavigationStandard/NavigationStandard.tsx
|
|
3941
|
-
import { useEffect as
|
|
3950
|
+
import { useEffect as useEffect14, useState as useState11, useRef as useRef4 } from "react";
|
|
3942
3951
|
import { Fragment as Fragment20, jsx as jsx30, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
3943
3952
|
var Navigation = ({
|
|
3944
3953
|
setIsMenyOpen,
|
|
@@ -3951,8 +3960,8 @@ var Navigation = ({
|
|
|
3951
3960
|
activePath = null
|
|
3952
3961
|
}) => {
|
|
3953
3962
|
const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
|
|
3954
|
-
const navRef =
|
|
3955
|
-
const firstVisitRef =
|
|
3963
|
+
const navRef = useRef4(null);
|
|
3964
|
+
const firstVisitRef = useRef4(true);
|
|
3956
3965
|
const [openSubMenu, setOpenSubMenu] = useState11(null);
|
|
3957
3966
|
const handleSubMenu = (label) => {
|
|
3958
3967
|
setOpenSubMenu(openSubMenu === label ? null : label);
|
|
@@ -3962,7 +3971,7 @@ var Navigation = ({
|
|
|
3962
3971
|
setIsMenyOpen == null ? void 0 : setIsMenyOpen(false);
|
|
3963
3972
|
typeOfInteraction === "close" ? (_a = openButtonRef == null ? void 0 : openButtonRef.current) == null ? void 0 : _a.focus() : navigationCloseFocusId && ((_b = document.getElementById(navigationCloseFocusId)) == null ? void 0 : _b.focus());
|
|
3964
3973
|
};
|
|
3965
|
-
|
|
3974
|
+
useEffect14(() => {
|
|
3966
3975
|
var _a, _b;
|
|
3967
3976
|
if (!isOpen) {
|
|
3968
3977
|
setOpenSubMenu(null);
|
|
@@ -3974,7 +3983,7 @@ var Navigation = ({
|
|
|
3974
3983
|
})) == null ? void 0 : _a.label[activatedLanguage]) != null ? _b : null;
|
|
3975
3984
|
setOpenSubMenu(defaultOpenSubMenu);
|
|
3976
3985
|
}, [isOpen, activePath, menuLinks, activatedLanguage]);
|
|
3977
|
-
|
|
3986
|
+
useEffect14(() => {
|
|
3978
3987
|
if (!isOpen || !navRef.current) {
|
|
3979
3988
|
return;
|
|
3980
3989
|
}
|
|
@@ -4025,7 +4034,7 @@ var Navigation = ({
|
|
|
4025
4034
|
return "\xD6ppna undermeny f\xF6r " + label["sv"];
|
|
4026
4035
|
};
|
|
4027
4036
|
const [instruction, setInstruction] = useState11("");
|
|
4028
|
-
|
|
4037
|
+
useEffect14(() => {
|
|
4029
4038
|
if (firstVisitRef.current) {
|
|
4030
4039
|
firstVisitRef.current = false;
|
|
4031
4040
|
return;
|
|
@@ -4193,7 +4202,7 @@ var NavigationHeader = ({
|
|
|
4193
4202
|
else return "Svenska";
|
|
4194
4203
|
};
|
|
4195
4204
|
const [isMenuOpen, setIsMenuOpen] = useState13(false);
|
|
4196
|
-
const menuButtonFocusRef =
|
|
4205
|
+
const menuButtonFocusRef = useRef5(null);
|
|
4197
4206
|
const handleMenuClick = () => {
|
|
4198
4207
|
setIsMenuOpen((prev) => !prev);
|
|
4199
4208
|
};
|