optimized-react-component-library-xyz123 0.1.161 → 0.1.162
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +26 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/css/questions.css +5 -1
package/dist/index.mjs
CHANGED
|
@@ -923,9 +923,9 @@ var PreviewAddFiles = ({
|
|
|
923
923
|
};
|
|
924
924
|
|
|
925
925
|
// src/components/input-components/SingleCheckboxStandard/SingleCheckboxStandard.tsx
|
|
926
|
-
import { useState as useState5 } from "react";
|
|
926
|
+
import { useEffect as useEffect5, useState as useState5 } from "react";
|
|
927
927
|
import { Fragment as Fragment11, jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
928
|
-
var
|
|
928
|
+
var SingleCheckbox = ({
|
|
929
929
|
question,
|
|
930
930
|
handleQuestionInputChange,
|
|
931
931
|
showPreview = false,
|
|
@@ -937,14 +937,21 @@ var SingleCheckboxes = ({
|
|
|
937
937
|
const aboutId = `about-${question.id}`;
|
|
938
938
|
const errorId = `error-${question.id}`;
|
|
939
939
|
const [checked, setChecked] = useState5(false);
|
|
940
|
+
useEffect5(() => {
|
|
941
|
+
if (question.answer && question.answer === "true") {
|
|
942
|
+
setChecked(true);
|
|
943
|
+
} else {
|
|
944
|
+
setChecked(false);
|
|
945
|
+
}
|
|
946
|
+
}, [question.answer]);
|
|
940
947
|
const handleInputChange = (event) => {
|
|
941
|
-
let answer = checked ? question.questionLabel : "";
|
|
942
948
|
setChecked(event.target.checked);
|
|
949
|
+
let answer = event.target.checked ? "true" : "false";
|
|
943
950
|
const e = { target: { value: answer } };
|
|
944
951
|
handleQuestionInputChange(e, question);
|
|
945
952
|
};
|
|
946
953
|
return /* @__PURE__ */ jsxs9(Fragment11, { children: [
|
|
947
|
-
!showPreview && question.visible && /* @__PURE__ */
|
|
954
|
+
!showPreview && question.visible && /* @__PURE__ */ jsxs9("div", { id: questionId, className: "pts-root-question pts-singleCheckbox-container", children: [
|
|
948
955
|
/* @__PURE__ */ jsx11(
|
|
949
956
|
"input",
|
|
950
957
|
{
|
|
@@ -963,7 +970,7 @@ var SingleCheckboxes = ({
|
|
|
963
970
|
"aria-errormessage": question.hasValidationError ? errorId : void 0
|
|
964
971
|
}
|
|
965
972
|
),
|
|
966
|
-
/* @__PURE__ */ jsx11("label", { htmlFor: `${
|
|
973
|
+
/* @__PURE__ */ jsx11("label", { htmlFor: `${inputId}`, children: question.questionLabel }),
|
|
967
974
|
question.isQuestionMandatory && /* @__PURE__ */ jsx11("span", { "aria-hidden": true, className: "pts-root-mandatoryAsterisk", children: "*" }),
|
|
968
975
|
" ",
|
|
969
976
|
question.aboutText && /* @__PURE__ */ jsx11(
|
|
@@ -981,13 +988,13 @@ var SingleCheckboxes = ({
|
|
|
981
988
|
/* @__PURE__ */ jsx11("span", { className: "errorText", children: question.validationDefaultMessesege })
|
|
982
989
|
] }),
|
|
983
990
|
" "
|
|
984
|
-
] })
|
|
991
|
+
] }),
|
|
985
992
|
" ",
|
|
986
|
-
showPreview && /* @__PURE__ */ jsx11(
|
|
993
|
+
showPreview && /* @__PURE__ */ jsx11(PreviewSingleCheckbox, { activatedLanguage, question })
|
|
987
994
|
] });
|
|
988
995
|
};
|
|
989
|
-
var SingleCheckboxStandard_default =
|
|
990
|
-
var
|
|
996
|
+
var SingleCheckboxStandard_default = SingleCheckbox;
|
|
997
|
+
var PreviewSingleCheckbox = ({
|
|
991
998
|
question,
|
|
992
999
|
activatedLanguage
|
|
993
1000
|
}) => {
|
|
@@ -995,12 +1002,12 @@ var PreviewSingleCheckboxes = ({
|
|
|
995
1002
|
const previewId = `preview-${question.id}`;
|
|
996
1003
|
return /* @__PURE__ */ jsxs9(Fragment11, { children: [
|
|
997
1004
|
/* @__PURE__ */ jsx11("dt", { id: `question-${previewId}`, children: (_a = question.previewLabel) != null ? _a : question.questionLabel }),
|
|
998
|
-
((_b = question.answer) == null ? void 0 : _b.trim()) ? /* @__PURE__ */ jsx11("dd", { className: "pts-singleCheckbox-preview pts-root-answer", id: `answer-${previewId}`, children: question.
|
|
1005
|
+
((_b = question.answer) == null ? void 0 : _b.trim()) ? /* @__PURE__ */ jsx11("dd", { className: "pts-singleCheckbox-preview pts-root-answer", id: `answer-${previewId}`, children: question.questionLabel }) : /* @__PURE__ */ jsx11(
|
|
999
1006
|
"dd",
|
|
1000
1007
|
{
|
|
1001
1008
|
className: "pts-singleCheckbox-preview pts-root-answer no-answer-preview-page",
|
|
1002
1009
|
id: `answer-${previewId}`,
|
|
1003
|
-
children: activatedLanguage === "
|
|
1010
|
+
children: question.answer === "false" ? activatedLanguage === "sv" ? "Nej" : "No" : activatedLanguage === "sv" ? "Ja" : "Yes"
|
|
1004
1011
|
}
|
|
1005
1012
|
)
|
|
1006
1013
|
] });
|
|
@@ -1729,14 +1736,6 @@ var QuestionRenderer = ({
|
|
|
1729
1736
|
showPreview
|
|
1730
1737
|
}
|
|
1731
1738
|
),
|
|
1732
|
-
question.questionType === "SingleCheckboxStandard" && /* @__PURE__ */ jsx12(
|
|
1733
|
-
SingleCheckboxStandard_default,
|
|
1734
|
-
{
|
|
1735
|
-
question,
|
|
1736
|
-
handleQuestionInputChange,
|
|
1737
|
-
showPreview
|
|
1738
|
-
}
|
|
1739
|
-
),
|
|
1740
1739
|
question.questionType === "TextField" && /* @__PURE__ */ jsx12(
|
|
1741
1740
|
TextFieldStandard_default,
|
|
1742
1741
|
{
|
|
@@ -1756,6 +1755,15 @@ var QuestionRenderer = ({
|
|
|
1756
1755
|
visible: question.visible
|
|
1757
1756
|
}
|
|
1758
1757
|
),
|
|
1758
|
+
question.questionType === "SingleCheckbox" && /* @__PURE__ */ jsx12(
|
|
1759
|
+
SingleCheckboxStandard_default,
|
|
1760
|
+
{
|
|
1761
|
+
question,
|
|
1762
|
+
handleQuestionInputChange,
|
|
1763
|
+
showPreview,
|
|
1764
|
+
activatedLanguage
|
|
1765
|
+
}
|
|
1766
|
+
),
|
|
1759
1767
|
question.questionType === "Checkbox" && /* @__PURE__ */ jsx12(
|
|
1760
1768
|
MultipleCheckboxesStandard_default,
|
|
1761
1769
|
{
|