@constructor-io/constructorio-ui-quizzes 1.9.5 → 1.9.7

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.
Files changed (31) hide show
  1. package/README.md +5 -2
  2. package/dist/constructorio-ui-quizzes-bundled.js +10 -10
  3. package/lib/cjs/components/CioQuiz/index.js +2 -2
  4. package/lib/cjs/components/CioQuiz/quizLocalReducer.js +7 -8
  5. package/lib/cjs/components/ControlBar/ControlBar.js +2 -2
  6. package/lib/cjs/components/SkipButton/SkipButton.js +3 -2
  7. package/lib/cjs/constants.js +2 -0
  8. package/lib/cjs/hooks/useQuiz.js +0 -1
  9. package/lib/cjs/hooks/useQuizEvents/useQuizAnswerChangeHandler.js +0 -3
  10. package/lib/cjs/hooks/useQuizState/useQuizApiState.js +1 -1
  11. package/lib/cjs/stories/Quiz/tests/mocks.js +1 -2
  12. package/lib/cjs/version.js +1 -1
  13. package/lib/mjs/components/CioQuiz/index.js +2 -2
  14. package/lib/mjs/components/CioQuiz/quizLocalReducer.js +0 -6
  15. package/lib/mjs/components/ControlBar/ControlBar.js +2 -2
  16. package/lib/mjs/components/SkipButton/SkipButton.js +3 -2
  17. package/lib/mjs/constants.js +2 -0
  18. package/lib/mjs/hooks/useQuiz.js +0 -1
  19. package/lib/mjs/hooks/useQuizEvents/useQuizAnswerChangeHandler.js +0 -3
  20. package/lib/mjs/hooks/useQuizState/useQuizApiState.js +1 -1
  21. package/lib/mjs/stories/Quiz/tests/mocks.js +1 -2
  22. package/lib/mjs/version.js +1 -1
  23. package/lib/styles.css +3 -6
  24. package/lib/types/components/CioQuiz/actions.d.ts +0 -1
  25. package/lib/types/components/CioQuiz/quizLocalReducer.d.ts +0 -1
  26. package/lib/types/components/ControlBar/ControlBar.d.ts +1 -0
  27. package/lib/types/components/SkipButton/SkipButton.d.ts +1 -0
  28. package/lib/types/constants.d.ts +1 -1
  29. package/lib/types/types.d.ts +4 -1
  30. package/lib/types/version.d.ts +1 -1
  31. package/package.json +1 -1
@@ -16,7 +16,7 @@ function CioQuiz(props) {
16
16
  var _a;
17
17
  const { cioClient, state, events: { hydrateQuiz, resetSessionStorageState }, getAddToCartButtonProps, getAddToFavoritesButtonProps, getCoverQuestionProps, getHydrateQuizButtonProps, getNextQuestionButtonProps, getSkipQuestionButtonProps, getOpenTextInputProps, getPreviousQuestionButtonProps, getQuizImageProps, getQuizResultButtonProps, getQuizResultLinkProps, getResetQuizButtonProps, getSelectInputProps, primaryColorStyles, } = (0, useQuiz_1.default)(props);
18
18
  const [showSessionPrompt, setShowSessionPrompt] = (0, react_1.useState)(false);
19
- const { resultsPageOptions, sessionStateOptions } = props;
19
+ const { resultsPageOptions, sessionStateOptions, questionsPageOptions } = props;
20
20
  const { quizSessionStorageState: { hasSessionStorageState, skipToResults }, } = state;
21
21
  (0, react_1.useEffect)(() => {
22
22
  // Respect showSessionModal if defined, else default to true.
@@ -66,7 +66,7 @@ function CioQuiz(props) {
66
66
  react_1.default.createElement(context_1.default.Provider, { value: contextValue }, state.quiz.results || skipToResults ? (react_1.default.createElement(ResultContainer_1.default, { options: resultsPageOptions })) : (state.quiz.currentQuestion && (react_1.default.createElement(react_1.default.Fragment, null,
67
67
  react_1.default.createElement(ProgressBar_1.default, null),
68
68
  react_1.default.createElement(QuizQuestions_1.default, null),
69
- react_1.default.createElement(ControlBar_1.default, { ctaButtonText: (questionData === null || questionData === void 0 ? void 0 : questionData.cta_text) || undefined })))))));
69
+ react_1.default.createElement(ControlBar_1.default, { skipQuestionButtonText: questionsPageOptions === null || questionsPageOptions === void 0 ? void 0 : questionsPageOptions.skipQuestionButtonText, ctaButtonText: (questionData === null || questionData === void 0 ? void 0 : questionData.cta_text) || undefined })))))));
70
70
  }
71
71
  return null;
72
72
  }
@@ -6,7 +6,6 @@ exports.initialState = {
6
6
  answers: [],
7
7
  answerInputs: {},
8
8
  prevAnswerInputs: {},
9
- isLastAnswer: false,
10
9
  isQuizCompleted: false,
11
10
  };
12
11
  function answerInputReducer(state, action) {
@@ -16,21 +15,21 @@ function answerInputReducer(state, action) {
16
15
  } });
17
16
  }
18
17
  function quizLocalReducer(state, action) {
19
- var _a, _b, _c, _d, _e;
18
+ var _a;
20
19
  switch (action.type) {
21
20
  case actions_1.QuestionTypes.OpenText:
22
- return Object.assign(Object.assign({}, state), { answerInputs: answerInputReducer(state.answerInputs, action), isLastAnswer: !!((_a = action.payload) === null || _a === void 0 ? void 0 : _a.isLastQuestion), isQuizCompleted: false });
21
+ return Object.assign(Object.assign({}, state), { answerInputs: answerInputReducer(state.answerInputs, action), isQuizCompleted: false });
23
22
  case actions_1.QuestionTypes.Cover:
24
- return Object.assign(Object.assign({}, state), { answerInputs: answerInputReducer(state.answerInputs, action), isLastAnswer: !!((_b = action.payload) === null || _b === void 0 ? void 0 : _b.isLastQuestion), isQuizCompleted: false });
23
+ return Object.assign(Object.assign({}, state), { answerInputs: answerInputReducer(state.answerInputs, action), isQuizCompleted: false });
25
24
  case actions_1.QuestionTypes.SingleSelect:
26
- return Object.assign(Object.assign({}, state), { answerInputs: answerInputReducer(state.answerInputs, action), isLastAnswer: !!((_c = action.payload) === null || _c === void 0 ? void 0 : _c.isLastQuestion), isQuizCompleted: false });
25
+ return Object.assign(Object.assign({}, state), { answerInputs: answerInputReducer(state.answerInputs, action), isQuizCompleted: false });
27
26
  case actions_1.QuestionTypes.MultipleSelect:
28
- return Object.assign(Object.assign({}, state), { answerInputs: answerInputReducer(state.answerInputs, action), isLastAnswer: !!((_d = action.payload) === null || _d === void 0 ? void 0 : _d.isLastQuestion), isQuizCompleted: false });
27
+ return Object.assign(Object.assign({}, state), { answerInputs: answerInputReducer(state.answerInputs, action), isQuizCompleted: false });
29
28
  case actions_1.QuestionTypes.Next: {
30
29
  const { answers, answerInputs } = state;
31
30
  const newAnswers = [...answers];
32
31
  const lastAnswerInputIndex = answers.length;
33
- const currentAnswerInput = (_e = Object.values(state.answerInputs)) === null || _e === void 0 ? void 0 : _e[lastAnswerInputIndex];
32
+ const currentAnswerInput = (_a = Object.values(state.answerInputs)) === null || _a === void 0 ? void 0 : _a[lastAnswerInputIndex];
34
33
  switch (currentAnswerInput.type) {
35
34
  case actions_1.QuestionTypes.OpenText:
36
35
  newAnswers.push(['true']);
@@ -72,7 +71,7 @@ function quizLocalReducer(state, action) {
72
71
  }
73
72
  case actions_1.QuestionTypes.Back: {
74
73
  const prevAnswerInputs = Object.assign({}, state.prevAnswerInputs);
75
- return Object.assign(Object.assign({}, state), { answerInputs: prevAnswerInputs, answers: [...state.answers.slice(0, -1)], isLastAnswer: false, isQuizCompleted: false });
74
+ return Object.assign(Object.assign({}, state), { answerInputs: prevAnswerInputs, answers: [...state.answers.slice(0, -1)], isQuizCompleted: false });
76
75
  }
77
76
  case actions_1.QuestionTypes.Reset:
78
77
  return Object.assign({}, exports.initialState);
@@ -7,12 +7,12 @@ const CTAButton_1 = tslib_1.__importDefault(require("../CTAButton/CTAButton"));
7
7
  const SkipButton_1 = tslib_1.__importDefault(require("../SkipButton/SkipButton"));
8
8
  const context_1 = tslib_1.__importDefault(require("../CioQuiz/context"));
9
9
  function ControlBar(props) {
10
- const { ctaButtonText } = props;
10
+ const { ctaButtonText, skipQuestionButtonText } = props;
11
11
  const { getNextQuestionButtonProps, getSkipQuestionButtonProps } = (0, react_1.useContext)(context_1.default);
12
12
  return (react_1.default.createElement("div", { className: 'cio-question-buttons-container' },
13
13
  react_1.default.createElement(BackButton_1.default, null),
14
14
  react_1.default.createElement("div", { className: 'cio-question-buttons-group' },
15
- react_1.default.createElement(SkipButton_1.default, { propsGetters: getSkipQuestionButtonProps }),
15
+ react_1.default.createElement(SkipButton_1.default, { skipQuestionButtonText: skipQuestionButtonText, propsGetters: getSkipQuestionButtonProps }),
16
16
  react_1.default.createElement(CTAButton_1.default, { ctaText: ctaButtonText, propsGetters: getNextQuestionButtonProps }))));
17
17
  }
18
18
  exports.default = ControlBar;
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const react_1 = tslib_1.__importDefault(require("react"));
5
5
  function SkipButton(props) {
6
- const { propsGetters, className = 'cio-button-container' } = props, rest = tslib_1.__rest(props, ["propsGetters", "className"]);
6
+ const { propsGetters, skipQuestionButtonText, className = 'cio-button-container' } = props, rest = tslib_1.__rest(props, ["propsGetters", "skipQuestionButtonText", "className"]);
7
+ const buttonText = skipQuestionButtonText || 'Skip';
7
8
  return (react_1.default.createElement("div", { className: `${className || ''}` }, propsGetters && (
8
9
  // eslint-disable-next-line react/button-has-type
9
- react_1.default.createElement("button", Object.assign({}, rest, propsGetters()), "Skip question"))));
10
+ react_1.default.createElement("button", Object.assign({}, rest, propsGetters(), { title: buttonText }), buttonText))));
10
11
  }
11
12
  exports.default = SkipButton;
@@ -30,6 +30,8 @@ exports.componentDescription = `- import \`CioQuiz\` to render in your JSX.
30
30
  - \`showSessionModal\` is a boolean used to decide whether to show the session modal. The default behavior is to show the session modal
31
31
  - \`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
32
32
  - \`sessionStateKey\` is a custom string that will be used as a session storage key
33
+ - \`questionsPageOptions\` lets you configure the question page
34
+ - \`skipQuestionButtonText\` is an optional string that will be used as the skip button text
33
35
  - Use different props to configure the behavior of this component.
34
36
  - The following stories show how different props affect the component's behavior
35
37
 
@@ -31,7 +31,6 @@ const useQuiz = (quizOptions) => {
31
31
  return Object.assign(Object.assign({ cioClient, state: {
32
32
  answers: {
33
33
  inputs: quizLocalState.answerInputs,
34
- isLastAnswer: quizLocalState.isLastAnswer,
35
34
  },
36
35
  quiz: {
37
36
  requestState: quizApiState.quizRequestState,
@@ -15,7 +15,6 @@ const useQuizAnswerChangeHandler = (quizApiState, dispatchLocalState) => {
15
15
  payload: {
16
16
  questionId: currentQuestion.next_question.id,
17
17
  input: '',
18
- isLastQuestion: currentQuestion.is_last_question,
19
18
  },
20
19
  });
21
20
  break;
@@ -25,7 +24,6 @@ const useQuizAnswerChangeHandler = (quizApiState, dispatchLocalState) => {
25
24
  payload: {
26
25
  questionId: currentQuestion.next_question.id,
27
26
  input: payload,
28
- isLastQuestion: currentQuestion.is_last_question,
29
27
  },
30
28
  });
31
29
  break;
@@ -36,7 +34,6 @@ const useQuizAnswerChangeHandler = (quizApiState, dispatchLocalState) => {
36
34
  payload: {
37
35
  questionId: currentQuestion.next_question.id,
38
36
  input: payload,
39
- isLastQuestion: currentQuestion.is_last_question,
40
37
  },
41
38
  });
42
39
  break;
@@ -41,7 +41,7 @@ const useQuizApiState = (quizOptions, cioClient, quizLocalState, skipToResults,
41
41
  dispatchApiState({
42
42
  type: actions_1.QuizAPIActionTypes.SET_IS_LOADING,
43
43
  });
44
- if (quizLocalState.isLastAnswer || skipToResults) {
44
+ if (skipToResults) {
45
45
  yield dispatchQuizResults();
46
46
  }
47
47
  else {
@@ -48,8 +48,7 @@ const getMockState = (question) => ({
48
48
  type: question === null || question === void 0 ? void 0 : question.type,
49
49
  value: '',
50
50
  },
51
- },
52
- isLastAnswer: false,
51
+ }, // Key is the question Id and value is the answer input
53
52
  },
54
53
  quiz: {
55
54
  requestState: constants_1.RequestStates.Success,
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '1.9.5';
3
+ exports.default = '1.9.7';
@@ -12,7 +12,7 @@ import ProgressBar from '../ProgressBar/ProgressBar';
12
12
  export default function CioQuiz(props) {
13
13
  const { cioClient, state, events: { hydrateQuiz, resetSessionStorageState }, getAddToCartButtonProps, getAddToFavoritesButtonProps, getCoverQuestionProps, getHydrateQuizButtonProps, getNextQuestionButtonProps, getSkipQuestionButtonProps, getOpenTextInputProps, getPreviousQuestionButtonProps, getQuizImageProps, getQuizResultButtonProps, getQuizResultLinkProps, getResetQuizButtonProps, getSelectInputProps, primaryColorStyles, } = useQuiz(props);
14
14
  const [showSessionPrompt, setShowSessionPrompt] = useState(false);
15
- const { resultsPageOptions, sessionStateOptions } = props;
15
+ const { resultsPageOptions, sessionStateOptions, questionsPageOptions } = props;
16
16
  const { quizSessionStorageState: { hasSessionStorageState, skipToResults }, } = state;
17
17
  useEffect(() => {
18
18
  // Respect showSessionModal if defined, else default to true.
@@ -62,7 +62,7 @@ export default function CioQuiz(props) {
62
62
  React.createElement(QuizContext.Provider, { value: contextValue }, state.quiz.results || skipToResults ? (React.createElement(ResultContainer, { options: resultsPageOptions })) : (state.quiz.currentQuestion && (React.createElement(React.Fragment, null,
63
63
  React.createElement(ProgressBar, null),
64
64
  React.createElement(QuizQuestions, null),
65
- React.createElement(ControlBar, { ctaButtonText: questionData?.cta_text || undefined })))))));
65
+ React.createElement(ControlBar, { skipQuestionButtonText: questionsPageOptions?.skipQuestionButtonText, ctaButtonText: questionData?.cta_text || undefined })))))));
66
66
  }
67
67
  return null;
68
68
  }
@@ -3,7 +3,6 @@ export const initialState = {
3
3
  answers: [],
4
4
  answerInputs: {},
5
5
  prevAnswerInputs: {},
6
- isLastAnswer: false,
7
6
  isQuizCompleted: false,
8
7
  };
9
8
  function answerInputReducer(state, action) {
@@ -21,28 +20,24 @@ export default function quizLocalReducer(state, action) {
21
20
  return {
22
21
  ...state,
23
22
  answerInputs: answerInputReducer(state.answerInputs, action),
24
- isLastAnswer: !!action.payload?.isLastQuestion,
25
23
  isQuizCompleted: false,
26
24
  };
27
25
  case QuestionTypes.Cover:
28
26
  return {
29
27
  ...state,
30
28
  answerInputs: answerInputReducer(state.answerInputs, action),
31
- isLastAnswer: !!action.payload?.isLastQuestion,
32
29
  isQuizCompleted: false,
33
30
  };
34
31
  case QuestionTypes.SingleSelect:
35
32
  return {
36
33
  ...state,
37
34
  answerInputs: answerInputReducer(state.answerInputs, action),
38
- isLastAnswer: !!action.payload?.isLastQuestion,
39
35
  isQuizCompleted: false,
40
36
  };
41
37
  case QuestionTypes.MultipleSelect:
42
38
  return {
43
39
  ...state,
44
40
  answerInputs: answerInputReducer(state.answerInputs, action),
45
- isLastAnswer: !!action.payload?.isLastQuestion,
46
41
  isQuizCompleted: false,
47
42
  };
48
43
  case QuestionTypes.Next: {
@@ -103,7 +98,6 @@ export default function quizLocalReducer(state, action) {
103
98
  ...state,
104
99
  answerInputs: prevAnswerInputs,
105
100
  answers: [...state.answers.slice(0, -1)],
106
- isLastAnswer: false,
107
101
  isQuizCompleted: false,
108
102
  };
109
103
  }
@@ -4,12 +4,12 @@ import CTAButton from '../CTAButton/CTAButton';
4
4
  import SkipButton from '../SkipButton/SkipButton';
5
5
  import QuizContext from '../CioQuiz/context';
6
6
  function ControlBar(props) {
7
- const { ctaButtonText } = props;
7
+ const { ctaButtonText, skipQuestionButtonText } = props;
8
8
  const { getNextQuestionButtonProps, getSkipQuestionButtonProps } = useContext(QuizContext);
9
9
  return (React.createElement("div", { className: 'cio-question-buttons-container' },
10
10
  React.createElement(BackButton, null),
11
11
  React.createElement("div", { className: 'cio-question-buttons-group' },
12
- React.createElement(SkipButton, { propsGetters: getSkipQuestionButtonProps }),
12
+ React.createElement(SkipButton, { skipQuestionButtonText: skipQuestionButtonText, propsGetters: getSkipQuestionButtonProps }),
13
13
  React.createElement(CTAButton, { ctaText: ctaButtonText, propsGetters: getNextQuestionButtonProps }))));
14
14
  }
15
15
  export default ControlBar;
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
  function SkipButton(props) {
3
- const { propsGetters, className = 'cio-button-container', ...rest } = props;
3
+ const { propsGetters, skipQuestionButtonText, className = 'cio-button-container', ...rest } = props;
4
+ const buttonText = skipQuestionButtonText || 'Skip';
4
5
  return (React.createElement("div", { className: `${className || ''}` }, propsGetters && (
5
6
  // eslint-disable-next-line react/button-has-type
6
- React.createElement("button", { ...rest, ...propsGetters() }, "Skip question"))));
7
+ React.createElement("button", { ...rest, ...propsGetters(), title: buttonText }, buttonText))));
7
8
  }
8
9
  export default SkipButton;
@@ -27,6 +27,8 @@ export const componentDescription = `- import \`CioQuiz\` to render in your JSX.
27
27
  - \`showSessionModal\` is a boolean used to decide whether to show the session modal. The default behavior is to show the session modal
28
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
29
29
  - \`sessionStateKey\` is a custom string that will be used as a session storage key
30
+ - \`questionsPageOptions\` lets you configure the question page
31
+ - \`skipQuestionButtonText\` is an optional string that will be used as the skip button text
30
32
  - Use different props to configure the behavior of this component.
31
33
  - The following stories show how different props affect the component's behavior
32
34
 
@@ -30,7 +30,6 @@ const useQuiz = (quizOptions) => {
30
30
  state: {
31
31
  answers: {
32
32
  inputs: quizLocalState.answerInputs,
33
- isLastAnswer: quizLocalState.isLastAnswer,
34
33
  },
35
34
  quiz: {
36
35
  requestState: quizApiState.quizRequestState,
@@ -12,7 +12,6 @@ const useQuizAnswerChangeHandler = (quizApiState, dispatchLocalState) => {
12
12
  payload: {
13
13
  questionId: currentQuestion.next_question.id,
14
14
  input: '',
15
- isLastQuestion: currentQuestion.is_last_question,
16
15
  },
17
16
  });
18
17
  break;
@@ -22,7 +21,6 @@ const useQuizAnswerChangeHandler = (quizApiState, dispatchLocalState) => {
22
21
  payload: {
23
22
  questionId: currentQuestion.next_question.id,
24
23
  input: payload,
25
- isLastQuestion: currentQuestion.is_last_question,
26
24
  },
27
25
  });
28
26
  break;
@@ -33,7 +31,6 @@ const useQuizAnswerChangeHandler = (quizApiState, dispatchLocalState) => {
33
31
  payload: {
34
32
  questionId: currentQuestion.next_question.id,
35
33
  input: payload,
36
- isLastQuestion: currentQuestion.is_last_question,
37
34
  },
38
35
  });
39
36
  break;
@@ -38,7 +38,7 @@ const useQuizApiState = (quizOptions, cioClient, quizLocalState, skipToResults,
38
38
  dispatchApiState({
39
39
  type: QuizAPIActionTypes.SET_IS_LOADING,
40
40
  });
41
- if (quizLocalState.isLastAnswer || skipToResults) {
41
+ if (skipToResults) {
42
42
  await dispatchQuizResults();
43
43
  }
44
44
  else {
@@ -60,8 +60,7 @@ export const getMockState = (question) => ({
60
60
  type: question?.type,
61
61
  value: '',
62
62
  },
63
- },
64
- isLastAnswer: false,
63
+ }, // Key is the question Id and value is the answer input
65
64
  },
66
65
  quiz: {
67
66
  requestState: RequestStates.Success,
@@ -1 +1 @@
1
- export default '1.9.5';
1
+ export default '1.9.7';
package/lib/styles.css CHANGED
@@ -267,6 +267,9 @@
267
267
  outline: none;
268
268
  font-size: 1rem;
269
269
  width: 100%;
270
+ text-overflow: ellipsis;
271
+ white-space: nowrap;
272
+ overflow: hidden;
270
273
  text-decoration: underline;
271
274
  text-decoration-color: transparent;
272
275
  transition: text-decoration-color 0.2s ease-in-out;
@@ -677,12 +680,6 @@
677
680
 
678
681
  /* Container Queries */
679
682
 
680
- @container quiz (max-width: 640px) {
681
- .cio-quiz .cio-question-skip-button span {
682
- display: none;
683
- }
684
- }
685
-
686
683
  /* Small Tablet */
687
684
  @container quiz (min-width: 640px) {
688
685
  .cio-quiz .cio-container {
@@ -15,7 +15,6 @@ export declare enum QuestionTypes {
15
15
  export interface QuestionAnswer<Value> {
16
16
  questionId: number;
17
17
  input: Value;
18
- isLastQuestion?: boolean;
19
18
  }
20
19
  export type SelectQuestionPayload = QuestionAnswer<Omit<QuestionOption, 'attribute' | 'images'>[]>;
21
20
  export type OpenTextQuestionPayload = QuestionAnswer<string>;
@@ -5,7 +5,6 @@ export type QuizLocalReducerState = {
5
5
  answers: Answers;
6
6
  answerInputs: AnswerInputState;
7
7
  prevAnswerInputs: AnswerInputState;
8
- isLastAnswer: boolean;
9
8
  isQuizCompleted: boolean;
10
9
  quizVersionId?: string;
11
10
  quizSessionId?: string;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  interface ControlBarProps {
3
3
  ctaButtonText?: string;
4
+ skipQuestionButtonText?: string;
4
5
  }
5
6
  declare function ControlBar(props: ControlBarProps): JSX.Element;
6
7
  export default ControlBar;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  interface SkipButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
3
3
  propsGetters?: () => React.ButtonHTMLAttributes<HTMLButtonElement>;
4
+ skipQuestionButtonText?: string;
4
5
  }
5
6
  declare function SkipButton(props: SkipButtonProps): JSX.Element;
6
7
  export default SkipButton;
@@ -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 - `numResultsToDisplay` is an optional parameter that determines how many results should be displayed on results page\n- `callbacks` lets you pass callback functions that will be called on certain actions\n - `onQuizNextQuestion` is an optional callback function that will be called when user moves to the next question\n - `onQuizSkipQuestion` is an optional callback function that will be called when user skips a question\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- `callbacks` lets you pass callback functions that will be called on certain actions\n - `onQuizNextQuestion` is an optional callback function that will be called when user moves to the next question\n - `onQuizSkipQuestion` is an optional callback function that will be called when user skips a question\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- `questionsPageOptions` lets you configure the question page\n - `skipQuestionButtonText` is an optional string that will be used as the skip button text\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 getSkipQuestionButtonProps: () => ({...})), // prop getter for jsx skip 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)";
@@ -26,6 +26,9 @@ export interface ResultsPageOptions extends ResultCardProps {
26
26
  onAddToCartClick: QuizResultsEventsProps.OnAddToCartClick;
27
27
  onAddToFavoritesClick?: QuizResultsEventsProps.OnAddToFavoritesClick;
28
28
  }
29
+ export interface QuestionsPageOptions {
30
+ skipQuestionButtonText?: string;
31
+ }
29
32
  export interface SessionStateOptions {
30
33
  showSessionModal?: boolean;
31
34
  showSessionModalOnResults?: boolean;
@@ -50,11 +53,11 @@ export interface IQuizProps {
50
53
  primaryColor?: string;
51
54
  enableHydration?: boolean;
52
55
  callbacks?: Callbacks;
56
+ questionsPageOptions?: QuestionsPageOptions;
53
57
  }
54
58
  export interface QuizReturnState {
55
59
  answers: {
56
60
  inputs: AnswerInputState;
57
- isLastAnswer: boolean;
58
61
  };
59
62
  quiz: {
60
63
  requestState: RequestStates;
@@ -1,2 +1,2 @@
1
- declare const _default: "1.9.5";
1
+ declare const _default: "1.9.7";
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-ui-quizzes",
3
- "version": "1.9.5",
3
+ "version": "1.9.7",
4
4
  "description": "Constructor.io Quizzes UI library for web applications",
5
5
  "author": "constructor.io",
6
6
  "license": "MIT",