posthog-js 1.136.5 → 1.136.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.
- package/dist/array.full.js +2 -2
- package/dist/array.full.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/es.js +1 -1
- package/dist/es.js.map +1 -1
- package/dist/lib/src/extensions/surveys/components/ConfirmationMessage.d.ts +3 -3
- package/dist/lib/src/extensions/surveys/components/QuestionTypes.d.ts +8 -12
- package/dist/lib/src/extensions/surveys/surveys-utils.d.ts +3 -3
- package/dist/lib/src/extensions/surveys.d.ts +3 -5
- package/dist/lib/src/posthog-surveys-types.d.ts +1 -1
- package/dist/module.d.ts +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/surveys-module-previews.js +1 -1
- package/dist/surveys-module-previews.js.map +1 -1
- package/dist/surveys.js +1 -1
- package/dist/surveys.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/src/extensions/replay/sessionrecording.js +2 -0
- package/lib/src/extensions/replay/sessionrecording.js.map +1 -1
- package/lib/src/extensions/surveys/components/BottomSection.jsx +3 -3
- package/lib/src/extensions/surveys/components/BottomSection.jsx.map +1 -1
- package/lib/src/extensions/surveys/components/ConfirmationMessage.d.ts +3 -3
- package/lib/src/extensions/surveys/components/ConfirmationMessage.jsx +3 -3
- package/lib/src/extensions/surveys/components/ConfirmationMessage.jsx.map +1 -1
- package/lib/src/extensions/surveys/components/QuestionHeader.jsx +2 -2
- package/lib/src/extensions/surveys/components/QuestionHeader.jsx.map +1 -1
- package/lib/src/extensions/surveys/components/QuestionTypes.d.ts +8 -12
- package/lib/src/extensions/surveys/components/QuestionTypes.jsx +21 -17
- package/lib/src/extensions/surveys/components/QuestionTypes.jsx.map +1 -1
- package/lib/src/extensions/surveys/surveys-utils.d.ts +3 -3
- package/lib/src/extensions/surveys/surveys-utils.jsx +7 -7
- package/lib/src/extensions/surveys/surveys-utils.jsx.map +1 -1
- package/lib/src/extensions/surveys.d.ts +3 -5
- package/lib/src/extensions/surveys.jsx +104 -68
- package/lib/src/extensions/surveys.jsx.map +1 -1
- package/lib/src/posthog-surveys-types.d.ts +1 -1
- package/lib/src/posthog-surveys-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuestionTypes.jsx","sourceRoot":"","sources":["../../../../../src/extensions/surveys/components/QuestionTypes.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAMH,kBAAkB,GACrB,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAC1E,OAAO,EACH,QAAQ,EACR,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,kBAAkB,GACrB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEzD,MAAM,UAAU,gBAAgB,CAAC,EAUhC;QATG,QAAQ,cAAA,EACR,UAAU,gBAAA,EACV,QAAQ,cAAA,EACR,gBAAgB,sBAAA;IAOhB,IAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;IACtB,IAAA,KAAA,OAAkB,QAAQ,CAAC,EAAE,CAAC,IAAA,EAA7B,IAAI,QAAA,EAAE,OAAO,QAAgB,CAAA;IAEpC,OAAO,CACH,CAAC,GAAG,CACA,SAAS,CAAC,YAAY,CACtB,KAAK,CAAC,CAAC,EAAE,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c;gBACf,eAAe,CAAC,MAAM,KAAK,CAAC;gBAC5B,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC5B,CAAC,QAAQ,CAAC,QAAQ,CACrB,CACD,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,QAAQ,CAAC,CAAC;YACN,IAAI,kBAAkB,IAAI,QAAQ,CAAC,IAAI,KAAK,kBAAkB,CAAC,cAAc,EAAE;gBAC3E,IAAI,OAAO,CAAC,eAAe,CAAC,EAAE;oBAC1B,QAAQ,wCAAK,eAAe,YAAE,cAAc,UAAE,CAAA;iBACjD;aACJ;iBAAM;gBACH,QAAQ,CAAC,eAAe,CAAC,CAAA;aAC5B;QACL,CAAC,CAAC,EAEV;QAAA,EAAE,GAAG,CAAC,CACT,CAAA;AACL,CAAC;AAED,IAAM,gBAAgB,GAAG,CAAC,iBAAiB,EAAE,YAAY,EAAE,cAAc,CAAC,CAAA;AAC1E,IAAM,eAAe,GAAG,CAAC,qBAAqB,EAAE,iBAAiB,EAAE,YAAY,EAAE,cAAc,EAAE,kBAAkB,CAAC,CAAA;AACpH,IAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;AACxC,IAAM,eAAe,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAA","sourcesContent":["import {\n BasicSurveyQuestion,\n SurveyAppearance,\n LinkSurveyQuestion,\n RatingSurveyQuestion,\n MultipleSurveyQuestion,\n SurveyQuestionType,\n} from '../../../posthog-surveys-types'\nimport { RefObject } from 'preact'\nimport { useRef, useState, useMemo } from 'preact/hooks'\nimport { isNull, isArray } from '../../../utils/type-utils'\nimport { useContrastingTextColor } from '../hooks/useContrastingTextColor'\nimport {\n checkSVG,\n dissatisfiedEmoji,\n neutralEmoji,\n satisfiedEmoji,\n veryDissatisfiedEmoji,\n verySatisfiedEmoji,\n} from '../icons'\nimport { defaultSurveyAppearance, getDisplayOrderChoices } from '../surveys-utils'\nimport { BottomSection } from './BottomSection'\nimport { Cancel, QuestionHeader } from './QuestionHeader'\n\nexport function OpenTextQuestion({\n question,\n appearance,\n onSubmit,\n closeSurveyPopup,\n}: {\n question: BasicSurveyQuestion\n appearance: SurveyAppearance\n onSubmit: (text: string) => void\n closeSurveyPopup: () => void\n}) {\n const textRef = useRef(null)\n const [text, setText] = useState('')\n\n return (\n <div\n className=\"survey-box\"\n style={{ backgroundColor: appearance.backgroundColor || defaultSurveyAppearance.backgroundColor }}\n ref={textRef}\n >\n <Cancel onClick={() => closeSurveyPopup()} />\n <QuestionHeader\n question={question.question}\n description={question.description}\n backgroundColor={appearance.backgroundColor}\n />\n <textarea rows={4} placeholder={appearance?.placeholder} onInput={(e) => setText(e.currentTarget.value)} />\n <BottomSection\n text={question.buttonText || 'Submit'}\n submitDisabled={!text && !question.optional}\n appearance={appearance}\n onSubmit={() => onSubmit(text)}\n />\n </div>\n )\n}\n\nexport function LinkQuestion({\n question,\n appearance,\n onSubmit,\n closeSurveyPopup,\n}: {\n question: LinkSurveyQuestion\n appearance: SurveyAppearance\n onSubmit: (clicked: string) => void\n closeSurveyPopup: () => void\n}) {\n return (\n <div className=\"survey-box\">\n <Cancel onClick={() => closeSurveyPopup()} />\n <QuestionHeader question={question.question} description={question.description} />\n <BottomSection\n text={question.buttonText || 'Submit'}\n submitDisabled={false}\n link={question.link}\n appearance={appearance}\n onSubmit={() => onSubmit('link clicked')}\n />\n </div>\n )\n}\n\nexport function RatingQuestion({\n question,\n questionIndex,\n appearance,\n onSubmit,\n closeSurveyPopup,\n}: {\n question: RatingSurveyQuestion\n questionIndex: number\n appearance: SurveyAppearance\n onSubmit: (rating: number | null) => void\n closeSurveyPopup: () => void\n}) {\n const scale = question.scale\n const starting = question.scale === 10 ? 0 : 1\n const [rating, setRating] = useState<number | null>(null)\n\n return (\n <div className=\"survey-box\">\n <Cancel onClick={() => closeSurveyPopup()} />\n <QuestionHeader\n question={question.question}\n description={question.description}\n backgroundColor={appearance.backgroundColor}\n />\n <div className=\"rating-section\">\n <div className=\"rating-options\">\n {question.display === 'emoji' && (\n <div className=\"rating-options-emoji\">\n {(question.scale === 3 ? threeScaleEmojis : fiveScaleEmojis).map((emoji, idx) => {\n const active = idx + 1 === rating\n return (\n <button\n className={`ratings-emoji question-${questionIndex}-rating-${idx} ${\n active ? 'rating-active' : null\n }`}\n value={idx + 1}\n key={idx}\n type=\"button\"\n onClick={() => {\n setRating(idx + 1)\n }}\n >\n {emoji}\n </button>\n )\n })}\n </div>\n )}\n {question.display === 'number' && (\n <div\n className=\"rating-options-number\"\n style={{ gridTemplateColumns: `repeat(${scale - starting + 1}, minmax(0, 1fr))` }}\n >\n {(question.scale === 5 ? fiveScaleNumbers : tenScaleNumbers).map((number, idx) => {\n const active = rating === number\n return (\n <RatingButton\n key={idx}\n questionIndex={questionIndex}\n active={active}\n appearance={appearance}\n num={number}\n setActiveNumber={(num) => {\n setRating(num)\n }}\n />\n )\n })}\n </div>\n )}\n </div>\n <div className=\"rating-text\">\n <div>{question.lowerBoundLabel}</div>\n <div>{question.upperBoundLabel}</div>\n </div>\n </div>\n <BottomSection\n text={question.buttonText || appearance?.submitButtonText || 'Submit'}\n submitDisabled={isNull(rating) && !question.optional}\n appearance={appearance}\n onSubmit={() => onSubmit(rating)}\n />\n </div>\n )\n}\n\nexport function RatingButton({\n num,\n active,\n questionIndex,\n appearance,\n setActiveNumber,\n}: {\n num: number\n active: boolean\n questionIndex: number\n appearance: any\n setActiveNumber: (num: number) => void\n}) {\n const { textColor, ref } = useContrastingTextColor({ appearance, defaultTextColor: 'black', forceUpdate: active })\n return (\n <button\n ref={ref as RefObject<HTMLButtonElement>}\n className={`ratings-number question-${questionIndex}-rating-${num} ${active ? 'rating-active' : null}`}\n type=\"button\"\n onClick={() => {\n setActiveNumber(num)\n }}\n style={{\n color: textColor,\n backgroundColor: active ? appearance.ratingButtonActiveColor : appearance.ratingButtonColor,\n borderColor: appearance.borderColor,\n }}\n >\n {num}\n </button>\n )\n}\n\nexport function MultipleChoiceQuestion({\n question,\n questionIndex,\n appearance,\n onSubmit,\n closeSurveyPopup,\n}: {\n question: MultipleSurveyQuestion\n questionIndex: number\n appearance: SurveyAppearance\n onSubmit: (choices: string | string[] | null) => void\n closeSurveyPopup: () => void\n}) {\n const textRef = useRef(null)\n const choices = useMemo(() => getDisplayOrderChoices(question), [question])\n const [selectedChoices, setSelectedChoices] = useState<string | string[] | null>(\n question.type === SurveyQuestionType.MultipleChoice ? [] : null\n )\n const [openChoiceSelected, setOpenChoiceSelected] = useState(false)\n const [openEndedInput, setOpenEndedInput] = useState('')\n\n const inputType = question.type === SurveyQuestionType.SingleChoice ? 'radio' : 'checkbox'\n return (\n <div\n className=\"survey-box\"\n style={{ backgroundColor: appearance.backgroundColor || defaultSurveyAppearance.backgroundColor }}\n ref={textRef}\n >\n <Cancel onClick={() => closeSurveyPopup()} />\n <QuestionHeader\n question={question.question}\n description={question.description}\n backgroundColor={appearance.backgroundColor}\n />\n <div className=\"multiple-choice-options\">\n {/* Remove the last element from the choices, if hasOpenChoice is set */}\n {/* shuffle all other options here if question.shuffleOptions is set */}\n {/* Always ensure that the open ended choice is the last option */}\n {choices.map((choice: string, idx: number) => {\n let choiceClass = 'choice-option'\n const val = choice\n const option = choice\n if (!!question.hasOpenChoice && idx === question.choices.length - 1) {\n choiceClass += ' choice-option-open'\n }\n return (\n <div className={choiceClass}>\n <input\n type={inputType}\n id={`surveyQuestion${questionIndex}Choice${idx}`}\n name={`question${questionIndex}`}\n value={val}\n disabled={!val}\n onInput={() => {\n if (question.hasOpenChoice && idx === question.choices.length - 1) {\n return setOpenChoiceSelected(!openChoiceSelected)\n }\n if (question.type === SurveyQuestionType.SingleChoice) {\n return setSelectedChoices(val)\n }\n if (\n question.type === SurveyQuestionType.MultipleChoice &&\n isArray(selectedChoices)\n ) {\n if (selectedChoices.includes(val)) {\n // filter out values because clicking on a selected choice should deselect it\n return setSelectedChoices(\n selectedChoices.filter((choice) => choice !== val)\n )\n }\n return setSelectedChoices([...selectedChoices, val])\n }\n }}\n />\n <label htmlFor={`surveyQuestion${questionIndex}Choice${idx}`} style={{ color: 'black' }}>\n {question.hasOpenChoice && idx === question.choices.length - 1 ? (\n <>\n <span>{option}:</span>\n <input\n type=\"text\"\n id={`surveyQuestion${questionIndex}Choice${idx}Open`}\n name={`question${questionIndex}`}\n onInput={(e) => {\n const userValue = e.currentTarget.value\n if (question.type === SurveyQuestionType.SingleChoice) {\n return setSelectedChoices(userValue)\n }\n if (\n question.type === SurveyQuestionType.MultipleChoice &&\n isArray(selectedChoices)\n ) {\n return setOpenEndedInput(userValue)\n }\n }}\n />\n </>\n ) : (\n option\n )}\n </label>\n <span className=\"choice-check\" style={{ color: 'black' }}>\n {checkSVG}\n </span>\n </div>\n )\n })}\n </div>\n <BottomSection\n text={question.buttonText || 'Submit'}\n submitDisabled={\n (isNull(selectedChoices) ||\n (isArray(selectedChoices) && !openChoiceSelected && selectedChoices.length === 0) ||\n (isArray(selectedChoices) &&\n openChoiceSelected &&\n !openEndedInput &&\n selectedChoices.length === 0 &&\n !question.optional)) &&\n !question.optional\n }\n appearance={appearance}\n onSubmit={() => {\n if (openChoiceSelected && question.type === SurveyQuestionType.MultipleChoice) {\n if (isArray(selectedChoices)) {\n onSubmit([...selectedChoices, openEndedInput])\n }\n } else {\n onSubmit(selectedChoices)\n }\n }}\n />\n </div>\n )\n}\n\nconst threeScaleEmojis = [dissatisfiedEmoji, neutralEmoji, satisfiedEmoji]\nconst fiveScaleEmojis = [veryDissatisfiedEmoji, dissatisfiedEmoji, neutralEmoji, satisfiedEmoji, verySatisfiedEmoji]\nconst fiveScaleNumbers = [1, 2, 3, 4, 5]\nconst tenScaleNumbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n"]}
|
|
1
|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AkB;gBAClB,CAAC,cAAc;gBACf,eAAe,CAAC,MAAM,KAAK,CAAC;gBAC5B,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC5B,CAAC,QAAQ,CAAC,QAAQ,CACrB,CACD,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,QAAQ,CAAC,CAAC;YACN,IAAI,kBAAkB,IAAI,QAAQ,CAAC,IAAI,KAAK,kBAAkB,CAAC,cAAc,EAAE;gBAC3E,IAAI,OAAO,CAAC,eAAe,CAAC,EAAE;oBAC1B,QAAQ,wCAAK,eAAe,YAAE,cAAc,UAAE,CAAA;iBACjD;aACJ;iBAAM;gBACH,QAAQ,CAAC,eAAe,CAAC,CAAA;aAC5B;QACL,CAAC,CAAC,EAEV;QAAA,EAAE,GAAG,CAAC,CACT,CAAA;AACL,CAAC;AAED,IAAM,gBAAgB,GAAG,CAAC,iBAAiB,EAAE,YAAY,EAAE,cAAc,CAAC,CAAA;AAC1E,IAAM,eAAe,GAAG,CAAC,qBAAqB,EAAE,iBAAiB,EAAE,YAAY,EAAE,cAAc,EAAE,kBAAkB,CAAC,CAAA;AACpH,IAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;AACxC,IAAM,eAAe,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAA","sourcesContent":["import {\n BasicSurveyQuestion,\n SurveyAppearance,\n LinkSurveyQuestion,\n RatingSurveyQuestion,\n MultipleSurveyQuestion,\n SurveyQuestionType,\n} from '../../../posthog-surveys-types'\nimport { RefObject } from 'preact'\nimport { useRef, useState, useMemo, useContext } from 'preact/hooks'\nimport { isNull, isArray } from '../../../utils/type-utils'\nimport { useContrastingTextColor } from '../hooks/useContrastingTextColor'\nimport {\n checkSVG,\n dissatisfiedEmoji,\n neutralEmoji,\n satisfiedEmoji,\n veryDissatisfiedEmoji,\n verySatisfiedEmoji,\n} from '../icons'\nimport { defaultSurveyAppearance, getDisplayOrderChoices, SurveyContext } from '../surveys-utils'\nimport { BottomSection } from './BottomSection'\nimport { Cancel, QuestionHeader } from './QuestionHeader'\n\nexport function OpenTextQuestion({\n question,\n appearance,\n onSubmit,\n}: {\n question: BasicSurveyQuestion\n appearance: SurveyAppearance\n onSubmit: (text: string) => void\n}) {\n const textRef = useRef(null)\n const [text, setText] = useState('')\n const { handleCloseSurveyPopup } = useContext(SurveyContext)\n\n return (\n <div\n className=\"survey-box\"\n style={{ backgroundColor: appearance.backgroundColor || defaultSurveyAppearance.backgroundColor }}\n ref={textRef}\n >\n <Cancel onClick={() => handleCloseSurveyPopup()} />\n <QuestionHeader\n question={question.question}\n description={question.description}\n backgroundColor={appearance.backgroundColor}\n />\n <textarea rows={4} placeholder={appearance?.placeholder} onInput={(e) => setText(e.currentTarget.value)} />\n <BottomSection\n text={question.buttonText || 'Submit'}\n submitDisabled={!text && !question.optional}\n appearance={appearance}\n onSubmit={() => onSubmit(text)}\n />\n </div>\n )\n}\n\nexport function LinkQuestion({\n question,\n appearance,\n onSubmit,\n}: {\n question: LinkSurveyQuestion\n appearance: SurveyAppearance\n onSubmit: (clicked: string) => void\n}) {\n const { handleCloseSurveyPopup } = useContext(SurveyContext)\n\n return (\n <div className=\"survey-box\">\n <Cancel onClick={() => handleCloseSurveyPopup()} />\n <QuestionHeader question={question.question} description={question.description} />\n <BottomSection\n text={question.buttonText || 'Submit'}\n submitDisabled={false}\n link={question.link}\n appearance={appearance}\n onSubmit={() => onSubmit('link clicked')}\n />\n </div>\n )\n}\n\nexport function RatingQuestion({\n question,\n displayQuestionIndex,\n appearance,\n onSubmit,\n}: {\n question: RatingSurveyQuestion\n displayQuestionIndex: number\n appearance: SurveyAppearance\n onSubmit: (rating: number | null) => void\n}) {\n const scale = question.scale\n const starting = question.scale === 10 ? 0 : 1\n const [rating, setRating] = useState<number | null>(null)\n const { handleCloseSurveyPopup } = useContext(SurveyContext)\n\n return (\n <div className=\"survey-box\">\n <Cancel onClick={() => handleCloseSurveyPopup()} />\n <QuestionHeader\n question={question.question}\n description={question.description}\n backgroundColor={appearance.backgroundColor}\n />\n <div className=\"rating-section\">\n <div className=\"rating-options\">\n {question.display === 'emoji' && (\n <div className=\"rating-options-emoji\">\n {(question.scale === 3 ? threeScaleEmojis : fiveScaleEmojis).map((emoji, idx) => {\n const active = idx + 1 === rating\n return (\n <button\n className={`ratings-emoji question-${displayQuestionIndex}-rating-${idx} ${\n active ? 'rating-active' : null\n }`}\n value={idx + 1}\n key={idx}\n type=\"button\"\n onClick={() => {\n setRating(idx + 1)\n }}\n >\n {emoji}\n </button>\n )\n })}\n </div>\n )}\n {question.display === 'number' && (\n <div\n className=\"rating-options-number\"\n style={{ gridTemplateColumns: `repeat(${scale - starting + 1}, minmax(0, 1fr))` }}\n >\n {(question.scale === 5 ? fiveScaleNumbers : tenScaleNumbers).map((number, idx) => {\n const active = rating === number\n return (\n <RatingButton\n key={idx}\n displayQuestionIndex={displayQuestionIndex}\n active={active}\n appearance={appearance}\n num={number}\n setActiveNumber={(num) => {\n setRating(num)\n }}\n />\n )\n })}\n </div>\n )}\n </div>\n <div className=\"rating-text\">\n <div>{question.lowerBoundLabel}</div>\n <div>{question.upperBoundLabel}</div>\n </div>\n </div>\n <BottomSection\n text={question.buttonText || appearance?.submitButtonText || 'Submit'}\n submitDisabled={isNull(rating) && !question.optional}\n appearance={appearance}\n onSubmit={() => onSubmit(rating)}\n />\n </div>\n )\n}\n\nexport function RatingButton({\n num,\n active,\n displayQuestionIndex,\n appearance,\n setActiveNumber,\n}: {\n num: number\n active: boolean\n displayQuestionIndex: number\n appearance: any\n setActiveNumber: (num: number) => void\n}) {\n const { textColor, ref } = useContrastingTextColor({ appearance, defaultTextColor: 'black', forceUpdate: active })\n return (\n <button\n ref={ref as RefObject<HTMLButtonElement>}\n className={`ratings-number question-${displayQuestionIndex}-rating-${num} ${\n active ? 'rating-active' : null\n }`}\n type=\"button\"\n onClick={() => {\n setActiveNumber(num)\n }}\n style={{\n color: textColor,\n backgroundColor: active ? appearance.ratingButtonActiveColor : appearance.ratingButtonColor,\n borderColor: appearance.borderColor,\n }}\n >\n {num}\n </button>\n )\n}\n\nexport function MultipleChoiceQuestion({\n question,\n displayQuestionIndex,\n appearance,\n onSubmit,\n}: {\n question: MultipleSurveyQuestion\n displayQuestionIndex: number\n appearance: SurveyAppearance\n onSubmit: (choices: string | string[] | null) => void\n}) {\n const textRef = useRef(null)\n const choices = useMemo(() => getDisplayOrderChoices(question), [question])\n const [selectedChoices, setSelectedChoices] = useState<string | string[] | null>(\n question.type === SurveyQuestionType.MultipleChoice ? [] : null\n )\n const [openChoiceSelected, setOpenChoiceSelected] = useState(false)\n const [openEndedInput, setOpenEndedInput] = useState('')\n const { handleCloseSurveyPopup } = useContext(SurveyContext)\n\n const inputType = question.type === SurveyQuestionType.SingleChoice ? 'radio' : 'checkbox'\n return (\n <div\n className=\"survey-box\"\n style={{ backgroundColor: appearance.backgroundColor || defaultSurveyAppearance.backgroundColor }}\n ref={textRef}\n >\n <Cancel onClick={() => handleCloseSurveyPopup()} />\n <QuestionHeader\n question={question.question}\n description={question.description}\n backgroundColor={appearance.backgroundColor}\n />\n <div className=\"multiple-choice-options\">\n {/* Remove the last element from the choices, if hasOpenChoice is set */}\n {/* shuffle all other options here if question.shuffleOptions is set */}\n {/* Always ensure that the open ended choice is the last option */}\n {choices.map((choice: string, idx: number) => {\n let choiceClass = 'choice-option'\n const val = choice\n const option = choice\n if (!!question.hasOpenChoice && idx === question.choices.length - 1) {\n choiceClass += ' choice-option-open'\n }\n return (\n <div className={choiceClass}>\n <input\n type={inputType}\n id={`surveyQuestion${displayQuestionIndex}Choice${idx}`}\n name={`question${displayQuestionIndex}`}\n value={val}\n disabled={!val}\n onInput={() => {\n if (question.hasOpenChoice && idx === question.choices.length - 1) {\n return setOpenChoiceSelected(!openChoiceSelected)\n }\n if (question.type === SurveyQuestionType.SingleChoice) {\n return setSelectedChoices(val)\n }\n if (\n question.type === SurveyQuestionType.MultipleChoice &&\n isArray(selectedChoices)\n ) {\n if (selectedChoices.includes(val)) {\n // filter out values because clicking on a selected choice should deselect it\n return setSelectedChoices(\n selectedChoices.filter((choice) => choice !== val)\n )\n }\n return setSelectedChoices([...selectedChoices, val])\n }\n }}\n />\n <label\n htmlFor={`surveyQuestion${displayQuestionIndex}Choice${idx}`}\n style={{ color: 'black' }}\n >\n {question.hasOpenChoice && idx === question.choices.length - 1 ? (\n <>\n <span>{option}:</span>\n <input\n type=\"text\"\n id={`surveyQuestion${displayQuestionIndex}Choice${idx}Open`}\n name={`question${displayQuestionIndex}`}\n onInput={(e) => {\n const userValue = e.currentTarget.value\n if (question.type === SurveyQuestionType.SingleChoice) {\n return setSelectedChoices(userValue)\n }\n if (\n question.type === SurveyQuestionType.MultipleChoice &&\n isArray(selectedChoices)\n ) {\n return setOpenEndedInput(userValue)\n }\n }}\n />\n </>\n ) : (\n option\n )}\n </label>\n <span className=\"choice-check\" style={{ color: 'black' }}>\n {checkSVG}\n </span>\n </div>\n )\n })}\n </div>\n <BottomSection\n text={question.buttonText || 'Submit'}\n submitDisabled={\n (isNull(selectedChoices) ||\n (isArray(selectedChoices) && !openChoiceSelected && selectedChoices.length === 0) ||\n (isArray(selectedChoices) &&\n openChoiceSelected &&\n !openEndedInput &&\n selectedChoices.length === 0 &&\n !question.optional)) &&\n !question.optional\n }\n appearance={appearance}\n onSubmit={() => {\n if (openChoiceSelected && question.type === SurveyQuestionType.MultipleChoice) {\n if (isArray(selectedChoices)) {\n onSubmit([...selectedChoices, openEndedInput])\n }\n } else {\n onSubmit(selectedChoices)\n }\n }}\n />\n </div>\n )\n}\n\nconst threeScaleEmojis = [dissatisfiedEmoji, neutralEmoji, satisfiedEmoji]\nconst fiveScaleEmojis = [veryDissatisfiedEmoji, dissatisfiedEmoji, neutralEmoji, satisfiedEmoji, verySatisfiedEmoji]\nconst fiveScaleNumbers = [1, 2, 3, 4, 5]\nconst tenScaleNumbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n"]}
|
|
@@ -11,7 +11,7 @@ export declare const shuffle: (array: any[]) => any[];
|
|
|
11
11
|
export declare const getDisplayOrderChoices: (question: MultipleSurveyQuestion) => string[];
|
|
12
12
|
export declare const getDisplayOrderQuestions: (survey: Survey) => SurveyQuestion[];
|
|
13
13
|
export declare const SurveyContext: import("preact").Context<{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
isPreviewMode: boolean;
|
|
15
|
+
previewPageIndex: number | undefined;
|
|
16
|
+
handleCloseSurveyPopup: () => void;
|
|
17
17
|
}>;
|
|
@@ -287,18 +287,18 @@ export var getDisplayOrderChoices = function (question) {
|
|
|
287
287
|
return shuffledOptions;
|
|
288
288
|
};
|
|
289
289
|
export var getDisplayOrderQuestions = function (survey) {
|
|
290
|
+
// retain the original questionIndex so we can correlate values in the webapp
|
|
291
|
+
survey.questions.forEach(function (question, idx) {
|
|
292
|
+
question.originalQuestionIndex = idx;
|
|
293
|
+
});
|
|
290
294
|
if (!survey.appearance || !survey.appearance.shuffleQuestions) {
|
|
291
295
|
return survey.questions;
|
|
292
296
|
}
|
|
293
|
-
// retain the original questionIndex so we can correlate values in the webapp
|
|
294
|
-
survey.questions.forEach(function (element, idx) {
|
|
295
|
-
element.questionIndex = idx;
|
|
296
|
-
});
|
|
297
297
|
return shuffle(survey.questions);
|
|
298
298
|
};
|
|
299
299
|
export var SurveyContext = createContext({
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
300
|
+
isPreviewMode: false,
|
|
301
|
+
previewPageIndex: 0,
|
|
302
|
+
handleCloseSurveyPopup: function () { },
|
|
303
303
|
});
|
|
304
304
|
//# sourceMappingURL=surveys-utils.jsx.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surveys-utils.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O,CAAA;KAC1B;IAED,IAAM,mBAAmB,GAAG,QAAQ,CAAC,OAAO,CAAA;IAC5C,IAAI,eAAe,GAAG,EAAE,CAAA;IACxB,IAAI,QAAQ,CAAC,aAAa,EAAE;QACxB,8FAA8F;QAC9F,eAAe,GAAG,mBAAmB,CAAC,GAAG,EAAG,CAAA;KAC/C;IAED,IAAM,eAAe,GAAG,mBAAmB,CAAC,mBAAmB,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAA;IAE9F,IAAI,QAAQ,CAAC,aAAa,EAAE;QACxB,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QACtC,eAAe,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;KACxC;IAED,OAAO,eAAe,CAAA;AAC1B,CAAC,CAAA;AAED,MAAM,CAAC,IAAM,wBAAwB,GAAG,UAAC,MAAc;IACnD,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,gBAAgB,EAAE;QAC3D,OAAO,MAAM,CAAC,SAAS,CAAA;KAC1B;IAED,6EAA6E;IAC7E,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,UAAC,OAAO,EAAE,GAAG;QAClC,OAAO,CAAC,aAAa,GAAG,GAAG,CAAA;IAC/B,CAAC,CAAC,CAAA;IAEF,OAAO,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;AACpC,CAAC,CAAA;AAED,MAAM,CAAC,IAAM,aAAa,GAAG,aAAa,CAIvC;IACC,QAAQ,EAAE,KAAK;IACf,oBAAoB,EAAE,CAAC;IACvB,SAAS,EAAE,OAAO;CACrB,CAAC,CAAA","sourcesContent":["import { PostHog } from '../../posthog-core'\nimport { Survey, SurveyAppearance, MultipleSurveyQuestion, SurveyQuestion } from '../../posthog-surveys-types'\nimport { window as _window, document as _document } from '../../utils/globals'\nimport { createContext } from 'preact'\n// We cast the types here which is dangerous but protected by the top level generateSurveys call\nconst window = _window as Window & typeof globalThis\nconst document = _document as Document\n\nexport const style = (appearance: SurveyAppearance | null) => {\n const positions = {\n left: 'left: 30px;',\n right: 'right: 30px;',\n center: `\n left: 50%;\n transform: translateX(-50%);\n `,\n }\n return `\n .survey-form {\n position: fixed;\n margin: 0px;\n bottom: 0px;\n color: black;\n font-weight: normal;\n font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", \"Roboto\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n text-align: left;\n max-width: ${parseInt(appearance?.maxWidth || '300')}px;\n z-index: ${parseInt(appearance?.zIndex || '99999')};\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n border-bottom: 0px;\n width: 100%;\n ${positions[appearance?.position || 'right'] || 'right: 30px;'}\n }\n .form-submit[disabled] {\n opacity: 0.6;\n filter: grayscale(50%);\n cursor: not-allowed;\n }\n .survey-form {\n flex-direction: column;\n background: ${appearance?.backgroundColor || '#eeeded'};\n border-top-left-radius: 10px;\n border-top-right-radius: 10px;\n box-shadow: -6px 0 16px -8px rgb(0 0 0 / 8%), -9px 0 28px 0 rgb(0 0 0 / 5%), -12px 0 48px 16px rgb(0 0 0 / 3%);\n }\n .survey-form textarea {\n color: #2d2d2d;\n font-size: 14px;\n font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", \"Roboto\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n background: white;\n color: black;\n outline: none;\n padding-left: 10px;\n padding-right: 10px;\n padding-top: 10px;\n border-radius: 6px;\n border-color: ${appearance?.borderColor || '#c9c6c6'};\n margin-top: 14px;\n }\n .form-submit {\n box-sizing: border-box;\n margin: 0;\n font-family: inherit;\n overflow: visible;\n text-transform: none;\n position: relative;\n display: inline-block;\n font-weight: 700;\n white-space: nowrap;\n text-align: center;\n border: 1.5px solid transparent;\n cursor: pointer;\n user-select: none;\n touch-action: manipulation;\n padding: 12px;\n font-size: 14px;\n border-radius: 6px;\n outline: 0;\n background: ${appearance?.submitButtonColor || 'black'} !important;\n text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.12);\n box-shadow: 0 2px 0 rgba(0, 0, 0, 0.045);\n width: 100%;\n }\n .form-cancel {\n float: right;\n border: none;\n background: none;\n cursor: pointer;\n }\n .cancel-btn-wrapper {\n position: absolute;\n width: 35px;\n height: 35px;\n border-radius: 100%;\n top: 0;\n right: 0;\n transform: translate(50%, -50%);\n background: white;\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .bolded { font-weight: 600; }\n .buttons {\n display: flex;\n justify-content: center;\n }\n .footer-branding {\n font-size: 11px;\n margin-top: 10px;\n text-align: center;\n display: flex;\n justify-content: center;\n gap: 4px;\n align-items: center;\n font-weight: 500;\n background: ${appearance?.backgroundColor || '#eeeded'};\n text-decoration: none;\n }\n .survey-box {\n padding: 20px 25px 10px;\n display: flex;\n flex-direction: column;\n border-radius: 10px;\n }\n .survey-question {\n font-weight: 500;\n font-size: 14px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .question-textarea-wrapper {\n display: flex;\n flex-direction: column;\n }\n .description {\n font-size: 13px;\n padding-top: 5px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .ratings-number {\n background-color: ${appearance?.ratingButtonColor || 'white'};\n font-size: 16px;\n font-weight: 600;\n padding: 8px 0px;\n border: none;\n }\n .ratings-number:hover {\n cursor: pointer;\n }\n .rating-options {\n margin-top: 14px;\n }\n .rating-options-number {\n display: grid;\n border-radius: 6px;\n overflow: hidden;\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n }\n .rating-options-number > .ratings-number {\n border-right: 1px solid ${appearance?.borderColor || '#c9c6c6'};\n }\n .rating-options-number > .ratings-number:last-of-type {\n border-right: 0px;\n }\n .rating-options-number .rating-active {\n background: ${appearance?.ratingButtonActiveColor || 'black'};\n }\n .rating-options-emoji {\n display: flex;\n justify-content: space-between;\n }\n .ratings-emoji {\n font-size: 16px;\n background-color: transparent;\n border: none;\n padding: 0px;\n }\n .ratings-emoji:hover {\n cursor: pointer;\n }\n .ratings-emoji.rating-active svg {\n fill: ${appearance?.ratingButtonActiveColor || 'black'};\n }\n .emoji-svg {\n fill: ${appearance?.ratingButtonColor || '#c9c6c6'};\n }\n .rating-text {\n display: flex;\n flex-direction: row;\n font-size: 11px;\n justify-content: space-between;\n margin-top: 6px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n opacity: .60;\n }\n .multiple-choice-options {\n margin-top: 13px;\n font-size: 14px;\n }\n .multiple-choice-options .choice-option {\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 13px;\n cursor: pointer;\n margin-bottom: 5px;\n position: relative;\n }\n .multiple-choice-options > .choice-option:last-of-type {\n margin-bottom: 0px;\n }\n .multiple-choice-options input {\n cursor: pointer;\n position: absolute;\n opacity: 0;\n }\n .choice-check {\n position: absolute;\n right: 10px;\n background: white;\n }\n .choice-check svg {\n display: none;\n }\n .multiple-choice-options .choice-option:hover .choice-check svg {\n display: inline-block;\n opacity: .25;\n }\n .multiple-choice-options input:checked + label + .choice-check svg {\n display: inline-block;\n opacity: 100% !important;\n }\n .multiple-choice-options input:checked + label {\n font-weight: bold;\n border: 1.5px solid rgba(0,0,0);\n }\n .multiple-choice-options input:checked + label input {\n font-weight: bold;\n }\n .multiple-choice-options label {\n width: 100%;\n cursor: pointer;\n padding: 10px;\n border: 1.5px solid rgba(0,0,0,.25);\n border-radius: 4px;\n background: white;\n }\n .multiple-choice-options .choice-option-open label {\n padding-right: 30px;\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n max-width: 100%;\n }\n .multiple-choice-options .choice-option-open label span {\n width: 100%;\n }\n .multiple-choice-options .choice-option-open input:disabled + label {\n opacity: 0.6;\n }\n .multiple-choice-options .choice-option-open label input {\n position: relative;\n opacity: 1;\n flex-grow: 1;\n border: 0;\n outline: 0;\n }\n .thank-you-message {\n position: fixed;\n bottom: 0px;\n z-index: ${parseInt(appearance?.zIndex || '99999')};\n box-shadow: -6px 0 16px -8px rgb(0 0 0 / 8%), -9px 0 28px 0 rgb(0 0 0 / 5%), -12px 0 48px 16px rgb(0 0 0 / 3%);\n font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", \"Roboto\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n border-top-left-radius: 10px;\n border-top-right-radius: 10px;\n padding: 20px 25px 10px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n text-align: center;\n max-width: ${parseInt(appearance?.maxWidth || '300')}px;\n min-width: 150px;\n width: 100%;\n ${positions[appearance?.position || 'right'] || 'right: 30px;'}\n }\n .thank-you-message-body {\n margin-top: 6px;\n font-size: 14px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .thank-you-message-header {\n margin: 10px 0px 0px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .thank-you-message-container .form-submit {\n margin-top: 20px;\n margin-bottom: 10px;\n }\n .thank-you-message-countdown {\n margin-left: 6px;\n }\n .bottom-section {\n margin-top: 14px;\n }\n `\n}\n\nfunction nameToHex(name: string) {\n return {\n aliceblue: '#f0f8ff',\n antiquewhite: '#faebd7',\n aqua: '#00ffff',\n aquamarine: '#7fffd4',\n azure: '#f0ffff',\n beige: '#f5f5dc',\n bisque: '#ffe4c4',\n black: '#000000',\n blanchedalmond: '#ffebcd',\n blue: '#0000ff',\n blueviolet: '#8a2be2',\n brown: '#a52a2a',\n burlywood: '#deb887',\n cadetblue: '#5f9ea0',\n chartreuse: '#7fff00',\n chocolate: '#d2691e',\n coral: '#ff7f50',\n cornflowerblue: '#6495ed',\n cornsilk: '#fff8dc',\n crimson: '#dc143c',\n cyan: '#00ffff',\n darkblue: '#00008b',\n darkcyan: '#008b8b',\n darkgoldenrod: '#b8860b',\n darkgray: '#a9a9a9',\n darkgreen: '#006400',\n darkkhaki: '#bdb76b',\n darkmagenta: '#8b008b',\n darkolivegreen: '#556b2f',\n darkorange: '#ff8c00',\n darkorchid: '#9932cc',\n darkred: '#8b0000',\n darksalmon: '#e9967a',\n darkseagreen: '#8fbc8f',\n darkslateblue: '#483d8b',\n darkslategray: '#2f4f4f',\n darkturquoise: '#00ced1',\n darkviolet: '#9400d3',\n deeppink: '#ff1493',\n deepskyblue: '#00bfff',\n dimgray: '#696969',\n dodgerblue: '#1e90ff',\n firebrick: '#b22222',\n floralwhite: '#fffaf0',\n forestgreen: '#228b22',\n fuchsia: '#ff00ff',\n gainsboro: '#dcdcdc',\n ghostwhite: '#f8f8ff',\n gold: '#ffd700',\n goldenrod: '#daa520',\n gray: '#808080',\n green: '#008000',\n greenyellow: '#adff2f',\n honeydew: '#f0fff0',\n hotpink: '#ff69b4',\n 'indianred ': '#cd5c5c',\n indigo: '#4b0082',\n ivory: '#fffff0',\n khaki: '#f0e68c',\n lavender: '#e6e6fa',\n lavenderblush: '#fff0f5',\n lawngreen: '#7cfc00',\n lemonchiffon: '#fffacd',\n lightblue: '#add8e6',\n lightcoral: '#f08080',\n lightcyan: '#e0ffff',\n lightgoldenrodyellow: '#fafad2',\n lightgrey: '#d3d3d3',\n lightgreen: '#90ee90',\n lightpink: '#ffb6c1',\n lightsalmon: '#ffa07a',\n lightseagreen: '#20b2aa',\n lightskyblue: '#87cefa',\n lightslategray: '#778899',\n lightsteelblue: '#b0c4de',\n lightyellow: '#ffffe0',\n lime: '#00ff00',\n limegreen: '#32cd32',\n linen: '#faf0e6',\n magenta: '#ff00ff',\n maroon: '#800000',\n mediumaquamarine: '#66cdaa',\n mediumblue: '#0000cd',\n mediumorchid: '#ba55d3',\n mediumpurple: '#9370d8',\n mediumseagreen: '#3cb371',\n mediumslateblue: '#7b68ee',\n mediumspringgreen: '#00fa9a',\n mediumturquoise: '#48d1cc',\n mediumvioletred: '#c71585',\n midnightblue: '#191970',\n mintcream: '#f5fffa',\n mistyrose: '#ffe4e1',\n moccasin: '#ffe4b5',\n navajowhite: '#ffdead',\n navy: '#000080',\n oldlace: '#fdf5e6',\n olive: '#808000',\n olivedrab: '#6b8e23',\n orange: '#ffa500',\n orangered: '#ff4500',\n orchid: '#da70d6',\n palegoldenrod: '#eee8aa',\n palegreen: '#98fb98',\n paleturquoise: '#afeeee',\n palevioletred: '#d87093',\n papayawhip: '#ffefd5',\n peachpuff: '#ffdab9',\n peru: '#cd853f',\n pink: '#ffc0cb',\n plum: '#dda0dd',\n powderblue: '#b0e0e6',\n purple: '#800080',\n red: '#ff0000',\n rosybrown: '#bc8f8f',\n royalblue: '#4169e1',\n saddlebrown: '#8b4513',\n salmon: '#fa8072',\n sandybrown: '#f4a460',\n seagreen: '#2e8b57',\n seashell: '#fff5ee',\n sienna: '#a0522d',\n silver: '#c0c0c0',\n skyblue: '#87ceeb',\n slateblue: '#6a5acd',\n slategray: '#708090',\n snow: '#fffafa',\n springgreen: '#00ff7f',\n steelblue: '#4682b4',\n tan: '#d2b48c',\n teal: '#008080',\n thistle: '#d8bfd8',\n tomato: '#ff6347',\n turquoise: '#40e0d0',\n violet: '#ee82ee',\n wheat: '#f5deb3',\n white: '#ffffff',\n whitesmoke: '#f5f5f5',\n yellow: '#ffff00',\n yellowgreen: '#9acd32',\n }[name.toLowerCase()]\n}\n\nfunction hex2rgb(c: string) {\n if (c[0] === '#') {\n const hexColor = c.replace(/^#/, '')\n const r = parseInt(hexColor.slice(0, 2), 16)\n const g = parseInt(hexColor.slice(2, 4), 16)\n const b = parseInt(hexColor.slice(4, 6), 16)\n return 'rgb(' + r + ',' + g + ',' + b + ')'\n }\n return 'rgb(255, 255, 255)'\n}\n\nexport function getContrastingTextColor(color: string = defaultBackgroundColor) {\n let rgb\n if (color[0] === '#') {\n rgb = hex2rgb(color)\n }\n if (color.startsWith('rgb')) {\n rgb = color\n }\n // otherwise it's a color name\n const nameColorToHex = nameToHex(color)\n if (nameColorToHex) {\n rgb = hex2rgb(nameColorToHex)\n }\n if (!rgb) {\n return 'black'\n }\n const colorMatch = rgb.match(/^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*(\\d+(?:\\.\\d+)?))?\\)$/)\n if (colorMatch) {\n const r = parseInt(colorMatch[1])\n const g = parseInt(colorMatch[2])\n const b = parseInt(colorMatch[3])\n const hsp = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b))\n return hsp > 127.5 ? 'black' : 'white'\n }\n return 'black'\n}\nexport function getTextColor(el: HTMLElement) {\n const backgroundColor = window.getComputedStyle(el).backgroundColor\n if (backgroundColor === 'rgba(0, 0, 0, 0)') {\n return 'black'\n }\n const colorMatch = backgroundColor.match(/^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*(\\d+(?:\\.\\d+)?))?\\)$/)\n if (!colorMatch) return 'black'\n\n const r = parseInt(colorMatch[1])\n const g = parseInt(colorMatch[2])\n const b = parseInt(colorMatch[3])\n const hsp = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b))\n return hsp > 127.5 ? 'black' : 'white'\n}\n\nexport const defaultSurveyAppearance: SurveyAppearance = {\n backgroundColor: '#eeeded',\n submitButtonColor: 'black',\n ratingButtonColor: 'white',\n ratingButtonActiveColor: 'black',\n borderColor: '#c9c6c6',\n placeholder: 'Start typing...',\n whiteLabel: false,\n displayThankYouMessage: true,\n thankYouMessageHeader: 'Thank you for your feedback!',\n position: 'right',\n}\n\nexport const defaultBackgroundColor = '#eeeded'\n\nexport const createShadow = (styleSheet: string, surveyId: string) => {\n const div = document.createElement('div')\n div.className = `PostHogSurvey${surveyId}`\n const shadow = div.attachShadow({ mode: 'open' })\n if (styleSheet) {\n const styleElement = Object.assign(document.createElement('style'), {\n innerText: styleSheet,\n })\n shadow.appendChild(styleElement)\n }\n document.body.appendChild(div)\n return shadow\n}\n\nexport const sendSurveyEvent = (\n responses: Record<string, string | number | string[] | null> = {},\n survey: Survey,\n posthog?: PostHog\n) => {\n if (!posthog) return\n localStorage.setItem(`seenSurvey_${survey.id}`, 'true')\n posthog.capture('survey sent', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_questions: survey.questions.map((question) => question.question),\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n ...responses,\n $set: {\n [`$survey_responded/${survey.id}`]: true,\n },\n })\n window.dispatchEvent(new Event('PHSurveySent'))\n}\n\n// Use the Fisher-yates algorithm to shuffle this array\n// https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle\nexport const shuffle = (array: any[]) => {\n return array\n .map((a) => ({ sort: Math.floor(Math.random() * 10), value: a }))\n .sort((a, b) => a.sort - b.sort)\n .map((a) => a.value)\n}\n\nconst reverseIfUnshuffled = (unshuffled: string[], shuffled: string[]): string[] => {\n if (unshuffled.length === shuffled.length && unshuffled.every((val, index) => val === shuffled[index])) {\n return shuffled.reverse()\n }\n\n return shuffled\n}\n\nexport const getDisplayOrderChoices = (question: MultipleSurveyQuestion): string[] => {\n if (!question.shuffleOptions) {\n return question.choices\n }\n\n const displayOrderChoices = question.choices\n let openEndedChoice = ''\n if (question.hasOpenChoice) {\n // if the question has an open-ended choice, its always the last element in the choices array.\n openEndedChoice = displayOrderChoices.pop()!\n }\n\n const shuffledOptions = reverseIfUnshuffled(displayOrderChoices, shuffle(displayOrderChoices))\n\n if (question.hasOpenChoice) {\n question.choices.push(openEndedChoice)\n shuffledOptions.push(openEndedChoice)\n }\n\n return shuffledOptions\n}\n\nexport const getDisplayOrderQuestions = (survey: Survey): SurveyQuestion[] => {\n if (!survey.appearance || !survey.appearance.shuffleQuestions) {\n return survey.questions\n }\n\n // retain the original questionIndex so we can correlate values in the webapp\n survey.questions.forEach((element, idx) => {\n element.questionIndex = idx\n })\n\n return shuffle(survey.questions)\n}\n\nexport const SurveyContext = createContext<{\n readOnly: boolean\n previewQuestionIndex: number\n textColor: string\n}>({\n readOnly: false,\n previewQuestionIndex: 0,\n textColor: 'black',\n})\n"]}
|
|
1
|
+
{"version":3,"file":"surveys-utils.jsx","sourceRoot":"","sources":["../../../../src/extensions/surveys/surveys-utils.tsx"],"names":[],"mappings":";;;;;;;;;;;AAEA,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,gGAAgG;AAChG,IAAM,MAAM,GAAG,OAAqC,CAAA;AACpD,IAAM,QAAQ,GAAG,SAAqB,CAAA;AAEtC,MAAM,CAAC,IAAM,KAAK,GAAG,UAAC,UAAmC;IACrD,IAAM,SAAS,GAAG;QACd,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,cAAc;QACrB,MAAM,EAAE,gFAGL;KACN,CAAA;IACD,OAAO,2bASgB,QAAQ,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,KAAI,KAAK,CAAC,yCACzC,QAAQ,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,KAAI,OAAO,CAAC,kDAC5B,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,WAAW,KAAI,SAAS,6FAGxD,SAAS,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,KAAI,OAAO,CAAC,IAAI,cAAc,gRAShD,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,eAAe,KAAI,SAAS,gyBAgBtC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,WAAW,KAAI,SAAS,yuBAsBtC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,iBAAiB,KAAI,OAAO,8pBAoBhC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,WAAW,KAAI,SAAS,ylBAmB5C,CAAA,UAAU,aAAV,UAAU,u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UAAC,QAAgC;IACnE,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE;QAC1B,OAAO,QAAQ,CAAC,OAAO,CAAA;KAC1B;IAED,IAAM,mBAAmB,GAAG,QAAQ,CAAC,OAAO,CAAA;IAC5C,IAAI,eAAe,GAAG,EAAE,CAAA;IACxB,IAAI,QAAQ,CAAC,aAAa,EAAE;QACxB,8FAA8F;QAC9F,eAAe,GAAG,mBAAmB,CAAC,GAAG,EAAG,CAAA;KAC/C;IAED,IAAM,eAAe,GAAG,mBAAmB,CAAC,mBAAmB,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAA;IAE9F,IAAI,QAAQ,CAAC,aAAa,EAAE;QACxB,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QACtC,eAAe,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;KACxC;IAED,OAAO,eAAe,CAAA;AAC1B,CAAC,CAAA;AAED,MAAM,CAAC,IAAM,wBAAwB,GAAG,UAAC,MAAc;IACnD,6EAA6E;IAC7E,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,UAAC,QAAQ,EAAE,GAAG;QACnC,QAAQ,CAAC,qBAAqB,GAAG,GAAG,CAAA;IACxC,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,gBAAgB,EAAE;QAC3D,OAAO,MAAM,CAAC,SAAS,CAAA;KAC1B;IAED,OAAO,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;AACpC,CAAC,CAAA;AAED,MAAM,CAAC,IAAM,aAAa,GAAG,aAAa,CAIvC;IACC,aAAa,EAAE,KAAK;IACpB,gBAAgB,EAAE,CAAC;IACnB,sBAAsB,EAAE,cAAO,CAAC;CACnC,CAAC,CAAA","sourcesContent":["import { PostHog } from '../../posthog-core'\nimport { Survey, SurveyAppearance, MultipleSurveyQuestion, SurveyQuestion } from '../../posthog-surveys-types'\nimport { window as _window, document as _document } from '../../utils/globals'\nimport { createContext } from 'preact'\n// We cast the types here which is dangerous but protected by the top level generateSurveys call\nconst window = _window as Window & typeof globalThis\nconst document = _document as Document\n\nexport const style = (appearance: SurveyAppearance | null) => {\n const positions = {\n left: 'left: 30px;',\n right: 'right: 30px;',\n center: `\n left: 50%;\n transform: translateX(-50%);\n `,\n }\n return `\n .survey-form {\n position: fixed;\n margin: 0px;\n bottom: 0px;\n color: black;\n font-weight: normal;\n font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", \"Roboto\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n text-align: left;\n max-width: ${parseInt(appearance?.maxWidth || '300')}px;\n z-index: ${parseInt(appearance?.zIndex || '99999')};\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n border-bottom: 0px;\n width: 100%;\n ${positions[appearance?.position || 'right'] || 'right: 30px;'}\n }\n .form-submit[disabled] {\n opacity: 0.6;\n filter: grayscale(50%);\n cursor: not-allowed;\n }\n .survey-form {\n flex-direction: column;\n background: ${appearance?.backgroundColor || '#eeeded'};\n border-top-left-radius: 10px;\n border-top-right-radius: 10px;\n box-shadow: -6px 0 16px -8px rgb(0 0 0 / 8%), -9px 0 28px 0 rgb(0 0 0 / 5%), -12px 0 48px 16px rgb(0 0 0 / 3%);\n }\n .survey-form textarea {\n color: #2d2d2d;\n font-size: 14px;\n font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", \"Roboto\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n background: white;\n color: black;\n outline: none;\n padding-left: 10px;\n padding-right: 10px;\n padding-top: 10px;\n border-radius: 6px;\n border-color: ${appearance?.borderColor || '#c9c6c6'};\n margin-top: 14px;\n }\n .form-submit {\n box-sizing: border-box;\n margin: 0;\n font-family: inherit;\n overflow: visible;\n text-transform: none;\n position: relative;\n display: inline-block;\n font-weight: 700;\n white-space: nowrap;\n text-align: center;\n border: 1.5px solid transparent;\n cursor: pointer;\n user-select: none;\n touch-action: manipulation;\n padding: 12px;\n font-size: 14px;\n border-radius: 6px;\n outline: 0;\n background: ${appearance?.submitButtonColor || 'black'} !important;\n text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.12);\n box-shadow: 0 2px 0 rgba(0, 0, 0, 0.045);\n width: 100%;\n }\n .form-cancel {\n float: right;\n border: none;\n background: none;\n cursor: pointer;\n }\n .cancel-btn-wrapper {\n position: absolute;\n width: 35px;\n height: 35px;\n border-radius: 100%;\n top: 0;\n right: 0;\n transform: translate(50%, -50%);\n background: white;\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .bolded { font-weight: 600; }\n .buttons {\n display: flex;\n justify-content: center;\n }\n .footer-branding {\n font-size: 11px;\n margin-top: 10px;\n text-align: center;\n display: flex;\n justify-content: center;\n gap: 4px;\n align-items: center;\n font-weight: 500;\n background: ${appearance?.backgroundColor || '#eeeded'};\n text-decoration: none;\n }\n .survey-box {\n padding: 20px 25px 10px;\n display: flex;\n flex-direction: column;\n border-radius: 10px;\n }\n .survey-question {\n font-weight: 500;\n font-size: 14px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .question-textarea-wrapper {\n display: flex;\n flex-direction: column;\n }\n .description {\n font-size: 13px;\n padding-top: 5px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .ratings-number {\n background-color: ${appearance?.ratingButtonColor || 'white'};\n font-size: 16px;\n font-weight: 600;\n padding: 8px 0px;\n border: none;\n }\n .ratings-number:hover {\n cursor: pointer;\n }\n .rating-options {\n margin-top: 14px;\n }\n .rating-options-number {\n display: grid;\n border-radius: 6px;\n overflow: hidden;\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n }\n .rating-options-number > .ratings-number {\n border-right: 1px solid ${appearance?.borderColor || '#c9c6c6'};\n }\n .rating-options-number > .ratings-number:last-of-type {\n border-right: 0px;\n }\n .rating-options-number .rating-active {\n background: ${appearance?.ratingButtonActiveColor || 'black'};\n }\n .rating-options-emoji {\n display: flex;\n justify-content: space-between;\n }\n .ratings-emoji {\n font-size: 16px;\n background-color: transparent;\n border: none;\n padding: 0px;\n }\n .ratings-emoji:hover {\n cursor: pointer;\n }\n .ratings-emoji.rating-active svg {\n fill: ${appearance?.ratingButtonActiveColor || 'black'};\n }\n .emoji-svg {\n fill: ${appearance?.ratingButtonColor || '#c9c6c6'};\n }\n .rating-text {\n display: flex;\n flex-direction: row;\n font-size: 11px;\n justify-content: space-between;\n margin-top: 6px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n opacity: .60;\n }\n .multiple-choice-options {\n margin-top: 13px;\n font-size: 14px;\n }\n .multiple-choice-options .choice-option {\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 13px;\n cursor: pointer;\n margin-bottom: 5px;\n position: relative;\n }\n .multiple-choice-options > .choice-option:last-of-type {\n margin-bottom: 0px;\n }\n .multiple-choice-options input {\n cursor: pointer;\n position: absolute;\n opacity: 0;\n }\n .choice-check {\n position: absolute;\n right: 10px;\n background: white;\n }\n .choice-check svg {\n display: none;\n }\n .multiple-choice-options .choice-option:hover .choice-check svg {\n display: inline-block;\n opacity: .25;\n }\n .multiple-choice-options input:checked + label + .choice-check svg {\n display: inline-block;\n opacity: 100% !important;\n }\n .multiple-choice-options input:checked + label {\n font-weight: bold;\n border: 1.5px solid rgba(0,0,0);\n }\n .multiple-choice-options input:checked + label input {\n font-weight: bold;\n }\n .multiple-choice-options label {\n width: 100%;\n cursor: pointer;\n padding: 10px;\n border: 1.5px solid rgba(0,0,0,.25);\n border-radius: 4px;\n background: white;\n }\n .multiple-choice-options .choice-option-open label {\n padding-right: 30px;\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n max-width: 100%;\n }\n .multiple-choice-options .choice-option-open label span {\n width: 100%;\n }\n .multiple-choice-options .choice-option-open input:disabled + label {\n opacity: 0.6;\n }\n .multiple-choice-options .choice-option-open label input {\n position: relative;\n opacity: 1;\n flex-grow: 1;\n border: 0;\n outline: 0;\n }\n .thank-you-message {\n position: fixed;\n bottom: 0px;\n z-index: ${parseInt(appearance?.zIndex || '99999')};\n box-shadow: -6px 0 16px -8px rgb(0 0 0 / 8%), -9px 0 28px 0 rgb(0 0 0 / 5%), -12px 0 48px 16px rgb(0 0 0 / 3%);\n font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", \"Roboto\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n border-top-left-radius: 10px;\n border-top-right-radius: 10px;\n padding: 20px 25px 10px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n text-align: center;\n max-width: ${parseInt(appearance?.maxWidth || '300')}px;\n min-width: 150px;\n width: 100%;\n ${positions[appearance?.position || 'right'] || 'right: 30px;'}\n }\n .thank-you-message-body {\n margin-top: 6px;\n font-size: 14px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .thank-you-message-header {\n margin: 10px 0px 0px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .thank-you-message-container .form-submit {\n margin-top: 20px;\n margin-bottom: 10px;\n }\n .thank-you-message-countdown {\n margin-left: 6px;\n }\n .bottom-section {\n margin-top: 14px;\n }\n `\n}\n\nfunction nameToHex(name: string) {\n return {\n aliceblue: '#f0f8ff',\n antiquewhite: '#faebd7',\n aqua: '#00ffff',\n aquamarine: '#7fffd4',\n azure: '#f0ffff',\n beige: '#f5f5dc',\n bisque: '#ffe4c4',\n black: '#000000',\n blanchedalmond: '#ffebcd',\n blue: '#0000ff',\n blueviolet: '#8a2be2',\n brown: '#a52a2a',\n burlywood: '#deb887',\n cadetblue: '#5f9ea0',\n chartreuse: '#7fff00',\n chocolate: '#d2691e',\n coral: '#ff7f50',\n cornflowerblue: '#6495ed',\n cornsilk: '#fff8dc',\n crimson: '#dc143c',\n cyan: '#00ffff',\n darkblue: '#00008b',\n darkcyan: '#008b8b',\n darkgoldenrod: '#b8860b',\n darkgray: '#a9a9a9',\n darkgreen: '#006400',\n darkkhaki: '#bdb76b',\n darkmagenta: '#8b008b',\n darkolivegreen: '#556b2f',\n darkorange: '#ff8c00',\n darkorchid: '#9932cc',\n darkred: '#8b0000',\n darksalmon: '#e9967a',\n darkseagreen: '#8fbc8f',\n darkslateblue: '#483d8b',\n darkslategray: '#2f4f4f',\n darkturquoise: '#00ced1',\n darkviolet: '#9400d3',\n deeppink: '#ff1493',\n deepskyblue: '#00bfff',\n dimgray: '#696969',\n dodgerblue: '#1e90ff',\n firebrick: '#b22222',\n floralwhite: '#fffaf0',\n forestgreen: '#228b22',\n fuchsia: '#ff00ff',\n gainsboro: '#dcdcdc',\n ghostwhite: '#f8f8ff',\n gold: '#ffd700',\n goldenrod: '#daa520',\n gray: '#808080',\n green: '#008000',\n greenyellow: '#adff2f',\n honeydew: '#f0fff0',\n hotpink: '#ff69b4',\n 'indianred ': '#cd5c5c',\n indigo: '#4b0082',\n ivory: '#fffff0',\n khaki: '#f0e68c',\n lavender: '#e6e6fa',\n lavenderblush: '#fff0f5',\n lawngreen: '#7cfc00',\n lemonchiffon: '#fffacd',\n lightblue: '#add8e6',\n lightcoral: '#f08080',\n lightcyan: '#e0ffff',\n lightgoldenrodyellow: '#fafad2',\n lightgrey: '#d3d3d3',\n lightgreen: '#90ee90',\n lightpink: '#ffb6c1',\n lightsalmon: '#ffa07a',\n lightseagreen: '#20b2aa',\n lightskyblue: '#87cefa',\n lightslategray: '#778899',\n lightsteelblue: '#b0c4de',\n lightyellow: '#ffffe0',\n lime: '#00ff00',\n limegreen: '#32cd32',\n linen: '#faf0e6',\n magenta: '#ff00ff',\n maroon: '#800000',\n mediumaquamarine: '#66cdaa',\n mediumblue: '#0000cd',\n mediumorchid: '#ba55d3',\n mediumpurple: '#9370d8',\n mediumseagreen: '#3cb371',\n mediumslateblue: '#7b68ee',\n mediumspringgreen: '#00fa9a',\n mediumturquoise: '#48d1cc',\n mediumvioletred: '#c71585',\n midnightblue: '#191970',\n mintcream: '#f5fffa',\n mistyrose: '#ffe4e1',\n moccasin: '#ffe4b5',\n navajowhite: '#ffdead',\n navy: '#000080',\n oldlace: '#fdf5e6',\n olive: '#808000',\n olivedrab: '#6b8e23',\n orange: '#ffa500',\n orangered: '#ff4500',\n orchid: '#da70d6',\n palegoldenrod: '#eee8aa',\n palegreen: '#98fb98',\n paleturquoise: '#afeeee',\n palevioletred: '#d87093',\n papayawhip: '#ffefd5',\n peachpuff: '#ffdab9',\n peru: '#cd853f',\n pink: '#ffc0cb',\n plum: '#dda0dd',\n powderblue: '#b0e0e6',\n purple: '#800080',\n red: '#ff0000',\n rosybrown: '#bc8f8f',\n royalblue: '#4169e1',\n saddlebrown: '#8b4513',\n salmon: '#fa8072',\n sandybrown: '#f4a460',\n seagreen: '#2e8b57',\n seashell: '#fff5ee',\n sienna: '#a0522d',\n silver: '#c0c0c0',\n skyblue: '#87ceeb',\n slateblue: '#6a5acd',\n slategray: '#708090',\n snow: '#fffafa',\n springgreen: '#00ff7f',\n steelblue: '#4682b4',\n tan: '#d2b48c',\n teal: '#008080',\n thistle: '#d8bfd8',\n tomato: '#ff6347',\n turquoise: '#40e0d0',\n violet: '#ee82ee',\n wheat: '#f5deb3',\n white: '#ffffff',\n whitesmoke: '#f5f5f5',\n yellow: '#ffff00',\n yellowgreen: '#9acd32',\n }[name.toLowerCase()]\n}\n\nfunction hex2rgb(c: string) {\n if (c[0] === '#') {\n const hexColor = c.replace(/^#/, '')\n const r = parseInt(hexColor.slice(0, 2), 16)\n const g = parseInt(hexColor.slice(2, 4), 16)\n const b = parseInt(hexColor.slice(4, 6), 16)\n return 'rgb(' + r + ',' + g + ',' + b + ')'\n }\n return 'rgb(255, 255, 255)'\n}\n\nexport function getContrastingTextColor(color: string = defaultBackgroundColor) {\n let rgb\n if (color[0] === '#') {\n rgb = hex2rgb(color)\n }\n if (color.startsWith('rgb')) {\n rgb = color\n }\n // otherwise it's a color name\n const nameColorToHex = nameToHex(color)\n if (nameColorToHex) {\n rgb = hex2rgb(nameColorToHex)\n }\n if (!rgb) {\n return 'black'\n }\n const colorMatch = rgb.match(/^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*(\\d+(?:\\.\\d+)?))?\\)$/)\n if (colorMatch) {\n const r = parseInt(colorMatch[1])\n const g = parseInt(colorMatch[2])\n const b = parseInt(colorMatch[3])\n const hsp = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b))\n return hsp > 127.5 ? 'black' : 'white'\n }\n return 'black'\n}\nexport function getTextColor(el: HTMLElement) {\n const backgroundColor = window.getComputedStyle(el).backgroundColor\n if (backgroundColor === 'rgba(0, 0, 0, 0)') {\n return 'black'\n }\n const colorMatch = backgroundColor.match(/^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*(\\d+(?:\\.\\d+)?))?\\)$/)\n if (!colorMatch) return 'black'\n\n const r = parseInt(colorMatch[1])\n const g = parseInt(colorMatch[2])\n const b = parseInt(colorMatch[3])\n const hsp = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b))\n return hsp > 127.5 ? 'black' : 'white'\n}\n\nexport const defaultSurveyAppearance: SurveyAppearance = {\n backgroundColor: '#eeeded',\n submitButtonColor: 'black',\n ratingButtonColor: 'white',\n ratingButtonActiveColor: 'black',\n borderColor: '#c9c6c6',\n placeholder: 'Start typing...',\n whiteLabel: false,\n displayThankYouMessage: true,\n thankYouMessageHeader: 'Thank you for your feedback!',\n position: 'right',\n}\n\nexport const defaultBackgroundColor = '#eeeded'\n\nexport const createShadow = (styleSheet: string, surveyId: string) => {\n const div = document.createElement('div')\n div.className = `PostHogSurvey${surveyId}`\n const shadow = div.attachShadow({ mode: 'open' })\n if (styleSheet) {\n const styleElement = Object.assign(document.createElement('style'), {\n innerText: styleSheet,\n })\n shadow.appendChild(styleElement)\n }\n document.body.appendChild(div)\n return shadow\n}\n\nexport const sendSurveyEvent = (\n responses: Record<string, string | number | string[] | null> = {},\n survey: Survey,\n posthog?: PostHog\n) => {\n if (!posthog) return\n localStorage.setItem(`seenSurvey_${survey.id}`, 'true')\n posthog.capture('survey sent', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_questions: survey.questions.map((question) => question.question),\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n ...responses,\n $set: {\n [`$survey_responded/${survey.id}`]: true,\n },\n })\n window.dispatchEvent(new Event('PHSurveySent'))\n}\n\n// Use the Fisher-yates algorithm to shuffle this array\n// https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle\nexport const shuffle = (array: any[]) => {\n return array\n .map((a) => ({ sort: Math.floor(Math.random() * 10), value: a }))\n .sort((a, b) => a.sort - b.sort)\n .map((a) => a.value)\n}\n\nconst reverseIfUnshuffled = (unshuffled: string[], shuffled: string[]): string[] => {\n if (unshuffled.length === shuffled.length && unshuffled.every((val, index) => val === shuffled[index])) {\n return shuffled.reverse()\n }\n\n return shuffled\n}\n\nexport const getDisplayOrderChoices = (question: MultipleSurveyQuestion): string[] => {\n if (!question.shuffleOptions) {\n return question.choices\n }\n\n const displayOrderChoices = question.choices\n let openEndedChoice = ''\n if (question.hasOpenChoice) {\n // if the question has an open-ended choice, its always the last element in the choices array.\n openEndedChoice = displayOrderChoices.pop()!\n }\n\n const shuffledOptions = reverseIfUnshuffled(displayOrderChoices, shuffle(displayOrderChoices))\n\n if (question.hasOpenChoice) {\n question.choices.push(openEndedChoice)\n shuffledOptions.push(openEndedChoice)\n }\n\n return shuffledOptions\n}\n\nexport const getDisplayOrderQuestions = (survey: Survey): SurveyQuestion[] => {\n // retain the original questionIndex so we can correlate values in the webapp\n survey.questions.forEach((question, idx) => {\n question.originalQuestionIndex = idx\n })\n\n if (!survey.appearance || !survey.appearance.shuffleQuestions) {\n return survey.questions\n }\n\n return shuffle(survey.questions)\n}\n\nexport const SurveyContext = createContext<{\n isPreviewMode: boolean\n previewPageIndex: number | undefined\n handleCloseSurveyPopup: () => void\n}>({\n isPreviewMode: false,\n previewPageIndex: 0,\n handleCloseSurveyPopup: () => {},\n})\n"]}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { PostHog } from '../posthog-core';
|
|
2
2
|
import { Survey } from '../posthog-surveys-types';
|
|
3
3
|
export declare const callSurveys: (posthog: PostHog, forceReload?: boolean) => void;
|
|
4
|
-
export declare const renderSurveysPreview: (survey: Survey,
|
|
4
|
+
export declare const renderSurveysPreview: (survey: Survey, parentElement: HTMLElement, previewPageIndex: number) => void;
|
|
5
5
|
export declare const renderFeedbackWidgetPreview: (survey: Survey, root: HTMLElement) => void;
|
|
6
6
|
export declare function generateSurveys(posthog: PostHog): void;
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function SurveyPopup({ survey, posthog, style, previewPageIndex, }: {
|
|
8
8
|
survey: Survey;
|
|
9
9
|
posthog?: PostHog;
|
|
10
|
-
readOnly?: boolean;
|
|
11
10
|
style?: React.CSSProperties;
|
|
12
|
-
|
|
13
|
-
previewQuestionIndex?: number;
|
|
11
|
+
previewPageIndex?: number | undefined;
|
|
14
12
|
}): JSX.Element;
|
|
15
13
|
export declare function Questions({ survey, posthog, styleOverrides, }: {
|
|
16
14
|
survey: Survey;
|
|
@@ -25,7 +25,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
25
25
|
}
|
|
26
26
|
return ar;
|
|
27
27
|
};
|
|
28
|
-
import { SurveyQuestionType, SurveyType
|
|
28
|
+
import { SurveyQuestionType, SurveyType } from '../posthog-surveys-types';
|
|
29
29
|
import { window as _window, document as _document } from '../utils/globals';
|
|
30
30
|
import { style, defaultSurveyAppearance, sendSurveyEvent, createShadow, getContrastingTextColor, SurveyContext, getDisplayOrderQuestions, } from './surveys/surveys-utils';
|
|
31
31
|
import * as Preact from 'preact';
|
|
@@ -92,25 +92,31 @@ export var callSurveys = function (posthog, forceReload) {
|
|
|
92
92
|
}
|
|
93
93
|
if (!localStorage.getItem("seenSurvey_".concat(survey.id))) {
|
|
94
94
|
var shadow = createShadow(style(survey === null || survey === void 0 ? void 0 : survey.appearance), survey.id);
|
|
95
|
-
Preact.render(<
|
|
95
|
+
Preact.render(<SurveyPopup key={'popover-survey'} posthog={posthog} survey={survey}/>, shadow);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
}, forceReload);
|
|
100
100
|
};
|
|
101
|
-
export var renderSurveysPreview = function (survey,
|
|
101
|
+
export var renderSurveysPreview = function (survey, parentElement, previewPageIndex) {
|
|
102
102
|
var _a, _b;
|
|
103
103
|
var surveyStyleSheet = style(survey.appearance);
|
|
104
104
|
var styleElement = Object.assign(document.createElement('style'), { innerText: surveyStyleSheet });
|
|
105
|
-
|
|
105
|
+
// Remove previously attached <style>
|
|
106
|
+
Array.from(parentElement.children).forEach(function (child) {
|
|
107
|
+
if (child instanceof HTMLStyleElement) {
|
|
108
|
+
parentElement.removeChild(child);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
parentElement.appendChild(styleElement);
|
|
106
112
|
var textColor = getContrastingTextColor(((_a = survey.appearance) === null || _a === void 0 ? void 0 : _a.backgroundColor) || defaultSurveyAppearance.backgroundColor || 'white');
|
|
107
|
-
Preact.render(<
|
|
113
|
+
Preact.render(<SurveyPopup key="surveys-render-preview" survey={survey} style={{
|
|
108
114
|
position: 'relative',
|
|
109
115
|
right: 0,
|
|
110
116
|
borderBottom: "1px solid ".concat((_b = survey.appearance) === null || _b === void 0 ? void 0 : _b.borderColor),
|
|
111
117
|
borderRadius: 10,
|
|
112
118
|
color: textColor,
|
|
113
|
-
}}/>,
|
|
119
|
+
}} previewPageIndex={previewPageIndex}/>, parentElement);
|
|
114
120
|
};
|
|
115
121
|
export var renderFeedbackWidgetPreview = function (survey, root) {
|
|
116
122
|
var _a;
|
|
@@ -131,13 +137,24 @@ export function generateSurveys(posthog) {
|
|
|
131
137
|
callSurveys(posthog, false);
|
|
132
138
|
}, 3000);
|
|
133
139
|
}
|
|
134
|
-
export function
|
|
135
|
-
var _b, _c
|
|
136
|
-
var survey = _a.survey, posthog = _a.posthog,
|
|
137
|
-
var
|
|
140
|
+
export function SurveyPopup(_a) {
|
|
141
|
+
var _b, _c;
|
|
142
|
+
var survey = _a.survey, posthog = _a.posthog, style = _a.style, previewPageIndex = _a.previewPageIndex;
|
|
143
|
+
var _d = __read(useState(true), 2), isPopupVisible = _d[0], setIsPopupVisible = _d[1];
|
|
144
|
+
var _e = __read(useState(false), 2), isSurveySent = _e[0], setIsSurveySent = _e[1];
|
|
145
|
+
var shouldShowConfirmation = isSurveySent || previewPageIndex === survey.questions.length;
|
|
146
|
+
var isPreviewMode = Number.isInteger(previewPageIndex);
|
|
147
|
+
var confirmationBoxLeftStyle = (style === null || style === void 0 ? void 0 : style.left) && isNumber(style === null || style === void 0 ? void 0 : style.left) ? { left: style.left - 40 } : {};
|
|
148
|
+
// Ensure the popup stays in the same position for the preview
|
|
149
|
+
if (isPreviewMode) {
|
|
150
|
+
style = style || {};
|
|
151
|
+
style.left = 'unset';
|
|
152
|
+
style.right = 'unset';
|
|
153
|
+
style.transform = 'unset';
|
|
154
|
+
}
|
|
138
155
|
useEffect(function () {
|
|
139
156
|
var _a;
|
|
140
|
-
if (
|
|
157
|
+
if (isPreviewMode || !posthog) {
|
|
141
158
|
return;
|
|
142
159
|
}
|
|
143
160
|
window.dispatchEvent(new Event('PHSurveyShown'));
|
|
@@ -148,88 +165,107 @@ export function Surveys(_a) {
|
|
|
148
165
|
});
|
|
149
166
|
localStorage.setItem("lastSeenSurveyDate", new Date().toISOString());
|
|
150
167
|
window.addEventListener('PHSurveyClosed', function () {
|
|
151
|
-
|
|
168
|
+
setIsPopupVisible(false);
|
|
152
169
|
});
|
|
153
170
|
window.addEventListener('PHSurveySent', function () {
|
|
154
171
|
var _a, _b;
|
|
155
172
|
if (!((_a = survey.appearance) === null || _a === void 0 ? void 0 : _a.displayThankYouMessage)) {
|
|
156
|
-
return
|
|
173
|
+
return setIsPopupVisible(false);
|
|
157
174
|
}
|
|
158
|
-
|
|
175
|
+
setIsSurveySent(true);
|
|
159
176
|
if ((_b = survey.appearance) === null || _b === void 0 ? void 0 : _b.autoDisappear) {
|
|
160
177
|
setTimeout(function () {
|
|
161
|
-
|
|
178
|
+
setIsPopupVisible(false);
|
|
162
179
|
}, 5000);
|
|
163
180
|
}
|
|
164
181
|
});
|
|
165
182
|
}, []);
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
previewQuestionIndex: previewQuestionIndex !== null && previewQuestionIndex !== void 0 ? previewQuestionIndex : 0,
|
|
171
|
-
textColor: getContrastingTextColor(((_b = survey.appearance) === null || _b === void 0 ? void 0 : _b.backgroundColor) || defaultSurveyAppearance.backgroundColor),
|
|
183
|
+
return isPopupVisible ? (<SurveyContext.Provider value={{
|
|
184
|
+
isPreviewMode: isPreviewMode,
|
|
185
|
+
previewPageIndex: previewPageIndex,
|
|
186
|
+
handleCloseSurveyPopup: function () { return closeSurveyPopup(survey, posthog, isPreviewMode); },
|
|
172
187
|
}}>
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
</SurveyContext.Provider>
|
|
176
|
-
</>);
|
|
188
|
+
{!shouldShowConfirmation ? (<Questions survey={survey} posthog={posthog} styleOverrides={style}/>) : (<ConfirmationMessage header={((_b = survey.appearance) === null || _b === void 0 ? void 0 : _b.thankYouMessageHeader) || 'Thank you!'} description={((_c = survey.appearance) === null || _c === void 0 ? void 0 : _c.thankYouMessageDescription) || ''} appearance={survey.appearance || defaultSurveyAppearance} styleOverrides={__assign(__assign({}, style), confirmationBoxLeftStyle)} onClose={function () { return setIsPopupVisible(false); }}/>)}
|
|
189
|
+
</SurveyContext.Provider>) : (<></>);
|
|
177
190
|
}
|
|
178
|
-
var
|
|
179
|
-
var
|
|
180
|
-
var
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
191
|
+
var getQuestionComponent = function (_a) {
|
|
192
|
+
var _b, _c;
|
|
193
|
+
var question = _a.question, displayQuestionIndex = _a.displayQuestionIndex, appearance = _a.appearance, onSubmit = _a.onSubmit;
|
|
194
|
+
var questionComponents = (_b = {},
|
|
195
|
+
_b[SurveyQuestionType.Open] = OpenTextQuestion,
|
|
196
|
+
_b[SurveyQuestionType.Link] = LinkQuestion,
|
|
197
|
+
_b[SurveyQuestionType.Rating] = RatingQuestion,
|
|
198
|
+
_b[SurveyQuestionType.SingleChoice] = MultipleChoiceQuestion,
|
|
199
|
+
_b[SurveyQuestionType.MultipleChoice] = MultipleChoiceQuestion,
|
|
200
|
+
_b);
|
|
201
|
+
var commonProps = {
|
|
202
|
+
question: question,
|
|
203
|
+
appearance: appearance,
|
|
204
|
+
onSubmit: onSubmit,
|
|
205
|
+
};
|
|
206
|
+
var additionalProps = (_c = {},
|
|
207
|
+
_c[SurveyQuestionType.Open] = {},
|
|
208
|
+
_c[SurveyQuestionType.Link] = {},
|
|
209
|
+
_c[SurveyQuestionType.Rating] = { displayQuestionIndex: displayQuestionIndex },
|
|
210
|
+
_c[SurveyQuestionType.SingleChoice] = { displayQuestionIndex: displayQuestionIndex },
|
|
211
|
+
_c[SurveyQuestionType.MultipleChoice] = { displayQuestionIndex: displayQuestionIndex },
|
|
212
|
+
_c);
|
|
213
|
+
var Component = questionComponents[question.type];
|
|
214
|
+
var componentProps = __assign(__assign({}, commonProps), additionalProps[question.type]);
|
|
215
|
+
return <Component {...componentProps}/>;
|
|
188
216
|
};
|
|
189
217
|
export function Questions(_a) {
|
|
190
|
-
var _b, _c
|
|
218
|
+
var _b, _c;
|
|
191
219
|
var survey = _a.survey, posthog = _a.posthog, styleOverrides = _a.styleOverrides;
|
|
192
220
|
var textColor = getContrastingTextColor(((_b = survey.appearance) === null || _b === void 0 ? void 0 : _b.backgroundColor) || defaultSurveyAppearance.backgroundColor);
|
|
193
|
-
var
|
|
194
|
-
var
|
|
195
|
-
var
|
|
221
|
+
var _d = __read(useState({}), 2), questionsResponses = _d[0], setQuestionsResponses = _d[1];
|
|
222
|
+
var _e = useContext(SurveyContext), isPreviewMode = _e.isPreviewMode, previewPageIndex = _e.previewPageIndex;
|
|
223
|
+
var _f = __read(useState(previewPageIndex || 0), 2), currentQuestionIndex = _f[0], setCurrentQuestionIndex = _f[1];
|
|
196
224
|
var surveyQuestions = useMemo(function () { return getDisplayOrderQuestions(survey); }, [survey]);
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
225
|
+
// Sync preview state
|
|
226
|
+
useEffect(function () {
|
|
227
|
+
setCurrentQuestionIndex(previewPageIndex !== null && previewPageIndex !== void 0 ? previewPageIndex : 0);
|
|
228
|
+
}, [previewPageIndex]);
|
|
229
|
+
var onNextButtonClick = function (_a) {
|
|
230
|
+
var _b, _c;
|
|
231
|
+
var res = _a.res, originalQuestionIndex = _a.originalQuestionIndex, displayQuestionIndex = _a.displayQuestionIndex;
|
|
232
|
+
var isLastDisplayedQuestion = displayQuestionIndex === survey.questions.length - 1;
|
|
233
|
+
var responseKey = originalQuestionIndex === 0 ? "$survey_response" : "$survey_response_".concat(originalQuestionIndex);
|
|
234
|
+
if (isLastDisplayedQuestion) {
|
|
235
|
+
return sendSurveyEvent(__assign(__assign({}, questionsResponses), (_b = {}, _b[responseKey] = res, _b)), survey, posthog);
|
|
202
236
|
}
|
|
203
237
|
else {
|
|
204
|
-
setQuestionsResponses(__assign(__assign({}, questionsResponses), (
|
|
205
|
-
|
|
238
|
+
setQuestionsResponses(__assign(__assign({}, questionsResponses), (_c = {}, _c[responseKey] = res, _c)));
|
|
239
|
+
setCurrentQuestionIndex(displayQuestionIndex + 1);
|
|
206
240
|
}
|
|
207
241
|
};
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
242
|
+
return (<form className="survey-form" style={__assign({ color: textColor, borderColor: (_c = survey.appearance) === null || _c === void 0 ? void 0 : _c.borderColor }, styleOverrides)}>
|
|
243
|
+
{surveyQuestions.map(function (question, displayQuestionIndex) {
|
|
244
|
+
var originalQuestionIndex = question.originalQuestionIndex;
|
|
245
|
+
var isVisible = isPreviewMode
|
|
246
|
+
? currentQuestionIndex === originalQuestionIndex
|
|
247
|
+
: currentQuestionIndex === displayQuestionIndex;
|
|
248
|
+
return (isVisible && (<div>
|
|
249
|
+
{getQuestionComponent({
|
|
250
|
+
question: question,
|
|
251
|
+
displayQuestionIndex: displayQuestionIndex,
|
|
252
|
+
appearance: survey.appearance || defaultSurveyAppearance,
|
|
253
|
+
onSubmit: function (res) {
|
|
254
|
+
return onNextButtonClick({
|
|
255
|
+
res: res,
|
|
256
|
+
originalQuestionIndex: originalQuestionIndex,
|
|
257
|
+
displayQuestionIndex: displayQuestionIndex,
|
|
258
|
+
});
|
|
259
|
+
},
|
|
260
|
+
})}
|
|
261
|
+
</div>));
|
|
262
|
+
})}
|
|
226
263
|
</form>);
|
|
227
264
|
}
|
|
228
|
-
var closeSurveyPopup = function (survey, posthog,
|
|
265
|
+
var closeSurveyPopup = function (survey, posthog, isPreviewMode) {
|
|
229
266
|
var _a;
|
|
230
267
|
var _b;
|
|
231
|
-
|
|
232
|
-
if (readOnly || !posthog) {
|
|
268
|
+
if (isPreviewMode || !posthog) {
|
|
233
269
|
return;
|
|
234
270
|
}
|
|
235
271
|
posthog.capture('survey dismissed', {
|
|
@@ -280,7 +316,7 @@ export function FeedbackWidget(_a) {
|
|
|
280
316
|
<div className="ph-survey-widget-tab-icon"></div>
|
|
281
317
|
{((_c = survey.appearance) === null || _c === void 0 ? void 0 : _c.widgetLabel) || ''}
|
|
282
318
|
</div>)}
|
|
283
|
-
{showSurvey && (<
|
|
319
|
+
{showSurvey && (<SurveyPopup key={'feedback-widget-survey'} posthog={posthog} survey={survey} style={styleOverrides}/>)}
|
|
284
320
|
</>);
|
|
285
321
|
}
|
|
286
322
|
//# sourceMappingURL=surveys.jsx.map
|