@newsoftglobal/feedbackkit-js 1.0.0 → 1.0.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/feedbackkit.js +26 -2
- package/dist/feedbackkit.min.js +24 -4
- package/package.json +3 -3
package/dist/feedbackkit.js
CHANGED
|
@@ -8,6 +8,18 @@
|
|
|
8
8
|
|
|
9
9
|
const SERVER_URL = 'https://backend.feedbackkit.dev';
|
|
10
10
|
|
|
11
|
+
// Auto-load html2canvas if not present
|
|
12
|
+
function _loadHtml2Canvas() {
|
|
13
|
+
if (typeof html2canvas !== 'undefined') return Promise.resolve();
|
|
14
|
+
return new Promise(function (resolve) {
|
|
15
|
+
var s = document.createElement('script');
|
|
16
|
+
s.src = 'https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js';
|
|
17
|
+
s.onload = resolve;
|
|
18
|
+
s.onerror = resolve; // continue without it
|
|
19
|
+
document.head.appendChild(s);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
11
23
|
// ==================== CSS ====================
|
|
12
24
|
const CSS = `
|
|
13
25
|
.fk-fab{position:fixed;bottom:24px;right:24px;width:52px;height:52px;border-radius:16px;border:none;background:linear-gradient(135deg,#6366f1,#8b5cf6);color:#fff;cursor:pointer;box-shadow:0 4px 20px rgba(99,102,241,.4);display:flex;align-items:center;justify-content:center;z-index:99999;transition:all .2s}
|
|
@@ -205,7 +217,8 @@
|
|
|
205
217
|
tabList.textContent = '📋 My Feedbacks';
|
|
206
218
|
tabList.onclick = () => { this.activeTab = 'list'; this._loadFeedbacks(); this._showPanel(); };
|
|
207
219
|
|
|
208
|
-
tabs.append(tabNew
|
|
220
|
+
tabs.append(tabNew);
|
|
221
|
+
if (this.api.hasUser) tabs.append(tabList);
|
|
209
222
|
panel.appendChild(tabs);
|
|
210
223
|
|
|
211
224
|
if (this.activeTab === 'new') {
|
|
@@ -634,7 +647,18 @@
|
|
|
634
647
|
return;
|
|
635
648
|
}
|
|
636
649
|
this._api = new FeedbackKitAPI(options.apiKey);
|
|
637
|
-
|
|
650
|
+
_loadHtml2Canvas();
|
|
651
|
+
|
|
652
|
+
const self = this;
|
|
653
|
+
const boot = () => {
|
|
654
|
+
self._widget = new FeedbackKitWidget(self._api);
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
if (document.readyState === 'loading') {
|
|
658
|
+
document.addEventListener('DOMContentLoaded', boot);
|
|
659
|
+
} else {
|
|
660
|
+
boot();
|
|
661
|
+
}
|
|
638
662
|
return this;
|
|
639
663
|
},
|
|
640
664
|
|
package/dist/feedbackkit.min.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
(function (root) {
|
|
2
2
|
'use strict';
|
|
3
|
-
const SERVER_URL = 'https
|
|
3
|
+
const SERVER_URL = 'https://backend.feedbackkit.dev';
|
|
4
|
+
function _loadHtml2Canvas() {
|
|
5
|
+
if (typeof html2canvas !== 'undefined') return Promise.resolve();
|
|
6
|
+
return new Promise(function (resolve) {
|
|
7
|
+
var s = document.createElement('script');
|
|
8
|
+
s.src = 'https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js';
|
|
9
|
+
s.onload = resolve;
|
|
10
|
+
s.onerror = resolve; // continue without it
|
|
11
|
+
document.head.appendChild(s);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
4
14
|
const CSS = `
|
|
5
15
|
.fk-fab{position:fixed;bottom:24px;right:24px;width:52px;height:52px;border-radius:16px;border:none;background:linear-gradient(135deg,#6366f1,#8b5cf6);color:#fff;cursor:pointer;box-shadow:0 4px 20px rgba(99,102,241,.4);display:flex;align-items:center;justify-content:center;z-index:99999;transition:all .2s}
|
|
6
16
|
.fk-fab:hover{transform:scale(1.06);box-shadow:0 6px 28px rgba(99,102,241,.55)}
|
|
@@ -134,7 +144,7 @@ return res.json();
|
|
|
134
144
|
class FeedbackKitWidget {
|
|
135
145
|
constructor(api) {
|
|
136
146
|
this.api = api;
|
|
137
|
-
this.state = 'idle';
|
|
147
|
+
this.state = 'idle'; // idle, panel, capturing, form, success, detail
|
|
138
148
|
this.screenshot = null;
|
|
139
149
|
this.activeTab = 'new';
|
|
140
150
|
this.feedbacks = [];
|
|
@@ -176,7 +186,8 @@ tabNew.onclick = () => { this.activeTab = 'new'; this._showPanel(); };
|
|
|
176
186
|
const tabList = this._el('button', `fk-tab ${this.activeTab === 'list' ? 'active' : ''}`);
|
|
177
187
|
tabList.textContent = '📋 My Feedbacks';
|
|
178
188
|
tabList.onclick = () => { this.activeTab = 'list'; this._loadFeedbacks(); this._showPanel(); };
|
|
179
|
-
tabs.append(tabNew
|
|
189
|
+
tabs.append(tabNew);
|
|
190
|
+
if (this.api.hasUser) tabs.append(tabList);
|
|
180
191
|
panel.appendChild(tabs);
|
|
181
192
|
if (this.activeTab === 'new') {
|
|
182
193
|
const body = this._el('div', 'fk-panel-body');
|
|
@@ -534,7 +545,16 @@ console.warn('[FeedbackKit] Missing apiKey');
|
|
|
534
545
|
return;
|
|
535
546
|
}
|
|
536
547
|
this._api = new FeedbackKitAPI(options.apiKey);
|
|
537
|
-
|
|
548
|
+
_loadHtml2Canvas();
|
|
549
|
+
const self = this;
|
|
550
|
+
const boot = () => {
|
|
551
|
+
self._widget = new FeedbackKitWidget(self._api);
|
|
552
|
+
};
|
|
553
|
+
if (document.readyState === 'loading') {
|
|
554
|
+
document.addEventListener('DOMContentLoaded', boot);
|
|
555
|
+
} else {
|
|
556
|
+
boot();
|
|
557
|
+
}
|
|
538
558
|
return this;
|
|
539
559
|
},
|
|
540
560
|
setUser(userInfo) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newsoftglobal/feedbackkit-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "FeedbackKit Vanilla JS SDK — Collect user feedback with screenshots, comments, and tracking",
|
|
5
5
|
"author": "NewSoft Global",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
],
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
|
-
"url": "https://bitbucket.org/newsoftglobal/feedbackkit"
|
|
23
|
+
"url": "https://bitbucket.org/newsoftglobal/feedbackkit-js"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "node build.js",
|
|
27
27
|
"prepublishOnly": "npm run build"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {}
|
|
30
|
-
}
|
|
30
|
+
}
|