optimized-react-component-library-xyz123 0.21.2 → 0.22.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.js CHANGED
@@ -91,46 +91,63 @@ var InputRadio = ({
91
91
  const questionId = `question-${question.id}`;
92
92
  const groupId = `radio-group-${question.id}`;
93
93
  const errorId = `error-${question.id}`;
94
+ let optionsInfoText = [];
95
+ const languageObj = question.languageSupport[0];
96
+ if ("optionsInfoText" in languageObj) {
97
+ optionsInfoText.push(languageObj.optionsInfoText);
98
+ console.log(languageObj.optionsInfoText);
99
+ }
94
100
  const handleInputChange = (event) => {
95
101
  const e = { target: { value: event.target.value } };
96
102
  handleQuestionInputChange(e, question);
97
103
  };
98
104
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
99
- !showPreview && question.visible && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pts-root-question pts-radioMultiple-container", id: questionId, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
100
- "fieldset",
101
- {
102
- "aria-required": question.isQuestionMandatory,
103
- "aria-invalid": question.hasValidationError ? question.hasValidationError : void 0,
104
- "aria-errormessage": question.hasValidationError ? errorId : void 0,
105
- children: [
106
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("legend", { id: `label-${groupId}`, children: [
107
- question.questionLabel,
108
- " ",
109
- question.isQuestionMandatory && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": true, className: "pts-root-mandatoryAsterisk", children: "*" })
110
- ] }),
111
- (_a = question.options) == null ? void 0 : _a.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pts-radio-option", children: [
112
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
113
- "input",
114
- {
115
- type: "radio",
116
- name: `name-${question.id}`,
117
- id: `${groupId}-option-${index}`,
118
- value: option.value,
119
- checked: question.answer === option.value,
120
- onChange: handleInputChange
121
- }
122
- ),
123
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: `${groupId}-option-${index}`, children: option.label }),
124
- " "
125
- ] }, index)),
126
- question.hasValidationError && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pts-root-error", id: errorId, children: [
127
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": true, className: "errorDot", children: "!" }),
128
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: "Valideringsfel" }),
129
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "errorText", children: question.validationDefaultMessesege })
130
- ] })
131
- ]
132
- }
133
- ) }),
105
+ !showPreview && question.visible && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pts-root-question pts-radioMultiple-container", id: questionId, children: [
106
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
107
+ "fieldset",
108
+ {
109
+ "aria-required": question.isQuestionMandatory,
110
+ "aria-invalid": question.hasValidationError ? question.hasValidationError : void 0,
111
+ "aria-errormessage": question.hasValidationError ? errorId : void 0,
112
+ children: [
113
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("legend", { id: `label-${groupId}`, children: [
114
+ question.questionLabel,
115
+ " ",
116
+ question.isQuestionMandatory && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": true, className: "pts-root-mandatoryAsterisk", children: "*" })
117
+ ] }),
118
+ (_a = question.options) == null ? void 0 : _a.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pts-radio-option", children: [
119
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
120
+ "input",
121
+ {
122
+ type: "radio",
123
+ name: `name-${question.id}`,
124
+ id: `${groupId}-option-${index}`,
125
+ value: option.value,
126
+ checked: question.answer === option.value,
127
+ onChange: handleInputChange,
128
+ "aria-describedby": "about_" + option.value
129
+ }
130
+ ),
131
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: `${groupId}-option-${index}`, children: option.label }),
132
+ " "
133
+ ] }, index)),
134
+ question.hasValidationError && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pts-root-error", id: errorId, children: [
135
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": true, className: "errorDot", children: "!" }),
136
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: "Valideringsfel" }),
137
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "errorText", children: question.validationDefaultMessesege })
138
+ ] })
139
+ ]
140
+ }
141
+ ),
142
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
143
+ "div",
144
+ {
145
+ id: "textinfo-option3",
146
+ "aria-live": "polite",
147
+ "aria-atomic": "true"
148
+ }
149
+ )
150
+ ] }),
134
151
  showPreview && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PreviewRadio, { question })
135
152
  ] });
136
153
  };
@@ -702,9 +719,7 @@ var SelectedFiles = ({
702
719
  let newFiles = questionObject.files.filter((f) => f !== file);
703
720
  const newCountOfFiles = newFiles.length;
704
721
  setNumberOfFiles(newCountOfFiles);
705
- let e = { target: { value: `${newCountOfFiles} files`, files: newFiles } };
706
- const targetValue = e.target.value === "0 files" ? "" : e.target.value;
707
- e = { ...e, target: { ...e.target, value: targetValue } };
722
+ const e = { target: { value: `${newCountOfFiles} files`, files: newFiles } };
708
723
  isTouched(e, questionObject);
709
724
  removeFile(newCountOfFiles);
710
725
  };
@@ -994,7 +1009,7 @@ var AddFiles = ({
994
1009
  const currentFiles = questionObject.files ? questionObject.files : [];
995
1010
  const e = {
996
1011
  target: {
997
- value: currentFiles.length + newFiles.length > 0 ? `${currentFiles.length + newFiles.length} files` : "",
1012
+ value: `${currentFiles.length + newFiles.length} files`,
998
1013
  files: [...currentFiles, ...newFiles]
999
1014
  }
1000
1015
  };
@@ -1017,75 +1032,68 @@ var AddFiles = ({
1017
1032
  setErrorMessageAddingFile([]);
1018
1033
  };
1019
1034
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1020
- !showPreview && visible && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1021
- "div",
1022
- {
1023
- className: "root-question addFile-question-container",
1024
- id: `question-${questionObject.id}`,
1025
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { role: "group", children: [
1026
- questionObject.aboutText && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1027
- "p",
1028
- {
1029
- id: aboutId,
1030
- className: (0, import_clsx3.default)(
1031
- "addFilesMandatory",
1032
- questionObject.hasValidationError ? " error" : ""
1033
- ),
1034
- children: [
1035
- questionObject.aboutText,
1036
- questionObject.isQuestionMandatory && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "pts-root-mandatoryAsterisk", "aria-label": "Obligatorisk fr\xE5ga", children: [
1037
- " ",
1038
- "*"
1039
- ] })
1040
- ]
1041
- }
1042
- ),
1043
- questionObject.hasValidationError && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "pts-root-error error addfileserror", id: errorId, children: [
1044
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { "aria-hidden": true, className: "errorDot", children: "!" }),
1045
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "sr-only", children: "Valideringsfel" }),
1046
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "errorText", children: questionObject.validationDefaultMessesege })
1047
- ] }),
1048
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1049
- ExploreFilesStandard_default,
1050
- {
1051
- FilesSelected: onDrop,
1052
- numberOfFiles,
1053
- allowedNumberOfFiles,
1054
- activatedLanguage,
1055
- inputId,
1056
- labelId,
1057
- aboutId,
1058
- errorId,
1059
- questionObject,
1060
- errorMessageAddingFile,
1061
- removeUploadErrors: handleRemoveErrors
1062
- }
1063
- ),
1064
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1065
- DropFilesStandard_default,
1066
- {
1067
- FilesSelected: onDrop,
1068
- DropFilesText: dropFilesText,
1069
- language: activatedLanguage
1070
- }
1035
+ !showPreview && visible && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "root-question addFile-question-container", id: `question-${questionObject.id}`, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { role: "group", children: [
1036
+ questionObject.aboutText && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1037
+ "p",
1038
+ {
1039
+ id: aboutId,
1040
+ className: (0, import_clsx3.default)(
1041
+ "addFilesMandatory",
1042
+ questionObject.hasValidationError ? " error" : ""
1071
1043
  ),
1072
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1073
- SelectedFilesStandard_default,
1074
- {
1075
- questionObject,
1076
- isTouched: handleQuestionInputChange,
1077
- removeFile: removeFileFromNumberOfFiles,
1078
- removeError,
1079
- errorMessageAddingFile,
1080
- activatedLanguage,
1081
- numberOfFiles,
1082
- setNumberOfFiles,
1083
- removeUploadErrors: handleRemoveErrors
1084
- }
1085
- )
1086
- ] })
1087
- }
1088
- ),
1044
+ children: [
1045
+ questionObject.aboutText,
1046
+ questionObject.isQuestionMandatory && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "pts-root-mandatoryAsterisk", "aria-label": "Obligatorisk fr\xE5ga", children: [
1047
+ " ",
1048
+ "*"
1049
+ ] })
1050
+ ]
1051
+ }
1052
+ ),
1053
+ questionObject.hasValidationError && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "pts-root-error error addfileserror", id: errorId, children: [
1054
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { "aria-hidden": true, className: "errorDot", children: "!" }),
1055
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "sr-only", children: "Valideringsfel" }),
1056
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "errorText", children: questionObject.validationDefaultMessesege })
1057
+ ] }),
1058
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1059
+ ExploreFilesStandard_default,
1060
+ {
1061
+ FilesSelected: onDrop,
1062
+ numberOfFiles,
1063
+ allowedNumberOfFiles,
1064
+ activatedLanguage,
1065
+ inputId,
1066
+ labelId,
1067
+ aboutId,
1068
+ errorId,
1069
+ questionObject,
1070
+ errorMessageAddingFile,
1071
+ removeUploadErrors: handleRemoveErrors
1072
+ }
1073
+ ),
1074
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1075
+ DropFilesStandard_default,
1076
+ {
1077
+ FilesSelected: onDrop,
1078
+ DropFilesText: dropFilesText,
1079
+ language: activatedLanguage
1080
+ }
1081
+ ),
1082
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1083
+ SelectedFilesStandard_default,
1084
+ {
1085
+ questionObject,
1086
+ isTouched: handleQuestionInputChange,
1087
+ removeFile: removeFileFromNumberOfFiles,
1088
+ removeError,
1089
+ errorMessageAddingFile,
1090
+ activatedLanguage,
1091
+ numberOfFiles,
1092
+ setNumberOfFiles,
1093
+ removeUploadErrors: handleRemoveErrors
1094
+ }
1095
+ )
1096
+ ] }) }),
1089
1097
  showPreview && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PreviewAddFiles, { activatedLanguage, questionObject })
1090
1098
  ] });
1091
1099
  };