@constructor-io/constructorio-ui-quizzes 1.5.2 → 1.7.0
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 +13 -13
- package/lib/cjs/components/CioQuiz/index.js +2 -0
- package/lib/cjs/components/ProgressBar/ProgressBar.js +17 -0
- package/lib/cjs/components/ResultContainer/ResultContainer.js +8 -2
- package/lib/cjs/constants.js +1 -0
- package/lib/cjs/services/index.js +10 -0
- package/lib/cjs/stories/Quiz/tests/mocks.js +1 -0
- package/lib/mjs/components/CioQuiz/index.js +2 -0
- package/lib/mjs/components/ProgressBar/ProgressBar.js +13 -0
- package/lib/mjs/components/ResultContainer/ResultContainer.js +8 -2
- package/lib/mjs/constants.js +1 -0
- package/lib/mjs/services/index.js +6 -0
- package/lib/mjs/stories/Quiz/tests/mocks.js +1 -0
- package/lib/styles.css +36 -1
- package/lib/types/components/ProgressBar/ProgressBar.d.ts +2 -0
- package/lib/types/constants.d.ts +1 -1
- package/package.json +2 -2
|
@@ -11,6 +11,7 @@ const Spinner_1 = tslib_1.__importDefault(require("../Spinner/Spinner"));
|
|
|
11
11
|
const useQuiz_1 = tslib_1.__importDefault(require("../../hooks/useQuiz"));
|
|
12
12
|
const SessionPromptModal_1 = tslib_1.__importDefault(require("../SessionPromptModal/SessionPromptModal"));
|
|
13
13
|
const utils_1 = require("../../utils");
|
|
14
|
+
const ProgressBar_1 = tslib_1.__importDefault(require("../ProgressBar/ProgressBar"));
|
|
14
15
|
function CioQuiz(props) {
|
|
15
16
|
var _a;
|
|
16
17
|
const { cioClient, state, events: { hydrateQuiz, hasSessionStorageState, resetSessionStorageState }, getAddToCartButtonProps, getAddToFavoritesButtonProps, getCoverQuestionProps, getHydrateQuizButtonProps, getNextQuestionButtonProps, getOpenTextInputProps, getPreviousQuestionButtonProps, getQuizImageProps, getQuizResultButtonProps, getQuizResultLinkProps, getResetQuizButtonProps, getSelectInputProps, primaryColorStyles, } = (0, useQuiz_1.default)(props);
|
|
@@ -65,6 +66,7 @@ function CioQuiz(props) {
|
|
|
65
66
|
(0, utils_1.convertPrimaryColorsToString)(primaryColorStyles)),
|
|
66
67
|
react_1.default.createElement(SessionPromptModal_1.default, { resetStoredState: resetSessionStorageState, continueSession: hydrateQuiz, showSessionPrompt: showSessionPrompt, setShowSessionPrompt: setShowSessionPrompt }),
|
|
67
68
|
react_1.default.createElement(context_1.default.Provider, { value: contextValue }, state.quiz.results || state.quiz.skipToResults ? (react_1.default.createElement(ResultContainer_1.default, { options: resultsPageOptions })) : (state.quiz.currentQuestion && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
69
|
+
react_1.default.createElement(ProgressBar_1.default, null),
|
|
68
70
|
react_1.default.createElement(QuizQuestions_1.default, null),
|
|
69
71
|
react_1.default.createElement(ControlBar_1.default, { ctaButtonText: (questionData === null || questionData === void 0 ? void 0 : questionData.cta_text) || undefined })))))));
|
|
70
72
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const context_1 = tslib_1.__importDefault(require("../CioQuiz/context"));
|
|
6
|
+
function ProgressBar() {
|
|
7
|
+
const { state } = (0, react_1.useContext)(context_1.default);
|
|
8
|
+
const currentQuestion = state === null || state === void 0 ? void 0 : state.quiz.currentQuestion;
|
|
9
|
+
if (!currentQuestion)
|
|
10
|
+
return null;
|
|
11
|
+
return (react_1.default.createElement("div", { className: 'cio-question-progress-affixed-container' },
|
|
12
|
+
react_1.default.createElement("div", { className: 'cio-question-progress-progress-container' },
|
|
13
|
+
react_1.default.createElement("div", { className: 'cio-question-progress-progress-bar', style: {
|
|
14
|
+
width: `${((currentQuestion.next_question.id - 1) / currentQuestion.total_questions) * 100}%`,
|
|
15
|
+
} }))));
|
|
16
|
+
}
|
|
17
|
+
exports.default = ProgressBar;
|
|
@@ -13,7 +13,8 @@ function ResultContainer(props) {
|
|
|
13
13
|
const { options } = props;
|
|
14
14
|
const { resultCardSalePriceKey, resultCardRegularPriceKey, resultCardRatingCountKey, resultCardRatingScoreKey, renderResultCardPriceDetails, } = options;
|
|
15
15
|
const { state } = (0, react_1.useContext)(context_1.default);
|
|
16
|
-
const
|
|
16
|
+
const numberOfResults = (_c = (_b = (_a = state === null || state === void 0 ? void 0 : state.quiz.results) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.results) === null || _c === void 0 ? void 0 : _c.length;
|
|
17
|
+
const zeroResults = !numberOfResults;
|
|
17
18
|
const resultsTitle = zeroResults ? '' : 'Here are your results';
|
|
18
19
|
if (state === null || state === void 0 ? void 0 : state.quiz.results) {
|
|
19
20
|
return (react_1.default.createElement("div", { className: 'cio-results-container' },
|
|
@@ -21,7 +22,12 @@ function ResultContainer(props) {
|
|
|
21
22
|
react_1.default.createElement("div", { className: 'cio-results-filter-and-redo-container' },
|
|
22
23
|
react_1.default.createElement(ResultFilters_1.default, { hasNoResults: zeroResults }),
|
|
23
24
|
react_1.default.createElement(RedoButton_1.default, null)),
|
|
24
|
-
!zeroResults && (react_1.default.createElement(
|
|
25
|
+
!zeroResults && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
26
|
+
react_1.default.createElement("div", { className: 'cio-results-num-results' },
|
|
27
|
+
numberOfResults,
|
|
28
|
+
" ",
|
|
29
|
+
numberOfResults === 1 ? 'result' : 'results'),
|
|
30
|
+
react_1.default.createElement(Results_1.default, { resultCardSalePriceKey: resultCardSalePriceKey, resultCardRegularPriceKey: resultCardRegularPriceKey, resultCardRatingCountKey: resultCardRatingCountKey, resultCardRatingScoreKey: resultCardRatingScoreKey, renderResultCardPriceDetails: renderResultCardPriceDetails }))),
|
|
25
31
|
zeroResults && react_1.default.createElement(ZeroResults_1.default, null)));
|
|
26
32
|
}
|
|
27
33
|
return (react_1.default.createElement("div", { className: 'cio-results-container' },
|
package/lib/cjs/constants.js
CHANGED
|
@@ -22,6 +22,7 @@ exports.componentDescription = `- import \`CioQuiz\` to render in your JSX.
|
|
|
22
22
|
- \`resultCardRatingCountKey\` is an optional parameter that specifies the metadata field name for the ratings count
|
|
23
23
|
- \`resultCardRatingScoreKey\` is an optional parameter that specifies the metadata field name for the ratings score
|
|
24
24
|
- \`renderResultCardPriceDetails\` is an optional render function to render custom prices section in result card
|
|
25
|
+
- \`numResultsToDisplay\` is an optional parameter that determines how many results should be displayed on results page
|
|
25
26
|
- \`sessionStateOptions\` lets you configure the session modal behavior
|
|
26
27
|
- \`showSessionModal\` is a boolean used to decide whether to show the session modal. The default behavior is to show the session modal
|
|
27
28
|
- \`showSessionModalOnResults\` is a boolean to decide whether to show the session modal after reaching the results page. The default behavior is to not show the session modal
|
|
@@ -20,7 +20,16 @@ const getQuizResults = (cioClient, quizId, parameters) => tslib_1.__awaiter(void
|
|
|
20
20
|
exports.getQuizResults = getQuizResults;
|
|
21
21
|
// Tracking requests
|
|
22
22
|
const trackQuizResultsLoaded = (cioClient, quizResults) => {
|
|
23
|
+
var _a;
|
|
23
24
|
const { quiz_id, quiz_session_id, quiz_version_id, result_id, request, response } = quizResults;
|
|
25
|
+
const items = (_a = response === null || response === void 0 ? void 0 : response.results) === null || _a === void 0 ? void 0 : _a.map((result) => {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
return ({
|
|
28
|
+
itemId: (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.id,
|
|
29
|
+
variationId: (_b = result === null || result === void 0 ? void 0 : result.data) === null || _b === void 0 ? void 0 : _b.variation_id,
|
|
30
|
+
itemName: result === null || result === void 0 ? void 0 : result.value,
|
|
31
|
+
});
|
|
32
|
+
});
|
|
24
33
|
cioClient === null || cioClient === void 0 ? void 0 : cioClient.tracker.trackQuizResultsLoaded({
|
|
25
34
|
quizId: quiz_id,
|
|
26
35
|
quizVersionId: quiz_version_id,
|
|
@@ -30,6 +39,7 @@ const trackQuizResultsLoaded = (cioClient, quizResults) => {
|
|
|
30
39
|
resultCount: response === null || response === void 0 ? void 0 : response.total_num_results,
|
|
31
40
|
resultPage: request === null || request === void 0 ? void 0 : request.page,
|
|
32
41
|
resultId: result_id,
|
|
42
|
+
items,
|
|
33
43
|
});
|
|
34
44
|
};
|
|
35
45
|
exports.trackQuizResultsLoaded = trackQuizResultsLoaded;
|
|
@@ -64,6 +64,7 @@ const getMockState = (question) => ({
|
|
|
64
64
|
isSingleQuestion: (question === null || question === void 0 ? void 0 : question.type) === 'single',
|
|
65
65
|
isMultipleQuestion: (question === null || question === void 0 ? void 0 : question.type) === 'multiple',
|
|
66
66
|
isSelectQuestion: (question === null || question === void 0 ? void 0 : question.type) === 'single',
|
|
67
|
+
total_questions: 1,
|
|
67
68
|
},
|
|
68
69
|
results: {
|
|
69
70
|
response: {
|
|
@@ -8,6 +8,7 @@ import Spinner from '../Spinner/Spinner';
|
|
|
8
8
|
import useQuiz from '../../hooks/useQuiz';
|
|
9
9
|
import SessionPromptModal from '../SessionPromptModal/SessionPromptModal';
|
|
10
10
|
import { convertPrimaryColorsToString, renderImages } from '../../utils';
|
|
11
|
+
import ProgressBar from '../ProgressBar/ProgressBar';
|
|
11
12
|
export default function CioQuiz(props) {
|
|
12
13
|
const { cioClient, state, events: { hydrateQuiz, hasSessionStorageState, resetSessionStorageState }, getAddToCartButtonProps, getAddToFavoritesButtonProps, getCoverQuestionProps, getHydrateQuizButtonProps, getNextQuestionButtonProps, getOpenTextInputProps, getPreviousQuestionButtonProps, getQuizImageProps, getQuizResultButtonProps, getQuizResultLinkProps, getResetQuizButtonProps, getSelectInputProps, primaryColorStyles, } = useQuiz(props);
|
|
13
14
|
const [showSessionPrompt, setShowSessionPrompt] = useState(false);
|
|
@@ -61,6 +62,7 @@ export default function CioQuiz(props) {
|
|
|
61
62
|
convertPrimaryColorsToString(primaryColorStyles)),
|
|
62
63
|
React.createElement(SessionPromptModal, { resetStoredState: resetSessionStorageState, continueSession: hydrateQuiz, showSessionPrompt: showSessionPrompt, setShowSessionPrompt: setShowSessionPrompt }),
|
|
63
64
|
React.createElement(QuizContext.Provider, { value: contextValue }, state.quiz.results || state.quiz.skipToResults ? (React.createElement(ResultContainer, { options: resultsPageOptions })) : (state.quiz.currentQuestion && (React.createElement(React.Fragment, null,
|
|
65
|
+
React.createElement(ProgressBar, null),
|
|
64
66
|
React.createElement(QuizQuestions, null),
|
|
65
67
|
React.createElement(ControlBar, { ctaButtonText: questionData?.cta_text || undefined })))))));
|
|
66
68
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import QuizContext from '../CioQuiz/context';
|
|
3
|
+
export default function ProgressBar() {
|
|
4
|
+
const { state } = useContext(QuizContext);
|
|
5
|
+
const currentQuestion = state?.quiz.currentQuestion;
|
|
6
|
+
if (!currentQuestion)
|
|
7
|
+
return null;
|
|
8
|
+
return (React.createElement("div", { className: 'cio-question-progress-affixed-container' },
|
|
9
|
+
React.createElement("div", { className: 'cio-question-progress-progress-container' },
|
|
10
|
+
React.createElement("div", { className: 'cio-question-progress-progress-bar', style: {
|
|
11
|
+
width: `${((currentQuestion.next_question.id - 1) / currentQuestion.total_questions) * 100}%`,
|
|
12
|
+
} }))));
|
|
13
|
+
}
|
|
@@ -9,7 +9,8 @@ export default function ResultContainer(props) {
|
|
|
9
9
|
const { options } = props;
|
|
10
10
|
const { resultCardSalePriceKey, resultCardRegularPriceKey, resultCardRatingCountKey, resultCardRatingScoreKey, renderResultCardPriceDetails, } = options;
|
|
11
11
|
const { state } = useContext(QuizContext);
|
|
12
|
-
const
|
|
12
|
+
const numberOfResults = state?.quiz.results?.response?.results?.length;
|
|
13
|
+
const zeroResults = !numberOfResults;
|
|
13
14
|
const resultsTitle = zeroResults ? '' : 'Here are your results';
|
|
14
15
|
if (state?.quiz.results) {
|
|
15
16
|
return (React.createElement("div", { className: 'cio-results-container' },
|
|
@@ -17,7 +18,12 @@ export default function ResultContainer(props) {
|
|
|
17
18
|
React.createElement("div", { className: 'cio-results-filter-and-redo-container' },
|
|
18
19
|
React.createElement(ResultFilters, { hasNoResults: zeroResults }),
|
|
19
20
|
React.createElement(RedoButton, null)),
|
|
20
|
-
!zeroResults && (React.createElement(
|
|
21
|
+
!zeroResults && (React.createElement(React.Fragment, null,
|
|
22
|
+
React.createElement("div", { className: 'cio-results-num-results' },
|
|
23
|
+
numberOfResults,
|
|
24
|
+
" ",
|
|
25
|
+
numberOfResults === 1 ? 'result' : 'results'),
|
|
26
|
+
React.createElement(Results, { resultCardSalePriceKey: resultCardSalePriceKey, resultCardRegularPriceKey: resultCardRegularPriceKey, resultCardRatingCountKey: resultCardRatingCountKey, resultCardRatingScoreKey: resultCardRatingScoreKey, renderResultCardPriceDetails: renderResultCardPriceDetails }))),
|
|
21
27
|
zeroResults && React.createElement(ZeroResults, null)));
|
|
22
28
|
}
|
|
23
29
|
return (React.createElement("div", { className: 'cio-results-container' },
|
package/lib/mjs/constants.js
CHANGED
|
@@ -19,6 +19,7 @@ export const componentDescription = `- import \`CioQuiz\` to render in your JSX.
|
|
|
19
19
|
- \`resultCardRatingCountKey\` is an optional parameter that specifies the metadata field name for the ratings count
|
|
20
20
|
- \`resultCardRatingScoreKey\` is an optional parameter that specifies the metadata field name for the ratings score
|
|
21
21
|
- \`renderResultCardPriceDetails\` is an optional render function to render custom prices section in result card
|
|
22
|
+
- \`numResultsToDisplay\` is an optional parameter that determines how many results should be displayed on results page
|
|
22
23
|
- \`sessionStateOptions\` lets you configure the session modal behavior
|
|
23
24
|
- \`showSessionModal\` is a boolean used to decide whether to show the session modal. The default behavior is to show the session modal
|
|
24
25
|
- \`showSessionModalOnResults\` is a boolean to decide whether to show the session modal after reaching the results page. The default behavior is to not show the session modal
|
|
@@ -14,6 +14,11 @@ export const getQuizResults = async (cioClient, quizId, parameters) => cioClient
|
|
|
14
14
|
// Tracking requests
|
|
15
15
|
export const trackQuizResultsLoaded = (cioClient, quizResults) => {
|
|
16
16
|
const { quiz_id, quiz_session_id, quiz_version_id, result_id, request, response } = quizResults;
|
|
17
|
+
const items = response?.results?.map((result) => ({
|
|
18
|
+
itemId: result?.data?.id,
|
|
19
|
+
variationId: result?.data?.variation_id,
|
|
20
|
+
itemName: result?.value,
|
|
21
|
+
}));
|
|
17
22
|
cioClient?.tracker.trackQuizResultsLoaded({
|
|
18
23
|
quizId: quiz_id,
|
|
19
24
|
quizVersionId: quiz_version_id,
|
|
@@ -23,6 +28,7 @@ export const trackQuizResultsLoaded = (cioClient, quizResults) => {
|
|
|
23
28
|
resultCount: response?.total_num_results,
|
|
24
29
|
resultPage: request?.page,
|
|
25
30
|
resultId: result_id,
|
|
31
|
+
items,
|
|
26
32
|
});
|
|
27
33
|
};
|
|
28
34
|
export const trackQuizResultClick = (cioClient, quizResults, result, position) => {
|
package/lib/styles.css
CHANGED
|
@@ -395,6 +395,35 @@
|
|
|
395
395
|
margin-bottom: -1rem;
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
+
/* Affixed progress bar */
|
|
399
|
+
.cio-quiz .cio-question-progress-affixed-container {
|
|
400
|
+
position: fixed;
|
|
401
|
+
top: 8px;
|
|
402
|
+
right: 16px;
|
|
403
|
+
z-index: 100;
|
|
404
|
+
display: flex;
|
|
405
|
+
flex-direction: row;
|
|
406
|
+
align-items: center;
|
|
407
|
+
gap: 7px;
|
|
408
|
+
font-size: 0.75rem;
|
|
409
|
+
padding: 8px;
|
|
410
|
+
color: white;
|
|
411
|
+
mix-blend-mode: difference;
|
|
412
|
+
}
|
|
413
|
+
.cio-quiz .cio-question-progress-progress-container {
|
|
414
|
+
width: 100px;
|
|
415
|
+
border-color: white;
|
|
416
|
+
height: 6px;
|
|
417
|
+
border-width: 1px;
|
|
418
|
+
border-style: solid;
|
|
419
|
+
background: transparent;
|
|
420
|
+
border-radius: 4px;
|
|
421
|
+
}
|
|
422
|
+
.cio-quiz .cio-question-progress-progress-bar {
|
|
423
|
+
background: white;
|
|
424
|
+
height: 100%;
|
|
425
|
+
}
|
|
426
|
+
|
|
398
427
|
/* Results component */
|
|
399
428
|
.cio-quiz .cio-results-container {
|
|
400
429
|
width: 100%;
|
|
@@ -434,6 +463,13 @@
|
|
|
434
463
|
align-items: center;
|
|
435
464
|
font-size: 0.75rem;
|
|
436
465
|
}
|
|
466
|
+
.cio-quiz .cio-results-num-results {
|
|
467
|
+
margin-top: 2.75rem;
|
|
468
|
+
font-family: 'Inter', sans-serif;
|
|
469
|
+
font-size: 0.875rem;
|
|
470
|
+
line-height: 1.25rem;
|
|
471
|
+
color: var(--gray-dust-500);
|
|
472
|
+
}
|
|
437
473
|
.cio-quiz .cio-results {
|
|
438
474
|
display: flex;
|
|
439
475
|
flex-direction: row;
|
|
@@ -738,7 +774,6 @@
|
|
|
738
774
|
flex-wrap: wrap;
|
|
739
775
|
justify-content: center;
|
|
740
776
|
margin-bottom: 2rem;
|
|
741
|
-
margin-top: 0;
|
|
742
777
|
}
|
|
743
778
|
.cio-quiz .cio-question-option-container-text-only {
|
|
744
779
|
margin: 0;
|
package/lib/types/constants.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const apiKey = "key_wJSdZSiesX5hiVLt";
|
|
2
2
|
export declare const quizId = "coffee-quiz";
|
|
3
3
|
export declare const quizSessionStateKey = "constructorIOQuizState";
|
|
4
|
-
export declare const componentDescription = "- import `CioQuiz` to render in your JSX.\n- This component handles state management, data fetching, and rendering logic.\n- To use this component, `quizId`, `resultsPageOptions`, and one of `apiKey` or `cioJsClient` are required.\n- `resultsPageOptions` lets you configure the results page\n - `onAddToCartClick` is a callback function that will be called when the \"Add to cart\" button is clicked\n - `onAddToFavoritesClick` is an optional callback function that will be called when the \"Add To Favorites\" heart icon is clicked\n - `onQuizResultClick` is an optional callback function that will be called when the result card is clicked. The default behavior is redirecting the user to the item's URL\n - `onQuizResultsLoaded` is an optional callback function that will be called when the quiz results are loaded\n - `resultCardRegularPriceKey` is a parameter that specifies the metadata field name for the regular price\n - `resultCardSalePriceKey` is an optional parameter that specifies the metadata field name for the sale price \n - `resultCardRatingCountKey` is an optional parameter that specifies the metadata field name for the ratings count \n - `resultCardRatingScoreKey` is an optional parameter that specifies the metadata field name for the ratings score \n - `renderResultCardPriceDetails` is an optional render function to render custom prices section in result card \n- `sessionStateOptions` lets you configure the session modal behavior\n - `showSessionModal` is a boolean used to decide whether to show the session modal. The default behavior is to show the session modal\n - `showSessionModalOnResults` is a boolean to decide whether to show the session modal after reaching the results page. The default behavior is to not show the session modal\n - `sessionStateKey` is a custom string that will be used as a session storage key\n- Use different props to configure the behavior of this component.\n- The following stories show how different props affect the component's behavior\n\n> Note: `cioJsClient` refers to an instance of the [constructorio-client-javascript](https://www.npmjs.com/package/@constructor-io/constructorio-client-javascript)\n";
|
|
4
|
+
export declare const componentDescription = "- import `CioQuiz` to render in your JSX.\n- This component handles state management, data fetching, and rendering logic.\n- To use this component, `quizId`, `resultsPageOptions`, and one of `apiKey` or `cioJsClient` are required.\n- `resultsPageOptions` lets you configure the results page\n - `onAddToCartClick` is a callback function that will be called when the \"Add to cart\" button is clicked\n - `onAddToFavoritesClick` is an optional callback function that will be called when the \"Add To Favorites\" heart icon is clicked\n - `onQuizResultClick` is an optional callback function that will be called when the result card is clicked. The default behavior is redirecting the user to the item's URL\n - `onQuizResultsLoaded` is an optional callback function that will be called when the quiz results are loaded\n - `resultCardRegularPriceKey` is a parameter that specifies the metadata field name for the regular price\n - `resultCardSalePriceKey` is an optional parameter that specifies the metadata field name for the sale price \n - `resultCardRatingCountKey` is an optional parameter that specifies the metadata field name for the ratings count \n - `resultCardRatingScoreKey` is an optional parameter that specifies the metadata field name for the ratings score \n - `renderResultCardPriceDetails` is an optional render function to render custom prices section in result card \n - `numResultsToDisplay` is an optional parameter that determines how many results should be displayed on results page\n- `sessionStateOptions` lets you configure the session modal behavior\n - `showSessionModal` is a boolean used to decide whether to show the session modal. The default behavior is to show the session modal\n - `showSessionModalOnResults` is a boolean to decide whether to show the session modal after reaching the results page. The default behavior is to not show the session modal\n - `sessionStateKey` is a custom string that will be used as a session storage key\n- Use different props to configure the behavior of this component.\n- The following stories show how different props affect the component's behavior\n\n> Note: `cioJsClient` refers to an instance of the [constructorio-client-javascript](https://www.npmjs.com/package/@constructor-io/constructorio-client-javascript)\n";
|
|
5
5
|
export declare const hookDescription = "- import `useCioQuiz` and call this custom hook in a functional component.\n- This hook leaves rendering logic up to you, while handling:\n - state management\n - data fetching\n - keyboard navigation\n - mouse interactions\n - focus and submit event handling\n- Since the markup is controlled by you, the default styles might not be applied if you have a different DOM structure\n- To use this hook, an `apiKey` and `quizId` are required, and `resultsPageOptions` must be passed to the `useCioQuiz` hook to configure behavior. All other values are optional.\n- use the <a href=\"https://kentcdodds.com/blog/how-to-give-rendering-control-to-users-with-prop-getters\" target=\"__blank\">prop getters</a> and other variables returned by this hook (below) to leverage the functionality described above with jsx elements in your react component definitions\n\nCalling the `useCioQuiz` hook returns an object with the following keys:\n\n```jsx\nconst {\n // must be used for a hooks integrations\n state: QuizReturnState, // Quiz state\n events: [{...}], // array of quiz events\n getAddToCartButtonProps: () => ({...})), // prop getter for jsx add to cart button for quiz result,\n getAddToFavoritesButtonProps: () => ({...})), // prop getter for jsx add to favorites button for quiz result,\n getCoverQuestionProps: () => ({...})), // prop getter for jsx quiz cover question,\n getHydrateQuizButtonProps: () => ({...})), // prop getter for jsx hydrate quiz button,\n getNextQuestionButtonProps: () => ({...})), // prop getter for jsx next button to traverse the quiz,\n getPreviousQuestionButtonProps: () => ({...})), // prop getter for jsx back button to traverse the quiz, \n getOpenTextInputProps: () => ({...})), // prop getter for jsx open text input,\n getSelectInputProps: () => ({...})), // prop getter for jsx select input for select type questions,\n getQuizImageProps: () => ({...})), // prop getter for jsx quiz image,\n getQuizResultButtonProps: () => ({...})), // prop getter for jsx result card click as a button,\n getQuizResultLinkProps: () => ({...})), // prop getter for jsx result card click as a link. Should be spread into <a> tags,\n getResetQuizButtonProps: () => ({...})), // prop getter for jsx reset quiz button,\n cioClient, // instance of constructorio-client-javascript\n } = useCioQuiz(args);\n```\n\n> Note: when we say `cioClient`, we are referring to an instance of the [constructorio-client-javascript](https://www.npmjs.com/package/@constructor-io/constructorio-client-javascript)\n";
|
|
6
6
|
export declare const basicDescription = "Pass an `apiKey` and a `quizId` to request questions and quiz results from Constructor's servers";
|
|
7
7
|
export declare const cioJsClientDescription = "If you are already using an instance of the `ConstructorIOClient`, you can pass a `cioJsClient` instead of an `apiKey` to request results from Constructor's servers\n\n> Note: `cioJsClient` refers to an instance of the [constructorio-client-javascript](https://www.npmjs.com/package/@constructor-io/constructorio-client-javascript)";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructor-io/constructorio-ui-quizzes",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Constructor.io Quizzes UI library for web applications",
|
|
5
5
|
"author": "constructor.io",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"check-license": "license-checker --production --onlyAllow 'Apache-2.0;BSD-3-Clause;MIT;0BSD;BSD-2-Clause' --excludePackages 'picocolors@1.0.0'"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@constructor-io/constructorio-client-javascript": "^2.35.
|
|
61
|
+
"@constructor-io/constructorio-client-javascript": "^2.35.17",
|
|
62
62
|
"react": ">=16.12.0",
|
|
63
63
|
"react-dom": ">=16.12.0",
|
|
64
64
|
"tslib": "^2.4.0"
|