@eox/feedback 1.2.1 → 1.3.0
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/eox-feedback.js +76 -68
- package/dist/eox-feedback.umd.cjs +16 -15
- package/package.json +3 -3
- package/src/main.js +39 -33
- package/types/main.d.ts +6 -1
- package/types/main.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eox/feedback",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git@github.com:EOX-A/EOxElements.git"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"vite": "^8.
|
|
10
|
+
"vite": "^8.3.5"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@eox/elements-utils": "^1.
|
|
13
|
+
"@eox/elements-utils": "^1.3.0",
|
|
14
14
|
"@eox/ui": "^1.1.0",
|
|
15
15
|
"region-screenshot-js": "^1.1.0"
|
|
16
16
|
},
|
package/src/main.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import RegionScreenshot from "region-screenshot-js";
|
|
2
|
+
import { dispatchElementEvent } from "@eox/elements-utils";
|
|
2
3
|
import { style } from "./style";
|
|
3
4
|
import { styleEOX } from "./style.eox";
|
|
4
5
|
import "./feedback-button.js";
|
|
@@ -37,10 +38,14 @@ import "./feedback-button.js";
|
|
|
37
38
|
*
|
|
38
39
|
* @fires close - The modal was closed.
|
|
39
40
|
* @fires submit - The feedback was submitted. The `CustomEvent.detail` contains the FormData object.
|
|
41
|
+
* @fires {CustomEvent<import("@eox/elements-utils").EOxActivityDetail>} eox:activity - Fires on genuine user interactions, wrapping the original event for analytics tracking.
|
|
40
42
|
*/
|
|
41
43
|
export class EOxFeedback extends HTMLElement {
|
|
42
44
|
static observedAttributes = ["endpoint", "unstyled"];
|
|
43
45
|
|
|
46
|
+
/** @type {AbortController | null} */
|
|
47
|
+
#listenerController = null;
|
|
48
|
+
|
|
44
49
|
constructor() {
|
|
45
50
|
super();
|
|
46
51
|
this.attachShadow({ mode: "open" });
|
|
@@ -109,6 +114,9 @@ export class EOxFeedback extends HTMLElement {
|
|
|
109
114
|
}
|
|
110
115
|
|
|
111
116
|
connectedCallback() {
|
|
117
|
+
this.#listenerController?.abort();
|
|
118
|
+
this.#listenerController = new AbortController();
|
|
119
|
+
const { signal } = this.#listenerController;
|
|
112
120
|
this.endpoint =
|
|
113
121
|
this.endpoint ||
|
|
114
122
|
this.getAttribute("endpoint") ||
|
|
@@ -117,55 +125,42 @@ export class EOxFeedback extends HTMLElement {
|
|
|
117
125
|
this.render();
|
|
118
126
|
this.shadowRoot
|
|
119
127
|
.querySelector("input[type=checkbox]")
|
|
120
|
-
.addEventListener("click", (e) => this.onToggleScreenshot(e));
|
|
128
|
+
.addEventListener("click", (e) => this.onToggleScreenshot(e), { signal });
|
|
121
129
|
this.shadowRoot
|
|
122
130
|
.querySelector("button#submit")
|
|
123
|
-
.addEventListener("click", () => this.onSubmit());
|
|
131
|
+
.addEventListener("click", () => this.onSubmit(), { signal });
|
|
124
132
|
this.shadowRoot
|
|
125
133
|
.querySelector("button#cancel")
|
|
126
|
-
.addEventListener("click", () => this.onCancel());
|
|
134
|
+
.addEventListener("click", () => this.onCancel(true), { signal });
|
|
127
135
|
|
|
128
136
|
const jsonForm = this.shadowRoot.querySelector("eox-jsonform");
|
|
129
137
|
if (jsonForm) {
|
|
130
|
-
jsonForm.addEventListener("change", () => this.onJsonFormChange()
|
|
138
|
+
jsonForm.addEventListener("change", () => this.onJsonFormChange(), {
|
|
139
|
+
signal,
|
|
140
|
+
});
|
|
131
141
|
}
|
|
132
142
|
|
|
133
143
|
const textarea = this.shadowRoot.querySelector("textarea#message");
|
|
134
144
|
if (textarea) {
|
|
135
|
-
textarea.addEventListener("input", () => this.onTextareaInput()
|
|
145
|
+
textarea.addEventListener("input", () => this.onTextareaInput(), {
|
|
146
|
+
signal,
|
|
147
|
+
});
|
|
136
148
|
}
|
|
137
149
|
|
|
138
|
-
document.addEventListener("keyup", (e) => this.onKeyboardInput(e)
|
|
150
|
+
document.addEventListener("keyup", (e) => this.onKeyboardInput(e), {
|
|
151
|
+
signal,
|
|
152
|
+
});
|
|
139
153
|
}
|
|
140
154
|
|
|
141
155
|
disconnectedCallback() {
|
|
142
|
-
this
|
|
143
|
-
|
|
144
|
-
.removeEventListener("click", (e) => this.onToggleScreenshot(e));
|
|
145
|
-
this.shadowRoot
|
|
146
|
-
.querySelector("button#submit")
|
|
147
|
-
.removeEventListener("click", () => this.onSubmit());
|
|
148
|
-
this.shadowRoot
|
|
149
|
-
.querySelector("button#cancel")
|
|
150
|
-
.removeEventListener("click", () => this.onCancel());
|
|
151
|
-
|
|
152
|
-
const jsonForm = this.shadowRoot.querySelector("eox-jsonform");
|
|
153
|
-
if (jsonForm) {
|
|
154
|
-
jsonForm.removeEventListener("change", () => this.onJsonFormChange());
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const textarea = this.shadowRoot.querySelector("textarea#message");
|
|
158
|
-
if (textarea) {
|
|
159
|
-
textarea.removeEventListener("input", () => this.onTextareaInput());
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
document.removeEventListener("keyup", (e) => this.onKeyboardInput(e));
|
|
156
|
+
this.#listenerController?.abort();
|
|
157
|
+
this.#listenerController = null;
|
|
163
158
|
}
|
|
164
159
|
|
|
165
160
|
/** @private */
|
|
166
161
|
onKeyboardInput(e) {
|
|
167
162
|
if (e.keyCode === 27) {
|
|
168
|
-
this.onCancel();
|
|
163
|
+
this.onCancel(true);
|
|
169
164
|
}
|
|
170
165
|
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
|
171
166
|
const submitButton = this.shadowRoot.querySelector("button#submit");
|
|
@@ -347,7 +342,11 @@ export class EOxFeedback extends HTMLElement {
|
|
|
347
342
|
<p class="red-text middle-align center-align">Oh no - something went wrong! Apologies, we'll try to find out what happened.</p>
|
|
348
343
|
`;
|
|
349
344
|
}
|
|
350
|
-
this
|
|
345
|
+
dispatchElementEvent(this, "submit", {
|
|
346
|
+
detail: requestBody,
|
|
347
|
+
activity: true,
|
|
348
|
+
action: "submit",
|
|
349
|
+
});
|
|
351
350
|
|
|
352
351
|
form.classList.add("hidden");
|
|
353
352
|
container.appendChild(message);
|
|
@@ -355,17 +354,23 @@ export class EOxFeedback extends HTMLElement {
|
|
|
355
354
|
container.classList.remove("disabled");
|
|
356
355
|
progress.classList.add("hidden");
|
|
357
356
|
setTimeout(() => {
|
|
358
|
-
this.onCancel();
|
|
357
|
+
this.onCancel(false);
|
|
359
358
|
}, 4000);
|
|
360
359
|
}
|
|
361
360
|
|
|
362
|
-
/**
|
|
363
|
-
|
|
361
|
+
/**
|
|
362
|
+
* @param {boolean} [isUser=false]
|
|
363
|
+
* @private
|
|
364
|
+
*/
|
|
365
|
+
onCancel(isUser = false) {
|
|
364
366
|
if (this.regionScreenshot) {
|
|
365
367
|
this.regionScreenshot.close();
|
|
366
368
|
}
|
|
369
|
+
dispatchElementEvent(this, "close", {
|
|
370
|
+
activity: isUser,
|
|
371
|
+
action: "close",
|
|
372
|
+
});
|
|
367
373
|
this.remove();
|
|
368
|
-
this.dispatchEvent(new Event("close"));
|
|
369
374
|
}
|
|
370
375
|
|
|
371
376
|
/** @private */
|
|
@@ -477,6 +482,7 @@ export class EOxFeedback extends HTMLElement {
|
|
|
477
482
|
/** @type {import("@eox/jsonform").EOxJSONForm} */
|
|
478
483
|
const jsonForm = this.shadowRoot.querySelector("eox-jsonform");
|
|
479
484
|
jsonForm.schema = this.schema;
|
|
485
|
+
jsonForm.addEventListener("eox:activity", (e) => e.stopPropagation());
|
|
480
486
|
}
|
|
481
487
|
}
|
|
482
488
|
}
|
package/types/main.d.ts
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
*
|
|
33
33
|
* @fires close - The modal was closed.
|
|
34
34
|
* @fires submit - The feedback was submitted. The `CustomEvent.detail` contains the FormData object.
|
|
35
|
+
* @fires {CustomEvent<import("@eox/elements-utils").EOxActivityDetail>} eox:activity - Fires on genuine user interactions, wrapping the original event for analytics tracking.
|
|
35
36
|
*/
|
|
36
37
|
export class EOxFeedback extends HTMLElement {
|
|
37
38
|
static observedAttributes: string[];
|
|
@@ -78,9 +79,13 @@ export class EOxFeedback extends HTMLElement {
|
|
|
78
79
|
private onToggleScreenshot;
|
|
79
80
|
/** @private */
|
|
80
81
|
private onSubmit;
|
|
81
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* @param {boolean} [isUser=false]
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
82
86
|
private onCancel;
|
|
83
87
|
/** @private */
|
|
84
88
|
private render;
|
|
89
|
+
#private;
|
|
85
90
|
}
|
|
86
91
|
//# sourceMappingURL=main.d.ts.map
|
package/types/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH;IACE,oCAAqD;IASnD,eAAe;IACf,0BAA6B;IAC7B,eAAe;IACf,sBAAyB;IAEzB,eAAe;IACf,yBAA4B;IAE5B,eAAe;IACf,uBAA0B;IAE1B,eAAe;IACf,kBAAqB;IAErB,eAAe;IACf,gBAAmB;IAEnB,eAAe;IACf,mBAAuB;IAUzB;;OAEG;IACH,kBAFW,MAAM,EAQhB;IAhBD;;OAEG;IACH,gBAFa,MAAM,CAIlB;IAoBD;;OAEG;IACH,sBAFW,GAAkC,GAAC,IAAI,EAKjD;IAbD;;OAEG;IACH,cAFa,GAAkC,GAAC,IAAI,CAInD;IAUD,oEAOC;IAED,0BAqCC;IAED,6BAGC;IAED,eAAe;IACf,wBAUC;IAED,eAAe;IACf,wBAQC;IAED,eAAe;IACf,yBAYC;IAED,eAAe;IACf,2BAoEC;IAED,eAAe;IACf,iBAwFC;IAED;;;OAGG;IACH,iBASC;IAED,eAAe;IACf,eA8GC;;CACF"}
|