@eox/feedback 1.1.0 → 1.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eox/feedback",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,10 +25,16 @@ export class EOxFeedbackButton extends HTMLElement {
25
25
  this._schema = null;
26
26
  }
27
27
 
28
+ /**
29
+ * @returns {import("@eox/jsonform").JsonSchema|null}
30
+ */
28
31
  get schema() {
29
32
  return this._schema;
30
33
  }
31
34
 
35
+ /**
36
+ * @param {import("@eox/jsonform").JsonSchema|null} newSchema
37
+ */
32
38
  set schema(newSchema) {
33
39
  this._schema = newSchema;
34
40
  if (this.modal) {
package/src/main.js CHANGED
@@ -10,7 +10,11 @@ import "./feedback-button.js";
10
10
  * @element eox-feedback
11
11
  *
12
12
  * @attr {string} endpoint - The endpoint to send the feedback to as POST message.
13
- * @attr {string|null} [unstyled=undefined] - If provided, the element will not be styled with EOX styles.
13
+ * @attr {string} unstyled - If provided, the element will not be styled with EOX styles.
14
+ *
15
+ * @property {string} endpoint - The endpoint to send the feedback to as POST message.
16
+ * @property {string} unstyled - If provided, the element will not be styled with EOX styles.
17
+ * @property {import("@eox/jsonform").JsonSchema} schema - The JSON schema for the feedback form (option). Requires `eox-jsonform` to be imported.
14
18
  *
15
19
  * @fires close - The modal was closed.
16
20
  * @fires submit - The feedback was submitted. The `CustomEvent.detail` contains the FormData object.
@@ -22,38 +26,72 @@ export class EOxFeedback extends HTMLElement {
22
26
  super();
23
27
  this.attachShadow({ mode: "open" });
24
28
 
29
+ /** @private */
25
30
  this.includeScreenshot = null;
31
+ /** @private */
26
32
  this.areaSelection = null;
27
33
 
34
+ /** @private */
28
35
  this.regionScreenshot = null;
29
36
 
37
+ /** @private */
30
38
  this.screenShotFile = null;
31
39
 
32
- this.endpoint = null;
40
+ /** @private */
41
+ this._endpoint = null;
33
42
 
43
+ /** @private */
34
44
  this._schema = null;
35
45
 
46
+ /** @private */
36
47
  this._submitted = false;
37
48
  }
38
49
 
50
+ /**
51
+ * @returns {string}
52
+ */
53
+ get endpoint() {
54
+ return this._endpoint;
55
+ }
56
+
57
+ /**
58
+ * @param {string} val
59
+ */
60
+ set endpoint(val) {
61
+ this._endpoint = val;
62
+ if (val && this.getAttribute("endpoint") !== val) {
63
+ this.setAttribute("endpoint", val);
64
+ }
65
+ this.render();
66
+ }
67
+
68
+ /**
69
+ * @returns {import("@eox/jsonform").JsonSchema|null}
70
+ */
39
71
  get schema() {
40
72
  return this._schema;
41
73
  }
42
74
 
75
+ /**
76
+ * @param {import("@eox/jsonform").JsonSchema|null} newSchema
77
+ */
43
78
  set schema(newSchema) {
44
79
  this._schema = newSchema;
45
80
  this.render();
46
81
  }
47
82
 
48
- /**
49
- * @returns {import("@eox/jsonform").EOxJSONForm}
50
- */
51
- get jsonForm() {
52
- return this.shadowRoot.querySelector("eox-jsonform");
83
+ attributeChangedCallback(name, oldVal, newVal) {
84
+ if (oldVal === newVal) return;
85
+ if (name === "endpoint" && this.endpoint !== newVal) {
86
+ this.endpoint = newVal;
87
+ } else if (name === "unstyled") {
88
+ this.render();
89
+ }
53
90
  }
54
91
 
55
92
  connectedCallback() {
56
93
  this.endpoint =
94
+ this.endpoint ||
57
95
  this.getAttribute("endpoint") ||
58
96
  document.querySelector("eox-feedback-button")?.getAttribute("endpoint");
59
97
 
@@ -105,6 +143,7 @@ export class EOxFeedback extends HTMLElement {
105
143
  document.removeEventListener("keyup", (e) => this.onKeyboardInput(e));
106
144
  }
107
145
 
146
+ /** @private */
108
147
  onKeyboardInput(e) {
109
148
  if (e.keyCode === 27) {
110
149
  this.onCancel();
@@ -117,6 +156,7 @@ export class EOxFeedback extends HTMLElement {
117
156
  }
118
157
  }
119
158
 
159
+ /** @private */
120
160
  onTextareaInput() {
121
161
  const submitButton = this.shadowRoot.querySelector("button#submit");
122
162
  const textarea = this.shadowRoot.querySelector("textarea#message");
@@ -127,10 +167,7 @@ export class EOxFeedback extends HTMLElement {
127
167
  }
128
168
  }
129
169
 
130
- onOverlayDraw(e) {
131
- this.areaSelection = e.detail;
132
- }
133
-
170
+ /** @private */
134
171
  onJsonFormChange() {
135
172
  /** @type {import("@eox/jsonform").EOxJSONForm} */
136
173
  const jsonForm = this.shadowRoot.querySelector("eox-jsonform");
@@ -145,6 +182,7 @@ export class EOxFeedback extends HTMLElement {
145
182
  }
146
183
  }
147
184
 
185
+ /** @private */
148
186
  async onToggleScreenshot(e) {
149
187
  this.includeScreenshot = e.target.checked;
150
188
 
@@ -212,6 +250,7 @@ export class EOxFeedback extends HTMLElement {
212
250
  });
213
251
  }
214
252
 
253
+ /** @private */
215
254
  async onSubmit() {
216
255
  const container = this.shadowRoot.querySelector("article > div");
217
256
  const form = this.shadowRoot.querySelector("#form");
@@ -293,6 +332,7 @@ export class EOxFeedback extends HTMLElement {
293
332
  }, 4000);
294
333
  }
295
334
 
335
+ /** @private */
296
336
  onCancel() {
297
337
  if (this.regionScreenshot) {
298
338
  this.regionScreenshot.close();
@@ -301,6 +341,7 @@ export class EOxFeedback extends HTMLElement {
301
341
  this.dispatchEvent(new Event("close"));
302
342
  }
303
343
 
344
+ /** @private */
304
345
  render() {
305
346
  /**
306
347
  * @type {import("./feedback-button").EOxFeedbackButton}
@@ -9,9 +9,15 @@ export class EOxFeedbackButton extends HTMLElement {
9
9
  */
10
10
  modal: import("./main").EOxFeedback;
11
11
  position: string;
12
- _schema: any;
13
- set schema(newSchema: any);
14
- get schema(): any;
12
+ _schema: import("@eox/jsonform").JsonSchema;
13
+ /**
14
+ * @param {import("@eox/jsonform").JsonSchema|null} newSchema
15
+ */
16
+ set schema(newSchema: import("@eox/jsonform").JsonSchema | null);
17
+ /**
18
+ * @returns {import("@eox/jsonform").JsonSchema|null}
19
+ */
20
+ get schema(): import("@eox/jsonform").JsonSchema | null;
15
21
  attributeChangedCallback(name: any, oldValue: any, newValue: any): void;
16
22
  connectedCallback(): void;
17
23
  disconnectedCallback(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"feedback-button.d.ts","sourceRoot":"","sources":["../../../src/feedback-button.js"],"names":[],"mappings":"AAMA;;;GAGG;AACH;IACE,oCAAqD;IAMnD;;OAEG;IACH,OAFU,OAAO,QAAQ,EAAE,WAAW,CAErB;IAEjB,iBAA2B;IAE3B,aAAmB;IAOrB,2BAKC;IATD,kBAEC;IASD,wEAOC;IAED,0BAKC;IAED,6BAIC;IAED,sBAiBC;IAED,eAuBC;CACF"}
1
+ {"version":3,"file":"feedback-button.d.ts","sourceRoot":"","sources":["../../../src/feedback-button.js"],"names":[],"mappings":"AAMA;;;GAGG;AACH;IACE,oCAAqD;IAMnD;;OAEG;IACH,OAFU,OAAO,QAAQ,EAAE,WAAW,CAErB;IAEjB,iBAA2B;IAE3B,4CAAmB;IAUrB;;OAEG;IACH,sBAFW,OAAO,eAAe,EAAE,UAAU,GAAC,IAAI,EAOjD;IAfD;;OAEG;IACH,cAFa,OAAO,eAAe,EAAE,UAAU,GAAC,IAAI,CAInD;IAYD,wEAOC;IAED,0BAKC;IAED,6BAIC;IAED,sBAiBC;IAED,eAuBC;CACF"}
@@ -5,35 +5,63 @@
5
5
  * @element eox-feedback
6
6
  *
7
7
  * @attr {string} endpoint - The endpoint to send the feedback to as POST message.
8
- * @attr {string|null} [unstyled=undefined] - If provided, the element will not be styled with EOX styles.
8
+ * @attr {string} unstyled - If provided, the element will not be styled with EOX styles.
9
+ *
10
+ * @property {string} endpoint - The endpoint to send the feedback to as POST message.
11
+ * @property {string} unstyled - If provided, the element will not be styled with EOX styles.
12
+ * @property {import("@eox/jsonform").JsonSchema} schema - The JSON schema for the feedback form (option). Requires `eox-jsonform` to be imported.
9
13
  *
10
14
  * @fires close - The modal was closed.
11
15
  * @fires submit - The feedback was submitted. The `CustomEvent.detail` contains the FormData object.
12
16
  */
13
17
  export class EOxFeedback extends HTMLElement {
14
18
  static observedAttributes: string[];
15
- includeScreenshot: any;
16
- areaSelection: any;
17
- regionScreenshot: any;
18
- screenShotFile: File;
19
- endpoint: string;
20
- _schema: any;
21
- _submitted: boolean;
22
- set schema(newSchema: any);
23
- get schema(): any;
19
+ /** @private */
20
+ private includeScreenshot;
21
+ /** @private */
22
+ private areaSelection;
23
+ /** @private */
24
+ private regionScreenshot;
25
+ /** @private */
26
+ private screenShotFile;
27
+ /** @private */
28
+ private _endpoint;
29
+ /** @private */
30
+ private _schema;
31
+ /** @private */
32
+ private _submitted;
33
+ /**
34
+ * @param {string} val
35
+ */
36
+ set endpoint(val: string);
37
+ /**
38
+ * @returns {string}
39
+ */
40
+ get endpoint(): string;
41
+ /**
42
+ * @param {import("@eox/jsonform").JsonSchema|null} newSchema
43
+ */
44
+ set schema(newSchema: import("@eox/jsonform").JsonSchema | null);
24
45
  /**
25
- * @returns {import("@eox/jsonform").EOxJSONForm}
46
+ * @returns {import("@eox/jsonform").JsonSchema|null}
26
47
  */
27
- get jsonForm(): import("@eox/jsonform").EOxJSONForm;
48
+ get schema(): import("@eox/jsonform").JsonSchema | null;
49
+ attributeChangedCallback(name: any, oldVal: any, newVal: any): void;
28
50
  connectedCallback(): void;
29
51
  disconnectedCallback(): void;
30
- onKeyboardInput(e: any): void;
31
- onTextareaInput(): void;
32
- onOverlayDraw(e: any): void;
33
- onJsonFormChange(): void;
34
- onToggleScreenshot(e: any): Promise<void>;
35
- onSubmit(): Promise<void>;
36
- onCancel(): void;
37
- render(): void;
52
+ /** @private */
53
+ private onKeyboardInput;
54
+ /** @private */
55
+ private onTextareaInput;
56
+ /** @private */
57
+ private onJsonFormChange;
58
+ /** @private */
59
+ private onToggleScreenshot;
60
+ /** @private */
61
+ private onSubmit;
62
+ /** @private */
63
+ private onCancel;
64
+ /** @private */
65
+ private render;
38
66
  }
39
67
  //# sourceMappingURL=main.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/main.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH;IACE,oCAAqD;IAMnD,uBAA6B;IAC7B,mBAAyB;IAEzB,sBAA4B;IAE5B,qBAA0B;IAE1B,iBAAoB;IAEpB,aAAmB;IAEnB,oBAAuB;IAOzB,2BAGC;IAPD,kBAEC;IAOD;;OAEG;IACH,gBAFa,OAAO,eAAe,EAAE,WAAW,CAI/C;IAED,0BA2BC;IAED,6BAsBC;IAED,8BAUC;IAED,wBAQC;IAED,4BAEC;IAED,yBAYC;IAED,0CAiEC;IAED,0BA+EC;IAED,iBAMC;IAED,eAwGC;CACF"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/main.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;GAeG;AACH;IACE,oCAAqD;IAMnD,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,OAAO,eAAe,EAAE,UAAU,GAAC,IAAI,EAKjD;IAbD;;OAEG;IACH,cAFa,OAAO,eAAe,EAAE,UAAU,GAAC,IAAI,CAInD;IAUD,oEAOC;IAED,0BA4BC;IAED,6BAsBC;IAED,eAAe;IACf,wBAUC;IAED,eAAe;IACf,wBAQC;IAED,eAAe;IACf,yBAYC;IAED,eAAe;IACf,2BAiEC;IAED,eAAe;IACf,iBA+EC;IAED,eAAe;IACf,iBAMC;IAED,eAAe;IACf,eAwGC;CACF"}