optimized-react-component-library-xyz123 3.0.0 → 3.0.2

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.mjs CHANGED
@@ -289,6 +289,7 @@ var PreviewCheckboxGroup = ({
289
289
  };
290
290
 
291
291
  // src/components/input-components/TextAreaStandard/TextAreaStandard.tsx
292
+ import { useState as useState3 } from "react";
292
293
  import DOMPurify from "dompurify";
293
294
  import { Fragment as Fragment4, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
294
295
  var InputTextarea = ({
@@ -302,12 +303,17 @@ var InputTextarea = ({
302
303
  const inputId = `textarea-${question.id}`;
303
304
  const aboutId = `about-${question.id}`;
304
305
  const errorId = `error-${question.id}`;
306
+ const [localAnswer, setLocalAnswer] = useState3(question.answer);
305
307
  const defaultMaxLength = 1e3;
306
308
  const answerLength = (_b = (_a = question.answer) == null ? void 0 : _a.length) != null ? _b : 0;
307
309
  const maxLength = (_d = (_c = question.questionExtraAttribute) == null ? void 0 : _c.answerMaxLength) != null ? _d : defaultMaxLength;
308
310
  const isTooLong = answerLength > maxLength;
309
311
  const counterText = activatedLanguage === "en" ? `${answerLength} of ${maxLength} characters` : `${answerLength} av ${maxLength} tecken`;
310
312
  const maxLengthErrorText = activatedLanguage === "en" ? `The text must be ${maxLength} characters or less` : `Texten f\xE5r inte vara l\xE4ngre \xE4n ${maxLength} tecken`;
313
+ const onChange = (e) => {
314
+ setLocalAnswer(e.target.value);
315
+ handleQuestionInputChange(e, question);
316
+ };
311
317
  return /* @__PURE__ */ jsxs5(Fragment4, { children: [
312
318
  !showPreview && question.visible && /* @__PURE__ */ jsxs5(
313
319
  "div",
@@ -334,8 +340,8 @@ var InputTextarea = ({
334
340
  "textarea",
335
341
  {
336
342
  className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0,
337
- onChange: (e) => handleQuestionInputChange(e, question),
338
- value: question.answer,
343
+ onChange: (e) => onChange(e),
344
+ value: localAnswer,
339
345
  required: question.isQuestionMandatory,
340
346
  "aria-required": question.isQuestionMandatory,
341
347
  "aria-invalid": question.hasValidationError,
@@ -391,6 +397,7 @@ var PreviewTextarea = ({
391
397
  };
392
398
 
393
399
  // src/components/input-components/TextFieldStandard/TextFieldStandard.tsx
400
+ import { useState as useState4 } from "react";
394
401
  import DOMPurify2 from "dompurify";
395
402
  import { Fragment as Fragment5, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
396
403
  var TextFieldStandard = ({
@@ -404,10 +411,15 @@ var TextFieldStandard = ({
404
411
  const inputId = `textField-${question.id}`;
405
412
  const aboutId = `about-${question.id}`;
406
413
  const errorId = `error-${question.id}`;
414
+ const [localAnswer, setLocalAnswer] = useState4(question.answer);
407
415
  const answerLength = (_b = (_a = question.answer) == null ? void 0 : _a.length) != null ? _b : 0;
408
416
  const maxLength = 100;
409
417
  const isTooLong = answerLength > maxLength;
410
418
  const maxLengthErrorText = activatedLanguage === "en" ? `The text must be ${maxLength} characters or less` : `Texten f\xE5r inte vara l\xE4ngre \xE4n ${maxLength} tecken`;
419
+ const onChange = (e) => {
420
+ setLocalAnswer(e.target.value);
421
+ handleQuestionInputChange(e, question);
422
+ };
411
423
  return /* @__PURE__ */ jsxs6(Fragment5, { children: [
412
424
  !showPreview && question.visible && /* @__PURE__ */ jsxs6(
413
425
  "div",
@@ -438,8 +450,8 @@ var TextFieldStandard = ({
438
450
  inputMode: (_i = (_h = question.questionExtraAttribute) == null ? void 0 : _h.inputMode) != null ? _i : void 0,
439
451
  name: `question-name-${question.id}`,
440
452
  className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0,
441
- onChange: (e) => handleQuestionInputChange(e, question),
442
- value: question.answer,
453
+ onChange: (e) => onChange(e),
454
+ value: localAnswer,
443
455
  id: inputId,
444
456
  disabled: (_j = question.questionExtraAttribute) == null ? void 0 : _j.disabled,
445
457
  required: question.isQuestionMandatory,
@@ -495,7 +507,7 @@ var PreviewTextField = ({
495
507
  };
496
508
 
497
509
  // src/components/input-components/AddFilesStandard/AddFilesStandard.tsx
498
- import { useCallback, useEffect as useEffect5, useState as useState5 } from "react";
510
+ import { useCallback, useEffect as useEffect5, useState as useState7 } from "react";
499
511
  import clsx3 from "clsx";
500
512
 
501
513
  // src/components/input-components/AddFilesStandard/DropFilesStandard.tsx
@@ -551,15 +563,15 @@ import { useRef } from "react";
551
563
  import clsx from "clsx";
552
564
 
553
565
  // src/components/input-components/AddFilesStandard/ScreenReaderErrors.tsx
554
- import React from "react";
566
+ import React3 from "react";
555
567
  import { Fragment as Fragment7, jsx as jsx8 } from "react/jsx-runtime";
556
568
  var ScreenReaderErrors = ({
557
569
  errorMessageAddingFile,
558
570
  activatedLanguage
559
571
  }) => {
560
- const [activateErrorMessagesForScreenReader, setActivateErrorMessagesForScreenReader] = React.useState(false);
561
- const [errorMessagesForScreenReader, setErrorMessagesForScreenReader] = React.useState("");
562
- React.useEffect(() => {
572
+ const [activateErrorMessagesForScreenReader, setActivateErrorMessagesForScreenReader] = React3.useState(false);
573
+ const [errorMessagesForScreenReader, setErrorMessagesForScreenReader] = React3.useState("");
574
+ React3.useEffect(() => {
563
575
  if (errorMessageAddingFile.length > 0) {
564
576
  let errorMessages = "";
565
577
  errorMessages += errorMessageAddingFile.length;
@@ -659,16 +671,16 @@ var ExploreFiles = ({
659
671
  var ExploreFilesStandard_default = ExploreFiles;
660
672
 
661
673
  // src/components/input-components/AddFilesStandard/SelectedFilesStandard.tsx
662
- import React4, { useEffect as useEffect4, useState as useState4, useRef as useRef2 } from "react";
674
+ import React6, { useEffect as useEffect4, useState as useState6, useRef as useRef2 } from "react";
663
675
  import { Col, Row } from "react-bootstrap";
664
676
 
665
677
  // src/components/input-components/AddFilesStandard/IndicatorStandard.tsx
666
- import { useState as useState3 } from "react";
678
+ import { useState as useState5 } from "react";
667
679
  import clsx2 from "clsx";
668
680
  import { Fragment as Fragment9, jsx as jsx10 } from "react/jsx-runtime";
669
681
  var Indicator = (filename) => {
670
- const [uploadPercentage, setUploadPercentage] = useState3(0);
671
- const [uploadDone, setUploadDone] = useState3(false);
682
+ const [uploadPercentage, setUploadPercentage] = useState5(0);
683
+ const [uploadDone, setUploadDone] = useState5(false);
672
684
  return /* @__PURE__ */ jsx10(Fragment9, { children: /* @__PURE__ */ jsx10("div", { className: clsx2("uploadIndicator", "uploadDone") }) });
673
685
  };
674
686
  var IndicatorStandard_default = Indicator;
@@ -699,7 +711,7 @@ var SelectedFiles = ({
699
711
  removeFile(newCountOfFiles);
700
712
  };
701
713
  const useWindowWidth = () => {
702
- const [windowWidth2, setWindowWidth] = useState4(window.innerWidth);
714
+ const [windowWidth2, setWindowWidth] = useState6(window.innerWidth);
703
715
  useEffect4(() => {
704
716
  const handleResize = () => {
705
717
  setWindowWidth(window.innerWidth);
@@ -723,7 +735,7 @@ var SelectedFiles = ({
723
735
  mobileFirstFileName = mobileFirstFileName.length > 8 ? mobileFirstFileName.substring(0, 8) + ".." : mobileFirstFileName;
724
736
  const fileType = errorObj.FileName.split(".").pop();
725
737
  mobileFirstFileName = mobileFirstFileName + "." + fileType;
726
- return /* @__PURE__ */ jsx11("li", { children: /* @__PURE__ */ jsx11(React4.Fragment, { children: /* @__PURE__ */ jsx11("div", { children: /* @__PURE__ */ jsx11("div", { className: "fileInListContainer", children: /* @__PURE__ */ jsxs9("div", { className: "fileInList", children: [
738
+ return /* @__PURE__ */ jsx11("li", { children: /* @__PURE__ */ jsx11(React6.Fragment, { children: /* @__PURE__ */ jsx11("div", { children: /* @__PURE__ */ jsx11("div", { className: "fileInListContainer", children: /* @__PURE__ */ jsxs9("div", { className: "fileInList", children: [
727
739
  /* @__PURE__ */ jsx11(Row, { children: /* @__PURE__ */ jsx11(Col, { children: windowWidth < 768 ? /* @__PURE__ */ jsx11("span", { className: "mobileFirstFileName", children: mobileFirstFileName }) : /* @__PURE__ */ jsx11("span", { className: "desktopFileName", children: errorObj.FileName }) }) }),
728
740
  /* @__PURE__ */ jsx11(Row, { children: /* @__PURE__ */ jsx11(
729
741
  Col,
@@ -776,7 +788,7 @@ var SelectedFiles = ({
776
788
  mobileFirstFileName = mobileFirstFileName.length > 8 ? mobileFirstFileName.substring(0, 8) + ".." : mobileFirstFileName;
777
789
  const fileType = file.FileName.split(".").pop();
778
790
  mobileFirstFileName = mobileFirstFileName + "." + fileType;
779
- return /* @__PURE__ */ jsx11("li", { children: /* @__PURE__ */ jsx11(React4.Fragment, { children: /* @__PURE__ */ jsx11("div", { children: /* @__PURE__ */ jsx11("div", { className: "fileInListContainer", children: /* @__PURE__ */ jsxs9("div", { className: "fileInList", children: [
791
+ return /* @__PURE__ */ jsx11("li", { children: /* @__PURE__ */ jsx11(React6.Fragment, { children: /* @__PURE__ */ jsx11("div", { children: /* @__PURE__ */ jsx11("div", { className: "fileInListContainer", children: /* @__PURE__ */ jsxs9("div", { className: "fileInList", children: [
780
792
  /* @__PURE__ */ jsxs9("div", { className: "fileItem", children: [
781
793
  /* @__PURE__ */ jsx11(Col, { style: { maxWidth: "30px" }, children: /* @__PURE__ */ jsx11("span", { "aria-hidden": "true", className: "uploadedDot", children: /* @__PURE__ */ jsx11(
782
794
  "svg",
@@ -869,11 +881,11 @@ var AddFiles = ({
869
881
  const errorId = `error-${questionObject.id}`;
870
882
  const labelId = `label-${questionObject.id}`;
871
883
  const maxSizeMB = Math.round(allowedTotalFileSize / 1048576);
872
- const [numberOfFiles, setNumberOfFiles] = useState5(0);
873
- const [totalFileSize, setTotalFileSize] = useState5(0);
874
- const [errorMessageAddingFile, setErrorMessageAddingFile] = useState5([]);
875
- const [newFiles, setNewFiles] = useState5([]);
876
- const [dropFilesText, setDropFilesText] = useState5("Dra och sl\xE4pp dina filer h\xE4r");
884
+ const [numberOfFiles, setNumberOfFiles] = useState7(0);
885
+ const [totalFileSize, setTotalFileSize] = useState7(0);
886
+ const [errorMessageAddingFile, setErrorMessageAddingFile] = useState7([]);
887
+ const [newFiles, setNewFiles] = useState7([]);
888
+ const [dropFilesText, setDropFilesText] = useState7("Dra och sl\xE4pp dina filer h\xE4r");
877
889
  useEffect5(() => {
878
890
  if (activatedLanguage === "sv") {
879
891
  setDropFilesText("Dra och sl\xE4pp dina filer h\xE4r");
@@ -1096,7 +1108,7 @@ var PreviewAddFiles = ({
1096
1108
  };
1097
1109
 
1098
1110
  // src/components/input-components/SingleCheckboxStandard/SingleCheckboxStandard.tsx
1099
- import { useEffect as useEffect6, useState as useState6 } from "react";
1111
+ import { useEffect as useEffect6, useState as useState8 } from "react";
1100
1112
  import DOMPurify3 from "dompurify";
1101
1113
  import { Fragment as Fragment12, jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
1102
1114
  var SingleCheckbox = ({
@@ -1110,7 +1122,7 @@ var SingleCheckbox = ({
1110
1122
  const inputId = `checkbox-${question.id}`;
1111
1123
  const aboutId = `about-${question.id}`;
1112
1124
  const errorId = `error-${question.id}`;
1113
- const [checked, setChecked] = useState6(false);
1125
+ const [checked, setChecked] = useState8(false);
1114
1126
  useEffect6(() => {
1115
1127
  if (question.answer && question.answer === "true") {
1116
1128
  setChecked(true);
@@ -2039,10 +2051,10 @@ var InputInfoOnly = ({
2039
2051
  var InfoOnlyStandard_default = InputInfoOnly;
2040
2052
 
2041
2053
  // src/components/input-components/RadioMultipleWithInfoStandard/RadioMultipleWithInfoStandard.tsx
2042
- import React7 from "react";
2054
+ import React9 from "react";
2043
2055
 
2044
2056
  // src/components/input-components/RadioMultipleWithInfoStandard/RadioCollapseItem.tsx
2045
- import { useEffect as useEffect7, useState as useState7 } from "react";
2057
+ import { useEffect as useEffect7, useState as useState9 } from "react";
2046
2058
  import DOMPurify7 from "dompurify";
2047
2059
  import { jsx as jsx20, jsxs as jsxs16 } from "react/jsx-runtime";
2048
2060
  var RadioCollapseItem = ({
@@ -2058,7 +2070,7 @@ var RadioCollapseItem = ({
2058
2070
  activatedLanguage = "sv",
2059
2071
  initialOpen = false
2060
2072
  }) => {
2061
- const [isOpen, setIsOpen] = useState7(initialOpen);
2073
+ const [isOpen, setIsOpen] = useState9(initialOpen);
2062
2074
  const contentId = `${questionId}-content-${index}`;
2063
2075
  const buttonId = `${questionId}-button-${index}`;
2064
2076
  const openLabel = activatedLanguage === "sv" ? "Visa mer information om" : "Show more information about";
@@ -2174,7 +2186,7 @@ var RadioWithInfo = ({
2174
2186
  groupedOptionArray.map((group, g_index) => {
2175
2187
  var _a2;
2176
2188
  let subId = "subheading-" + g_index;
2177
- return /* @__PURE__ */ jsxs17(React7.Fragment, { children: [
2189
+ return /* @__PURE__ */ jsxs17(React9.Fragment, { children: [
2178
2190
  /* @__PURE__ */ jsx21("legend", { className: "pts-radioWithInfo-sub-headline", id: subId, children: group.category }),
2179
2191
  /* @__PURE__ */ jsx21("div", { role: "group", "aria-labelledby": subId, children: (_a2 = group.items) == null ? void 0 : _a2.map((option, o_index) => {
2180
2192
  var _a3, _b2, _c2, _d, _e;
@@ -3000,9 +3012,9 @@ var getGroupCheckIds = (validationType) => {
3000
3012
  var getGroupCheckIds_default = getGroupCheckIds;
3001
3013
 
3002
3014
  // src/hooks/useFormStatusModal/useFormStatusModal.ts
3003
- import * as React8 from "react";
3015
+ import * as React10 from "react";
3004
3016
  var useFormStatusModal = (formStatus, handleModalOpen, handleModalClose, mainSelector = "#main-content") => {
3005
- React8.useEffect(() => {
3017
+ React10.useEffect(() => {
3006
3018
  if (formStatus === "loading") {
3007
3019
  handleModalOpen();
3008
3020
  }
@@ -3066,7 +3078,7 @@ var useInputMethodDetection = ({
3066
3078
  };
3067
3079
 
3068
3080
  // src/hooks/useCookieConsent/useCookieConsent.ts
3069
- import { useCallback as useCallback2, useEffect as useEffect11, useMemo as useMemo2, useState as useState8 } from "react";
3081
+ import { useCallback as useCallback2, useEffect as useEffect11, useMemo as useMemo2, useState as useState10 } from "react";
3070
3082
  var useCookieConsent = ({
3071
3083
  cookieName,
3072
3084
  choiceKey,
@@ -3087,7 +3099,7 @@ var useCookieConsent = ({
3087
3099
  }),
3088
3100
  [cookieName, choiceKey, expiryYears]
3089
3101
  );
3090
- const [showBanner, setShowBanner] = useState8(false);
3102
+ const [showBanner, setShowBanner] = useState10(false);
3091
3103
  const handleCookieStateChange = useCallback2(() => {
3092
3104
  const cookiesNowAccepted = areCookiesAccepted();
3093
3105
  if (onConsentChange) {
@@ -3923,10 +3935,10 @@ var Header = ({
3923
3935
  var HeaderStandard_default = Header;
3924
3936
 
3925
3937
  // src/components/layout/NavigationHeaderStandard/NavigationHeaderStandard.tsx
3926
- import { useRef as useRef4, useState as useState11 } from "react";
3938
+ import { useRef as useRef4, useState as useState13 } from "react";
3927
3939
 
3928
3940
  // src/components/layout/NavigationStandard/NavigationStandard.tsx
3929
- import { useEffect as useEffect13, useState as useState9, useRef as useRef3 } from "react";
3941
+ import { useEffect as useEffect13, useState as useState11, useRef as useRef3 } from "react";
3930
3942
  import { Fragment as Fragment20, jsx as jsx30, jsxs as jsxs26 } from "react/jsx-runtime";
3931
3943
  var Navigation = ({
3932
3944
  setIsMenyOpen,
@@ -3941,7 +3953,7 @@ var Navigation = ({
3941
3953
  const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
3942
3954
  const navRef = useRef3(null);
3943
3955
  const firstVisitRef = useRef3(true);
3944
- const [openSubMenu, setOpenSubMenu] = useState9(null);
3956
+ const [openSubMenu, setOpenSubMenu] = useState11(null);
3945
3957
  const handleSubMenu = (label) => {
3946
3958
  setOpenSubMenu(openSubMenu === label ? null : label);
3947
3959
  };
@@ -4012,7 +4024,7 @@ var Navigation = ({
4012
4024
  }
4013
4025
  return "\xD6ppna undermeny f\xF6r " + label["sv"];
4014
4026
  };
4015
- const [instruction, setInstruction] = useState9("");
4027
+ const [instruction, setInstruction] = useState11("");
4016
4028
  useEffect13(() => {
4017
4029
  if (firstVisitRef.current) {
4018
4030
  firstVisitRef.current = false;
@@ -4102,7 +4114,7 @@ var Navigation = ({
4102
4114
  var NavigationStandard_default = Navigation;
4103
4115
 
4104
4116
  // src/components/layout/SearchBarStandard/SearchBarStandard.tsx
4105
- import { useState as useState10 } from "react";
4117
+ import { useState as useState12 } from "react";
4106
4118
 
4107
4119
  // src/components/layout/SearchBarStandard/Icons.tsx
4108
4120
  import { jsx as jsx31, jsxs as jsxs27 } from "react/jsx-runtime";
@@ -4126,7 +4138,7 @@ var SearchIcon2 = ({ width = 15, height = 15, color = "#6E3282" }) => /* @__PURE
4126
4138
  // src/components/layout/SearchBarStandard/SearchBarStandard.tsx
4127
4139
  import { jsx as jsx32, jsxs as jsxs28 } from "react/jsx-runtime";
4128
4140
  var SearchBar = ({ activatedLanguage = "sv" }) => {
4129
- const [searchTerm, setSearchTerm] = useState10("");
4141
+ const [searchTerm, setSearchTerm] = useState12("");
4130
4142
  const handleSearch = () => {
4131
4143
  console.log("S\xF6kt efter:", searchTerm);
4132
4144
  };
@@ -4180,7 +4192,7 @@ var NavigationHeader = ({
4180
4192
  if (activatedLanguage === "sv") return "English";
4181
4193
  else return "Svenska";
4182
4194
  };
4183
- const [isMenuOpen, setIsMenuOpen] = useState11(false);
4195
+ const [isMenuOpen, setIsMenuOpen] = useState13(false);
4184
4196
  const menuButtonFocusRef = useRef4(null);
4185
4197
  const handleMenuClick = () => {
4186
4198
  setIsMenuOpen((prev) => !prev);
@@ -4195,7 +4207,7 @@ var NavigationHeader = ({
4195
4207
  const getMenuIcon = () => {
4196
4208
  return isMenuOpen ? /* @__PURE__ */ jsx33(CloseIcon, {}) : /* @__PURE__ */ jsx33(MenuIcon, {});
4197
4209
  };
4198
- const [isSearchOpen, setIsSearchOpen] = useState11(false);
4210
+ const [isSearchOpen, setIsSearchOpen] = useState13(false);
4199
4211
  const handleSearchClick = () => {
4200
4212
  if (!isSearchOpen) {
4201
4213
  setIsSearchOpen(true);
@@ -4436,7 +4448,7 @@ var LinkList = ({
4436
4448
  var LinkListStandard_default = LinkList;
4437
4449
 
4438
4450
  // src/components/layout/CollapseStandard/CollapseStandard.tsx
4439
- import { useState as useState12, useId as useId2 } from "react";
4451
+ import { useState as useState14, useId as useId2 } from "react";
4440
4452
  import { jsx as jsx38, jsxs as jsxs32 } from "react/jsx-runtime";
4441
4453
  var Collapse = ({
4442
4454
  title,
@@ -4446,7 +4458,7 @@ var Collapse = ({
4446
4458
  activatedLanguage = "sv",
4447
4459
  customClass = ""
4448
4460
  }) => {
4449
- const [isOpen, setIsOpen] = useState12(defaultOpen);
4461
+ const [isOpen, setIsOpen] = useState14(defaultOpen);
4450
4462
  const uniqueId = id != null ? id : useId2();
4451
4463
  const contentId = `${uniqueId}-content`;
4452
4464
  const openLabel = activatedLanguage === "sv" ? "Visa" : "Show";
@@ -4561,14 +4573,14 @@ var StepperButtons = ({
4561
4573
  var StepperButtonsStandard_default = StepperButtons;
4562
4574
 
4563
4575
  // src/components/stepper/StepperStandard/StepperStandard.tsx
4564
- import React11 from "react";
4576
+ import React13 from "react";
4565
4577
  import { jsx as jsx42, jsxs as jsxs34 } from "react/jsx-runtime";
4566
4578
  var Stepper = ({ arraySteps = [], activeStep = 1 }) => {
4567
4579
  return /* @__PURE__ */ jsx42("div", { className: "pts-stepper-container", "aria-hidden": "true", children: arraySteps.map((step, index) => {
4568
4580
  const isActive = step.step === activeStep;
4569
4581
  const lastElement = arraySteps.length;
4570
4582
  const isDone = step.step < activeStep;
4571
- return /* @__PURE__ */ jsxs34(React11.Fragment, { children: [
4583
+ return /* @__PURE__ */ jsxs34(React13.Fragment, { children: [
4572
4584
  /* @__PURE__ */ jsxs34("div", { className: "pts-stepper-step", children: [
4573
4585
  /* @__PURE__ */ jsx42(
4574
4586
  "div",