@constructor-io/constructorio-ui-quizzes 1.9.2 → 1.9.4
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/constructorio-ui-quizzes-bundled.js +10 -10
- package/lib/cjs/{src/components → components}/CioQuiz/quizLocalReducer.js +1 -3
- package/lib/cjs/{src/hooks → hooks}/usePropsGetters/useSelectInputProps.js +10 -3
- package/lib/cjs/{src/services → services}/index.js +2 -2
- package/lib/cjs/version.js +3 -0
- package/lib/mjs/{src/components → components}/CioQuiz/quizLocalReducer.js +1 -3
- package/lib/mjs/{src/hooks → hooks}/usePropsGetters/useSelectInputProps.js +11 -3
- package/lib/mjs/{src/services → services}/index.js +2 -2
- package/lib/mjs/version.js +1 -0
- package/lib/types/{src/components → components}/CioQuiz/actions.d.ts +2 -2
- package/lib/types/{src/types.d.ts → types.d.ts} +2 -2
- package/lib/types/version.d.ts +2 -0
- package/package.json +4 -3
- package/lib/cjs/package.json +0 -105
- package/lib/mjs/package.json +0 -105
- /package/lib/cjs/{src/components → components}/BackButton/BackButton.js +0 -0
- /package/lib/cjs/{src/components → components}/CTAButton/CTAButton.js +0 -0
- /package/lib/cjs/{src/components → components}/CioQuiz/actions.js +0 -0
- /package/lib/cjs/{src/components → components}/CioQuiz/context.js +0 -0
- /package/lib/cjs/{src/components → components}/CioQuiz/index.js +0 -0
- /package/lib/cjs/{src/components → components}/CioQuiz/quizApiReducer.js +0 -0
- /package/lib/cjs/{src/components → components}/ControlBar/ControlBar.js +0 -0
- /package/lib/cjs/{src/components → components}/CoverTypeQuestion/CoverTypeQuestion.js +0 -0
- /package/lib/cjs/{src/components → components}/OpenTextTypeQuestion/OpenTextTypeQuestion.js +0 -0
- /package/lib/cjs/{src/components → components}/ProgressBar/ProgressBar.js +0 -0
- /package/lib/cjs/{src/components → components}/QuestionDescription/QuestionDescription.js +0 -0
- /package/lib/cjs/{src/components → components}/QuestionTitle/QuestionTitle.js +0 -0
- /package/lib/cjs/{src/components → components}/QuizQuestions/index.js +0 -0
- /package/lib/cjs/{src/components → components}/RedoButton/RedoButton.js +0 -0
- /package/lib/cjs/{src/components → components}/RedoButton/RedoSVG.js +0 -0
- /package/lib/cjs/{src/components → components}/ResultCard/ResultCard.js +0 -0
- /package/lib/cjs/{src/components → components}/ResultContainer/ResultContainer.js +0 -0
- /package/lib/cjs/{src/components → components}/ResultCtaButton/ResultCtaButton.js +0 -0
- /package/lib/cjs/{src/components → components}/ResultFavoritesButton/ResultFavoritesButton.js +0 -0
- /package/lib/cjs/{src/components → components}/ResultFilters/ResultFilters.js +0 -0
- /package/lib/cjs/{src/components → components}/ResultHeroCard/ResultHeroCard.js +0 -0
- /package/lib/cjs/{src/components → components}/Results/Results.js +0 -0
- /package/lib/cjs/{src/components → components}/SelectTypeQuestion/SelectTypeQuestion.js +0 -0
- /package/lib/cjs/{src/components → components}/SessionPromptModal/SessionPromptModal.js +0 -0
- /package/lib/cjs/{src/components → components}/SkipButton/SkipButton.js +0 -0
- /package/lib/cjs/{src/components → components}/Spinner/Spinner.js +0 -0
- /package/lib/cjs/{src/components → components}/ZeroResults/ZeroResults.js +0 -0
- /package/lib/cjs/{src/constants.js → constants.js} +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useCioClient.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useConsoleErrors.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/usePrimaryColorStyles.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/usePropsGetters/index.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/usePropsGetters/useAddToFavoritesButtonProps.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/usePropsGetters/useCoverQuestionProps.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/usePropsGetters/useNextQuestionButtonProps.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/usePropsGetters/useOpenTextInputProps.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/usePropsGetters/usePreviousQuestionButtonProps.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/usePropsGetters/useSkipQuestionButtonProps.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useQuiz.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useQuizEvents/index.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useQuizEvents/useHydrateQuizLocalState.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useQuizEvents/useQuizAddToCart.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useQuizEvents/useQuizAddToFavorites.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useQuizEvents/useQuizAnswerChangeHandler.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useQuizEvents/useQuizBackClick.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useQuizEvents/useQuizNextClick.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useQuizEvents/useQuizResetClick.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useQuizEvents/useQuizResultClick.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useQuizEvents/useQuizResultsLoaded.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useQuizEvents/useQuizSkipClick.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useQuizState/index.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useQuizState/useQuizApiState.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useQuizState/useQuizLocalState.js +0 -0
- /package/lib/cjs/{src/hooks → hooks}/useQuizState/useSessionStorageState.js +0 -0
- /package/lib/cjs/{src/index.js → index.js} +0 -0
- /package/lib/cjs/{src/stories → stories}/Quiz/argTypes.js +0 -0
- /package/lib/cjs/{src/stories → stories}/Quiz/tests/mocks.js +0 -0
- /package/lib/cjs/{src/types.js → types.js} +0 -0
- /package/lib/cjs/{src/utils.js → utils.js} +0 -0
- /package/lib/mjs/{src/components → components}/BackButton/BackButton.js +0 -0
- /package/lib/mjs/{src/components → components}/CTAButton/CTAButton.js +0 -0
- /package/lib/mjs/{src/components → components}/CioQuiz/actions.js +0 -0
- /package/lib/mjs/{src/components → components}/CioQuiz/context.js +0 -0
- /package/lib/mjs/{src/components → components}/CioQuiz/index.js +0 -0
- /package/lib/mjs/{src/components → components}/CioQuiz/quizApiReducer.js +0 -0
- /package/lib/mjs/{src/components → components}/ControlBar/ControlBar.js +0 -0
- /package/lib/mjs/{src/components → components}/CoverTypeQuestion/CoverTypeQuestion.js +0 -0
- /package/lib/mjs/{src/components → components}/OpenTextTypeQuestion/OpenTextTypeQuestion.js +0 -0
- /package/lib/mjs/{src/components → components}/ProgressBar/ProgressBar.js +0 -0
- /package/lib/mjs/{src/components → components}/QuestionDescription/QuestionDescription.js +0 -0
- /package/lib/mjs/{src/components → components}/QuestionTitle/QuestionTitle.js +0 -0
- /package/lib/mjs/{src/components → components}/QuizQuestions/index.js +0 -0
- /package/lib/mjs/{src/components → components}/RedoButton/RedoButton.js +0 -0
- /package/lib/mjs/{src/components → components}/RedoButton/RedoSVG.js +0 -0
- /package/lib/mjs/{src/components → components}/ResultCard/ResultCard.js +0 -0
- /package/lib/mjs/{src/components → components}/ResultContainer/ResultContainer.js +0 -0
- /package/lib/mjs/{src/components → components}/ResultCtaButton/ResultCtaButton.js +0 -0
- /package/lib/mjs/{src/components → components}/ResultFavoritesButton/ResultFavoritesButton.js +0 -0
- /package/lib/mjs/{src/components → components}/ResultFilters/ResultFilters.js +0 -0
- /package/lib/mjs/{src/components → components}/ResultHeroCard/ResultHeroCard.js +0 -0
- /package/lib/mjs/{src/components → components}/Results/Results.js +0 -0
- /package/lib/mjs/{src/components → components}/SelectTypeQuestion/SelectTypeQuestion.js +0 -0
- /package/lib/mjs/{src/components → components}/SessionPromptModal/SessionPromptModal.js +0 -0
- /package/lib/mjs/{src/components → components}/SkipButton/SkipButton.js +0 -0
- /package/lib/mjs/{src/components → components}/Spinner/Spinner.js +0 -0
- /package/lib/mjs/{src/components → components}/ZeroResults/ZeroResults.js +0 -0
- /package/lib/mjs/{src/constants.js → constants.js} +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useCioClient.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useConsoleErrors.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/usePrimaryColorStyles.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/usePropsGetters/index.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/usePropsGetters/useAddToFavoritesButtonProps.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/usePropsGetters/useCoverQuestionProps.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/usePropsGetters/useNextQuestionButtonProps.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/usePropsGetters/useOpenTextInputProps.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/usePropsGetters/usePreviousQuestionButtonProps.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/usePropsGetters/useSkipQuestionButtonProps.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useQuiz.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useQuizEvents/index.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useQuizEvents/useHydrateQuizLocalState.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useQuizEvents/useQuizAddToCart.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useQuizEvents/useQuizAddToFavorites.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useQuizEvents/useQuizAnswerChangeHandler.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useQuizEvents/useQuizBackClick.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useQuizEvents/useQuizNextClick.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useQuizEvents/useQuizResetClick.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useQuizEvents/useQuizResultClick.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useQuizEvents/useQuizResultsLoaded.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useQuizEvents/useQuizSkipClick.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useQuizState/index.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useQuizState/useQuizApiState.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useQuizState/useQuizLocalState.js +0 -0
- /package/lib/mjs/{src/hooks → hooks}/useQuizState/useSessionStorageState.js +0 -0
- /package/lib/mjs/{src/index.js → index.js} +0 -0
- /package/lib/mjs/{src/stories → stories}/Quiz/argTypes.js +0 -0
- /package/lib/mjs/{src/stories → stories}/Quiz/tests/mocks.js +0 -0
- /package/lib/mjs/{src/types.js → types.js} +0 -0
- /package/lib/mjs/{src/utils.js → utils.js} +0 -0
- /package/lib/types/{src/components → components}/BackButton/BackButton.d.ts +0 -0
- /package/lib/types/{src/components → components}/CTAButton/CTAButton.d.ts +0 -0
- /package/lib/types/{src/components → components}/CioQuiz/context.d.ts +0 -0
- /package/lib/types/{src/components → components}/CioQuiz/index.d.ts +0 -0
- /package/lib/types/{src/components → components}/CioQuiz/quizApiReducer.d.ts +0 -0
- /package/lib/types/{src/components → components}/CioQuiz/quizLocalReducer.d.ts +0 -0
- /package/lib/types/{src/components → components}/ControlBar/ControlBar.d.ts +0 -0
- /package/lib/types/{src/components → components}/CoverTypeQuestion/CoverTypeQuestion.d.ts +0 -0
- /package/lib/types/{src/components → components}/OpenTextTypeQuestion/OpenTextTypeQuestion.d.ts +0 -0
- /package/lib/types/{src/components → components}/ProgressBar/ProgressBar.d.ts +0 -0
- /package/lib/types/{src/components → components}/QuestionDescription/QuestionDescription.d.ts +0 -0
- /package/lib/types/{src/components → components}/QuestionTitle/QuestionTitle.d.ts +0 -0
- /package/lib/types/{src/components → components}/QuizQuestions/index.d.ts +0 -0
- /package/lib/types/{src/components → components}/RedoButton/RedoButton.d.ts +0 -0
- /package/lib/types/{src/components → components}/RedoButton/RedoSVG.d.ts +0 -0
- /package/lib/types/{src/components → components}/ResultCard/ResultCard.d.ts +0 -0
- /package/lib/types/{src/components → components}/ResultContainer/ResultContainer.d.ts +0 -0
- /package/lib/types/{src/components → components}/ResultCtaButton/ResultCtaButton.d.ts +0 -0
- /package/lib/types/{src/components → components}/ResultFavoritesButton/ResultFavoritesButton.d.ts +0 -0
- /package/lib/types/{src/components → components}/ResultFilters/ResultFilters.d.ts +0 -0
- /package/lib/types/{src/components → components}/ResultHeroCard/ResultHeroCard.d.ts +0 -0
- /package/lib/types/{src/components → components}/Results/Results.d.ts +0 -0
- /package/lib/types/{src/components → components}/SelectTypeQuestion/SelectTypeQuestion.d.ts +0 -0
- /package/lib/types/{src/components → components}/SessionPromptModal/SessionPromptModal.d.ts +0 -0
- /package/lib/types/{src/components → components}/SkipButton/SkipButton.d.ts +0 -0
- /package/lib/types/{src/components → components}/Spinner/Spinner.d.ts +0 -0
- /package/lib/types/{src/components → components}/ZeroResults/ZeroResults.d.ts +0 -0
- /package/lib/types/{src/constants.d.ts → constants.d.ts} +0 -0
- /package/lib/types/{src/hooks → hooks}/useCioClient.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/useConsoleErrors.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/usePrimaryColorStyles.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/usePropsGetters/index.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/usePropsGetters/useAddToFavoritesButtonProps.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/usePropsGetters/useCoverQuestionProps.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/usePropsGetters/useNextQuestionButtonProps.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/usePropsGetters/useOpenTextInputProps.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/usePropsGetters/usePreviousQuestionButtonProps.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/usePropsGetters/useSelectInputProps.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/usePropsGetters/useSkipQuestionButtonProps.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/useQuiz.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/useQuizEvents/index.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/useQuizEvents/useHydrateQuizLocalState.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/useQuizEvents/useQuizAddToCart.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/useQuizEvents/useQuizAddToFavorites.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/useQuizEvents/useQuizAnswerChangeHandler.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/useQuizEvents/useQuizBackClick.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/useQuizEvents/useQuizNextClick.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/useQuizEvents/useQuizResetClick.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/useQuizEvents/useQuizResultClick.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/useQuizEvents/useQuizResultsLoaded.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/useQuizEvents/useQuizSkipClick.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/useQuizState/index.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/useQuizState/useQuizApiState.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/useQuizState/useQuizLocalState.d.ts +0 -0
- /package/lib/types/{src/hooks → hooks}/useQuizState/useSessionStorageState.d.ts +0 -0
- /package/lib/types/{src/index.d.ts → index.d.ts} +0 -0
- /package/lib/types/{src/services → services}/index.d.ts +0 -0
- /package/lib/types/{src/stories → stories}/Quiz/argTypes.d.ts +0 -0
- /package/lib/types/{src/stories → stories}/Quiz/tests/mocks.d.ts +0 -0
- /package/lib/types/{src/utils.d.ts → utils.d.ts} +0 -0
|
@@ -39,10 +39,8 @@ function quizLocalReducer(state, action) {
|
|
|
39
39
|
newAnswers.push(['seen']);
|
|
40
40
|
break;
|
|
41
41
|
case actions_1.QuestionTypes.SingleSelect:
|
|
42
|
-
newAnswers.push(currentAnswerInput.value);
|
|
43
|
-
break;
|
|
44
42
|
case actions_1.QuestionTypes.MultipleSelect:
|
|
45
|
-
newAnswers.push(currentAnswerInput.value);
|
|
43
|
+
newAnswers.push(currentAnswerInput.value.map((answer) => answer.id));
|
|
46
44
|
break;
|
|
47
45
|
default:
|
|
48
46
|
newAnswers.push([]);
|
|
@@ -39,7 +39,7 @@ function useSelectInputProps(quizAnswerChanged, nextQuestion, currentQuestionDat
|
|
|
39
39
|
const prevSelected = {};
|
|
40
40
|
if (Array.isArray(currentAnswer === null || currentAnswer === void 0 ? void 0 : currentAnswer.value)) {
|
|
41
41
|
(_a = currentAnswer === null || currentAnswer === void 0 ? void 0 : currentAnswer.value) === null || _a === void 0 ? void 0 : _a.forEach((answer) => {
|
|
42
|
-
prevSelected[Number(answer)] = true;
|
|
42
|
+
prevSelected[Number(answer.id)] = true;
|
|
43
43
|
setSelected(prevSelected);
|
|
44
44
|
});
|
|
45
45
|
}
|
|
@@ -52,11 +52,18 @@ function useSelectInputProps(quizAnswerChanged, nextQuestion, currentQuestionDat
|
|
|
52
52
|
}, [currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.id]);
|
|
53
53
|
// Update global state
|
|
54
54
|
(0, react_1.useEffect)(() => {
|
|
55
|
+
var _a, _b;
|
|
55
56
|
if ((currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.type) === 'multiple' || (currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.type) === 'single') {
|
|
56
|
-
const selectedAnswers =
|
|
57
|
+
const selectedAnswers = (_b = (_a = currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.options) === null || _a === void 0 ? void 0 : _a.filter((opt) => selected[Number(opt.id)])) === null || _b === void 0 ? void 0 : _b.map((opt) => ({ id: opt.id, value: opt.value }));
|
|
57
58
|
quizAnswerChanged(selectedAnswers);
|
|
58
59
|
}
|
|
59
|
-
}, [
|
|
60
|
+
}, [
|
|
61
|
+
selected,
|
|
62
|
+
currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.id,
|
|
63
|
+
currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.type,
|
|
64
|
+
currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.options,
|
|
65
|
+
quizAnswerChanged,
|
|
66
|
+
]);
|
|
60
67
|
// Go to next question only every time answerInputs (answers input state) changes...
|
|
61
68
|
// and it's a singleSelectQuestion and user has just clicked on an option
|
|
62
69
|
(0, react_1.useEffect)(() => {
|
|
@@ -4,13 +4,13 @@ exports.trackQuizConversion = exports.trackQuizResultClick = exports.trackQuizRe
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
6
6
|
const constructorio_client_javascript_1 = tslib_1.__importDefault(require("@constructor-io/constructorio-client-javascript"));
|
|
7
|
-
const
|
|
7
|
+
const version_1 = tslib_1.__importDefault(require("../version"));
|
|
8
8
|
const getCioClient = (apiKey) => {
|
|
9
9
|
if (apiKey) {
|
|
10
10
|
return new constructorio_client_javascript_1.default({
|
|
11
11
|
apiKey,
|
|
12
12
|
sendTrackingEvents: true,
|
|
13
|
-
version: `cio-ui-quizzes-${
|
|
13
|
+
version: `cio-ui-quizzes-${version_1.default}`,
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
return undefined;
|
|
@@ -58,10 +58,8 @@ export default function quizLocalReducer(state, action) {
|
|
|
58
58
|
newAnswers.push(['seen']);
|
|
59
59
|
break;
|
|
60
60
|
case QuestionTypes.SingleSelect:
|
|
61
|
-
newAnswers.push(currentAnswerInput.value);
|
|
62
|
-
break;
|
|
63
61
|
case QuestionTypes.MultipleSelect:
|
|
64
|
-
newAnswers.push(currentAnswerInput.value);
|
|
62
|
+
newAnswers.push(currentAnswerInput.value.map((answer) => answer.id));
|
|
65
63
|
break;
|
|
66
64
|
default:
|
|
67
65
|
newAnswers.push([]);
|
|
@@ -35,7 +35,7 @@ export default function useSelectInputProps(quizAnswerChanged, nextQuestion, cur
|
|
|
35
35
|
const prevSelected = {};
|
|
36
36
|
if (Array.isArray(currentAnswer?.value)) {
|
|
37
37
|
currentAnswer?.value?.forEach((answer) => {
|
|
38
|
-
prevSelected[Number(answer)] = true;
|
|
38
|
+
prevSelected[Number(answer.id)] = true;
|
|
39
39
|
setSelected(prevSelected);
|
|
40
40
|
});
|
|
41
41
|
}
|
|
@@ -49,10 +49,18 @@ export default function useSelectInputProps(quizAnswerChanged, nextQuestion, cur
|
|
|
49
49
|
// Update global state
|
|
50
50
|
useEffect(() => {
|
|
51
51
|
if (currentQuestionData?.type === 'multiple' || currentQuestionData?.type === 'single') {
|
|
52
|
-
const selectedAnswers =
|
|
52
|
+
const selectedAnswers = currentQuestionData?.options
|
|
53
|
+
?.filter((opt) => selected[Number(opt.id)])
|
|
54
|
+
?.map((opt) => ({ id: opt.id, value: opt.value }));
|
|
53
55
|
quizAnswerChanged(selectedAnswers);
|
|
54
56
|
}
|
|
55
|
-
}, [
|
|
57
|
+
}, [
|
|
58
|
+
selected,
|
|
59
|
+
currentQuestionData?.id,
|
|
60
|
+
currentQuestionData?.type,
|
|
61
|
+
currentQuestionData?.options,
|
|
62
|
+
quizAnswerChanged,
|
|
63
|
+
]);
|
|
56
64
|
// Go to next question only every time answerInputs (answers input state) changes...
|
|
57
65
|
// and it's a singleSelectQuestion and user has just clicked on an option
|
|
58
66
|
useEffect(() => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
2
|
import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';
|
|
3
|
-
import
|
|
3
|
+
import version from '../version';
|
|
4
4
|
export const getCioClient = (apiKey) => {
|
|
5
5
|
if (apiKey) {
|
|
6
6
|
return new ConstructorIOClient({
|
|
7
7
|
apiKey,
|
|
8
8
|
sendTrackingEvents: true,
|
|
9
|
-
version: `cio-ui-quizzes-${
|
|
9
|
+
version: `cio-ui-quizzes-${version}`,
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
return undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default '1.9.4';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CurrentQuestion, NextQuestionResponse, QuizResultsResponse } from '../../types';
|
|
1
|
+
import { CurrentQuestion, NextQuestionResponse, QuestionOption, QuizResultsResponse } from '../../types';
|
|
2
2
|
import type { QuizLocalReducerState } from './quizLocalReducer';
|
|
3
3
|
export declare enum QuestionTypes {
|
|
4
4
|
OpenText = "open",
|
|
@@ -17,7 +17,7 @@ export interface QuestionAnswer<Value> {
|
|
|
17
17
|
input: Value;
|
|
18
18
|
isLastQuestion?: boolean;
|
|
19
19
|
}
|
|
20
|
-
export type SelectQuestionPayload = QuestionAnswer<
|
|
20
|
+
export type SelectQuestionPayload = QuestionAnswer<Omit<QuestionOption, 'attribute' | 'images'>[]>;
|
|
21
21
|
export type OpenTextQuestionPayload = QuestionAnswer<string>;
|
|
22
22
|
export type CoverQuestionPayload = QuestionAnswer<string>;
|
|
23
23
|
interface Action<Type, Payload = {}> {
|
|
@@ -68,7 +68,7 @@ export interface QuizReturnState {
|
|
|
68
68
|
}
|
|
69
69
|
export type AnswerInput = {
|
|
70
70
|
type: InputQuestionsTypes;
|
|
71
|
-
value: string |
|
|
71
|
+
value: string | Omit<QuestionOption, 'attribute' | 'images'>[] | null;
|
|
72
72
|
};
|
|
73
73
|
export type AnswerInputState = {
|
|
74
74
|
[key: string]: AnswerInput;
|
|
@@ -88,7 +88,7 @@ export type CurrentQuestion = NextQuestionResponse & {
|
|
|
88
88
|
isSelectQuestion: boolean;
|
|
89
89
|
};
|
|
90
90
|
export declare namespace QuizEventsReturn {
|
|
91
|
-
type QuizAnswerChanged = (payload?: string |
|
|
91
|
+
type QuizAnswerChanged = (payload?: string | Omit<QuestionOption, 'attribute' | 'images'>[]) => void;
|
|
92
92
|
type NextQuestion = () => void;
|
|
93
93
|
type SkipQuestion = () => void;
|
|
94
94
|
type PreviousQuestion = () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructor-io/constructorio-ui-quizzes",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.4",
|
|
4
4
|
"description": "Constructor.io Quizzes UI library for web applications",
|
|
5
5
|
"author": "constructor.io",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,8 +53,9 @@
|
|
|
53
53
|
"build-storybook": "storybook build -o 'docs'",
|
|
54
54
|
"serve-built-storybook": "npx http-server docs",
|
|
55
55
|
"verify-node-version": "chmod +x ./scripts/verify-node-version.sh && ./scripts/verify-node-version.sh",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
56
|
+
"preversion": "node ./src/generateVersion.js",
|
|
57
|
+
"version": "npm run preversion && npm run verify-node-version && npm run build-storybook && git add -u ./docs && git add ./docs/* && git add ./src/version.ts && npm run compile",
|
|
58
|
+
"compile": "node ./src/generateVersion.js && rm -rf lib && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && npm run copy-styles && vite build",
|
|
58
59
|
"check-license": "license-checker --production --onlyAllow 'Apache-2.0;BSD-3-Clause;MIT;0BSD;BSD-2-Clause' --excludePackages 'picocolors@1.0.0'"
|
|
59
60
|
},
|
|
60
61
|
"peerDependencies": {
|
package/lib/cjs/package.json
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@constructor-io/constructorio-ui-quizzes",
|
|
3
|
-
"version": "1.9.2",
|
|
4
|
-
"description": "Constructor.io Quizzes UI library for web applications",
|
|
5
|
-
"author": "constructor.io",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"homepage": "https://github.com/Constructor-io/constructorio-ui-quizzes#readme",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/Constructor-io/constructorio-ui-quizzes.git"
|
|
11
|
-
},
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/Constructor-io/constructorio-ui-quizzes/issues"
|
|
14
|
-
},
|
|
15
|
-
"main": "lib/cjs/index.js",
|
|
16
|
-
"module": "lib/mjs/index.js",
|
|
17
|
-
"exports": {
|
|
18
|
-
"./styles.css": {
|
|
19
|
-
"import": "./lib/styles.css",
|
|
20
|
-
"require": "./lib/styles.css"
|
|
21
|
-
},
|
|
22
|
-
"./constructorio-ui-quizzes-bundled": {
|
|
23
|
-
"import": "./dist/constructorio-ui-quizzes-bundled.js",
|
|
24
|
-
"require": "./dist/constructorio-ui-quizzes-bundled.js"
|
|
25
|
-
},
|
|
26
|
-
".": {
|
|
27
|
-
"import": "./lib/mjs/index.js",
|
|
28
|
-
"require": "./lib/cjs/index.js"
|
|
29
|
-
},
|
|
30
|
-
"./cjs": {
|
|
31
|
-
"import": "./lib/cjs/index.js",
|
|
32
|
-
"require": "./lib/cjs/index.js"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"files": [
|
|
36
|
-
"lib/**/*",
|
|
37
|
-
"dist/constructorio-ui-quizzes-bundled.js"
|
|
38
|
-
],
|
|
39
|
-
"engines": {
|
|
40
|
-
"node": ">=14"
|
|
41
|
-
},
|
|
42
|
-
"types": "lib/types/index.d.ts",
|
|
43
|
-
"scripts": {
|
|
44
|
-
"lint": "eslint src --ext js,ts,jsx,tsx",
|
|
45
|
-
"check-types": "npx tsc --noEmit",
|
|
46
|
-
"copy-styles": "cp src/styles.css lib/styles.css",
|
|
47
|
-
"prepare": "husky install",
|
|
48
|
-
"dev": "storybook dev -p 6006",
|
|
49
|
-
"storybook:ci": "storybook dev --ci --quiet -p 6006",
|
|
50
|
-
"test-storybook": "test-storybook",
|
|
51
|
-
"test-storybook:watch": "test-storybook --watch",
|
|
52
|
-
"test-storybook:ci": "start-server-and-test storybook:ci http://localhost:6006 test-storybook",
|
|
53
|
-
"build-storybook": "storybook build -o 'docs'",
|
|
54
|
-
"serve-built-storybook": "npx http-server docs",
|
|
55
|
-
"verify-node-version": "chmod +x ./scripts/verify-node-version.sh && ./scripts/verify-node-version.sh",
|
|
56
|
-
"version": "npm run verify-node-version && npm run build-storybook && git add -u ./docs && git add ./docs/* && npm run compile",
|
|
57
|
-
"compile": "rm -rf lib && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && npm run copy-styles && vite build",
|
|
58
|
-
"check-license": "license-checker --production --onlyAllow 'Apache-2.0;BSD-3-Clause;MIT;0BSD;BSD-2-Clause' --excludePackages 'picocolors@1.0.0'"
|
|
59
|
-
},
|
|
60
|
-
"peerDependencies": {
|
|
61
|
-
"@constructor-io/constructorio-client-javascript": "^2.35.17",
|
|
62
|
-
"react": ">=16.12.0",
|
|
63
|
-
"react-dom": ">=16.12.0",
|
|
64
|
-
"tslib": "^2.4.0"
|
|
65
|
-
},
|
|
66
|
-
"devDependencies": {
|
|
67
|
-
"@axe-core/react": "^4.7.0",
|
|
68
|
-
"@cspell/eslint-plugin": "^6.18.1",
|
|
69
|
-
"@storybook/addon-a11y": "^7.0.11",
|
|
70
|
-
"@storybook/addon-actions": "7.0.11",
|
|
71
|
-
"@storybook/addon-essentials": "7.0.11",
|
|
72
|
-
"@storybook/addon-interactions": "^7.0.11",
|
|
73
|
-
"@storybook/addon-links": "7.0.11",
|
|
74
|
-
"@storybook/addon-docs": "7.0.11",
|
|
75
|
-
"@storybook/jest": "^0.1.0",
|
|
76
|
-
"@storybook/react-webpack5": "7.0.11",
|
|
77
|
-
"@storybook/test-runner": "0.10.0",
|
|
78
|
-
"@storybook/testing-library": "^0.1.0",
|
|
79
|
-
"@types/react": "^18.0.26",
|
|
80
|
-
"@types/react-dom": "^18.0.9",
|
|
81
|
-
"@typescript-eslint/eslint-plugin": "^5.47.0",
|
|
82
|
-
"@typescript-eslint/parser": "^5.47.0",
|
|
83
|
-
"chromatic": "^6.21.0",
|
|
84
|
-
"eslint": "^8.30.0",
|
|
85
|
-
"eslint-config-airbnb": "^19.0.4",
|
|
86
|
-
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
87
|
-
"eslint-config-prettier": "^8.5.0",
|
|
88
|
-
"eslint-plugin-import": "^2.26.0",
|
|
89
|
-
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
90
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
91
|
-
"eslint-plugin-react": "^7.31.11",
|
|
92
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
|
93
|
-
"eslint-plugin-storybook": "^0.6.12",
|
|
94
|
-
"husky": "^8.0.1",
|
|
95
|
-
"license-checker": "^25.0.1",
|
|
96
|
-
"react": "^18.2.0",
|
|
97
|
-
"react-dom": "^18.2.0",
|
|
98
|
-
"start-server-and-test": "^2.0.0",
|
|
99
|
-
"storybook": "7.0.11",
|
|
100
|
-
"typescript": "^4.9.4",
|
|
101
|
-
"vite": "^4.2.1",
|
|
102
|
-
"vite-plugin-css-injected-by-js": "^3.1.0",
|
|
103
|
-
"webpack": "^5.75.0"
|
|
104
|
-
}
|
|
105
|
-
}
|
package/lib/mjs/package.json
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@constructor-io/constructorio-ui-quizzes",
|
|
3
|
-
"version": "1.9.2",
|
|
4
|
-
"description": "Constructor.io Quizzes UI library for web applications",
|
|
5
|
-
"author": "constructor.io",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"homepage": "https://github.com/Constructor-io/constructorio-ui-quizzes#readme",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/Constructor-io/constructorio-ui-quizzes.git"
|
|
11
|
-
},
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/Constructor-io/constructorio-ui-quizzes/issues"
|
|
14
|
-
},
|
|
15
|
-
"main": "lib/cjs/index.js",
|
|
16
|
-
"module": "lib/mjs/index.js",
|
|
17
|
-
"exports": {
|
|
18
|
-
"./styles.css": {
|
|
19
|
-
"import": "./lib/styles.css",
|
|
20
|
-
"require": "./lib/styles.css"
|
|
21
|
-
},
|
|
22
|
-
"./constructorio-ui-quizzes-bundled": {
|
|
23
|
-
"import": "./dist/constructorio-ui-quizzes-bundled.js",
|
|
24
|
-
"require": "./dist/constructorio-ui-quizzes-bundled.js"
|
|
25
|
-
},
|
|
26
|
-
".": {
|
|
27
|
-
"import": "./lib/mjs/index.js",
|
|
28
|
-
"require": "./lib/cjs/index.js"
|
|
29
|
-
},
|
|
30
|
-
"./cjs": {
|
|
31
|
-
"import": "./lib/cjs/index.js",
|
|
32
|
-
"require": "./lib/cjs/index.js"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"files": [
|
|
36
|
-
"lib/**/*",
|
|
37
|
-
"dist/constructorio-ui-quizzes-bundled.js"
|
|
38
|
-
],
|
|
39
|
-
"engines": {
|
|
40
|
-
"node": ">=14"
|
|
41
|
-
},
|
|
42
|
-
"types": "lib/types/index.d.ts",
|
|
43
|
-
"scripts": {
|
|
44
|
-
"lint": "eslint src --ext js,ts,jsx,tsx",
|
|
45
|
-
"check-types": "npx tsc --noEmit",
|
|
46
|
-
"copy-styles": "cp src/styles.css lib/styles.css",
|
|
47
|
-
"prepare": "husky install",
|
|
48
|
-
"dev": "storybook dev -p 6006",
|
|
49
|
-
"storybook:ci": "storybook dev --ci --quiet -p 6006",
|
|
50
|
-
"test-storybook": "test-storybook",
|
|
51
|
-
"test-storybook:watch": "test-storybook --watch",
|
|
52
|
-
"test-storybook:ci": "start-server-and-test storybook:ci http://localhost:6006 test-storybook",
|
|
53
|
-
"build-storybook": "storybook build -o 'docs'",
|
|
54
|
-
"serve-built-storybook": "npx http-server docs",
|
|
55
|
-
"verify-node-version": "chmod +x ./scripts/verify-node-version.sh && ./scripts/verify-node-version.sh",
|
|
56
|
-
"version": "npm run verify-node-version && npm run build-storybook && git add -u ./docs && git add ./docs/* && npm run compile",
|
|
57
|
-
"compile": "rm -rf lib && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && npm run copy-styles && vite build",
|
|
58
|
-
"check-license": "license-checker --production --onlyAllow 'Apache-2.0;BSD-3-Clause;MIT;0BSD;BSD-2-Clause' --excludePackages 'picocolors@1.0.0'"
|
|
59
|
-
},
|
|
60
|
-
"peerDependencies": {
|
|
61
|
-
"@constructor-io/constructorio-client-javascript": "^2.35.17",
|
|
62
|
-
"react": ">=16.12.0",
|
|
63
|
-
"react-dom": ">=16.12.0",
|
|
64
|
-
"tslib": "^2.4.0"
|
|
65
|
-
},
|
|
66
|
-
"devDependencies": {
|
|
67
|
-
"@axe-core/react": "^4.7.0",
|
|
68
|
-
"@cspell/eslint-plugin": "^6.18.1",
|
|
69
|
-
"@storybook/addon-a11y": "^7.0.11",
|
|
70
|
-
"@storybook/addon-actions": "7.0.11",
|
|
71
|
-
"@storybook/addon-essentials": "7.0.11",
|
|
72
|
-
"@storybook/addon-interactions": "^7.0.11",
|
|
73
|
-
"@storybook/addon-links": "7.0.11",
|
|
74
|
-
"@storybook/addon-docs": "7.0.11",
|
|
75
|
-
"@storybook/jest": "^0.1.0",
|
|
76
|
-
"@storybook/react-webpack5": "7.0.11",
|
|
77
|
-
"@storybook/test-runner": "0.10.0",
|
|
78
|
-
"@storybook/testing-library": "^0.1.0",
|
|
79
|
-
"@types/react": "^18.0.26",
|
|
80
|
-
"@types/react-dom": "^18.0.9",
|
|
81
|
-
"@typescript-eslint/eslint-plugin": "^5.47.0",
|
|
82
|
-
"@typescript-eslint/parser": "^5.47.0",
|
|
83
|
-
"chromatic": "^6.21.0",
|
|
84
|
-
"eslint": "^8.30.0",
|
|
85
|
-
"eslint-config-airbnb": "^19.0.4",
|
|
86
|
-
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
87
|
-
"eslint-config-prettier": "^8.5.0",
|
|
88
|
-
"eslint-plugin-import": "^2.26.0",
|
|
89
|
-
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
90
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
91
|
-
"eslint-plugin-react": "^7.31.11",
|
|
92
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
|
93
|
-
"eslint-plugin-storybook": "^0.6.12",
|
|
94
|
-
"husky": "^8.0.1",
|
|
95
|
-
"license-checker": "^25.0.1",
|
|
96
|
-
"react": "^18.2.0",
|
|
97
|
-
"react-dom": "^18.2.0",
|
|
98
|
-
"start-server-and-test": "^2.0.0",
|
|
99
|
-
"storybook": "7.0.11",
|
|
100
|
-
"typescript": "^4.9.4",
|
|
101
|
-
"vite": "^4.2.1",
|
|
102
|
-
"vite-plugin-css-injected-by-js": "^3.1.0",
|
|
103
|
-
"webpack": "^5.75.0"
|
|
104
|
-
}
|
|
105
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/lib/cjs/{src/components → components}/ResultFavoritesButton/ResultFavoritesButton.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/lib/mjs/{src/components → components}/ResultFavoritesButton/ResultFavoritesButton.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|