@product7/product7-js 0.1.2 → 0.1.4
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 +59 -51
- 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/Product7.js +3 -1
- package/src/index.js +0 -29
- package/src/styles/base.js +19 -2
- package/src/styles/changelog.js +4 -0
- package/src/styles/messenger-components.js +6 -9
- package/src/styles/messenger-features.js +1 -1
- package/src/styles/messenger-views.js +6 -1
- package/src/widgets/ChangelogWidget.js +4 -6
- package/src/widgets/messenger/views/ChangelogView.js +8 -1
- package/src/widgets/messenger/views/HomeView.js +8 -1
package/package.json
CHANGED
package/src/core/Product7.js
CHANGED
|
@@ -153,7 +153,9 @@ export class Product7 {
|
|
|
153
153
|
includeEligibility: true,
|
|
154
154
|
includeIneligible: true,
|
|
155
155
|
});
|
|
156
|
-
const surveyConfig = surveys.find(
|
|
156
|
+
const surveyConfig = surveys.find(
|
|
157
|
+
(s) => s.surveyId === surveyId || s.id === surveyId
|
|
158
|
+
);
|
|
157
159
|
|
|
158
160
|
if (!surveyConfig) {
|
|
159
161
|
throw new SDKError(
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { APIService } from './core/APIService.js';
|
|
2
2
|
import { EventBus } from './core/EventBus.js';
|
|
3
3
|
import { Product7 as Product7SDK } from './core/Product7.js';
|
|
4
|
-
import { CSS_STYLES } from './styles/styles.js';
|
|
5
4
|
import {
|
|
6
5
|
APIError,
|
|
7
6
|
ConfigError,
|
|
@@ -19,25 +18,6 @@ import { SurveyWidget } from './widgets/SurveyWidget.js';
|
|
|
19
18
|
import { TabWidget } from './widgets/TabWidget.js';
|
|
20
19
|
import { WidgetFactory } from './widgets/WidgetFactory.js';
|
|
21
20
|
|
|
22
|
-
function injectStyles() {
|
|
23
|
-
if (typeof document === 'undefined') return;
|
|
24
|
-
|
|
25
|
-
if (!document.querySelector('#product7-styles')) {
|
|
26
|
-
const style = document.createElement('style');
|
|
27
|
-
style.id = 'product7-styles';
|
|
28
|
-
style.textContent = CSS_STYLES;
|
|
29
|
-
document.head.appendChild(style);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!document.querySelector('#product7-iconify')) {
|
|
33
|
-
const script = document.createElement('script');
|
|
34
|
-
script.id = 'product7-iconify';
|
|
35
|
-
script.src =
|
|
36
|
-
'https://cdn.jsdelivr.net/npm/iconify-icon@2/dist/iconify-icon.min.js';
|
|
37
|
-
script.async = true;
|
|
38
|
-
document.head.appendChild(script);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
21
|
|
|
42
22
|
// --- Identify: transform flat user data into internal format ---
|
|
43
23
|
|
|
@@ -125,7 +105,6 @@ async function ensureSDK(options) {
|
|
|
125
105
|
if (Product7._sdk) return Product7._sdk;
|
|
126
106
|
|
|
127
107
|
if (options.organization) {
|
|
128
|
-
injectStyles();
|
|
129
108
|
const config = cleanUndefined({
|
|
130
109
|
workspace: options.organization,
|
|
131
110
|
debug: options.debug,
|
|
@@ -164,8 +143,6 @@ const Product7 = {
|
|
|
164
143
|
|
|
165
144
|
async identify(data = {}, callback) {
|
|
166
145
|
try {
|
|
167
|
-
injectStyles();
|
|
168
|
-
|
|
169
146
|
const transformed = transformIdentifyData(data);
|
|
170
147
|
Product7._organization = transformed.workspace;
|
|
171
148
|
|
|
@@ -251,8 +228,6 @@ const Product7 = {
|
|
|
251
228
|
return null;
|
|
252
229
|
}
|
|
253
230
|
|
|
254
|
-
injectStyles();
|
|
255
|
-
|
|
256
231
|
const widgetOptions = cleanUndefined({
|
|
257
232
|
displayMode: options.displayMode || 'panel',
|
|
258
233
|
theme: options.theme || sdk.config.theme || 'light',
|
|
@@ -359,8 +334,6 @@ const Product7 = {
|
|
|
359
334
|
return null;
|
|
360
335
|
}
|
|
361
336
|
|
|
362
|
-
injectStyles();
|
|
363
|
-
|
|
364
337
|
const widgetOptions = cleanUndefined({
|
|
365
338
|
theme: options.theme || sdk.config.theme || 'light',
|
|
366
339
|
primaryColor: options.primaryColor,
|
|
@@ -464,8 +437,6 @@ const Product7 = {
|
|
|
464
437
|
return null;
|
|
465
438
|
}
|
|
466
439
|
|
|
467
|
-
injectStyles();
|
|
468
|
-
|
|
469
440
|
// placement → position
|
|
470
441
|
let position = 'right';
|
|
471
442
|
if (options.placement === 'right') {
|
package/src/styles/base.js
CHANGED
|
@@ -2,7 +2,12 @@ export const baseStyles = `
|
|
|
2
2
|
.feedback-widget,
|
|
3
3
|
.messenger-widget,
|
|
4
4
|
.changelog-widget,
|
|
5
|
-
.feedback-survey
|
|
5
|
+
.feedback-survey,
|
|
6
|
+
.feedback-panel,
|
|
7
|
+
.feedback-modal,
|
|
8
|
+
.changelog-modal,
|
|
9
|
+
.changelog-list-modal,
|
|
10
|
+
.product7-notification {
|
|
6
11
|
box-sizing: border-box;
|
|
7
12
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', Oxygen, Ubuntu, Cantarell, sans-serif;
|
|
8
13
|
}
|
|
@@ -18,7 +23,19 @@ export const baseStyles = `
|
|
|
18
23
|
.changelog-widget *::after,
|
|
19
24
|
.feedback-survey *,
|
|
20
25
|
.feedback-survey *::before,
|
|
21
|
-
.feedback-survey *::after
|
|
26
|
+
.feedback-survey *::after,
|
|
27
|
+
.feedback-panel *,
|
|
28
|
+
.feedback-panel *::before,
|
|
29
|
+
.feedback-panel *::after,
|
|
30
|
+
.feedback-modal *,
|
|
31
|
+
.feedback-modal *::before,
|
|
32
|
+
.feedback-modal *::after,
|
|
33
|
+
.changelog-modal *,
|
|
34
|
+
.changelog-modal *::before,
|
|
35
|
+
.changelog-modal *::after,
|
|
36
|
+
.changelog-list-modal *,
|
|
37
|
+
.changelog-list-modal *::before,
|
|
38
|
+
.changelog-list-modal *::after {
|
|
22
39
|
box-sizing: border-box;
|
|
23
40
|
}
|
|
24
41
|
|
package/src/styles/changelog.js
CHANGED
|
@@ -268,6 +268,10 @@ export const changelogStyles = `
|
|
|
268
268
|
font-size: var(--font-size-md);
|
|
269
269
|
line-height: var(--line-height-loose);
|
|
270
270
|
color: var(--color-text-secondary);
|
|
271
|
+
display: -webkit-box;
|
|
272
|
+
-webkit-line-clamp: 2;
|
|
273
|
+
-webkit-box-orient: vertical;
|
|
274
|
+
overflow: hidden;
|
|
271
275
|
}
|
|
272
276
|
|
|
273
277
|
.changelog-popup-btn {
|
|
@@ -37,16 +37,12 @@ export const messengerComponentsStyles = `
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
.messenger-message-sender {
|
|
40
|
-
|
|
41
|
-
font-weight: var(--font-weight-medium);
|
|
42
|
-
color: var(--msg-text-secondary);
|
|
43
|
-
margin-bottom: 2px;
|
|
44
|
-
margin-left: 0;
|
|
40
|
+
display: none;
|
|
45
41
|
}
|
|
46
42
|
|
|
47
43
|
.messenger-message-bubble {
|
|
48
|
-
padding:
|
|
49
|
-
border-radius: 1.
|
|
44
|
+
padding: 7px 13px;
|
|
45
|
+
border-radius: 1.125rem;
|
|
50
46
|
word-wrap: break-word;
|
|
51
47
|
max-width: 100%;
|
|
52
48
|
}
|
|
@@ -66,6 +62,7 @@ export const messengerComponentsStyles = `
|
|
|
66
62
|
|
|
67
63
|
.messenger-message-content {
|
|
68
64
|
font-size: var(--font-size-base);
|
|
65
|
+
font-weight: var(--font-weight-medium);
|
|
69
66
|
line-height: var(--line-height-relaxed);
|
|
70
67
|
}
|
|
71
68
|
|
|
@@ -240,7 +237,7 @@ export const messengerComponentsStyles = `
|
|
|
240
237
|
|
|
241
238
|
.messenger-chat-empty h3 {
|
|
242
239
|
margin: 0 0 var(--spacing-2);
|
|
243
|
-
font-size: var(--font-size-
|
|
240
|
+
font-size: var(--font-size-base);
|
|
244
241
|
font-weight: var(--font-weight-semibold);
|
|
245
242
|
color: var(--msg-text);
|
|
246
243
|
}
|
|
@@ -560,7 +557,7 @@ export const messengerComponentsStyles = `
|
|
|
560
557
|
|
|
561
558
|
.messenger-prechat-title {
|
|
562
559
|
margin: 0 0 var(--spacing-2);
|
|
563
|
-
font-size: var(--font-size-
|
|
560
|
+
font-size: var(--font-size-base);
|
|
564
561
|
font-weight: var(--font-weight-semibold);
|
|
565
562
|
color: var(--msg-text);
|
|
566
563
|
}
|
|
@@ -90,11 +90,11 @@ export const messengerFeaturesStyles = `
|
|
|
90
90
|
EMPTY STATE
|
|
91
91
|
======================================== */
|
|
92
92
|
.messenger-empty-state {
|
|
93
|
+
flex: 1;
|
|
93
94
|
display: flex;
|
|
94
95
|
flex-direction: column;
|
|
95
96
|
align-items: center;
|
|
96
97
|
justify-content: center;
|
|
97
|
-
height: 100%;
|
|
98
98
|
text-align: center;
|
|
99
99
|
padding: var(--spacing-10);
|
|
100
100
|
}
|
|
@@ -283,9 +283,14 @@ export const messengerViewsStyles = `
|
|
|
283
283
|
|
|
284
284
|
.messenger-home-changelog-card-desc {
|
|
285
285
|
margin: 0;
|
|
286
|
-
font-size: var(--font-size-
|
|
286
|
+
font-size: var(--font-size-sm);
|
|
287
|
+
font-weight: var(--font-weight-normal);
|
|
287
288
|
color: var(--msg-text-secondary);
|
|
288
289
|
line-height: var(--line-height-relaxed);
|
|
290
|
+
display: -webkit-box;
|
|
291
|
+
-webkit-line-clamp: 3;
|
|
292
|
+
-webkit-box-orient: vertical;
|
|
293
|
+
overflow: hidden;
|
|
289
294
|
}
|
|
290
295
|
|
|
291
296
|
.messenger-home-availability,
|
|
@@ -329,9 +329,8 @@ export class ChangelogWidget extends BaseWidget {
|
|
|
329
329
|
const date = changelog.published_at
|
|
330
330
|
? this._formatDate(changelog.published_at)
|
|
331
331
|
: '';
|
|
332
|
-
const description = this.
|
|
333
|
-
changelog.excerpt || changelog.description
|
|
334
|
-
100
|
|
332
|
+
const description = this._stripHtml(
|
|
333
|
+
changelog.excerpt || changelog.description
|
|
335
334
|
);
|
|
336
335
|
const labelsHTML =
|
|
337
336
|
changelog.labels && changelog.labels.length > 0
|
|
@@ -400,9 +399,8 @@ export class ChangelogWidget extends BaseWidget {
|
|
|
400
399
|
const hasImage = changelog.cover_image || changelog.image;
|
|
401
400
|
const imageUrl = changelog.cover_image || changelog.image;
|
|
402
401
|
const hasMultiple = this.changelogs.length > 1;
|
|
403
|
-
const description = this.
|
|
404
|
-
changelog.excerpt || changelog.description
|
|
405
|
-
160
|
|
402
|
+
const description = this._stripHtml(
|
|
403
|
+
changelog.excerpt || changelog.description
|
|
406
404
|
);
|
|
407
405
|
|
|
408
406
|
content.innerHTML = `
|
|
@@ -62,6 +62,13 @@ export class ChangelogView {
|
|
|
62
62
|
this._attachChangelogEvents();
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
_stripHtml(html) {
|
|
66
|
+
if (!html) return '';
|
|
67
|
+
const tmp = document.createElement('div');
|
|
68
|
+
tmp.innerHTML = html;
|
|
69
|
+
return (tmp.textContent || tmp.innerText || '').trim();
|
|
70
|
+
}
|
|
71
|
+
|
|
65
72
|
_renderChangelogCard(item) {
|
|
66
73
|
const dateStr = this._formatDate(item.publishedAt || item.date);
|
|
67
74
|
const labelsHtml =
|
|
@@ -83,7 +90,7 @@ export class ChangelogView {
|
|
|
83
90
|
${labelsHtml}
|
|
84
91
|
</div>
|
|
85
92
|
<h3 class="messenger-changelog-title">${item.title}</h3>
|
|
86
|
-
${item.description ? `<p class="messenger-changelog-description">${item.description}</p>` : ''}
|
|
93
|
+
${item.description ? `<p class="messenger-changelog-description">${this._stripHtml(item.description)}</p>` : ''}
|
|
87
94
|
</div>
|
|
88
95
|
${item.coverImage ? `<div class="messenger-changelog-thumb"><img src="${item.coverImage}" alt="${item.title}" onerror="this.style.display='none';" /></div>` : ''}
|
|
89
96
|
<iconify-icon icon="ph:caret-right" class="messenger-changelog-arrow" width="16" height="16"></iconify-icon>
|
|
@@ -184,7 +184,7 @@ export class HomeView {
|
|
|
184
184
|
}
|
|
185
185
|
<div class="messenger-home-changelog-card-content">
|
|
186
186
|
<h4 class="messenger-home-changelog-card-title">${item.title}</h4>
|
|
187
|
-
<p class="messenger-home-changelog-card-desc">${item.description
|
|
187
|
+
<p class="messenger-home-changelog-card-desc">${this._stripHtml(item.description)}</p>
|
|
188
188
|
</div>
|
|
189
189
|
</div>
|
|
190
190
|
`
|
|
@@ -198,6 +198,13 @@ export class HomeView {
|
|
|
198
198
|
`;
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
_stripHtml(html) {
|
|
202
|
+
if (!html) return '';
|
|
203
|
+
const tmp = document.createElement('div');
|
|
204
|
+
tmp.innerHTML = html;
|
|
205
|
+
return (tmp.textContent || tmp.innerText || '').trim();
|
|
206
|
+
}
|
|
207
|
+
|
|
201
208
|
_formatDate(dateString) {
|
|
202
209
|
if (!dateString) return '';
|
|
203
210
|
const date = new Date(dateString);
|