@constructor-io/constructorio-ui-quizzes 1.9.9 → 1.10.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.
Files changed (86) hide show
  1. package/README.md +2 -3
  2. package/dist/constructorio-ui-quizzes-bundled.js +14 -14
  3. package/lib/cjs/components/CioQuiz/actions.js +1 -0
  4. package/lib/cjs/components/CioQuiz/index.js +10 -6
  5. package/lib/cjs/components/CioQuiz/quizApiReducer.js +4 -1
  6. package/lib/cjs/components/ResultContainer/ResultContainer.js +25 -19
  7. package/lib/cjs/components/ShareButton/ShareButton.js +17 -0
  8. package/lib/cjs/components/ShareButton/ShareSVG.js +11 -0
  9. package/lib/cjs/components/ShareResultsModal/AlertCircleSVG.js +11 -0
  10. package/lib/cjs/components/ShareResultsModal/CheckMarkCircleSVG.js +10 -0
  11. package/lib/cjs/components/ShareResultsModal/CloseSVG.js +10 -0
  12. package/lib/cjs/components/ShareResultsModal/EmailField.js +50 -0
  13. package/lib/cjs/components/ShareResultsModal/LinkField.js +30 -0
  14. package/lib/cjs/components/ShareResultsModal/ShareResultsModal.js +24 -0
  15. package/lib/cjs/constants.js +3 -42
  16. package/lib/cjs/hooks/useConsoleErrors.js +4 -8
  17. package/lib/cjs/hooks/usePropsGetters/index.js +2 -0
  18. package/lib/cjs/hooks/useQueryParams.js +31 -0
  19. package/lib/cjs/hooks/useQuiz.js +3 -3
  20. package/lib/cjs/hooks/useQuizEvents/index.js +10 -5
  21. package/lib/cjs/hooks/useQuizEvents/useQuizResetClick.js +15 -2
  22. package/lib/cjs/hooks/useQuizState/useQuizApiState.js +27 -2
  23. package/lib/cjs/hooks/useShareResultsLink.js +18 -0
  24. package/lib/cjs/index.js +3 -1
  25. package/lib/cjs/services/index.js +3 -1
  26. package/lib/cjs/stories/Quiz/argTypes.js +258 -7
  27. package/lib/cjs/utils.js +1 -0
  28. package/lib/cjs/version.js +1 -1
  29. package/lib/mjs/components/CioQuiz/actions.js +1 -0
  30. package/lib/mjs/components/CioQuiz/index.js +10 -6
  31. package/lib/mjs/components/CioQuiz/quizApiReducer.js +9 -0
  32. package/lib/mjs/components/ResultContainer/ResultContainer.js +25 -19
  33. package/lib/mjs/components/ShareButton/ShareButton.js +14 -0
  34. package/lib/mjs/components/ShareButton/ShareSVG.js +7 -0
  35. package/lib/mjs/components/ShareResultsModal/AlertCircleSVG.js +7 -0
  36. package/lib/mjs/components/ShareResultsModal/CheckMarkCircleSVG.js +6 -0
  37. package/lib/mjs/components/ShareResultsModal/CloseSVG.js +6 -0
  38. package/lib/mjs/components/ShareResultsModal/EmailField.js +46 -0
  39. package/lib/mjs/components/ShareResultsModal/LinkField.js +26 -0
  40. package/lib/mjs/components/ShareResultsModal/ShareResultsModal.js +20 -0
  41. package/lib/mjs/constants.js +2 -41
  42. package/lib/mjs/hooks/useConsoleErrors.js +4 -8
  43. package/lib/mjs/hooks/usePropsGetters/index.js +2 -0
  44. package/lib/mjs/hooks/useQueryParams.js +29 -0
  45. package/lib/mjs/hooks/useQuiz.js +3 -3
  46. package/lib/mjs/hooks/useQuizEvents/index.js +10 -5
  47. package/lib/mjs/hooks/useQuizEvents/useQuizResetClick.js +14 -2
  48. package/lib/mjs/hooks/useQuizState/useQuizApiState.js +28 -3
  49. package/lib/mjs/hooks/useShareResultsLink.js +14 -0
  50. package/lib/mjs/index.js +1 -0
  51. package/lib/mjs/services/index.js +1 -0
  52. package/lib/mjs/stories/Quiz/argTypes.js +257 -6
  53. package/lib/mjs/utils.js +1 -0
  54. package/lib/mjs/version.js +1 -1
  55. package/lib/styles.css +194 -2
  56. package/lib/types/components/CioQuiz/actions.d.ts +7 -3
  57. package/lib/types/components/CioQuiz/context.d.ts +2 -1
  58. package/lib/types/components/CioQuiz/quizApiReducer.d.ts +2 -2
  59. package/lib/types/components/ResultCard/ResultCard.d.ts +2 -2
  60. package/lib/types/components/ResultContainer/ResultContainer.d.ts +5 -3
  61. package/lib/types/components/Results/Results.d.ts +2 -2
  62. package/lib/types/components/ShareButton/ShareButton.d.ts +7 -0
  63. package/lib/types/components/ShareButton/ShareSVG.d.ts +2 -0
  64. package/lib/types/components/ShareResultsModal/AlertCircleSVG.d.ts +2 -0
  65. package/lib/types/components/ShareResultsModal/CheckMarkCircleSVG.d.ts +2 -0
  66. package/lib/types/components/ShareResultsModal/CloseSVG.d.ts +2 -0
  67. package/lib/types/components/ShareResultsModal/EmailField.d.ts +6 -0
  68. package/lib/types/components/ShareResultsModal/LinkField.d.ts +6 -0
  69. package/lib/types/components/ShareResultsModal/ShareResultsModal.d.ts +9 -0
  70. package/lib/types/constants.d.ts +1 -5
  71. package/lib/types/hooks/usePropsGetters/index.d.ts +2 -1
  72. package/lib/types/hooks/useQueryParams.d.ts +7 -0
  73. package/lib/types/hooks/useQuizEvents/useQuizNextClick.d.ts +2 -2
  74. package/lib/types/hooks/useQuizEvents/useQuizResetClick.d.ts +9 -2
  75. package/lib/types/hooks/useQuizEvents/useQuizSkipClick.d.ts +2 -2
  76. package/lib/types/hooks/useShareResultsLink.d.ts +2 -0
  77. package/lib/types/index.d.ts +1 -0
  78. package/lib/types/services/index.d.ts +6 -5
  79. package/lib/types/stories/Quiz/argTypes.d.ts +253 -6
  80. package/lib/types/types.d.ts +32 -14
  81. package/lib/types/utils.d.ts +2 -1
  82. package/lib/types/version.d.ts +1 -1
  83. package/package.json +2 -2
  84. package/lib/cjs/stories/Quiz/tests/mocks.js +0 -170
  85. package/lib/mjs/stories/Quiz/tests/mocks.js +0 -198
  86. package/lib/types/stories/Quiz/tests/mocks.d.ts +0 -44
package/lib/mjs/utils.js CHANGED
@@ -51,6 +51,7 @@ export const functionStrings = {
51
51
  onQuizResultsLoaded: `(results) => console.dir(results)`,
52
52
  onQuizNextQuestion: `(question) => console.dir(question)`,
53
53
  onQuizSkipQuestion: `(question) => console.dir(question)`,
54
+ onEmailResults: `(data) => console.dir(data)`,
54
55
  cioJsClient: `cioJsClient`,
55
56
  };
56
57
  export const stringifyWithDefaults = (obj) => {
@@ -1 +1 @@
1
- export default '1.9.7';
1
+ export default '1.10.0';
package/lib/styles.css CHANGED
@@ -678,6 +678,21 @@
678
678
  margin-top: 1px;
679
679
  }
680
680
 
681
+ /* Share results Button Component */
682
+ .cio-quiz .cio-question-share-results-button {
683
+ background: none;
684
+ border: none;
685
+ display: flex;
686
+ gap: 0.5rem;
687
+ align-items: center;
688
+ }
689
+ .cio-quiz .cio-question-share-results-button:hover {
690
+ text-decoration: underline;
691
+ }
692
+ .cio-quiz .cio-question-share-results-button span {
693
+ margin-top: 1px;
694
+ }
695
+
681
696
  /* Container Queries */
682
697
 
683
698
  /* Small Tablet */
@@ -696,13 +711,18 @@
696
711
  align-self: normal;
697
712
  }
698
713
 
699
- /* Image */
714
+ /* Image Container */
700
715
  .cio-quiz .cio-question-image-container {
701
716
  flex-basis: 50%;
702
717
  flex-shrink: 0;
703
718
  border-radius: 4px;
704
719
  }
705
720
 
721
+ /* Image */
722
+ .cio-quiz .cio-question-image {
723
+ height: auto;
724
+ }
725
+
706
726
  /* Cover Page Component */
707
727
  .cio-quiz .cio-cover-question-container--with-image {
708
728
  margin-bottom: 0;
@@ -721,7 +741,7 @@
721
741
  .cio-quiz .cio-results-container {
722
742
  padding: 3rem 4rem;
723
743
  }
724
- .cio-quiz .cio-results-filter-and-redo-container {
744
+ .cio-quiz .cio-results-button-group {
725
745
  display: flex;
726
746
  justify-content: space-between;
727
747
  align-items: end;
@@ -897,3 +917,175 @@
897
917
  transform: rotate(360deg);
898
918
  }
899
919
  }
920
+
921
+ /* Share results modal */
922
+ .cio-quiz .cio-share-results-modal {
923
+ position: absolute;
924
+ display: flex;
925
+ z-index: 100;
926
+ width: 100%;
927
+ height: 100%;
928
+ background-color: rgba(0, 0, 0, 0.5);
929
+ justify-content: space-between;
930
+ }
931
+
932
+ .cio-quiz .cio-share-results-container {
933
+ max-width: 600px;
934
+ width: 100%;
935
+ margin: auto;
936
+ }
937
+
938
+ .cio-quiz .cio-share-results-content {
939
+ display: flex;
940
+ flex-direction: column;
941
+ gap: 24px;
942
+ background: #ffffff;
943
+ line-height: 1.5;
944
+ padding: 40px;
945
+ padding-bottom: 80px;
946
+ border-radius: 8px;
947
+ }
948
+
949
+ .cio-quiz .cio-share-results-header {
950
+ display: flex;
951
+ flex-direction: row;
952
+ justify-content: space-between;
953
+ }
954
+
955
+ .cio-quiz .cio-share-results-description {
956
+ font-size: 1rem;
957
+ font-weight: 700;
958
+ }
959
+
960
+ .cio-quiz .cio-share-results-title {
961
+ font-weight: 700;
962
+ font-size: 24px;
963
+ text-transform: capitalize;
964
+ }
965
+
966
+ .cio-quiz .cio-modal-close-button {
967
+ background: none;
968
+ border: none;
969
+ display: flex;
970
+ gap: 0.5rem;
971
+ align-items: center;
972
+ }
973
+
974
+ .cio-quiz .cio-share-results-button-group {
975
+ display: flex;
976
+ flex-direction: row;
977
+ gap: 1rem;
978
+ }
979
+
980
+ .cio-quiz .cio-share-results-feature-group {
981
+ display: flex;
982
+ flex-direction: column;
983
+ gap: 1rem;
984
+ }
985
+
986
+ .cio-quiz .cio-results-redo-and-share-button-group {
987
+ display: flex;
988
+ gap: 8px;
989
+ align-items: end;
990
+ justify-content: space-between;
991
+ }
992
+
993
+ .cio-quiz .cio-share-results-share-button {
994
+ background: #d3e5fb;
995
+ color: var(--primary-color);
996
+ border: 2px solid #d3e5fb;
997
+ border-radius: 4px;
998
+ height: 3rem;
999
+ font-size: 1rem;
1000
+ flex-grow: 1;
1001
+ width: 100%;
1002
+ padding: 12px 32px;
1003
+ }
1004
+
1005
+ .cio-quiz .cio-share-results-share-button:hover {
1006
+ background: var(--primary-color-variant-500);
1007
+ border: 2px solid var(--primary-color-variant-600);
1008
+ color: white;
1009
+ }
1010
+ .cio-quiz .cio-share-results-share-button:active {
1011
+ background: var(--primary-color-variant-700);
1012
+ border: 2px solid var(--primary-color-variant-800);
1013
+ color: white;
1014
+ }
1015
+ .cio-quiz .cio-share-results-share-button:focus {
1016
+ outline: 3px solid var(--primary-color-variant-100);
1017
+ }
1018
+
1019
+ .cio-quiz .cio-share-results-notification {
1020
+ width: 100%;
1021
+ padding: 20px;
1022
+ border-radius: 8px;
1023
+ border: 1px;
1024
+ font-weight: 500;
1025
+ border: 1px solid #c8daee;
1026
+ box-shadow: 0px 4px 10px 0px rgba(93, 124, 232, 0.15);
1027
+ display: flex;
1028
+ flex-direction: row;
1029
+ gap: 12px;
1030
+ }
1031
+
1032
+ .cio-quiz .cio-share-results-link-input {
1033
+ font-size: 1rem;
1034
+ padding: 12px 20px;
1035
+ border-radius: 4px;
1036
+ border: 1px solid #c8daee;
1037
+ color: var(--gray-dust-100);
1038
+ width: '100%';
1039
+ flex-grow: 1;
1040
+ }
1041
+
1042
+ .cio-quiz .cio-share-results-email-input-group {
1043
+ display: flex;
1044
+ flex-direction: column;
1045
+ gap: 4px;
1046
+ flex-grow: 1;
1047
+ }
1048
+
1049
+ .cio-quiz .cio-share-results-email-input-error-message {
1050
+ color: #e0182d;
1051
+ }
1052
+
1053
+ .cio-quiz .cio-share-results-email-input {
1054
+ padding: 0.5rem;
1055
+ border: 0;
1056
+ border-bottom: 1px solid var(--gray-dust-100);
1057
+ color: var(--primary-color-variant-500);
1058
+ padding: 0.8rem;
1059
+ outline: none;
1060
+ font-size: 1rem;
1061
+ width: 100%;
1062
+ flex-grow: 1;
1063
+ }
1064
+
1065
+ .cio-quiz .cio-share-results-email-input--error {
1066
+ border-bottom: 1px solid #e0182d;
1067
+ }
1068
+
1069
+ @container (max-width: 500px) {
1070
+ .cio-quiz .cio-share-results-button-group {
1071
+ display: flex;
1072
+ flex-direction: column;
1073
+ gap: 1rem;
1074
+ }
1075
+
1076
+ .cio-quiz .cio-share-results-share-button {
1077
+ max-width: 100%;
1078
+ }
1079
+ }
1080
+
1081
+ @container (min-width: 500px) {
1082
+ .cio-quiz .cio-share-results-button-group {
1083
+ display: flex;
1084
+ flex-direction: row;
1085
+ gap: 1rem;
1086
+ }
1087
+
1088
+ .cio-quiz .cio-share-results-share-button {
1089
+ max-width: 138px;
1090
+ }
1091
+ }
@@ -1,4 +1,4 @@
1
- import { CurrentQuestion, NextQuestionResponse, QuestionOption, QuizResultsResponse } from '../../types';
1
+ import { CurrentQuestion, NextQuestionResponse, QuestionOption, QuizResultsResponse, QuizSharedResultsData } from '../../types';
2
2
  import type { QuizLocalReducerState } from './quizLocalReducer';
3
3
  export declare enum QuestionTypes {
4
4
  OpenText = "open",
@@ -30,18 +30,22 @@ export declare enum QuizAPIActionTypes {
30
30
  SET_IS_ERROR = 1,
31
31
  SET_QUIZ_RESULTS = 2,
32
32
  SET_CURRENT_QUESTION = 3,
33
- RESET_QUIZ = 4
33
+ RESET_QUIZ = 4,
34
+ SET_QUIZ_SHARED_RESULTS = 5
34
35
  }
35
36
  export type ActionSetIsLoading = Action<QuizAPIActionTypes.SET_IS_LOADING>;
36
37
  export type ActionSetIsError = Action<QuizAPIActionTypes.SET_IS_ERROR>;
37
38
  export type ActionSetQuizResults = Action<QuizAPIActionTypes.SET_QUIZ_RESULTS, {
38
39
  quizResults: QuizResultsResponse;
39
40
  }>;
41
+ export type ActionSetQuizSharedResults = Action<QuizAPIActionTypes.SET_QUIZ_SHARED_RESULTS, {
42
+ quizResults: QuizSharedResultsData;
43
+ }>;
40
44
  export type ActionSetCurrentQuestion = Action<QuizAPIActionTypes.SET_CURRENT_QUESTION, {
41
45
  quizCurrentQuestion: NextQuestionResponse;
42
46
  quizSessionId?: string;
43
47
  quizVersionId?: string;
44
48
  }>;
45
49
  export type ActionResetQuiz = Action<QuizAPIActionTypes.RESET_QUIZ>;
46
- export type ActionQuizAPI = ActionSetIsLoading | ActionSetIsError | ActionSetQuizResults | ActionSetCurrentQuestion | ActionResetQuiz;
50
+ export type ActionQuizAPI = ActionSetIsLoading | ActionSetIsError | ActionSetQuizResults | ActionSetCurrentQuestion | ActionResetQuiz | ActionSetQuizSharedResults;
47
51
  export {};
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';
3
- import { GetAddToCartButtonProps, GetAddToFavoritesButtonProps, GetCoverQuestionProps, GetHydrateQuizButtonProps, GetNextQuestionButtonProps, GetSkipQuestionButtonProps, GetOpenTextInputProps, GetPreviousQuestionButtonProps, GetQuizImageProps, GetQuizResultButtonProps, GetQuizResultLinkProps, GetResetQuizButtonProps, GetSelectInputProps, PrimaryColorStyles, QuizReturnState } from '../../types';
3
+ import { GetAddToCartButtonProps, GetAddToFavoritesButtonProps, GetCoverQuestionProps, GetHydrateQuizButtonProps, GetNextQuestionButtonProps, GetSkipQuestionButtonProps, GetOpenTextInputProps, GetPreviousQuestionButtonProps, GetQuizImageProps, GetQuizResultButtonProps, GetQuizResultLinkProps, GetResetQuizButtonProps, GetSelectInputProps, PrimaryColorStyles, QuizReturnState, GetShareResultsButtonProps } from '../../types';
4
4
  export interface QuizContextValue {
5
5
  cioClient?: ConstructorIOClient;
6
6
  state?: QuizReturnState;
@@ -12,6 +12,7 @@ export interface QuizContextValue {
12
12
  getSelectInputProps: GetSelectInputProps;
13
13
  getCoverQuestionProps: GetCoverQuestionProps;
14
14
  getResetQuizButtonProps: GetResetQuizButtonProps;
15
+ getShareResultsButtonProps: GetShareResultsButtonProps;
15
16
  getHydrateQuizButtonProps: GetHydrateQuizButtonProps;
16
17
  getAddToCartButtonProps: GetAddToCartButtonProps;
17
18
  getAddToFavoritesButtonProps: GetAddToFavoritesButtonProps;
@@ -1,11 +1,11 @@
1
1
  import { RequestStates } from '../../constants';
2
- import { CurrentQuestion, NextQuestionResponse, QuizResultsResponse } from '../../types';
2
+ import { CurrentQuestion, NextQuestionResponse, QuizResultsResponse, QuizSharedResultsData } from '../../types';
3
3
  import { ActionQuizAPI } from './actions';
4
4
  export type QuizAPIReducerState = {
5
5
  quizRequestState: RequestStates;
6
6
  quizCurrentQuestion?: CurrentQuestion;
7
7
  quizFirstQuestion?: NextQuestionResponse;
8
- quizResults?: QuizResultsResponse;
8
+ quizResults?: QuizResultsResponse | QuizSharedResultsData;
9
9
  selectedOptionsWithAttributes?: string[];
10
10
  };
11
11
  export declare const initialState: QuizAPIReducerState;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { QuizResultDataPartial } from '../../types';
3
- interface ResultCardProps {
3
+ interface ResultCardOptions {
4
4
  result: QuizResultDataPartial;
5
5
  salePriceKey?: string;
6
6
  regularPriceKey?: string;
@@ -9,5 +9,5 @@ interface ResultCardProps {
9
9
  resultPosition: number;
10
10
  renderResultCardPriceDetails?: (result: QuizResultDataPartial) => JSX.Element;
11
11
  }
12
- export default function ResultCard(props: ResultCardProps): JSX.Element;
12
+ export default function ResultCard(props: ResultCardOptions): JSX.Element;
13
13
  export {};
@@ -1,6 +1,8 @@
1
1
  /// <reference types="react" />
2
- import { ResultCardProps } from '../../types';
2
+ import { ResultCardOptions, ResultsPageOptions } from '../../types';
3
3
  export interface IResultContainerProps {
4
- options: ResultCardProps;
4
+ resultCardOptions?: ResultCardOptions;
5
+ resultsPageOptions?: ResultsPageOptions;
6
+ onShare: () => void;
5
7
  }
6
- export default function ResultContainer(props: IResultContainerProps): JSX.Element;
8
+ export default function ResultContainer(props: IResultContainerProps): JSX.Element | null;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { ResultCardProps } from '../../types';
3
- interface ResultsProps extends ResultCardProps {
2
+ import { ResultCardOptions } from '../../types';
3
+ interface ResultsProps extends ResultCardOptions {
4
4
  }
5
5
  declare function Results(props: ResultsProps): JSX.Element;
6
6
  export default Results;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ declare function ShareButton(props: Props): JSX.Element | null;
3
+ interface Props extends React.ButtonHTMLAttributes<HTMLButtonElement> {
4
+ shareText?: string;
5
+ onClick: () => void;
6
+ }
7
+ export default ShareButton;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export default function ShareSVG(): JSX.Element;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export default function AlertCircleSVG(): JSX.Element;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export default function CheckMarkCircleSVG(): JSX.Element;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export default function CloseSVG(): JSX.Element;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ interface EmailFieldProps {
3
+ onSubmit: (email: string) => Promise<void>;
4
+ }
5
+ export default function EmailField({ onSubmit }: EmailFieldProps): JSX.Element;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ interface LinkFieldProps {
3
+ url: string;
4
+ }
5
+ export default function LinkField({ url }: LinkFieldProps): JSX.Element;
6
+ export {};
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { QuizResultsEventsProps, QuizReturnState } from '../../types';
3
+ interface ShareResultsModalProps {
4
+ onClose: () => void;
5
+ quizState: QuizReturnState['quiz'];
6
+ onEmailResults?: QuizResultsEventsProps.OnEmailResults;
7
+ }
8
+ export default function ShareResultsModal({ onClose, quizState, onEmailResults, }: ShareResultsModalProps): JSX.Element;
9
+ export {};
@@ -1,14 +1,10 @@
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- `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
- 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";
4
+ 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
5
  export declare const basicDescription = "Pass an `apiKey` and a `quizId` to request questions and quiz results from Constructor's servers";
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)";
8
6
  export declare const smallContainerDescription = "If you are using the provided styles, CioQuiz component will respect the height and width of its parent container and use responsive styles based on the parent container's dimensions";
9
7
  export declare const changePrimaryColorDescription = "\nIf you would like to use a different primary color, pass a `primaryColor` string in RGB format ('R, G, B').\n\nAccent colors for borders and different states (hover, focus, active) will be calculated automatically based on the primary color you provided.\n\nBy default, the primary color has a value of \"35, 71, 199\" (Constructor Blue).\n\nIn the example below, the `primaryColor` prop has been used to override this color to \"255, 82, 48\" (Orange).\n\n> Advanced Option: Instead of passing a primaryColor prop, you can also override `--primary-color-h`, `--primary-color-s`, and `--primary-color-l` CSS variables within a `.cio-quiz` container element. If explicitly given a value in your CSS, then the values of these variables will be used as the HSL values for your quiz.\n";
10
- export declare const callbacksDescription = "Pass an `apiKey`, a `quizId`, and `callbacks`";
11
- export declare const favoritesDescription = "\nAdd `const [favorites, setFavorites] = useState([]);` or equivalent to manage the favorite items' state.\n\nPass favorites as an array to `favoriteItems` in `resultsPageOptions` as a prop to CioQuiz.\n\nPass a callback function to `onAddToFavoritesClick` in `resultsPageOptions` as a prop to CioQuiz to handle favorites state changes to update `favorites` array. \n";
12
8
  export declare enum RequestStates {
13
9
  Stale = "STALE",
14
10
  Loading = "LOADING",
@@ -1,4 +1,4 @@
1
- import { GetResetQuizButtonProps, GetCoverQuestionProps, GetNextQuestionButtonProps, GetOpenTextInputProps, GetPreviousQuestionButtonProps, GetQuizImageProps, GetSelectInputProps, QuizEventsReturn, GetHydrateQuizButtonProps, GetAddToCartButtonProps, GetQuizResultButtonProps, GetQuizResultLinkProps, GetSelectQuestionImageProps, GetAddToFavoritesButtonProps, GetSkipQuestionButtonProps } from '../../types';
1
+ import { GetResetQuizButtonProps, GetCoverQuestionProps, GetNextQuestionButtonProps, GetOpenTextInputProps, GetPreviousQuestionButtonProps, GetQuizImageProps, GetSelectInputProps, QuizEventsReturn, GetHydrateQuizButtonProps, GetAddToCartButtonProps, GetQuizResultButtonProps, GetQuizResultLinkProps, GetSelectQuestionImageProps, GetAddToFavoritesButtonProps, GetSkipQuestionButtonProps, GetShareResultsButtonProps } from '../../types';
2
2
  import { QuizAPIReducerState } from '../../components/CioQuiz/quizApiReducer';
3
3
  import { QuizLocalReducerState } from '../../components/CioQuiz/quizLocalReducer';
4
4
  declare const usePropsGetters: (quizEvents: QuizEventsReturn, quizApiState: QuizAPIReducerState, quizLocalState: QuizLocalReducerState, favoriteItems?: string[]) => {
@@ -10,6 +10,7 @@ declare const usePropsGetters: (quizEvents: QuizEventsReturn, quizApiState: Quiz
10
10
  getSelectInputProps: GetSelectInputProps;
11
11
  getCoverQuestionProps: GetCoverQuestionProps;
12
12
  getResetQuizButtonProps: GetResetQuizButtonProps;
13
+ getShareResultsButtonProps: GetShareResultsButtonProps;
13
14
  getHydrateQuizButtonProps: GetHydrateQuizButtonProps;
14
15
  getAddToCartButtonProps: GetAddToCartButtonProps;
15
16
  getAddToFavoritesButtonProps: GetAddToFavoritesButtonProps;
@@ -0,0 +1,7 @@
1
+ declare const useQueryParams: () => {
2
+ queryItems: string[];
3
+ queryAttributes: string[];
4
+ isSharedResultsQuery: boolean;
5
+ removeSharedResultsQueryParams: () => void;
6
+ };
7
+ export default useQueryParams;
@@ -1,6 +1,6 @@
1
1
  import { ActionAnswerQuestion } from '../../components/CioQuiz/actions';
2
2
  import { QuizAPIReducerState } from '../../components/CioQuiz/quizApiReducer';
3
3
  import { QuizLocalReducerState } from '../../components/CioQuiz/quizLocalReducer';
4
- import { QuizEventsReturn, OnQuizNextQuestion } from '../../types';
5
- declare const useQuizNextClick: (quizApiState: QuizAPIReducerState, quizLocalState: QuizLocalReducerState, dispatchLocalState: React.Dispatch<ActionAnswerQuestion>, onQuizNextQuestion?: OnQuizNextQuestion) => QuizEventsReturn.NextQuestion;
4
+ import { QuizEventsReturn, QuizResultsEventsProps } from '../../types';
5
+ declare const useQuizNextClick: (quizApiState: QuizAPIReducerState, quizLocalState: QuizLocalReducerState, dispatchLocalState: React.Dispatch<ActionAnswerQuestion>, onQuizNextQuestion?: QuizResultsEventsProps.OnQuizNextQuestion) => QuizEventsReturn.NextQuestion;
6
6
  export default useQuizNextClick;
@@ -1,4 +1,11 @@
1
+ /// <reference types="react" />
1
2
  import { ActionAnswerQuestion, ActionQuizAPI } from '../../components/CioQuiz/actions';
2
- import { QuizEventsReturn, QuizResultsResponse } from '../../types';
3
- declare const useQuizResetClick: (resetQuizSessionStorageState: () => void, dispatchLocalState: React.Dispatch<ActionAnswerQuestion>, dispatchApiState: React.Dispatch<ActionQuizAPI>, quizResults?: QuizResultsResponse) => QuizEventsReturn.NextQuestion;
3
+ import { QuizEventsReturn, QuizResultsResponse, QuizSharedResultsData } from '../../types';
4
+ type IUseQuizResetClickProps = {
5
+ resetQuizSessionStorageState: () => void;
6
+ dispatchLocalState: React.Dispatch<ActionAnswerQuestion>;
7
+ dispatchApiState: React.Dispatch<ActionQuizAPI>;
8
+ quizResults?: QuizResultsResponse | QuizSharedResultsData;
9
+ };
10
+ declare const useQuizResetClick: (props: IUseQuizResetClickProps) => QuizEventsReturn.NextQuestion;
4
11
  export default useQuizResetClick;
@@ -1,6 +1,6 @@
1
1
  import { ActionAnswerQuestion } from '../../components/CioQuiz/actions';
2
2
  import { QuizAPIReducerState } from '../../components/CioQuiz/quizApiReducer';
3
3
  import { QuizLocalReducerState } from '../../components/CioQuiz/quizLocalReducer';
4
- import { QuizEventsReturn, OnQuizSkipQuestion } from '../../types';
5
- declare const useQuizSkipClick: (quizApiState: QuizAPIReducerState, quizLocalState: QuizLocalReducerState, dispatchLocalState: React.Dispatch<ActionAnswerQuestion>, onQuizSkipQuestion?: OnQuizSkipQuestion) => QuizEventsReturn.NextQuestion;
4
+ import { QuizEventsReturn, QuizResultsEventsProps } from '../../types';
5
+ declare const useQuizSkipClick: (quizApiState: QuizAPIReducerState, quizLocalState: QuizLocalReducerState, dispatchLocalState: React.Dispatch<ActionAnswerQuestion>, onQuizSkipQuestion?: QuizResultsEventsProps.OnQuizSkipQuestion) => QuizEventsReturn.NextQuestion;
6
6
  export default useQuizSkipClick;
@@ -0,0 +1,2 @@
1
+ import { QuizReturnState } from '../types';
2
+ export default function useShareResultsLink(quizState: QuizReturnState['quiz']): string;
@@ -1,5 +1,6 @@
1
1
  import CioQuiz from './components/CioQuiz';
2
2
  export { default as useCioQuiz } from './hooks/useQuiz';
3
+ export { default as useShareResultsLink } from './hooks/useShareResultsLink';
3
4
  export { default as QuizQuestions } from './components/QuizQuestions/index';
4
5
  export { default as OpenTextQuestion } from './components/OpenTextTypeQuestion/OpenTextTypeQuestion';
5
6
  export { default as CoverQuestion } from './components/CoverTypeQuestion/CoverTypeQuestion';
@@ -1,8 +1,9 @@
1
- import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';
2
- import { QuizzesParameters, QuizzesResultsParameters, NextQuestionResponse, QuizResultsResponse, QuizResultDataPartial } from '../types';
1
+ import ConstructorIOClient, { type GetBrowseResultsForItemIdsResponse } from '@constructor-io/constructorio-client-javascript';
2
+ import { QuizzesParameters, QuizzesResultsParameters, NextQuestionResponse, QuizResultsResponse, QuizResultDataPartial, QuizSharedResultsData } from '../types';
3
3
  export declare const getCioClient: (apiKey?: string) => ConstructorIOClient | undefined;
4
4
  export declare const getNextQuestion: (cioClient: ConstructorIOClient, quizId: string, parameters: QuizzesParameters) => Promise<NextQuestionResponse>;
5
5
  export declare const getQuizResults: (cioClient: ConstructorIOClient, quizId: string, parameters: QuizzesResultsParameters) => Promise<QuizResultsResponse>;
6
- export declare const trackQuizResultsLoaded: (cioClient: ConstructorIOClient, quizResults: QuizResultsResponse) => void;
7
- export declare const trackQuizResultClick: (cioClient: ConstructorIOClient, quizResults: QuizResultsResponse, result: QuizResultDataPartial, position: number) => void;
8
- export declare const trackQuizConversion: (cioClient: ConstructorIOClient, quizResults: QuizResultsResponse, result: QuizResultDataPartial, price?: number, type?: string) => void;
6
+ export declare const getBrowseResultsForItemIds: (cioClient: ConstructorIOClient, itemIds: string[]) => Promise<GetBrowseResultsForItemIdsResponse>;
7
+ export declare const trackQuizResultsLoaded: (cioClient: ConstructorIOClient, quizResults: QuizResultsResponse | QuizSharedResultsData) => void;
8
+ export declare const trackQuizResultClick: (cioClient: ConstructorIOClient, quizResults: QuizResultsResponse | QuizSharedResultsData, result: QuizResultDataPartial, position: number) => void;
9
+ export declare const trackQuizConversion: (cioClient: ConstructorIOClient, quizResults: QuizResultsResponse | QuizSharedResultsData, result: QuizResultDataPartial, price?: number, type?: string) => void;