optimized-react-component-library-xyz123 0.1.18 → 0.1.19
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 +10 -12
- package/dist/index.mjs +10 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -841,26 +841,24 @@ var normalize = (str) => {
|
|
|
841
841
|
function CreateApiDataObject(data, specialMappedQuestions, translatedAnswers) {
|
|
842
842
|
return data.reduce((acc, question) => {
|
|
843
843
|
var _a;
|
|
844
|
-
let translatedAnswer = question.
|
|
845
|
-
if (question.
|
|
846
|
-
const answerNormalized = normalize(question.
|
|
847
|
-
const matchingIds = question.
|
|
848
|
-
(option) => answerNormalized.includes(normalize(option.label))
|
|
849
|
-
).map((option) => `^${option.id}^`);
|
|
844
|
+
let translatedAnswer = question.answer;
|
|
845
|
+
if (question.answer && typeof question.answer === "string" && Array.isArray(question.options) && question.mappingId && specialMappedQuestions.has(question.mappingId)) {
|
|
846
|
+
const answerNormalized = normalize(question.answer);
|
|
847
|
+
const matchingIds = question.options.filter((option) => answerNormalized.includes(normalize(option.label))).map((option) => `^${option.id}^`);
|
|
850
848
|
if (matchingIds.length > 0) {
|
|
851
849
|
translatedAnswer = matchingIds.join(",");
|
|
852
850
|
}
|
|
853
851
|
} else {
|
|
854
|
-
const shouldTranslate = question.
|
|
855
|
-
translatedAnswer = shouldTranslate ? shouldTranslate[question.
|
|
852
|
+
const shouldTranslate = question.mappingId ? translatedAnswers[question.mappingId] : void 0;
|
|
853
|
+
translatedAnswer = shouldTranslate ? shouldTranslate[question.answer] || question.answer : question.answer;
|
|
856
854
|
}
|
|
857
855
|
return {
|
|
858
856
|
...acc,
|
|
859
|
-
...question.
|
|
860
|
-
[question.
|
|
857
|
+
...question.mappingId && question.isDisplayed && question.answer && {
|
|
858
|
+
[question.mappingId]: translatedAnswer
|
|
861
859
|
},
|
|
862
|
-
...question.
|
|
863
|
-
files: question.
|
|
860
|
+
...question.questionType === "AddFiles" && ((_a = question.files) == null ? void 0 : _a.length) && question.files.length > 0 && {
|
|
861
|
+
files: question.files
|
|
864
862
|
}
|
|
865
863
|
};
|
|
866
864
|
}, {});
|
package/dist/index.mjs
CHANGED
|
@@ -777,26 +777,24 @@ var normalize = (str) => {
|
|
|
777
777
|
function CreateApiDataObject(data, specialMappedQuestions, translatedAnswers) {
|
|
778
778
|
return data.reduce((acc, question) => {
|
|
779
779
|
var _a;
|
|
780
|
-
let translatedAnswer = question.
|
|
781
|
-
if (question.
|
|
782
|
-
const answerNormalized = normalize(question.
|
|
783
|
-
const matchingIds = question.
|
|
784
|
-
(option) => answerNormalized.includes(normalize(option.label))
|
|
785
|
-
).map((option) => `^${option.id}^`);
|
|
780
|
+
let translatedAnswer = question.answer;
|
|
781
|
+
if (question.answer && typeof question.answer === "string" && Array.isArray(question.options) && question.mappingId && specialMappedQuestions.has(question.mappingId)) {
|
|
782
|
+
const answerNormalized = normalize(question.answer);
|
|
783
|
+
const matchingIds = question.options.filter((option) => answerNormalized.includes(normalize(option.label))).map((option) => `^${option.id}^`);
|
|
786
784
|
if (matchingIds.length > 0) {
|
|
787
785
|
translatedAnswer = matchingIds.join(",");
|
|
788
786
|
}
|
|
789
787
|
} else {
|
|
790
|
-
const shouldTranslate = question.
|
|
791
|
-
translatedAnswer = shouldTranslate ? shouldTranslate[question.
|
|
788
|
+
const shouldTranslate = question.mappingId ? translatedAnswers[question.mappingId] : void 0;
|
|
789
|
+
translatedAnswer = shouldTranslate ? shouldTranslate[question.answer] || question.answer : question.answer;
|
|
792
790
|
}
|
|
793
791
|
return {
|
|
794
792
|
...acc,
|
|
795
|
-
...question.
|
|
796
|
-
[question.
|
|
793
|
+
...question.mappingId && question.isDisplayed && question.answer && {
|
|
794
|
+
[question.mappingId]: translatedAnswer
|
|
797
795
|
},
|
|
798
|
-
...question.
|
|
799
|
-
files: question.
|
|
796
|
+
...question.questionType === "AddFiles" && ((_a = question.files) == null ? void 0 : _a.length) && question.files.length > 0 && {
|
|
797
|
+
files: question.files
|
|
800
798
|
}
|
|
801
799
|
};
|
|
802
800
|
}, {});
|
package/package.json
CHANGED