@product7/product7-js 0.4.3 → 0.4.5
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/product7-js.js +50 -19
- package/dist/product7-js.js.map +1 -1
- package/dist/product7-js.min.js +1 -1
- package/dist/product7-js.min.js.map +1 -1
- package/package.json +1 -1
- package/src/core/BaseAPIService.js +29 -7
- package/src/core/Product7.js +8 -2
- package/src/styles/survey.js +13 -10
package/package.json
CHANGED
|
@@ -115,6 +115,7 @@ export class BaseAPIService {
|
|
|
115
115
|
return {
|
|
116
116
|
sessionToken: this.sessionToken,
|
|
117
117
|
config: initData.config,
|
|
118
|
+
widgets: initData.widgets,
|
|
118
119
|
expiresIn: initData.expiresIn,
|
|
119
120
|
status: initData.status,
|
|
120
121
|
message: initData.message,
|
|
@@ -135,8 +136,23 @@ export class BaseAPIService {
|
|
|
135
136
|
? response.data
|
|
136
137
|
: response || {};
|
|
137
138
|
|
|
138
|
-
const
|
|
139
|
-
|
|
139
|
+
const configData =
|
|
140
|
+
payload.config && typeof payload.config === 'object'
|
|
141
|
+
? payload.config
|
|
142
|
+
: {};
|
|
143
|
+
|
|
144
|
+
const sessionToken =
|
|
145
|
+
payload.session_token ||
|
|
146
|
+
payload.sessionToken ||
|
|
147
|
+
configData.session_token ||
|
|
148
|
+
configData.sessionToken;
|
|
149
|
+
|
|
150
|
+
const expiresIn = Number(
|
|
151
|
+
payload.expires_in ??
|
|
152
|
+
payload.expiresIn ??
|
|
153
|
+
configData.expires_in ??
|
|
154
|
+
configData.expiresIn
|
|
155
|
+
);
|
|
140
156
|
|
|
141
157
|
if (!sessionToken) {
|
|
142
158
|
throw new APIError(500, 'Invalid init response: missing session_token');
|
|
@@ -149,11 +165,17 @@ export class BaseAPIService {
|
|
|
149
165
|
return {
|
|
150
166
|
sessionToken,
|
|
151
167
|
expiresIn,
|
|
152
|
-
config:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
168
|
+
config: configData,
|
|
169
|
+
widgets:
|
|
170
|
+
payload.widgets && typeof payload.widgets === 'object'
|
|
171
|
+
? payload.widgets
|
|
172
|
+
: null,
|
|
173
|
+
configVersion:
|
|
174
|
+
configData.config_version ??
|
|
175
|
+
configData.configVersion ??
|
|
176
|
+
payload.config_version ??
|
|
177
|
+
payload.configVersion ??
|
|
178
|
+
null,
|
|
157
179
|
status: response?.status ?? payload?.status ?? true,
|
|
158
180
|
message: response?.message ?? payload?.message ?? null,
|
|
159
181
|
};
|
package/src/core/Product7.js
CHANGED
|
@@ -56,8 +56,12 @@ export class Product7 {
|
|
|
56
56
|
try {
|
|
57
57
|
const initData = await this.apiService.init();
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
const serverConfig = initData.config ? { ...initData.config } : {};
|
|
60
|
+
if (initData.widgets) {
|
|
61
|
+
serverConfig.widgets = initData.widgets;
|
|
62
|
+
}
|
|
63
|
+
if (Object.keys(serverConfig).length > 0) {
|
|
64
|
+
this.config = deepMerge(serverConfig, this.config);
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
this.initialized = true;
|
|
@@ -218,6 +222,8 @@ export class Product7 {
|
|
|
218
222
|
surveyConfig.showDescription ?? surveyConfig.show_description,
|
|
219
223
|
customQuestions: surveyConfig.customQuestions || surveyConfig.questions,
|
|
220
224
|
pages: surveyConfig.pages,
|
|
225
|
+
thankYouConfig:
|
|
226
|
+
surveyConfig.thankYouConfig || surveyConfig.thank_you_config || null,
|
|
221
227
|
enabled: surveyConfig.enabled,
|
|
222
228
|
...displayOptions,
|
|
223
229
|
});
|
package/src/styles/survey.js
CHANGED
|
@@ -201,14 +201,12 @@ export const surveyStyles = `
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
.feedback-survey-nps-btn:hover {
|
|
204
|
-
filter: brightness(1.
|
|
204
|
+
filter: brightness(1.12);
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
.feedback-survey-nps-btn.selected {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
position: relative;
|
|
211
|
-
box-shadow: 0 0 0 2px #fff, 0 0 0 4px currentColor;
|
|
208
|
+
filter: brightness(0.82);
|
|
209
|
+
box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25);
|
|
212
210
|
}
|
|
213
211
|
|
|
214
212
|
.feedback-survey-nps-btn:active {
|
|
@@ -216,10 +214,6 @@ export const surveyStyles = `
|
|
|
216
214
|
transition-duration: 100ms;
|
|
217
215
|
}
|
|
218
216
|
|
|
219
|
-
.feedback-survey-nps-btn.selected:active {
|
|
220
|
-
transform: scale(1.06) translateY(1px);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
217
|
/* NPS score colors */
|
|
224
218
|
.feedback-survey-nps-score-0 { background: #dc2626; border-color: #dc2626; }
|
|
225
219
|
.feedback-survey-nps-score-1 { background: #ef4444; border-color: #ef4444; }
|
|
@@ -350,7 +344,10 @@ export const surveyStyles = `
|
|
|
350
344
|
background: none;
|
|
351
345
|
border: none;
|
|
352
346
|
cursor: pointer;
|
|
353
|
-
padding:
|
|
347
|
+
padding: 4px;
|
|
348
|
+
width: 40px;
|
|
349
|
+
height: 40px;
|
|
350
|
+
flex-shrink: 0;
|
|
354
351
|
line-height: 1;
|
|
355
352
|
color: var(--color-neutral-300);
|
|
356
353
|
transition: color var(--transition-fast), transform var(--transition-fast);
|
|
@@ -359,6 +356,12 @@ export const surveyStyles = `
|
|
|
359
356
|
justify-content: center;
|
|
360
357
|
}
|
|
361
358
|
|
|
359
|
+
.feedback-survey-star-btn iconify-icon {
|
|
360
|
+
display: block;
|
|
361
|
+
pointer-events: none;
|
|
362
|
+
flex-shrink: 0;
|
|
363
|
+
}
|
|
364
|
+
|
|
362
365
|
.feedback-survey-star-btn.filled,
|
|
363
366
|
.feedback-survey-star-btn.hovered {
|
|
364
367
|
color: #f59e0b;
|