@posthog/browser-common 0.9.4 → 0.9.6
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/client.d.ts +6 -0
- package/dist/config.js +1 -1
- package/dist/config.mjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +58 -10
- package/dist/index.mjs +1 -0
- package/dist/survey-action-matcher.d.ts +27 -0
- package/dist/survey-action-matcher.js +169 -0
- package/dist/survey-action-matcher.mjs +131 -0
- package/dist/survey-constants.d.ts +86 -0
- package/dist/survey-constants.js +144 -0
- package/dist/survey-constants.mjs +76 -0
- package/dist/survey-event-host.d.ts +15 -0
- package/dist/survey-event-host.js +18 -0
- package/dist/survey-event-host.mjs +1 -0
- package/dist/survey-event-receiver-base.d.ts +180 -0
- package/dist/survey-event-receiver-base.js +354 -0
- package/dist/survey-event-receiver-base.mjs +316 -0
- package/dist/survey-event-receiver.d.ts +36 -0
- package/dist/survey-event-receiver.js +133 -0
- package/dist/survey-event-receiver.mjs +95 -0
- package/dist/survey-render-context.d.ts +13 -0
- package/dist/survey-render-context.js +45 -0
- package/dist/survey-render-context.mjs +7 -0
- package/dist/surveys/components/BottomSection.d.ts +12 -0
- package/dist/surveys/components/BottomSection.js +82 -0
- package/dist/surveys/components/BottomSection.mjs +44 -0
- package/dist/surveys/components/ConfirmationMessage.d.ts +10 -0
- package/dist/surveys/components/ConfirmationMessage.js +92 -0
- package/dist/surveys/components/ConfirmationMessage.mjs +54 -0
- package/dist/surveys/components/IntroScreen.d.ts +10 -0
- package/dist/surveys/components/IntroScreen.js +78 -0
- package/dist/surveys/components/IntroScreen.mjs +40 -0
- package/dist/surveys/components/PostHogLogo.d.ts +5 -0
- package/dist/surveys/components/PostHogLogo.js +54 -0
- package/dist/surveys/components/PostHogLogo.mjs +16 -0
- package/dist/surveys/components/QuestionHeader.d.ts +10 -0
- package/dist/surveys/components/QuestionHeader.js +82 -0
- package/dist/surveys/components/QuestionHeader.mjs +41 -0
- package/dist/surveys/components/QuestionTypes.d.ts +31 -0
- package/dist/surveys/components/QuestionTypes.js +519 -0
- package/dist/surveys/components/QuestionTypes.mjs +469 -0
- package/dist/surveys/icons.d.ts +12 -0
- package/dist/surveys/icons.js +212 -0
- package/dist/surveys/icons.mjs +147 -0
- package/dist/surveys/survey-branching.d.ts +12 -0
- package/dist/surveys/survey-branching.js +101 -0
- package/dist/surveys/survey-branching.mjs +60 -0
- package/dist/surveys/survey-styles.d.ts +1 -0
- package/dist/surveys/survey-styles.js +40 -0
- package/dist/surveys/survey-styles.mjs +2 -0
- package/dist/surveys/survey-translations.d.ts +22 -0
- package/dist/surveys/survey-translations.js +68 -0
- package/dist/surveys/survey-translations.mjs +27 -0
- package/dist/surveys/survey-url-prefill.d.ts +36 -0
- package/dist/surveys/survey-url-prefill.js +162 -0
- package/dist/surveys/survey-url-prefill.mjs +118 -0
- package/dist/surveys/surveys-extension-utils.d.ts +133 -0
- package/dist/surveys/surveys-extension-utils.js +739 -0
- package/dist/surveys/surveys-extension-utils.mjs +608 -0
- package/dist/surveys-config.d.ts +60 -0
- package/dist/surveys-config.js +68 -0
- package/dist/surveys-config.mjs +9 -0
- package/dist/surveys-renderer.d.ts +248 -0
- package/dist/surveys-renderer.js +1299 -0
- package/dist/surveys-renderer.mjs +1230 -0
- package/dist/surveys.d.ts +117 -0
- package/dist/surveys.js +566 -0
- package/dist/surveys.mjs +495 -0
- package/dist/types/surveys.d.ts +83 -86
- package/dist/types/surveys.js +1 -127
- package/dist/types/surveys.mjs +1 -76
- package/dist/utils/autocapture-utils.js +8 -9
- package/dist/utils/autocapture-utils.mjs +8 -9
- package/dist/utils/event-utils.js +1 -0
- package/dist/utils/event-utils.mjs +1 -0
- package/dist/utils/matcher-utils.d.ts +1 -1
- package/dist/utils/matcher-utils.js +13 -10
- package/dist/utils/matcher-utils.mjs +10 -7
- package/dist/utils/survey-utils.d.ts +16 -0
- package/dist/utils/survey-utils.js +121 -0
- package/dist/utils/survey-utils.mjs +38 -0
- package/dist/utils/url-targeting-utils.d.ts +3 -1
- package/dist/utils/url-targeting-utils.js +1 -2
- package/dist/utils/url-targeting-utils.mjs +1 -2
- package/dist/utils/uuidv7.js +4 -4
- package/dist/utils/uuidv7.mjs +4 -4
- package/package.json +97 -3
|
@@ -0,0 +1,739 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
SurveyContext: ()=>SurveyContext,
|
|
32
|
+
addSurveyCSSVariablesToElement: ()=>addSurveyCSSVariablesToElement,
|
|
33
|
+
canActivateRepeatedly: ()=>canActivateRepeatedly,
|
|
34
|
+
clearAllInMemoryInProgressSurveyState: ()=>clearAllInMemoryInProgressSurveyState,
|
|
35
|
+
clearInProgressSurveyState: ()=>clearInProgressSurveyState,
|
|
36
|
+
defaultSurveyAppearance: ()=>defaultSurveyAppearance,
|
|
37
|
+
dismissedSurveyEvent: ()=>dismissedSurveyEvent,
|
|
38
|
+
doesSurveyDeviceTypesMatch: ()=>doesSurveyDeviceTypesMatch,
|
|
39
|
+
doesSurveyMatchSelector: ()=>doesSurveyMatchSelector,
|
|
40
|
+
doesSurveyUrlMatch: ()=>doesSurveyUrlMatch,
|
|
41
|
+
getContrastingTextColor: ()=>getContrastingTextColor,
|
|
42
|
+
getDisplayOrderChoices: ()=>surveys_namespaceObject.getDisplayOrderChoices,
|
|
43
|
+
getDisplayOrderQuestions: ()=>getDisplayOrderQuestions,
|
|
44
|
+
getFontFamily: ()=>getFontFamily,
|
|
45
|
+
getInProgressSurveyState: ()=>getInProgressSurveyState,
|
|
46
|
+
getPopoverPosition: ()=>getPopoverPosition,
|
|
47
|
+
getQuestionOrder: ()=>getQuestionOrder,
|
|
48
|
+
getSurveyContainerClass: ()=>getSurveyContainerClass,
|
|
49
|
+
getSurveyResponseKey: ()=>surveys_namespaceObject.getSurveyResponseKey,
|
|
50
|
+
getSurveySeen: ()=>getSurveySeen,
|
|
51
|
+
getSurveyStylesheet: ()=>getSurveyStylesheet,
|
|
52
|
+
hasWaitPeriodPassed: ()=>hasWaitPeriodPassed,
|
|
53
|
+
hex2rgb: ()=>hex2rgb,
|
|
54
|
+
hexToRgba: ()=>hexToRgba,
|
|
55
|
+
isSurveyInProgress: ()=>isSurveyInProgress,
|
|
56
|
+
renderChildrenAsTextOrHtml: ()=>renderChildrenAsTextOrHtml,
|
|
57
|
+
retrieveSurveyShadow: ()=>retrieveSurveyShadow,
|
|
58
|
+
sendSurveyAbandonedEvent: ()=>sendSurveyAbandonedEvent,
|
|
59
|
+
sendSurveyEvent: ()=>sendSurveyEvent,
|
|
60
|
+
setInProgressSurveyState: ()=>setInProgressSurveyState,
|
|
61
|
+
shuffle: ()=>surveys_namespaceObject.shuffle,
|
|
62
|
+
useSurveyContext: ()=>useSurveyContext
|
|
63
|
+
});
|
|
64
|
+
const external_extension_tokens_js_namespaceObject = require("../extension-tokens.js");
|
|
65
|
+
const url_targeting_utils_js_namespaceObject = require("../utils/url-targeting-utils.js");
|
|
66
|
+
const external_survey_render_context_js_namespaceObject = require("../survey-render-context.js");
|
|
67
|
+
const external_preact_namespaceObject = require("preact");
|
|
68
|
+
const external_survey_constants_js_namespaceObject = require("../survey-constants.js");
|
|
69
|
+
const survey_utils_js_namespaceObject = require("../utils/survey-utils.js");
|
|
70
|
+
const core_namespaceObject = require("@posthog/core");
|
|
71
|
+
const surveys_namespaceObject = require("@posthog/core/surveys");
|
|
72
|
+
const stylesheet_loader_js_namespaceObject = require("../utils/stylesheet-loader.js");
|
|
73
|
+
const external_survey_styles_js_namespaceObject = require("./survey-styles.js");
|
|
74
|
+
const hooks_namespaceObject = require("preact/hooks");
|
|
75
|
+
const matcher_utils_js_namespaceObject = require("../utils/matcher-utils.js");
|
|
76
|
+
const Z_INDEX_SURVEYS = 2147483645;
|
|
77
|
+
function getFontFamily(fontFamily) {
|
|
78
|
+
if ('inherit' === fontFamily) return 'inherit';
|
|
79
|
+
const defaultFontStack = 'BlinkMacSystemFont, "Inter", "Segoe UI", "Roboto", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';
|
|
80
|
+
return fontFamily ? `${fontFamily}, ${defaultFontStack}` : `-apple-system, ${defaultFontStack}`;
|
|
81
|
+
}
|
|
82
|
+
const BLACK_TEXT_COLOR = '#020617';
|
|
83
|
+
const defaultSurveyAppearance = {
|
|
84
|
+
fontFamily: 'inherit',
|
|
85
|
+
backgroundColor: '#eeeded',
|
|
86
|
+
submitButtonColor: 'black',
|
|
87
|
+
submitButtonTextColor: 'white',
|
|
88
|
+
ratingButtonColor: 'white',
|
|
89
|
+
ratingButtonActiveColor: 'black',
|
|
90
|
+
borderColor: '#c9c6c6',
|
|
91
|
+
whiteLabel: false,
|
|
92
|
+
displayThankYouMessage: true,
|
|
93
|
+
thankYouMessageHeader: 'Thank you for your feedback!',
|
|
94
|
+
position: external_survey_constants_js_namespaceObject.SurveyPosition.Right,
|
|
95
|
+
widgetType: external_survey_constants_js_namespaceObject.SurveyWidgetType.Tab,
|
|
96
|
+
widgetLabel: 'Feedback',
|
|
97
|
+
widgetColor: 'black',
|
|
98
|
+
zIndex: String(Z_INDEX_SURVEYS),
|
|
99
|
+
disabledButtonOpacity: '0.6',
|
|
100
|
+
maxWidth: '300px',
|
|
101
|
+
textSubtleColor: '#939393',
|
|
102
|
+
boxPadding: '20px 24px',
|
|
103
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
|
|
104
|
+
borderRadius: '10px',
|
|
105
|
+
shuffleQuestions: false,
|
|
106
|
+
outlineColor: 'rgba(59, 130, 246, 0.8)',
|
|
107
|
+
inputBackground: 'white',
|
|
108
|
+
inputTextColor: BLACK_TEXT_COLOR,
|
|
109
|
+
scrollbarThumbColor: 'var(--ph-survey-border-color)',
|
|
110
|
+
scrollbarTrackColor: 'var(--ph-survey-background-color)'
|
|
111
|
+
};
|
|
112
|
+
const BOTTOM_BORDER_SURVEY_POSITIONS = [
|
|
113
|
+
external_survey_constants_js_namespaceObject.SurveyPosition.Center,
|
|
114
|
+
external_survey_constants_js_namespaceObject.SurveyPosition.Left,
|
|
115
|
+
external_survey_constants_js_namespaceObject.SurveyPosition.Right
|
|
116
|
+
];
|
|
117
|
+
const addSurveyCSSVariablesToElement = (element, type, appearance)=>{
|
|
118
|
+
const effectiveAppearance = {
|
|
119
|
+
...defaultSurveyAppearance,
|
|
120
|
+
...appearance
|
|
121
|
+
};
|
|
122
|
+
const hostStyle = element.style;
|
|
123
|
+
const surveyHasBottomBorder = !BOTTOM_BORDER_SURVEY_POSITIONS.includes(effectiveAppearance.position) || type === external_survey_constants_js_namespaceObject.SurveyType.Widget && appearance?.widgetType === external_survey_constants_js_namespaceObject.SurveyWidgetType.Tab;
|
|
124
|
+
hostStyle.setProperty('--ph-survey-font-family', getFontFamily(effectiveAppearance.fontFamily));
|
|
125
|
+
hostStyle.setProperty('--ph-survey-box-padding', effectiveAppearance.boxPadding);
|
|
126
|
+
hostStyle.setProperty('--ph-survey-max-width', effectiveAppearance.maxWidth);
|
|
127
|
+
hostStyle.setProperty('--ph-survey-z-index', effectiveAppearance.zIndex);
|
|
128
|
+
hostStyle.setProperty('--ph-survey-border-color', effectiveAppearance.borderColor);
|
|
129
|
+
if (surveyHasBottomBorder) {
|
|
130
|
+
hostStyle.setProperty('--ph-survey-border-radius', effectiveAppearance.borderRadius);
|
|
131
|
+
hostStyle.setProperty('--ph-survey-border-bottom', '1.5px solid var(--ph-survey-border-color)');
|
|
132
|
+
} else {
|
|
133
|
+
hostStyle.setProperty('--ph-survey-border-bottom', 'none');
|
|
134
|
+
hostStyle.setProperty('--ph-survey-border-radius', `${effectiveAppearance.borderRadius} ${effectiveAppearance.borderRadius} 0 0`);
|
|
135
|
+
}
|
|
136
|
+
hostStyle.setProperty('--ph-survey-background-color', effectiveAppearance.backgroundColor);
|
|
137
|
+
hostStyle.setProperty('--ph-survey-box-shadow', effectiveAppearance.boxShadow);
|
|
138
|
+
hostStyle.setProperty('--ph-survey-disabled-button-opacity', effectiveAppearance.disabledButtonOpacity);
|
|
139
|
+
hostStyle.setProperty('--ph-survey-submit-button-color', effectiveAppearance.submitButtonColor);
|
|
140
|
+
hostStyle.setProperty('--ph-survey-submit-button-text-color', appearance?.submitButtonTextColor || getContrastingTextColor(effectiveAppearance.submitButtonColor));
|
|
141
|
+
hostStyle.setProperty('--ph-survey-rating-bg-color', effectiveAppearance.ratingButtonColor);
|
|
142
|
+
hostStyle.setProperty('--ph-survey-rating-active-bg-color', effectiveAppearance.ratingButtonActiveColor);
|
|
143
|
+
hostStyle.setProperty('--ph-survey-rating-active-text-color', getContrastingTextColor(effectiveAppearance.ratingButtonActiveColor));
|
|
144
|
+
hostStyle.setProperty('--ph-survey-text-primary-color', appearance?.textColor || getContrastingTextColor(effectiveAppearance.backgroundColor));
|
|
145
|
+
hostStyle.setProperty('--ph-survey-text-subtle-color', effectiveAppearance.textSubtleColor);
|
|
146
|
+
hostStyle.setProperty('--ph-widget-color', effectiveAppearance.widgetColor);
|
|
147
|
+
hostStyle.setProperty('--ph-widget-text-color', getContrastingTextColor(effectiveAppearance.widgetColor));
|
|
148
|
+
hostStyle.setProperty('--ph-widget-z-index', effectiveAppearance.zIndex);
|
|
149
|
+
const userInputBg = appearance?.inputBackground || appearance?.inputBackgroundColor;
|
|
150
|
+
let inputBgColor = userInputBg || effectiveAppearance.inputBackground;
|
|
151
|
+
if (!userInputBg && 'white' === effectiveAppearance.backgroundColor) inputBgColor = '#f8f8f8';
|
|
152
|
+
hostStyle.setProperty('--ph-survey-input-background', inputBgColor);
|
|
153
|
+
const inputTextColor = appearance?.inputTextColor || getContrastingTextColor(inputBgColor);
|
|
154
|
+
hostStyle.setProperty('--ph-survey-input-text-color', inputTextColor);
|
|
155
|
+
hostStyle.setProperty('--ph-survey-rating-text-color', inputTextColor);
|
|
156
|
+
hostStyle.setProperty('--ph-survey-scrollbar-thumb-color', effectiveAppearance.scrollbarThumbColor);
|
|
157
|
+
hostStyle.setProperty('--ph-survey-scrollbar-track-color', effectiveAppearance.scrollbarTrackColor);
|
|
158
|
+
hostStyle.setProperty('--ph-survey-outline-color', effectiveAppearance.outlineColor);
|
|
159
|
+
};
|
|
160
|
+
function nameToHex(name) {
|
|
161
|
+
return ({
|
|
162
|
+
aliceblue: '#f0f8ff',
|
|
163
|
+
antiquewhite: '#faebd7',
|
|
164
|
+
aqua: '#00ffff',
|
|
165
|
+
aquamarine: '#7fffd4',
|
|
166
|
+
azure: '#f0ffff',
|
|
167
|
+
beige: '#f5f5dc',
|
|
168
|
+
bisque: '#ffe4c4',
|
|
169
|
+
black: '#000000',
|
|
170
|
+
blanchedalmond: '#ffebcd',
|
|
171
|
+
blue: '#0000ff',
|
|
172
|
+
blueviolet: '#8a2be2',
|
|
173
|
+
brown: '#a52a2a',
|
|
174
|
+
burlywood: '#deb887',
|
|
175
|
+
cadetblue: '#5f9ea0',
|
|
176
|
+
chartreuse: '#7fff00',
|
|
177
|
+
chocolate: '#d2691e',
|
|
178
|
+
coral: '#ff7f50',
|
|
179
|
+
cornflowerblue: '#6495ed',
|
|
180
|
+
cornsilk: '#fff8dc',
|
|
181
|
+
crimson: '#dc143c',
|
|
182
|
+
cyan: '#00ffff',
|
|
183
|
+
darkblue: '#00008b',
|
|
184
|
+
darkcyan: '#008b8b',
|
|
185
|
+
darkgoldenrod: '#b8860b',
|
|
186
|
+
darkgray: '#a9a9a9',
|
|
187
|
+
darkgreen: '#006400',
|
|
188
|
+
darkkhaki: '#bdb76b',
|
|
189
|
+
darkmagenta: '#8b008b',
|
|
190
|
+
darkolivegreen: '#556b2f',
|
|
191
|
+
darkorange: '#ff8c00',
|
|
192
|
+
darkorchid: '#9932cc',
|
|
193
|
+
darkred: '#8b0000',
|
|
194
|
+
darksalmon: '#e9967a',
|
|
195
|
+
darkseagreen: '#8fbc8f',
|
|
196
|
+
darkslateblue: '#483d8b',
|
|
197
|
+
darkslategray: '#2f4f4f',
|
|
198
|
+
darkturquoise: '#00ced1',
|
|
199
|
+
darkviolet: '#9400d3',
|
|
200
|
+
deeppink: '#ff1493',
|
|
201
|
+
deepskyblue: '#00bfff',
|
|
202
|
+
dimgray: '#696969',
|
|
203
|
+
dodgerblue: '#1e90ff',
|
|
204
|
+
firebrick: '#b22222',
|
|
205
|
+
floralwhite: '#fffaf0',
|
|
206
|
+
forestgreen: '#228b22',
|
|
207
|
+
fuchsia: '#ff00ff',
|
|
208
|
+
gainsboro: '#dcdcdc',
|
|
209
|
+
ghostwhite: '#f8f8ff',
|
|
210
|
+
gold: '#ffd700',
|
|
211
|
+
goldenrod: '#daa520',
|
|
212
|
+
gray: '#808080',
|
|
213
|
+
green: '#008000',
|
|
214
|
+
greenyellow: '#adff2f',
|
|
215
|
+
honeydew: '#f0fff0',
|
|
216
|
+
hotpink: '#ff69b4',
|
|
217
|
+
'indianred ': '#cd5c5c',
|
|
218
|
+
indigo: '#4b0082',
|
|
219
|
+
ivory: '#fffff0',
|
|
220
|
+
khaki: '#f0e68c',
|
|
221
|
+
lavender: '#e6e6fa',
|
|
222
|
+
lavenderblush: '#fff0f5',
|
|
223
|
+
lawngreen: '#7cfc00',
|
|
224
|
+
lemonchiffon: '#fffacd',
|
|
225
|
+
lightblue: '#add8e6',
|
|
226
|
+
lightcoral: '#f08080',
|
|
227
|
+
lightcyan: '#e0ffff',
|
|
228
|
+
lightgoldenrodyellow: '#fafad2',
|
|
229
|
+
lightgrey: '#d3d3d3',
|
|
230
|
+
lightgreen: '#90ee90',
|
|
231
|
+
lightpink: '#ffb6c1',
|
|
232
|
+
lightsalmon: '#ffa07a',
|
|
233
|
+
lightseagreen: '#20b2aa',
|
|
234
|
+
lightskyblue: '#87cefa',
|
|
235
|
+
lightslategray: '#778899',
|
|
236
|
+
lightsteelblue: '#b0c4de',
|
|
237
|
+
lightyellow: '#ffffe0',
|
|
238
|
+
lime: '#00ff00',
|
|
239
|
+
limegreen: '#32cd32',
|
|
240
|
+
linen: '#faf0e6',
|
|
241
|
+
magenta: '#ff00ff',
|
|
242
|
+
maroon: '#800000',
|
|
243
|
+
mediumaquamarine: '#66cdaa',
|
|
244
|
+
mediumblue: '#0000cd',
|
|
245
|
+
mediumorchid: '#ba55d3',
|
|
246
|
+
mediumpurple: '#9370d8',
|
|
247
|
+
mediumseagreen: '#3cb371',
|
|
248
|
+
mediumslateblue: '#7b68ee',
|
|
249
|
+
mediumspringgreen: '#00fa9a',
|
|
250
|
+
mediumturquoise: '#48d1cc',
|
|
251
|
+
mediumvioletred: '#c71585',
|
|
252
|
+
midnightblue: '#191970',
|
|
253
|
+
mintcream: '#f5fffa',
|
|
254
|
+
mistyrose: '#ffe4e1',
|
|
255
|
+
moccasin: '#ffe4b5',
|
|
256
|
+
navajowhite: '#ffdead',
|
|
257
|
+
navy: '#000080',
|
|
258
|
+
oldlace: '#fdf5e6',
|
|
259
|
+
olive: '#808000',
|
|
260
|
+
olivedrab: '#6b8e23',
|
|
261
|
+
orange: '#ffa500',
|
|
262
|
+
orangered: '#ff4500',
|
|
263
|
+
orchid: '#da70d6',
|
|
264
|
+
palegoldenrod: '#eee8aa',
|
|
265
|
+
palegreen: '#98fb98',
|
|
266
|
+
paleturquoise: '#afeeee',
|
|
267
|
+
palevioletred: '#d87093',
|
|
268
|
+
papayawhip: '#ffefd5',
|
|
269
|
+
peachpuff: '#ffdab9',
|
|
270
|
+
peru: '#cd853f',
|
|
271
|
+
pink: '#ffc0cb',
|
|
272
|
+
plum: '#dda0dd',
|
|
273
|
+
powderblue: '#b0e0e6',
|
|
274
|
+
purple: '#800080',
|
|
275
|
+
red: '#ff0000',
|
|
276
|
+
rosybrown: '#bc8f8f',
|
|
277
|
+
royalblue: '#4169e1',
|
|
278
|
+
saddlebrown: '#8b4513',
|
|
279
|
+
salmon: '#fa8072',
|
|
280
|
+
sandybrown: '#f4a460',
|
|
281
|
+
seagreen: '#2e8b57',
|
|
282
|
+
seashell: '#fff5ee',
|
|
283
|
+
sienna: '#a0522d',
|
|
284
|
+
silver: '#c0c0c0',
|
|
285
|
+
skyblue: '#87ceeb',
|
|
286
|
+
slateblue: '#6a5acd',
|
|
287
|
+
slategray: '#708090',
|
|
288
|
+
snow: '#fffafa',
|
|
289
|
+
springgreen: '#00ff7f',
|
|
290
|
+
steelblue: '#4682b4',
|
|
291
|
+
tan: '#d2b48c',
|
|
292
|
+
teal: '#008080',
|
|
293
|
+
thistle: '#d8bfd8',
|
|
294
|
+
tomato: '#ff6347',
|
|
295
|
+
turquoise: '#40e0d0',
|
|
296
|
+
violet: '#ee82ee',
|
|
297
|
+
wheat: '#f5deb3',
|
|
298
|
+
white: '#ffffff',
|
|
299
|
+
whitesmoke: '#f5f5f5',
|
|
300
|
+
yellow: '#ffff00',
|
|
301
|
+
yellowgreen: '#9acd32'
|
|
302
|
+
})[name.toLowerCase()];
|
|
303
|
+
}
|
|
304
|
+
function hex2rgb(c) {
|
|
305
|
+
if (c.startsWith('#')) {
|
|
306
|
+
let hexColor = c.replace(/^#/, '');
|
|
307
|
+
if (/^[0-9A-Fa-f]{3}$/.test(hexColor)) hexColor = hexColor[0] + hexColor[0] + hexColor[1] + hexColor[1] + hexColor[2] + hexColor[2];
|
|
308
|
+
if (!/^[0-9A-Fa-f]{6}$/.test(hexColor)) return 'rgb(255, 255, 255)';
|
|
309
|
+
const r = parseInt(hexColor.slice(0, 2), 16);
|
|
310
|
+
const g = parseInt(hexColor.slice(2, 4), 16);
|
|
311
|
+
const b = parseInt(hexColor.slice(4, 6), 16);
|
|
312
|
+
return `rgb(${r},${g},${b})`;
|
|
313
|
+
}
|
|
314
|
+
return 'rgb(255, 255, 255)';
|
|
315
|
+
}
|
|
316
|
+
function hexToRgba(hex, opacity) {
|
|
317
|
+
const rgb = hex2rgb(hex);
|
|
318
|
+
const match = rgb.match(/^rgb\((\d+),(\d+),(\d+)\)$/);
|
|
319
|
+
if (!match) return hex;
|
|
320
|
+
return `rgba(${match[1]}, ${match[2]}, ${match[3]}, ${opacity})`;
|
|
321
|
+
}
|
|
322
|
+
function getContrastingTextColor(color = defaultSurveyAppearance.backgroundColor) {
|
|
323
|
+
let rgb;
|
|
324
|
+
if ('#' === color[0]) rgb = hex2rgb(color);
|
|
325
|
+
if (color.startsWith('rgb')) rgb = color;
|
|
326
|
+
const nameColorToHex = nameToHex(color);
|
|
327
|
+
if (nameColorToHex) rgb = hex2rgb(nameColorToHex);
|
|
328
|
+
if (!rgb) return BLACK_TEXT_COLOR;
|
|
329
|
+
const colorMatch = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/);
|
|
330
|
+
if (colorMatch) {
|
|
331
|
+
const r = parseInt(colorMatch[1]);
|
|
332
|
+
const g = parseInt(colorMatch[2]);
|
|
333
|
+
const b = parseInt(colorMatch[3]);
|
|
334
|
+
const hsp = Math.sqrt(r * r * 0.299 + g * g * 0.587 + b * b * 0.114);
|
|
335
|
+
return hsp > 127.5 ? BLACK_TEXT_COLOR : 'white';
|
|
336
|
+
}
|
|
337
|
+
return BLACK_TEXT_COLOR;
|
|
338
|
+
}
|
|
339
|
+
function getSurveyStylesheet(posthog) {
|
|
340
|
+
const stylesheet = (0, stylesheet_loader_js_namespaceObject.prepareStylesheet)(document, 'string' == typeof external_survey_styles_js_namespaceObject.surveyStyles ? external_survey_styles_js_namespaceObject.surveyStyles : '', posthog?.config.prepareStylesheet);
|
|
341
|
+
stylesheet?.setAttribute('data-ph-survey-style', 'true');
|
|
342
|
+
return stylesheet;
|
|
343
|
+
}
|
|
344
|
+
const retrieveSurveyShadow = (survey, posthog, element)=>{
|
|
345
|
+
const widgetClassName = getSurveyContainerClass(survey);
|
|
346
|
+
const existingDiv = document.querySelector(`.${widgetClassName}`);
|
|
347
|
+
if (existingDiv && existingDiv.shadowRoot) return {
|
|
348
|
+
shadow: existingDiv.shadowRoot,
|
|
349
|
+
isNewlyCreated: false
|
|
350
|
+
};
|
|
351
|
+
const div = document.createElement('div');
|
|
352
|
+
addSurveyCSSVariablesToElement(div, survey.type, survey.appearance);
|
|
353
|
+
div.className = widgetClassName;
|
|
354
|
+
const shadow = div.attachShadow({
|
|
355
|
+
mode: 'open'
|
|
356
|
+
});
|
|
357
|
+
const stylesheet = getSurveyStylesheet(posthog);
|
|
358
|
+
if (stylesheet) {
|
|
359
|
+
const existingStylesheet = shadow.querySelector('style');
|
|
360
|
+
if (existingStylesheet) shadow.removeChild(existingStylesheet);
|
|
361
|
+
shadow.appendChild(stylesheet);
|
|
362
|
+
}
|
|
363
|
+
(element ? element : document.body).appendChild(div);
|
|
364
|
+
return {
|
|
365
|
+
shadow,
|
|
366
|
+
isNewlyCreated: true
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
const setSurveySeen = (survey)=>{
|
|
370
|
+
try {
|
|
371
|
+
const key = (0, survey_utils_js_namespaceObject.getSurveySeenKey)(survey);
|
|
372
|
+
if (!localStorage.getItem(key)) localStorage.setItem(key, 'true');
|
|
373
|
+
} catch (error) {
|
|
374
|
+
survey_utils_js_namespaceObject.SURVEY_LOGGER.error('Failed to persist survey seen state', error);
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
const sendSurveyEvent = ({ responses, survey, surveySubmissionId, posthog, isSurveyCompleted, properties, surveyLanguage, questionSnapshots })=>{
|
|
378
|
+
if (!posthog) return void survey_utils_js_namespaceObject.SURVEY_LOGGER.error('[survey sent] event not captured, PostHog instance not found.');
|
|
379
|
+
if (!posthog.client?.canCapture) return;
|
|
380
|
+
setSurveySeen(survey);
|
|
381
|
+
if (isSurveyCompleted) clearInProgressSurveyState(survey);
|
|
382
|
+
posthog.client?.capture(external_survey_constants_js_namespaceObject.SurveyEventName.SENT, {
|
|
383
|
+
[external_survey_constants_js_namespaceObject.SurveyEventProperties.SURVEY_NAME]: survey.name,
|
|
384
|
+
[external_survey_constants_js_namespaceObject.SurveyEventProperties.SURVEY_ID]: survey.id,
|
|
385
|
+
[external_survey_constants_js_namespaceObject.SurveyEventProperties.SURVEY_ITERATION]: survey.current_iteration,
|
|
386
|
+
[external_survey_constants_js_namespaceObject.SurveyEventProperties.SURVEY_ITERATION_START_DATE]: survey.current_iteration_start_date,
|
|
387
|
+
sessionRecordingUrl: (0, external_survey_render_context_js_namespaceObject.getSurveyReplayUrl)(posthog),
|
|
388
|
+
...(0, surveys_namespaceObject.buildSurveyResponseEventProperties)({
|
|
389
|
+
event: 'sent',
|
|
390
|
+
survey,
|
|
391
|
+
responses,
|
|
392
|
+
submissionId: surveySubmissionId,
|
|
393
|
+
completed: isSurveyCompleted,
|
|
394
|
+
...!(0, core_namespaceObject.isUndefined)(surveyLanguage) && {
|
|
395
|
+
surveyLanguage
|
|
396
|
+
},
|
|
397
|
+
...!(0, core_namespaceObject.isUndefined)(questionSnapshots) && {
|
|
398
|
+
questionSnapshots
|
|
399
|
+
}
|
|
400
|
+
}),
|
|
401
|
+
...properties,
|
|
402
|
+
$set: {
|
|
403
|
+
[(0, survey_utils_js_namespaceObject.getSurveyInteractionProperty)(survey, 'responded')]: true
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
if (isSurveyCompleted) {
|
|
407
|
+
window.dispatchEvent(new CustomEvent('PHSurveySent', {
|
|
408
|
+
detail: {
|
|
409
|
+
surveyId: survey.id
|
|
410
|
+
}
|
|
411
|
+
}));
|
|
412
|
+
posthog.client?.getExtension(external_extension_tokens_js_namespaceObject.FeatureFlagsCommonExtension)?.reloadFeatureFlags();
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
const _buildSurveyEventProperties = (event, survey, inProgressSurvey, posthog)=>({
|
|
416
|
+
[external_survey_constants_js_namespaceObject.SurveyEventProperties.SURVEY_NAME]: survey.name,
|
|
417
|
+
[external_survey_constants_js_namespaceObject.SurveyEventProperties.SURVEY_ID]: survey.id,
|
|
418
|
+
[external_survey_constants_js_namespaceObject.SurveyEventProperties.SURVEY_ITERATION]: survey.current_iteration,
|
|
419
|
+
[external_survey_constants_js_namespaceObject.SurveyEventProperties.SURVEY_ITERATION_START_DATE]: survey.current_iteration_start_date,
|
|
420
|
+
sessionRecordingUrl: (0, external_survey_render_context_js_namespaceObject.getSurveyReplayUrl)(posthog),
|
|
421
|
+
...(0, surveys_namespaceObject.buildSurveyResponseEventProperties)({
|
|
422
|
+
event,
|
|
423
|
+
survey,
|
|
424
|
+
...!(0, core_namespaceObject.isUndefined)(inProgressSurvey?.responses) && {
|
|
425
|
+
responses: inProgressSurvey.responses
|
|
426
|
+
},
|
|
427
|
+
...!(0, core_namespaceObject.isUndefined)(inProgressSurvey?.surveySubmissionId) && {
|
|
428
|
+
submissionId: inProgressSurvey.surveySubmissionId
|
|
429
|
+
},
|
|
430
|
+
...!(0, core_namespaceObject.isUndefined)(inProgressSurvey?.surveyLanguage) && {
|
|
431
|
+
surveyLanguage: inProgressSurvey.surveyLanguage
|
|
432
|
+
},
|
|
433
|
+
...!(0, core_namespaceObject.isUndefined)(inProgressSurvey?.questionSnapshots) && {
|
|
434
|
+
questionSnapshots: inProgressSurvey.questionSnapshots
|
|
435
|
+
}
|
|
436
|
+
})
|
|
437
|
+
});
|
|
438
|
+
const dismissedSurveyEvent = (survey, posthog, readOnly, surveyLanguage)=>{
|
|
439
|
+
if (!posthog) return void survey_utils_js_namespaceObject.SURVEY_LOGGER.error('[survey dismissed] event not captured, PostHog instance not found.');
|
|
440
|
+
if (readOnly) return;
|
|
441
|
+
const inProgressSurvey = getInProgressSurveyState(survey);
|
|
442
|
+
const effectiveLanguage = inProgressSurvey ? inProgressSurvey.surveyLanguage : surveyLanguage;
|
|
443
|
+
const properties = {
|
|
444
|
+
..._buildSurveyEventProperties('dismissed', survey, inProgressSurvey, posthog),
|
|
445
|
+
...effectiveLanguage && {
|
|
446
|
+
[external_survey_constants_js_namespaceObject.SurveyEventProperties.SURVEY_LANGUAGE]: effectiveLanguage
|
|
447
|
+
},
|
|
448
|
+
$set: {
|
|
449
|
+
[(0, survey_utils_js_namespaceObject.getSurveyInteractionProperty)(survey, 'dismissed')]: true
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
clearInProgressSurveyState(survey);
|
|
453
|
+
setSurveySeen(survey);
|
|
454
|
+
posthog.client?.capture(external_survey_constants_js_namespaceObject.SurveyEventName.DISMISSED, properties);
|
|
455
|
+
window.dispatchEvent(new CustomEvent('PHSurveyClosed', {
|
|
456
|
+
detail: {
|
|
457
|
+
surveyId: survey.id
|
|
458
|
+
}
|
|
459
|
+
}));
|
|
460
|
+
};
|
|
461
|
+
const sendSurveyAbandonedEvent = (survey, posthog)=>{
|
|
462
|
+
if (!posthog) return void survey_utils_js_namespaceObject.SURVEY_LOGGER.error('[survey abandoned] event not captured, PostHog instance not found.');
|
|
463
|
+
if (!posthog.client?.canCapture) return;
|
|
464
|
+
const abandonedKey = (0, survey_utils_js_namespaceObject.getSurveyAbandonedKey)(survey);
|
|
465
|
+
try {
|
|
466
|
+
if ('true' === localStorage.getItem(abandonedKey)) return;
|
|
467
|
+
} catch {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
const inProgressSurvey = getInProgressSurveyState(survey);
|
|
471
|
+
if (!inProgressSurvey) return;
|
|
472
|
+
try {
|
|
473
|
+
localStorage.setItem(abandonedKey, 'true');
|
|
474
|
+
} catch {}
|
|
475
|
+
posthog.client?.capture(external_survey_constants_js_namespaceObject.SurveyEventName.ABANDONED, _buildSurveyEventProperties('abandoned', survey, inProgressSurvey, posthog), {
|
|
476
|
+
delivery: 'unload'
|
|
477
|
+
});
|
|
478
|
+
};
|
|
479
|
+
const reverseIfUnshuffled = (unshuffled, shuffled)=>{
|
|
480
|
+
if (unshuffled.length === shuffled.length && unshuffled.every((val, index)=>val === shuffled[index])) return shuffled.reverse();
|
|
481
|
+
return shuffled;
|
|
482
|
+
};
|
|
483
|
+
const hasBranching = (survey)=>survey.questions.some((question)=>!!question.branching?.type);
|
|
484
|
+
const restorePersistedOrder = (survey, questionOrder)=>{
|
|
485
|
+
if (!questionOrder || questionOrder.length !== survey.questions.length) return null;
|
|
486
|
+
const questionsById = new Map(survey.questions.map((question)=>[
|
|
487
|
+
question.id,
|
|
488
|
+
question
|
|
489
|
+
]));
|
|
490
|
+
const restored = [];
|
|
491
|
+
for (const id of questionOrder){
|
|
492
|
+
const question = questionsById.get(id);
|
|
493
|
+
if (!question) return null;
|
|
494
|
+
restored.push(question);
|
|
495
|
+
}
|
|
496
|
+
return restored;
|
|
497
|
+
};
|
|
498
|
+
const getQuestionOrder = (questions)=>{
|
|
499
|
+
const ids = questions.map((question)=>question.id);
|
|
500
|
+
return ids.every((id)=>!!id) ? ids : void 0;
|
|
501
|
+
};
|
|
502
|
+
const getDisplayOrderQuestions = (survey, inProgressState)=>{
|
|
503
|
+
if (hasBranching(survey)) return survey.questions;
|
|
504
|
+
if (inProgressState) return restorePersistedOrder(survey, inProgressState.questionOrder) ?? survey.questions;
|
|
505
|
+
if (!survey.appearance || !survey.appearance.shuffleQuestions || survey.enable_partial_responses) return survey.questions;
|
|
506
|
+
return reverseIfUnshuffled(survey.questions, (0, surveys_namespaceObject.shuffle)(survey.questions));
|
|
507
|
+
};
|
|
508
|
+
const canActivateRepeatedly = (survey)=>(0, surveys_namespaceObject.canSurveyActivateRepeatedly)(survey) || isSurveyInProgress(survey);
|
|
509
|
+
const getSurveySeen = (survey)=>{
|
|
510
|
+
let surveySeen = null;
|
|
511
|
+
try {
|
|
512
|
+
surveySeen = localStorage.getItem((0, survey_utils_js_namespaceObject.getSurveySeenKey)(survey));
|
|
513
|
+
} catch (error) {
|
|
514
|
+
survey_utils_js_namespaceObject.SURVEY_LOGGER.error('localStorage error: ' + error);
|
|
515
|
+
}
|
|
516
|
+
if (surveySeen) return !canActivateRepeatedly(survey);
|
|
517
|
+
return false;
|
|
518
|
+
};
|
|
519
|
+
const LAST_SEEN_SURVEY_DATE_KEY = 'lastSeenSurveyDate';
|
|
520
|
+
const hasWaitPeriodPassed = (waitPeriodInDays)=>{
|
|
521
|
+
let lastSeenSurveyDate = null;
|
|
522
|
+
try {
|
|
523
|
+
lastSeenSurveyDate = localStorage.getItem(LAST_SEEN_SURVEY_DATE_KEY);
|
|
524
|
+
} catch (error) {
|
|
525
|
+
survey_utils_js_namespaceObject.SURVEY_LOGGER.error('localStorage error: ' + error);
|
|
526
|
+
}
|
|
527
|
+
return (0, matcher_utils_js_namespaceObject.hasPeriodPassed)(waitPeriodInDays, lastSeenSurveyDate);
|
|
528
|
+
};
|
|
529
|
+
const SurveyContext = (0, external_preact_namespaceObject.createContext)({
|
|
530
|
+
isPreviewMode: false,
|
|
531
|
+
previewPageIndex: 0,
|
|
532
|
+
onPopupSurveyDismissed: ()=>{},
|
|
533
|
+
isPopup: true,
|
|
534
|
+
onPreviewSubmit: ()=>{},
|
|
535
|
+
onPreviewBack: ()=>{},
|
|
536
|
+
surveySubmissionId: '',
|
|
537
|
+
properties: void 0,
|
|
538
|
+
surveyLanguage: null
|
|
539
|
+
});
|
|
540
|
+
const useSurveyContext = ()=>(0, hooks_namespaceObject.useContext)(SurveyContext);
|
|
541
|
+
const renderChildrenAsTextOrHtml = ({ component, children, renderAsHtml, style })=>renderAsHtml ? (0, external_preact_namespaceObject.cloneElement)(component, {
|
|
542
|
+
dangerouslySetInnerHTML: {
|
|
543
|
+
__html: children
|
|
544
|
+
},
|
|
545
|
+
style
|
|
546
|
+
}) : (0, external_preact_namespaceObject.cloneElement)(component, {
|
|
547
|
+
children,
|
|
548
|
+
style
|
|
549
|
+
});
|
|
550
|
+
function defaultMatchType(matchType) {
|
|
551
|
+
return matchType ?? 'icontains';
|
|
552
|
+
}
|
|
553
|
+
function doesSurveyUrlMatch(survey, posthog) {
|
|
554
|
+
if (!survey.conditions?.url) return true;
|
|
555
|
+
const href = (0, url_targeting_utils_js_namespaceObject.getTargetingUrl)(posthog) ?? ("u" > typeof window ? window.location.href : void 0);
|
|
556
|
+
if (!href) return false;
|
|
557
|
+
const targets = [
|
|
558
|
+
survey.conditions.url
|
|
559
|
+
];
|
|
560
|
+
const matchType = defaultMatchType(survey.conditions?.urlMatchType);
|
|
561
|
+
return surveys_namespaceObject.propertyComparisons[matchType](targets, [
|
|
562
|
+
href
|
|
563
|
+
]);
|
|
564
|
+
}
|
|
565
|
+
function doesSurveyDeviceTypesMatch(survey) {
|
|
566
|
+
return (0, matcher_utils_js_namespaceObject.doesDeviceTypeMatch)(survey.conditions?.deviceTypes, survey.conditions?.deviceTypesMatchType);
|
|
567
|
+
}
|
|
568
|
+
function doesSurveyMatchSelector(survey) {
|
|
569
|
+
if (!survey.conditions?.selector) return true;
|
|
570
|
+
return !!document?.querySelector(survey.conditions.selector);
|
|
571
|
+
}
|
|
572
|
+
const getInProgressSurveyStateKey = (survey)=>(0, survey_utils_js_namespaceObject.getSurveyStorageKey)(survey_utils_js_namespaceObject.SURVEY_IN_PROGRESS_PREFIX, survey);
|
|
573
|
+
const inMemoryInProgressSurveyState = {};
|
|
574
|
+
const clearAllInMemoryInProgressSurveyState = ()=>{
|
|
575
|
+
for (const key of Object.keys(inMemoryInProgressSurveyState))delete inMemoryInProgressSurveyState[key];
|
|
576
|
+
};
|
|
577
|
+
const setInProgressSurveyState = (survey, state)=>{
|
|
578
|
+
const key = getInProgressSurveyStateKey(survey);
|
|
579
|
+
try {
|
|
580
|
+
localStorage.setItem(key, JSON.stringify(state));
|
|
581
|
+
delete inMemoryInProgressSurveyState[key];
|
|
582
|
+
} catch (e) {
|
|
583
|
+
survey_utils_js_namespaceObject.SURVEY_LOGGER.error('Error setting in-progress survey state in localStorage', e);
|
|
584
|
+
inMemoryInProgressSurveyState[key] = state;
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
const getInProgressSurveyState = (survey)=>{
|
|
588
|
+
const key = getInProgressSurveyStateKey(survey);
|
|
589
|
+
const inMemoryState = inMemoryInProgressSurveyState[key];
|
|
590
|
+
if (inMemoryState) return inMemoryState;
|
|
591
|
+
try {
|
|
592
|
+
const stateString = localStorage.getItem(key);
|
|
593
|
+
if (stateString) return JSON.parse(stateString);
|
|
594
|
+
} catch (e) {
|
|
595
|
+
survey_utils_js_namespaceObject.SURVEY_LOGGER.error('Error getting in-progress survey state from localStorage', e);
|
|
596
|
+
}
|
|
597
|
+
return null;
|
|
598
|
+
};
|
|
599
|
+
const isSurveyInProgress = (survey)=>{
|
|
600
|
+
const state = getInProgressSurveyState(survey);
|
|
601
|
+
return !(0, core_namespaceObject.isNullish)(state?.surveySubmissionId);
|
|
602
|
+
};
|
|
603
|
+
const clearInProgressSurveyState = (survey)=>{
|
|
604
|
+
const key = getInProgressSurveyStateKey(survey);
|
|
605
|
+
delete inMemoryInProgressSurveyState[key];
|
|
606
|
+
try {
|
|
607
|
+
localStorage.removeItem(key);
|
|
608
|
+
} catch (e) {
|
|
609
|
+
survey_utils_js_namespaceObject.SURVEY_LOGGER.error('Error clearing in-progress survey state from localStorage', e);
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
function getSurveyContainerClass(survey, asSelector = false) {
|
|
613
|
+
const className = `PostHogSurvey-${survey.id}`;
|
|
614
|
+
return asSelector ? `.${className}` : className;
|
|
615
|
+
}
|
|
616
|
+
function getPopoverPosition(type, position = external_survey_constants_js_namespaceObject.SurveyPosition.Right, surveyWidgetType) {
|
|
617
|
+
if (type === external_survey_constants_js_namespaceObject.SurveyType.ExternalSurvey) return {};
|
|
618
|
+
switch(position){
|
|
619
|
+
case external_survey_constants_js_namespaceObject.SurveyPosition.TopLeft:
|
|
620
|
+
return {
|
|
621
|
+
top: '0',
|
|
622
|
+
left: '0',
|
|
623
|
+
transform: 'translate(30px, 30px)'
|
|
624
|
+
};
|
|
625
|
+
case external_survey_constants_js_namespaceObject.SurveyPosition.TopRight:
|
|
626
|
+
return {
|
|
627
|
+
top: '0',
|
|
628
|
+
right: '0',
|
|
629
|
+
transform: 'translate(-30px, 30px)'
|
|
630
|
+
};
|
|
631
|
+
case external_survey_constants_js_namespaceObject.SurveyPosition.TopCenter:
|
|
632
|
+
return {
|
|
633
|
+
top: '0',
|
|
634
|
+
left: '50%',
|
|
635
|
+
transform: 'translate(-50%, 30px)'
|
|
636
|
+
};
|
|
637
|
+
case external_survey_constants_js_namespaceObject.SurveyPosition.MiddleLeft:
|
|
638
|
+
return {
|
|
639
|
+
top: '50%',
|
|
640
|
+
left: '0',
|
|
641
|
+
transform: 'translate(30px, -50%)'
|
|
642
|
+
};
|
|
643
|
+
case external_survey_constants_js_namespaceObject.SurveyPosition.MiddleRight:
|
|
644
|
+
return {
|
|
645
|
+
top: '50%',
|
|
646
|
+
right: '0',
|
|
647
|
+
transform: 'translate(-30px, -50%)'
|
|
648
|
+
};
|
|
649
|
+
case external_survey_constants_js_namespaceObject.SurveyPosition.MiddleCenter:
|
|
650
|
+
return {
|
|
651
|
+
top: '50%',
|
|
652
|
+
left: '50%',
|
|
653
|
+
transform: 'translate(-50%, -50%)'
|
|
654
|
+
};
|
|
655
|
+
case external_survey_constants_js_namespaceObject.SurveyPosition.Left:
|
|
656
|
+
return {
|
|
657
|
+
left: '30px'
|
|
658
|
+
};
|
|
659
|
+
case external_survey_constants_js_namespaceObject.SurveyPosition.Center:
|
|
660
|
+
return {
|
|
661
|
+
left: '50%',
|
|
662
|
+
transform: 'translateX(-50%)'
|
|
663
|
+
};
|
|
664
|
+
default:
|
|
665
|
+
case external_survey_constants_js_namespaceObject.SurveyPosition.Right:
|
|
666
|
+
return {
|
|
667
|
+
right: type === external_survey_constants_js_namespaceObject.SurveyType.Widget && surveyWidgetType === external_survey_constants_js_namespaceObject.SurveyWidgetType.Tab ? '60px' : '30px'
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
exports.SurveyContext = __webpack_exports__.SurveyContext;
|
|
672
|
+
exports.addSurveyCSSVariablesToElement = __webpack_exports__.addSurveyCSSVariablesToElement;
|
|
673
|
+
exports.canActivateRepeatedly = __webpack_exports__.canActivateRepeatedly;
|
|
674
|
+
exports.clearAllInMemoryInProgressSurveyState = __webpack_exports__.clearAllInMemoryInProgressSurveyState;
|
|
675
|
+
exports.clearInProgressSurveyState = __webpack_exports__.clearInProgressSurveyState;
|
|
676
|
+
exports.defaultSurveyAppearance = __webpack_exports__.defaultSurveyAppearance;
|
|
677
|
+
exports.dismissedSurveyEvent = __webpack_exports__.dismissedSurveyEvent;
|
|
678
|
+
exports.doesSurveyDeviceTypesMatch = __webpack_exports__.doesSurveyDeviceTypesMatch;
|
|
679
|
+
exports.doesSurveyMatchSelector = __webpack_exports__.doesSurveyMatchSelector;
|
|
680
|
+
exports.doesSurveyUrlMatch = __webpack_exports__.doesSurveyUrlMatch;
|
|
681
|
+
exports.getContrastingTextColor = __webpack_exports__.getContrastingTextColor;
|
|
682
|
+
exports.getDisplayOrderChoices = __webpack_exports__.getDisplayOrderChoices;
|
|
683
|
+
exports.getDisplayOrderQuestions = __webpack_exports__.getDisplayOrderQuestions;
|
|
684
|
+
exports.getFontFamily = __webpack_exports__.getFontFamily;
|
|
685
|
+
exports.getInProgressSurveyState = __webpack_exports__.getInProgressSurveyState;
|
|
686
|
+
exports.getPopoverPosition = __webpack_exports__.getPopoverPosition;
|
|
687
|
+
exports.getQuestionOrder = __webpack_exports__.getQuestionOrder;
|
|
688
|
+
exports.getSurveyContainerClass = __webpack_exports__.getSurveyContainerClass;
|
|
689
|
+
exports.getSurveyResponseKey = __webpack_exports__.getSurveyResponseKey;
|
|
690
|
+
exports.getSurveySeen = __webpack_exports__.getSurveySeen;
|
|
691
|
+
exports.getSurveyStylesheet = __webpack_exports__.getSurveyStylesheet;
|
|
692
|
+
exports.hasWaitPeriodPassed = __webpack_exports__.hasWaitPeriodPassed;
|
|
693
|
+
exports.hex2rgb = __webpack_exports__.hex2rgb;
|
|
694
|
+
exports.hexToRgba = __webpack_exports__.hexToRgba;
|
|
695
|
+
exports.isSurveyInProgress = __webpack_exports__.isSurveyInProgress;
|
|
696
|
+
exports.renderChildrenAsTextOrHtml = __webpack_exports__.renderChildrenAsTextOrHtml;
|
|
697
|
+
exports.retrieveSurveyShadow = __webpack_exports__.retrieveSurveyShadow;
|
|
698
|
+
exports.sendSurveyAbandonedEvent = __webpack_exports__.sendSurveyAbandonedEvent;
|
|
699
|
+
exports.sendSurveyEvent = __webpack_exports__.sendSurveyEvent;
|
|
700
|
+
exports.setInProgressSurveyState = __webpack_exports__.setInProgressSurveyState;
|
|
701
|
+
exports.shuffle = __webpack_exports__.shuffle;
|
|
702
|
+
exports.useSurveyContext = __webpack_exports__.useSurveyContext;
|
|
703
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
704
|
+
"SurveyContext",
|
|
705
|
+
"addSurveyCSSVariablesToElement",
|
|
706
|
+
"canActivateRepeatedly",
|
|
707
|
+
"clearAllInMemoryInProgressSurveyState",
|
|
708
|
+
"clearInProgressSurveyState",
|
|
709
|
+
"defaultSurveyAppearance",
|
|
710
|
+
"dismissedSurveyEvent",
|
|
711
|
+
"doesSurveyDeviceTypesMatch",
|
|
712
|
+
"doesSurveyMatchSelector",
|
|
713
|
+
"doesSurveyUrlMatch",
|
|
714
|
+
"getContrastingTextColor",
|
|
715
|
+
"getDisplayOrderChoices",
|
|
716
|
+
"getDisplayOrderQuestions",
|
|
717
|
+
"getFontFamily",
|
|
718
|
+
"getInProgressSurveyState",
|
|
719
|
+
"getPopoverPosition",
|
|
720
|
+
"getQuestionOrder",
|
|
721
|
+
"getSurveyContainerClass",
|
|
722
|
+
"getSurveyResponseKey",
|
|
723
|
+
"getSurveySeen",
|
|
724
|
+
"getSurveyStylesheet",
|
|
725
|
+
"hasWaitPeriodPassed",
|
|
726
|
+
"hex2rgb",
|
|
727
|
+
"hexToRgba",
|
|
728
|
+
"isSurveyInProgress",
|
|
729
|
+
"renderChildrenAsTextOrHtml",
|
|
730
|
+
"retrieveSurveyShadow",
|
|
731
|
+
"sendSurveyAbandonedEvent",
|
|
732
|
+
"sendSurveyEvent",
|
|
733
|
+
"setInProgressSurveyState",
|
|
734
|
+
"shuffle",
|
|
735
|
+
"useSurveyContext"
|
|
736
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
737
|
+
Object.defineProperty(exports, '__esModule', {
|
|
738
|
+
value: true
|
|
739
|
+
});
|