posthog-js 1.151.2 → 1.152.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/lib/src/extensions/surveys/components/PostHogLogo.d.ts +1 -3
- package/dist/lib/src/extensions/surveys/surveys-utils.d.ts +2 -1
- package/dist/lib/src/extensions/surveys.d.ts +11 -3
- package/dist/lib/src/posthog-core.d.ts +4 -0
- package/dist/lib/src/posthog-surveys-types.d.ts +4 -0
- package/dist/lib/src/posthog-surveys.d.ts +3 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.d.ts +12 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/surveys-preview.js +1 -1
- package/dist/surveys-preview.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/surveys/components/BottomSection.jsx +4 -4
- package/lib/src/extensions/surveys/components/BottomSection.jsx.map +1 -1
- package/lib/src/extensions/surveys/components/ConfirmationMessage.jsx +5 -2
- package/lib/src/extensions/surveys/components/ConfirmationMessage.jsx.map +1 -1
- package/lib/src/extensions/surveys/components/PostHogLogo.d.ts +1 -3
- package/lib/src/extensions/surveys/components/PostHogLogo.jsx +2 -5
- package/lib/src/extensions/surveys/components/PostHogLogo.jsx.map +1 -1
- package/lib/src/extensions/surveys/components/QuestionHeader.jsx +2 -1
- package/lib/src/extensions/surveys/components/QuestionHeader.jsx.map +1 -1
- package/lib/src/extensions/surveys/components/QuestionTypes.jsx +9 -17
- package/lib/src/extensions/surveys/components/QuestionTypes.jsx.map +1 -1
- package/lib/src/extensions/surveys/surveys-utils.d.ts +2 -1
- package/lib/src/extensions/surveys/surveys-utils.jsx +4 -2
- package/lib/src/extensions/surveys/surveys-utils.jsx.map +1 -1
- package/lib/src/extensions/surveys.d.ts +11 -3
- package/lib/src/extensions/surveys.jsx +62 -7
- package/lib/src/extensions/surveys.jsx.map +1 -1
- package/lib/src/posthog-core.d.ts +4 -0
- package/lib/src/posthog-core.js +8 -0
- package/lib/src/posthog-core.js.map +1 -1
- package/lib/src/posthog-surveys-types.d.ts +4 -0
- package/lib/src/posthog-surveys-types.js.map +1 -1
- package/lib/src/posthog-surveys.d.ts +3 -0
- package/lib/src/posthog-surveys.js +23 -1
- package/lib/src/posthog-surveys.js.map +1 -1
- package/package.json +1 -1
package/lib/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { window } from '../../../utils/globals';
|
|
2
2
|
import { PostHogLogo } from './PostHogLogo';
|
|
3
3
|
import { useContext } from 'preact/hooks';
|
|
4
|
-
import { SurveyContext,
|
|
4
|
+
import { SurveyContext, defaultSurveyAppearance, getContrastingTextColor } from '../surveys-utils';
|
|
5
5
|
export function BottomSection(_a) {
|
|
6
6
|
var text = _a.text, submitDisabled = _a.submitDisabled, appearance = _a.appearance, onSubmit = _a.onSubmit, link = _a.link;
|
|
7
|
-
var
|
|
7
|
+
var _b = useContext(SurveyContext), isPreviewMode = _b.isPreviewMode, isPopup = _b.isPopup;
|
|
8
8
|
var textColor = getContrastingTextColor(appearance.submitButtonColor || defaultSurveyAppearance.submitButtonColor);
|
|
9
9
|
return (<div className="bottom-section">
|
|
10
10
|
<div className="buttons">
|
|
11
|
-
<button className="form-submit" disabled={submitDisabled && !isPreviewMode} type="button" style={{ color: textColor }} onClick={function () {
|
|
11
|
+
<button className="form-submit" disabled={submitDisabled && !isPreviewMode} type="button" style={isPopup ? { color: textColor } : {}} onClick={function () {
|
|
12
12
|
if (isPreviewMode)
|
|
13
13
|
return;
|
|
14
14
|
if (link) {
|
|
@@ -19,7 +19,7 @@ export function BottomSection(_a) {
|
|
|
19
19
|
{text}
|
|
20
20
|
</button>
|
|
21
21
|
</div>
|
|
22
|
-
{!appearance.whiteLabel &&
|
|
22
|
+
{!appearance.whiteLabel && <PostHogLogo />}
|
|
23
23
|
</div>);
|
|
24
24
|
}
|
|
25
25
|
//# sourceMappingURL=BottomSection.jsx.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSection.jsx","sourceRoot":"","sources":["../../../../../src/extensions/surveys/components/BottomSection.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAI/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"BottomSection.jsx","sourceRoot":"","sources":["../../../../../src/extensions/surveys/components/BottomSection.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAI/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAElG,MAAM,UAAU,aAAa,CAAC,EAY7B;QAXG,IAAI,UAAA,EACJ,cAAc,oBAAA,EACd,UAAU,gBAAA,EACV,QAAQ,cAAA,EACR,IAAI,UAAA;IAQE,IAAA,KAA6B,UAAU,CAAC,aAAa,CAAC,EAApD,aAAa,mBAAA,EAAE,OAAO,aAA8B,CAAA;IAC5D,IAAM,SAAS,GAAG,uBAAuB,CAAC,UAAU,CAAC,iBAAiB,IAAI,uBAAuB,CAAC,iBAAiB,CAAC,CAAA;IACpH,OAAO,CACH,CAAC,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAC3B;YAAA,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CACpB;gBAAA,CAAC,MAAM,CACH,SAAS,CAAC,aAAa,CACvB,QAAQ,CAAC,CAAC,cAAc,IAAI,CAAC,aAAa,CAAC,CAC3C,IAAI,CAAC,QAAQ,CACb,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC3C,OAAO,CAAC,CAAC;YACL,IAAI,aAAa;gBAAE,OAAM;YACzB,IAAI,IAAI,EAAE;gBACN,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAC,IAAI,CAAC,CAAA;aACrB;YACD,QAAQ,EAAE,CAAA;QACd,CAAC,CAAC,CAEF;oBAAA,CAAC,IAAI,CACT;gBAAA,EAAE,MAAM,CACZ;YAAA,EAAE,GAAG,CACL;YAAA,CAAC,CAAC,UAAU,CAAC,UAAU,IAAI,CAAC,WAAW,CAAC,AAAD,EAAG,CAC9C;QAAA,EAAE,GAAG,CAAC,CACT,CAAA;AACL,CAAC","sourcesContent":["import { window } from '../../../utils/globals'\n\nimport { SurveyAppearance } from '../../../posthog-surveys-types'\n\nimport { PostHogLogo } from './PostHogLogo'\nimport { useContext } from 'preact/hooks'\nimport { SurveyContext, defaultSurveyAppearance, getContrastingTextColor } from '../surveys-utils'\n\nexport function BottomSection({\n text,\n submitDisabled,\n appearance,\n onSubmit,\n link,\n}: {\n text: string\n submitDisabled: boolean\n appearance: SurveyAppearance\n onSubmit: () => void\n link?: string | null\n}) {\n const { isPreviewMode, isPopup } = useContext(SurveyContext)\n const textColor = getContrastingTextColor(appearance.submitButtonColor || defaultSurveyAppearance.submitButtonColor)\n return (\n <div className=\"bottom-section\">\n <div className=\"buttons\">\n <button\n className=\"form-submit\"\n disabled={submitDisabled && !isPreviewMode}\n type=\"button\"\n style={isPopup ? { color: textColor } : {}}\n onClick={() => {\n if (isPreviewMode) return\n if (link) {\n window?.open(link)\n }\n onSubmit()\n }}\n >\n {text}\n </button>\n </div>\n {!appearance.whiteLabel && <PostHogLogo />}\n </div>\n )\n}\n"]}
|
|
@@ -13,13 +13,16 @@ import { BottomSection } from './BottomSection';
|
|
|
13
13
|
import { Cancel } from './QuestionHeader';
|
|
14
14
|
import { defaultSurveyAppearance, getContrastingTextColor, renderChildrenAsTextOrHtml } from '../surveys-utils';
|
|
15
15
|
import { h } from 'preact';
|
|
16
|
+
import { useContext } from 'preact/hooks';
|
|
17
|
+
import { SurveyContext } from '../../surveys/surveys-utils';
|
|
16
18
|
export function ConfirmationMessage(_a) {
|
|
17
19
|
var header = _a.header, description = _a.description, contentType = _a.contentType, forceDisableHtml = _a.forceDisableHtml, appearance = _a.appearance, onClose = _a.onClose, styleOverrides = _a.styleOverrides;
|
|
18
20
|
var textColor = getContrastingTextColor(appearance.backgroundColor || defaultSurveyAppearance.backgroundColor);
|
|
21
|
+
var isPopup = useContext(SurveyContext).isPopup;
|
|
19
22
|
return (<>
|
|
20
23
|
<div className="thank-you-message" style={__assign({}, styleOverrides)}>
|
|
21
24
|
<div className="thank-you-message-container">
|
|
22
|
-
<Cancel onClick={function () { return onClose(); }}/>
|
|
25
|
+
{isPopup && <Cancel onClick={function () { return onClose(); }}/>}
|
|
23
26
|
<h3 className="thank-you-message-header" style={{ color: textColor }}>
|
|
24
27
|
{header}
|
|
25
28
|
</h3>
|
|
@@ -30,7 +33,7 @@ export function ConfirmationMessage(_a) {
|
|
|
30
33
|
renderAsHtml: !forceDisableHtml && contentType !== 'text',
|
|
31
34
|
style: { color: textColor },
|
|
32
35
|
})}
|
|
33
|
-
<BottomSection text={appearance.thankYouMessageCloseButtonText || 'Close'} submitDisabled={false} appearance={appearance} onSubmit={function () { return onClose(); }}/>
|
|
36
|
+
{isPopup && (<BottomSection text={appearance.thankYouMessageCloseButtonText || 'Close'} submitDisabled={false} appearance={appearance} onSubmit={function () { return onClose(); }}/>)}
|
|
34
37
|
</div>
|
|
35
38
|
</div>
|
|
36
39
|
</>);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmationMessage.jsx","sourceRoot":"","sources":["../../../../../src/extensions/surveys/components/ConfirmationMessage.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAC/G,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B,MAAM,UAAU,mBAAmB,CAAC,EAgBnC;QAfG,MAAM,YAAA,EACN,WAAW,iBAAA,EACX,WAAW,iBAAA,EACX,gBAAgB,sBAAA,EAChB,UAAU,gBAAA,EACV,OAAO,aAAA,EACP,cAAc,oBAAA;IAUd,IAAM,SAAS,GAAG,uBAAuB,CAAC,UAAU,CAAC,eAAe,IAAI,uBAAuB,CAAC,eAAe,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"ConfirmationMessage.jsx","sourceRoot":"","sources":["../../../../../src/extensions/surveys/components/ConfirmationMessage.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAC/G,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAE3D,MAAM,UAAU,mBAAmB,CAAC,EAgBnC;QAfG,MAAM,YAAA,EACN,WAAW,iBAAA,EACX,WAAW,iBAAA,EACX,gBAAgB,sBAAA,EAChB,UAAU,gBAAA,EACV,OAAO,aAAA,EACP,cAAc,oBAAA;IAUd,IAAM,SAAS,GAAG,uBAAuB,CAAC,UAAU,CAAC,eAAe,IAAI,uBAAuB,CAAC,eAAe,CAAC,CAAA;IAExG,IAAA,OAAO,GAAK,UAAU,CAAC,aAAa,CAAC,QAA9B,CAA8B;IAE7C,OAAO,CACH,EACI;YAAA,CAAC,GAAG,CAAC,SAAS,CAAC,mBAAmB,CAAC,KAAK,CAAC,cAAM,cAAc,EAAG,CAC5D;gBAAA,CAAC,GAAG,CAAC,SAAS,CAAC,6BAA6B,CACxC;oBAAA,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,cAAM,OAAA,OAAO,EAAE,EAAT,CAAS,CAAC,EAAG,CAChD;oBAAA,CAAC,EAAE,CAAC,SAAS,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CACjE;wBAAA,CAAC,MAAM,CACX;oBAAA,EAAE,EAAE,CACJ;oBAAA,CAAC,WAAW;YACR,0BAA0B,CAAC;gBACvB,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,wBAAwB,EAAE,CAAC;gBAC5D,QAAQ,EAAE,WAAW;gBACrB,YAAY,EAAE,CAAC,gBAAgB,IAAI,WAAW,KAAK,MAAM;gBACzD,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE;aAC9B,CAAC,CACN;oBAAA,CAAC,OAAO,IAAI,CACR,CAAC,aAAa,CACV,IAAI,CAAC,CAAC,UAAU,CAAC,8BAA8B,IAAI,OAAO,CAAC,CAC3D,cAAc,CAAC,CAAC,KAAK,CAAC,CACtB,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,QAAQ,CAAC,CAAC,cAAM,OAAA,OAAO,EAAE,EAAT,CAAS,CAAC,EAC5B,CACL,CACL;gBAAA,EAAE,GAAG,CACT;YAAA,EAAE,GAAG,CACT;QAAA,GAAG,CACN,CAAA;AACL,CAAC","sourcesContent":["import { BottomSection } from './BottomSection'\nimport { Cancel } from './QuestionHeader'\nimport { SurveyAppearance, SurveyQuestionDescriptionContentType } from '../../../posthog-surveys-types'\nimport { defaultSurveyAppearance, getContrastingTextColor, renderChildrenAsTextOrHtml } from '../surveys-utils'\nimport { h } from 'preact'\n\nimport { useContext } from 'preact/hooks'\nimport { SurveyContext } from '../../surveys/surveys-utils'\n\nexport function ConfirmationMessage({\n header,\n description,\n contentType,\n forceDisableHtml,\n appearance,\n onClose,\n styleOverrides,\n}: {\n header: string\n description: string\n forceDisableHtml: boolean\n contentType?: SurveyQuestionDescriptionContentType\n appearance: SurveyAppearance\n onClose: () => void\n styleOverrides?: React.CSSProperties\n}) {\n const textColor = getContrastingTextColor(appearance.backgroundColor || defaultSurveyAppearance.backgroundColor)\n\n const { isPopup } = useContext(SurveyContext)\n\n return (\n <>\n <div className=\"thank-you-message\" style={{ ...styleOverrides }}>\n <div className=\"thank-you-message-container\">\n {isPopup && <Cancel onClick={() => onClose()} />}\n <h3 className=\"thank-you-message-header\" style={{ color: textColor }}>\n {header}\n </h3>\n {description &&\n renderChildrenAsTextOrHtml({\n component: h('div', { className: 'thank-you-message-body' }),\n children: description,\n renderAsHtml: !forceDisableHtml && contentType !== 'text',\n style: { color: textColor },\n })}\n {isPopup && (\n <BottomSection\n text={appearance.thankYouMessageCloseButtonText || 'Close'}\n submitDisabled={false}\n appearance={appearance}\n onSubmit={() => onClose()}\n />\n )}\n </div>\n </div>\n </>\n )\n}\n"]}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { IconPosthogLogo } from '../icons';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var backgroundColor = _a.backgroundColor;
|
|
5
|
-
var textColor = getContrastingTextColor(backgroundColor);
|
|
6
|
-
return (<a href="https://posthog.com" target="_blank" rel="noopener" style={{ backgroundColor: backgroundColor, color: textColor }} className="footer-branding">
|
|
2
|
+
export function PostHogLogo() {
|
|
3
|
+
return (<a href="https://posthog.com" target="_blank" rel="noopener" className="footer-branding">
|
|
7
4
|
Survey by {IconPosthogLogo}
|
|
8
5
|
</a>);
|
|
9
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostHogLogo.jsx","sourceRoot":"","sources":["../../../../../src/extensions/surveys/components/PostHogLogo.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"PostHogLogo.jsx","sourceRoot":"","sources":["../../../../../src/extensions/surveys/components/PostHogLogo.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C,MAAM,UAAU,WAAW;IACvB,OAAO,CACH,CAAC,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,iBAAiB,CACpF;sBAAU,CAAC,eAAe,CAC9B;QAAA,EAAE,CAAC,CAAC,CACP,CAAA;AACL,CAAC","sourcesContent":["import { IconPosthogLogo } from '../icons'\n\nexport function PostHogLogo() {\n return (\n <a href=\"https://posthog.com\" target=\"_blank\" rel=\"noopener\" className=\"footer-branding\">\n Survey by {IconPosthogLogo}\n </a>\n )\n}\n"]}
|
|
@@ -4,7 +4,8 @@ import { useContext } from 'preact/hooks';
|
|
|
4
4
|
import { h } from 'preact';
|
|
5
5
|
export function QuestionHeader(_a) {
|
|
6
6
|
var question = _a.question, description = _a.description, descriptionContentType = _a.descriptionContentType, backgroundColor = _a.backgroundColor, forceDisableHtml = _a.forceDisableHtml;
|
|
7
|
-
|
|
7
|
+
var isPopup = useContext(SurveyContext).isPopup;
|
|
8
|
+
return (<div style={isPopup ? { backgroundColor: backgroundColor || defaultSurveyAppearance.backgroundColor } : {}}>
|
|
8
9
|
<div className="survey-question">{question}</div>
|
|
9
10
|
{description &&
|
|
10
11
|
renderChildrenAsTextOrHtml({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuestionHeader.jsx","sourceRoot":"","sources":["../../../../../src/extensions/surveys/components/QuestionHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AACrG,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B,MAAM,UAAU,cAAc,CAAC,EAY9B;QAXG,QAAQ,cAAA,EACR,WAAW,iBAAA,EACX,sBAAsB,4BAAA,EACtB,eAAe,qBAAA,EACf,gBAAgB,sBAAA;
|
|
1
|
+
{"version":3,"file":"QuestionHeader.jsx","sourceRoot":"","sources":["../../../../../src/extensions/surveys/components/QuestionHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AACrG,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B,MAAM,UAAU,cAAc,CAAC,EAY9B;QAXG,QAAQ,cAAA,EACR,WAAW,iBAAA,EACX,sBAAsB,4BAAA,EACtB,eAAe,qBAAA,EACf,gBAAgB,sBAAA;IAQR,IAAA,OAAO,GAAK,UAAU,CAAC,aAAa,CAAC,QAA9B,CAA8B;IAC7C,OAAO,CACH,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,eAAe,IAAI,uBAAuB,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CACvG;YAAA,CAAC,GAAG,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,EAAE,GAAG,CAChD;YAAA,CAAC,WAAW;YACR,0BAA0B,CAAC;gBACvB,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;gBACjD,QAAQ,EAAE,WAAW;gBACrB,YAAY,EAAE,CAAC,gBAAgB,IAAI,sBAAsB,KAAK,MAAM;aACvE,CAAC,CACV;QAAA,EAAE,GAAG,CAAC,CACT,CAAA;AACL,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,EAAoC;QAAlC,OAAO,aAAA;IACpB,IAAA,aAAa,GAAK,UAAU,CAAC,aAAa,CAAC,cAA9B,CAA8B;IAEnD,OAAO,CACH,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAC/B;YAAA,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,CACtE;gBAAA,CAAC,SAAS,CACd;YAAA,EAAE,MAAM,CACZ;QAAA,EAAE,GAAG,CAAC,CACT,CAAA;AACL,CAAC","sourcesContent":["import { SurveyContext, defaultSurveyAppearance, renderChildrenAsTextOrHtml } from '../surveys-utils'\nimport { cancelSVG } from '../icons'\nimport { useContext } from 'preact/hooks'\nimport { SurveyQuestionDescriptionContentType } from '../../../posthog-surveys-types'\nimport { h } from 'preact'\n\nexport function QuestionHeader({\n question,\n description,\n descriptionContentType,\n backgroundColor,\n forceDisableHtml,\n}: {\n question: string\n description?: string | null\n descriptionContentType?: SurveyQuestionDescriptionContentType\n forceDisableHtml: boolean\n backgroundColor?: string\n}) {\n const { isPopup } = useContext(SurveyContext)\n return (\n <div style={isPopup ? { backgroundColor: backgroundColor || defaultSurveyAppearance.backgroundColor } : {}}>\n <div className=\"survey-question\">{question}</div>\n {description &&\n renderChildrenAsTextOrHtml({\n component: h('div', { className: 'description' }),\n children: description,\n renderAsHtml: !forceDisableHtml && descriptionContentType !== 'text',\n })}\n </div>\n )\n}\n\nexport function Cancel({ onClick }: { onClick: () => void }) {\n const { isPreviewMode } = useContext(SurveyContext)\n\n return (\n <div className=\"cancel-btn-wrapper\">\n <button className=\"form-cancel\" onClick={onClick} disabled={isPreviewMode}>\n {cancelSVG}\n </button>\n </div>\n )\n}\n"]}
|
|
@@ -24,20 +24,18 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
24
24
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
25
|
};
|
|
26
26
|
import { SurveyQuestionType, } from '../../../posthog-surveys-types';
|
|
27
|
-
import { useRef, useState, useMemo
|
|
27
|
+
import { useRef, useState, useMemo } from 'preact/hooks';
|
|
28
28
|
import { isNull, isArray } from '../../../utils/type-utils';
|
|
29
29
|
import { useContrastingTextColor } from '../hooks/useContrastingTextColor';
|
|
30
30
|
import { checkSVG, dissatisfiedEmoji, neutralEmoji, satisfiedEmoji, veryDissatisfiedEmoji, verySatisfiedEmoji, } from '../icons';
|
|
31
|
-
import {
|
|
31
|
+
import { getDisplayOrderChoices } from '../surveys-utils';
|
|
32
32
|
import { BottomSection } from './BottomSection';
|
|
33
|
-
import {
|
|
33
|
+
import { QuestionHeader } from './QuestionHeader';
|
|
34
34
|
export function OpenTextQuestion(_a) {
|
|
35
35
|
var question = _a.question, forceDisableHtml = _a.forceDisableHtml, appearance = _a.appearance, onSubmit = _a.onSubmit;
|
|
36
36
|
var textRef = useRef(null);
|
|
37
37
|
var _b = __read(useState(''), 2), text = _b[0], setText = _b[1];
|
|
38
|
-
|
|
39
|
-
return (<div className="survey-box" style={{ backgroundColor: appearance.backgroundColor || defaultSurveyAppearance.backgroundColor }} ref={textRef}>
|
|
40
|
-
<Cancel onClick={function () { return handleCloseSurveyPopup(); }}/>
|
|
38
|
+
return (<div ref={textRef}>
|
|
41
39
|
<QuestionHeader question={question.question} description={question.description} descriptionContentType={question.descriptionContentType} backgroundColor={appearance.backgroundColor} forceDisableHtml={forceDisableHtml}/>
|
|
42
40
|
<textarea rows={4} placeholder={appearance === null || appearance === void 0 ? void 0 : appearance.placeholder} onInput={function (e) { return setText(e.currentTarget.value); }}/>
|
|
43
41
|
<BottomSection text={question.buttonText || 'Submit'} submitDisabled={!text && !question.optional} appearance={appearance} onSubmit={function () { return onSubmit(text); }}/>
|
|
@@ -45,21 +43,17 @@ export function OpenTextQuestion(_a) {
|
|
|
45
43
|
}
|
|
46
44
|
export function LinkQuestion(_a) {
|
|
47
45
|
var question = _a.question, forceDisableHtml = _a.forceDisableHtml, appearance = _a.appearance, onSubmit = _a.onSubmit;
|
|
48
|
-
|
|
49
|
-
return (<div className="survey-box">
|
|
50
|
-
<Cancel onClick={function () { return handleCloseSurveyPopup(); }}/>
|
|
46
|
+
return (<>
|
|
51
47
|
<QuestionHeader question={question.question} description={question.description} descriptionContentType={question.descriptionContentType} forceDisableHtml={forceDisableHtml}/>
|
|
52
48
|
<BottomSection text={question.buttonText || 'Submit'} submitDisabled={false} link={question.link} appearance={appearance} onSubmit={function () { return onSubmit('link clicked'); }}/>
|
|
53
|
-
|
|
49
|
+
</>);
|
|
54
50
|
}
|
|
55
51
|
export function RatingQuestion(_a) {
|
|
56
52
|
var question = _a.question, forceDisableHtml = _a.forceDisableHtml, displayQuestionIndex = _a.displayQuestionIndex, appearance = _a.appearance, onSubmit = _a.onSubmit;
|
|
57
53
|
var scale = question.scale;
|
|
58
54
|
var starting = question.scale === 10 ? 0 : 1;
|
|
59
55
|
var _b = __read(useState(null), 2), rating = _b[0], setRating = _b[1];
|
|
60
|
-
|
|
61
|
-
return (<div className="survey-box">
|
|
62
|
-
<Cancel onClick={function () { return handleCloseSurveyPopup(); }}/>
|
|
56
|
+
return (<>
|
|
63
57
|
<QuestionHeader question={question.question} description={question.description} descriptionContentType={question.descriptionContentType} forceDisableHtml={forceDisableHtml} backgroundColor={appearance.backgroundColor}/>
|
|
64
58
|
<div className="rating-section">
|
|
65
59
|
<div className="rating-options">
|
|
@@ -93,7 +87,7 @@ export function RatingQuestion(_a) {
|
|
|
93
87
|
</div>
|
|
94
88
|
</div>
|
|
95
89
|
<BottomSection text={question.buttonText || (appearance === null || appearance === void 0 ? void 0 : appearance.submitButtonText) || 'Submit'} submitDisabled={isNull(rating) && !question.optional} appearance={appearance} onSubmit={function () { return onSubmit(rating); }}/>
|
|
96
|
-
|
|
90
|
+
</>);
|
|
97
91
|
}
|
|
98
92
|
export function RatingButton(_a) {
|
|
99
93
|
var num = _a.num, active = _a.active, displayQuestionIndex = _a.displayQuestionIndex, appearance = _a.appearance, setActiveNumber = _a.setActiveNumber;
|
|
@@ -115,10 +109,8 @@ export function MultipleChoiceQuestion(_a) {
|
|
|
115
109
|
var _b = __read(useState(question.type === SurveyQuestionType.MultipleChoice ? [] : null), 2), selectedChoices = _b[0], setSelectedChoices = _b[1];
|
|
116
110
|
var _c = __read(useState(false), 2), openChoiceSelected = _c[0], setOpenChoiceSelected = _c[1];
|
|
117
111
|
var _d = __read(useState(''), 2), openEndedInput = _d[0], setOpenEndedInput = _d[1];
|
|
118
|
-
var handleCloseSurveyPopup = useContext(SurveyContext).handleCloseSurveyPopup;
|
|
119
112
|
var inputType = question.type === SurveyQuestionType.SingleChoice ? 'radio' : 'checkbox';
|
|
120
|
-
return (<div
|
|
121
|
-
<Cancel onClick={function () { return handleCloseSurveyPopup(); }}/>
|
|
113
|
+
return (<div ref={textRef}>
|
|
122
114
|
<QuestionHeader question={question.question} description={question.description} descriptionContentType={question.descriptionContentType} forceDisableHtml={forceDisableHtml} backgroundColor={appearance.backgroundColor}/>
|
|
123
115
|
<div className="multiple-choice-options">
|
|
124
116
|
{/* Remove the last element from the choices, if hasOpenChoice is set */}
|
|
@@ -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,UAAU,EAAE,MAAM,cAAc,CAAA;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C,CAAA;AAC/C,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;AAE1D,SAAS,eAAe,CAAC,KAAa;IAClC,QAAQ,KAAK,EAAE;QACX,KAAK,CAAC;YACF,OAAO,gBAAgB,CAAA;QAC3B,KAAK,CAAC;YACF,OAAO,iBAAiB,CAAA;QAC5B,KAAK,EAAE;YACH,OAAO,eAAe,CAAA;QAC1B;YACI,OAAO,gBAAgB,CAAA;KAC9B;AACL,CAAC","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 { SurveyContext, defaultSurveyAppearance, getDisplayOrderChoices } from '../surveys-utils'\nimport { BottomSection } from './BottomSection'\nimport { Cancel, QuestionHeader } from './QuestionHeader'\n\nexport function OpenTextQuestion({\n question,\n forceDisableHtml,\n appearance,\n onSubmit,\n}: {\n question: BasicSurveyQuestion\n forceDisableHtml: boolean\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 descriptionContentType={question.descriptionContentType}\n backgroundColor={appearance.backgroundColor}\n forceDisableHtml={forceDisableHtml}\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 forceDisableHtml,\n appearance,\n onSubmit,\n}: {\n question: LinkSurveyQuestion\n forceDisableHtml: boolean\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\n question={question.question}\n description={question.description}\n descriptionContentType={question.descriptionContentType}\n forceDisableHtml={forceDisableHtml}\n />\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 forceDisableHtml,\n displayQuestionIndex,\n appearance,\n onSubmit,\n}: {\n question: RatingSurveyQuestion\n forceDisableHtml: boolean\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 descriptionContentType={question.descriptionContentType}\n forceDisableHtml={forceDisableHtml}\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 style={{\n fill: active\n ? appearance.ratingButtonActiveColor\n : appearance.ratingButtonColor,\n borderColor: appearance.borderColor,\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 {getScaleNumbers(question.scale).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: SurveyAppearance\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 forceDisableHtml,\n displayQuestionIndex,\n appearance,\n onSubmit,\n}: {\n question: MultipleSurveyQuestion\n forceDisableHtml: boolean\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 descriptionContentType={question.descriptionContentType}\n forceDisableHtml={forceDisableHtml}\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 sevenScaleNumbers = [1, 2, 3, 4, 5, 6, 7]\nconst tenScaleNumbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n\nfunction getScaleNumbers(scale: number): number[] {\n switch (scale) {\n case 5:\n return fiveScaleNumbers\n case 7:\n return sevenScaleNumbers\n case 10:\n return tenScaleNumbers\n default:\n return fiveScaleNumbers\n }\n}\n"]}
|
|
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,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,UAAU,gBAAgB,CAAC,EAUhC;QATG,QAAQ,cAAA,EACR,gBAAgB,sBAAA,EAChB,UAAU,gBAAA,EACV,QAAQ,cAAA;IAOR,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,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CACd;YAAA,CAAC,cAAc,CACX,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAC5B,WAAW,CAAC,C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AAI,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,iBAAiB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;AAC/C,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;AAE1D,SAAS,eAAe,CAAC,KAAa;IAClC,QAAQ,KAAK,EAAE;QACX,KAAK,CAAC;YACF,OAAO,gBAAgB,CAAA;QAC3B,KAAK,CAAC;YACF,OAAO,iBAAiB,CAAA;QAC5B,KAAK,EAAE;YACH,OAAO,eAAe,CAAA;QAC1B;YACI,OAAO,gBAAgB,CAAA;KAC9B;AACL,CAAC","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 { getDisplayOrderChoices } from '../surveys-utils'\nimport { BottomSection } from './BottomSection'\nimport { QuestionHeader } from './QuestionHeader'\n\nexport function OpenTextQuestion({\n question,\n forceDisableHtml,\n appearance,\n onSubmit,\n}: {\n question: BasicSurveyQuestion\n forceDisableHtml: boolean\n appearance: SurveyAppearance\n onSubmit: (text: string) => void\n}) {\n const textRef = useRef(null)\n const [text, setText] = useState('')\n\n return (\n <div ref={textRef}>\n <QuestionHeader\n question={question.question}\n description={question.description}\n descriptionContentType={question.descriptionContentType}\n backgroundColor={appearance.backgroundColor}\n forceDisableHtml={forceDisableHtml}\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 forceDisableHtml,\n appearance,\n onSubmit,\n}: {\n question: LinkSurveyQuestion\n forceDisableHtml: boolean\n appearance: SurveyAppearance\n onSubmit: (clicked: string) => void\n}) {\n return (\n <>\n <QuestionHeader\n question={question.question}\n description={question.description}\n descriptionContentType={question.descriptionContentType}\n forceDisableHtml={forceDisableHtml}\n />\n <BottomSection\n text={question.buttonText || 'Submit'}\n submitDisabled={false}\n link={question.link}\n appearance={appearance}\n onSubmit={() => onSubmit('link clicked')}\n />\n </>\n )\n}\n\nexport function RatingQuestion({\n question,\n forceDisableHtml,\n displayQuestionIndex,\n appearance,\n onSubmit,\n}: {\n question: RatingSurveyQuestion\n forceDisableHtml: boolean\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\n return (\n <>\n <QuestionHeader\n question={question.question}\n description={question.description}\n descriptionContentType={question.descriptionContentType}\n forceDisableHtml={forceDisableHtml}\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 style={{\n fill: active\n ? appearance.ratingButtonActiveColor\n : appearance.ratingButtonColor,\n borderColor: appearance.borderColor,\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 {getScaleNumbers(question.scale).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 </>\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: SurveyAppearance\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 forceDisableHtml,\n displayQuestionIndex,\n appearance,\n onSubmit,\n}: {\n question: MultipleSurveyQuestion\n forceDisableHtml: boolean\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\n const inputType = question.type === SurveyQuestionType.SingleChoice ? 'radio' : 'checkbox'\n return (\n <div ref={textRef}>\n <QuestionHeader\n question={question.question}\n description={question.description}\n descriptionContentType={question.descriptionContentType}\n forceDisableHtml={forceDisableHtml}\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 sevenScaleNumbers = [1, 2, 3, 4, 5, 6, 7]\nconst tenScaleNumbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n\nfunction getScaleNumbers(scale: number): number[] {\n switch (scale) {\n case 5:\n return fiveScaleNumbers\n case 7:\n return sevenScaleNumbers\n case 10:\n return tenScaleNumbers\n default:\n return fiveScaleNumbers\n }\n}\n"]}
|
|
@@ -6,7 +6,7 @@ export declare function getContrastingTextColor(color?: string): "black" | "whit
|
|
|
6
6
|
export declare function getTextColor(el: HTMLElement): "black" | "white";
|
|
7
7
|
export declare const defaultSurveyAppearance: SurveyAppearance;
|
|
8
8
|
export declare const defaultBackgroundColor = "#eeeded";
|
|
9
|
-
export declare const createShadow: (styleSheet: string, surveyId: string) => ShadowRoot;
|
|
9
|
+
export declare const createShadow: (styleSheet: string, surveyId: string, element?: Element) => ShadowRoot;
|
|
10
10
|
export declare const sendSurveyEvent: (responses: Record<string, string | number | string[] | null> | undefined, survey: Survey, posthog?: PostHog) => void;
|
|
11
11
|
export declare const dismissedSurveyEvent: (survey: Survey, posthog?: PostHog, readOnly?: boolean) => void;
|
|
12
12
|
export declare const shuffle: (array: any[]) => any[];
|
|
@@ -25,6 +25,7 @@ export declare const SurveyContext: import("preact").Context<{
|
|
|
25
25
|
isPreviewMode: boolean;
|
|
26
26
|
previewPageIndex: number | undefined;
|
|
27
27
|
handleCloseSurveyPopup: () => void;
|
|
28
|
+
isPopup: boolean;
|
|
28
29
|
}>;
|
|
29
30
|
interface RenderProps {
|
|
30
31
|
component: VNode<{
|
|
@@ -230,7 +230,7 @@ export var defaultSurveyAppearance = {
|
|
|
230
230
|
position: 'right',
|
|
231
231
|
};
|
|
232
232
|
export var defaultBackgroundColor = '#eeeded';
|
|
233
|
-
export var createShadow = function (styleSheet, surveyId) {
|
|
233
|
+
export var createShadow = function (styleSheet, surveyId, element) {
|
|
234
234
|
var div = document.createElement('div');
|
|
235
235
|
div.className = "PostHogSurvey".concat(surveyId);
|
|
236
236
|
var shadow = div.attachShadow({ mode: 'open' });
|
|
@@ -240,7 +240,8 @@ export var createShadow = function (styleSheet, surveyId) {
|
|
|
240
240
|
});
|
|
241
241
|
shadow.appendChild(styleElement);
|
|
242
242
|
}
|
|
243
|
-
|
|
243
|
+
;
|
|
244
|
+
(element ? element : document.body).appendChild(div);
|
|
244
245
|
return shadow;
|
|
245
246
|
};
|
|
246
247
|
export var sendSurveyEvent = function (responses, survey, posthog) {
|
|
@@ -356,6 +357,7 @@ export var SurveyContext = createContext({
|
|
|
356
357
|
isPreviewMode: false,
|
|
357
358
|
previewPageIndex: 0,
|
|
358
359
|
handleCloseSurveyPopup: function () { },
|
|
360
|
+
isPopup: true,
|
|
359
361
|
});
|
|
360
362
|
export var renderChildrenAsTextOrHtml = function (_a) {
|
|
361
363
|
var component = _a.component, children = _a.children, renderAsHtml = _a.renderAsHtml, style = _a.style;
|
|
@@ -1 +1 @@
|
|
|
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,EAAS,YAAY,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAC3D,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,+cASgB,QAAQ,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,KAAI,KAAK,CAAC,qEA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Y,CAAC,SAAS,EAAE;YACpB,QAAQ,UAAA;YACR,KAAK,OAAA;SACR,CAAC,CAAA;AACZ,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 { VNode, cloneElement, 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, .thank-you-message {\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 width: 100%;\n z-index: ${parseInt(appearance?.zIndex || '99999')};\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n border-bottom: 0px;\n ${positions[appearance?.position || 'right'] || 'right: 30px;'}\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 \n .survey-box, .thank-you-message-container {\n padding: 20px 25px 10px;\n display: flex;\n flex-direction: column;\n border-radius: 10px;\n }\n\n .thank-you-message {\n text-align: center;\n }\n\n .form-submit[disabled] {\n opacity: 0.6;\n filter: grayscale(50%);\n cursor: not-allowed;\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 .survey-box:has(.survey-question:empty):not(:has(.description)) textarea {\n margin-top: 0;\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 display: flex;\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-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 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: '#939393';\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 .survey-box:has(.survey-question:empty):not(:has(.description)) .multiple-choice-options {\n margin-top: 0;\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-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(getSurveySeenKey(survey), 'true')\n\n posthog.capture('survey sent', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_iteration: survey.current_iteration,\n $survey_iteration_start_date: survey.current_iteration_start_date,\n $survey_questions: survey.questions.map((question) => question.question),\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n ...responses,\n $set: {\n [getSurveyInteractionProperty(survey, 'responded')]: true,\n },\n })\n window.dispatchEvent(new Event('PHSurveySent'))\n}\n\nexport const dismissedSurveyEvent = (survey: Survey, posthog?: PostHog, readOnly?: boolean) => {\n // TODO: state management and unit tests for this would be nice\n if (readOnly || !posthog) {\n return\n }\n posthog.capture('survey dismissed', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_iteration: survey.current_iteration,\n $survey_iteration_start_date: survey.current_iteration_start_date,\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n $set: {\n [getSurveyInteractionProperty(survey, 'dismissed')]: true,\n },\n })\n localStorage.setItem(getSurveySeenKey(survey), 'true')\n window.dispatchEvent(new Event('PHSurveyClosed'))\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: any[], shuffled: any[]): any[] => {\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 reverseIfUnshuffled(survey.questions, shuffle(survey.questions))\n}\n\nexport const hasEvents = (survey: Survey): boolean => {\n return survey.conditions?.events?.values?.length != undefined && survey.conditions?.events?.values?.length > 0\n}\n\nexport const canActivateRepeatedly = (survey: Survey): boolean => {\n return !!(survey.conditions?.events?.repeatedActivation && hasEvents(survey))\n}\n\n/**\n * getSurveySeen checks local storage for the surveySeen Key a\n * and overrides this value if the survey can be repeatedly activated by its events.\n * @param survey\n */\nexport const getSurveySeen = (survey: Survey): boolean => {\n const surveySeen = localStorage.getItem(getSurveySeenKey(survey))\n if (surveySeen) {\n // if a survey has already been seen,\n // we will override it with the event repeated activation value.\n return !canActivateRepeatedly(survey)\n }\n\n return false\n}\n\nexport const getSurveySeenKey = (survey: Survey): string => {\n let surveySeenKey = `seenSurvey_${survey.id}`\n if (survey.current_iteration && survey.current_iteration > 0) {\n surveySeenKey = `seenSurvey_${survey.id}_${survey.current_iteration}`\n }\n\n return surveySeenKey\n}\n\nconst getSurveyInteractionProperty = (survey: Survey, action: string): string => {\n let surveyProperty = `$survey_${action}/${survey.id}`\n if (survey.current_iteration && survey.current_iteration > 0) {\n surveyProperty = `$survey_${action}/${survey.id}/${survey.current_iteration}`\n }\n\n return surveyProperty\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\ninterface RenderProps {\n component: VNode<{ className: string }>\n children: string\n renderAsHtml?: boolean\n style?: React.CSSProperties\n}\n\nexport const renderChildrenAsTextOrHtml = ({ component, children, renderAsHtml, style }: RenderProps) => {\n return renderAsHtml\n ? cloneElement(component, {\n dangerouslySetInnerHTML: { __html: children },\n style,\n })\n : cloneElement(component, {\n children,\n style,\n })\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,EAAS,YAAY,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAC3D,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,+cASgB,QAAQ,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,KAAI,KAAK,CAAC,qEAEzC,QAAQ,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,KAAI,OAAO,CAAC,kDAC5B,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,WAAW,KAAI,SAAS,iEAExD,SAAS,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,KAAI,OAAO,CAAC,IAAI,cAAc,gFAEhD,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,eAAe,KAAI,SAAS,8uCAiCtC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,WAAW,KAAI,SAAS,02BAyBtC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,iBAAiB,KAAI,OAAO,4rBAqBh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AAE,CAAA;KACxE;IAED,OAAO,aAAa,CAAA;AACxB,CAAC,CAAA;AAED,IAAM,4BAA4B,GAAG,UAAC,MAAc,EAAE,MAAc;IAChE,IAAI,cAAc,GAAG,kBAAW,MAAM,cAAI,MAAM,CAAC,EAAE,CAAE,CAAA;IACrD,IAAI,MAAM,CAAC,iBAAiB,IAAI,MAAM,CAAC,iBAAiB,GAAG,CAAC,EAAE;QAC1D,cAAc,GAAG,kBAAW,MAAM,cAAI,MAAM,CAAC,EAAE,cAAI,MAAM,CAAC,iBAAiB,CAAE,CAAA;KAChF;IAED,OAAO,cAAc,CAAA;AACzB,CAAC,CAAA;AAED,MAAM,CAAC,IAAM,aAAa,GAAG,aAAa,CAKvC;IACC,aAAa,EAAE,KAAK;IACpB,gBAAgB,EAAE,CAAC;IACnB,sBAAsB,EAAE,cAAO,CAAC;IAChC,OAAO,EAAE,IAAI;CAChB,CAAC,CAAA;AASF,MAAM,CAAC,IAAM,0BAA0B,GAAG,UAAC,EAAyD;QAAvD,SAAS,eAAA,EAAE,QAAQ,cAAA,EAAE,YAAY,kBAAA,EAAE,KAAK,WAAA;IACjF,OAAO,YAAY;QACf,CAAC,CAAC,YAAY,CAAC,SAAS,EAAE;YACpB,uBAAuB,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;YAC7C,KAAK,OAAA;SACR,CAAC;QACJ,CAAC,CAAC,YAAY,CAAC,SAAS,EAAE;YACpB,QAAQ,UAAA;YACR,KAAK,OAAA;SACR,CAAC,CAAA;AACZ,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 { VNode, cloneElement, 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, .thank-you-message {\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 width: 100%;\n z-index: ${parseInt(appearance?.zIndex || '99999')};\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n border-bottom: 0px;\n ${positions[appearance?.position || 'right'] || 'right: 30px;'}\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 \n .survey-box, .thank-you-message-container {\n padding: 20px 25px 10px;\n display: flex;\n flex-direction: column;\n border-radius: 10px;\n }\n\n .thank-you-message {\n text-align: center;\n }\n\n .form-submit[disabled] {\n opacity: 0.6;\n filter: grayscale(50%);\n cursor: not-allowed;\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 .survey-box:has(.survey-question:empty):not(:has(.description)) textarea {\n margin-top: 0;\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 display: flex;\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-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 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: '#939393';\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 .survey-box:has(.survey-question:empty):not(:has(.description)) .multiple-choice-options {\n margin-top: 0;\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-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, element?: Element) => {\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 ;(element ? element : 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(getSurveySeenKey(survey), 'true')\n\n posthog.capture('survey sent', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_iteration: survey.current_iteration,\n $survey_iteration_start_date: survey.current_iteration_start_date,\n $survey_questions: survey.questions.map((question) => question.question),\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n ...responses,\n $set: {\n [getSurveyInteractionProperty(survey, 'responded')]: true,\n },\n })\n window.dispatchEvent(new Event('PHSurveySent'))\n}\n\nexport const dismissedSurveyEvent = (survey: Survey, posthog?: PostHog, readOnly?: boolean) => {\n // TODO: state management and unit tests for this would be nice\n if (readOnly || !posthog) {\n return\n }\n posthog.capture('survey dismissed', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_iteration: survey.current_iteration,\n $survey_iteration_start_date: survey.current_iteration_start_date,\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n $set: {\n [getSurveyInteractionProperty(survey, 'dismissed')]: true,\n },\n })\n localStorage.setItem(getSurveySeenKey(survey), 'true')\n window.dispatchEvent(new Event('PHSurveyClosed'))\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: any[], shuffled: any[]): any[] => {\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 reverseIfUnshuffled(survey.questions, shuffle(survey.questions))\n}\n\nexport const hasEvents = (survey: Survey): boolean => {\n return survey.conditions?.events?.values?.length != undefined && survey.conditions?.events?.values?.length > 0\n}\n\nexport const canActivateRepeatedly = (survey: Survey): boolean => {\n return !!(survey.conditions?.events?.repeatedActivation && hasEvents(survey))\n}\n\n/**\n * getSurveySeen checks local storage for the surveySeen Key a\n * and overrides this value if the survey can be repeatedly activated by its events.\n * @param survey\n */\nexport const getSurveySeen = (survey: Survey): boolean => {\n const surveySeen = localStorage.getItem(getSurveySeenKey(survey))\n if (surveySeen) {\n // if a survey has already been seen,\n // we will override it with the event repeated activation value.\n return !canActivateRepeatedly(survey)\n }\n\n return false\n}\n\nexport const getSurveySeenKey = (survey: Survey): string => {\n let surveySeenKey = `seenSurvey_${survey.id}`\n if (survey.current_iteration && survey.current_iteration > 0) {\n surveySeenKey = `seenSurvey_${survey.id}_${survey.current_iteration}`\n }\n\n return surveySeenKey\n}\n\nconst getSurveyInteractionProperty = (survey: Survey, action: string): string => {\n let surveyProperty = `$survey_${action}/${survey.id}`\n if (survey.current_iteration && survey.current_iteration > 0) {\n surveyProperty = `$survey_${action}/${survey.id}/${survey.current_iteration}`\n }\n\n return surveyProperty\n}\n\nexport const SurveyContext = createContext<{\n isPreviewMode: boolean\n previewPageIndex: number | undefined\n handleCloseSurveyPopup: () => void\n isPopup: boolean\n}>({\n isPreviewMode: false,\n previewPageIndex: 0,\n handleCloseSurveyPopup: () => {},\n isPopup: true,\n})\n\ninterface RenderProps {\n component: VNode<{ className: string }>\n children: string\n renderAsHtml?: boolean\n style?: React.CSSProperties\n}\n\nexport const renderChildrenAsTextOrHtml = ({ component, children, renderAsHtml, style }: RenderProps) => {\n return renderAsHtml\n ? cloneElement(component, {\n dangerouslySetInnerHTML: { __html: children },\n style,\n })\n : cloneElement(component, {\n children,\n style,\n })\n}\n"]}
|