@product7/product7-js 0.1.2 → 0.1.3
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 +38 -39
- 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/widgets/ChangelogWidget.js +4 -6
- package/src/widgets/messenger/views/ChangelogView.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 {
|
|
@@ -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>
|