@eox/feedback 1.0.1 → 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.
Files changed (192) hide show
  1. package/dist/eox-feedback.js +2478 -2404
  2. package/dist/eox-feedback.umd.cjs +49 -56
  3. package/package.json +10 -3
  4. package/src/feedback-button.js +28 -1
  5. package/src/main.js +196 -26
  6. package/types/drawtools/src/components/controller.d.ts +108 -0
  7. package/types/drawtools/src/components/controller.d.ts.map +1 -0
  8. package/types/drawtools/src/components/list.d.ts +144 -0
  9. package/types/drawtools/src/components/list.d.ts.map +1 -0
  10. package/types/drawtools/src/enums/draw.d.ts +9 -0
  11. package/types/drawtools/src/enums/draw.d.ts.map +1 -0
  12. package/types/drawtools/src/enums/index.d.ts +4 -0
  13. package/types/drawtools/src/enums/index.d.ts.map +1 -0
  14. package/types/drawtools/src/enums/stories.d.ts +26 -0
  15. package/types/drawtools/src/enums/stories.d.ts.map +1 -0
  16. package/types/drawtools/src/enums/test.d.ts +11 -0
  17. package/types/drawtools/src/enums/test.d.ts.map +1 -0
  18. package/types/drawtools/src/helpers/copy-text-to-clipboard.d.ts +7 -0
  19. package/types/drawtools/src/helpers/copy-text-to-clipboard.d.ts.map +1 -0
  20. package/types/drawtools/src/helpers/features-to-geojson.d.ts +12 -0
  21. package/types/drawtools/src/helpers/features-to-geojson.d.ts.map +1 -0
  22. package/types/drawtools/src/helpers/features-to-wkt.d.ts +9 -0
  23. package/types/drawtools/src/helpers/features-to-wkt.d.ts.map +1 -0
  24. package/types/drawtools/src/helpers/generate-upload-events.d.ts +19 -0
  25. package/types/drawtools/src/helpers/generate-upload-events.d.ts.map +1 -0
  26. package/types/drawtools/src/helpers/index.d.ts +4 -0
  27. package/types/drawtools/src/helpers/index.d.ts.map +1 -0
  28. package/types/drawtools/src/main.d.ts +270 -0
  29. package/types/drawtools/src/main.d.ts.map +1 -0
  30. package/types/drawtools/src/methods/controller/index.d.ts +2 -0
  31. package/types/drawtools/src/methods/controller/index.d.ts.map +1 -0
  32. package/types/drawtools/src/methods/controller/update-button-states.d.ts +12 -0
  33. package/types/drawtools/src/methods/controller/update-button-states.d.ts.map +1 -0
  34. package/types/drawtools/src/methods/draw/create-select-handler.d.ts +6 -0
  35. package/types/drawtools/src/methods/draw/create-select-handler.d.ts.map +1 -0
  36. package/types/drawtools/src/methods/draw/discard-drawing.d.ts +9 -0
  37. package/types/drawtools/src/methods/draw/discard-drawing.d.ts.map +1 -0
  38. package/types/drawtools/src/methods/draw/emit-drawn-features.d.ts +20 -0
  39. package/types/drawtools/src/methods/draw/emit-drawn-features.d.ts.map +1 -0
  40. package/types/drawtools/src/methods/draw/handle-layer-id.d.ts +12 -0
  41. package/types/drawtools/src/methods/draw/handle-layer-id.d.ts.map +1 -0
  42. package/types/drawtools/src/methods/draw/index.d.ts +9 -0
  43. package/types/drawtools/src/methods/draw/index.d.ts.map +1 -0
  44. package/types/drawtools/src/methods/draw/init-layer.d.ts +13 -0
  45. package/types/drawtools/src/methods/draw/init-layer.d.ts.map +1 -0
  46. package/types/drawtools/src/methods/draw/init-selection.d.ts +10 -0
  47. package/types/drawtools/src/methods/draw/init-selection.d.ts.map +1 -0
  48. package/types/drawtools/src/methods/draw/on-draw-end.d.ts +9 -0
  49. package/types/drawtools/src/methods/draw/on-draw-end.d.ts.map +1 -0
  50. package/types/drawtools/src/methods/draw/start-drawing.d.ts +9 -0
  51. package/types/drawtools/src/methods/draw/start-drawing.d.ts.map +1 -0
  52. package/types/drawtools/src/methods/list/delete-feature.d.ts +11 -0
  53. package/types/drawtools/src/methods/list/delete-feature.d.ts.map +1 -0
  54. package/types/drawtools/src/methods/list/first-update.d.ts +8 -0
  55. package/types/drawtools/src/methods/list/first-update.d.ts.map +1 -0
  56. package/types/drawtools/src/methods/list/hover-feature.d.ts +10 -0
  57. package/types/drawtools/src/methods/list/hover-feature.d.ts.map +1 -0
  58. package/types/drawtools/src/methods/list/index.d.ts +5 -0
  59. package/types/drawtools/src/methods/list/index.d.ts.map +1 -0
  60. package/types/drawtools/src/methods/list/select-deselect-feature.d.ts +9 -0
  61. package/types/drawtools/src/methods/list/select-deselect-feature.d.ts.map +1 -0
  62. package/types/drawtools/src/style.eox.d.ts.map +1 -0
  63. package/types/{enums → feedback/src/enums}/index.d.ts.map +1 -1
  64. package/types/{enums → feedback/src/enums}/test.d.ts.map +1 -1
  65. package/types/{feedback-button.d.ts → feedback/src/feedback-button.d.ts} +13 -1
  66. package/types/feedback/src/feedback-button.d.ts.map +1 -0
  67. package/types/feedback/src/main.d.ts +67 -0
  68. package/types/feedback/src/main.d.ts.map +1 -0
  69. package/types/{style.d.ts.map → feedback/src/style.d.ts.map} +1 -1
  70. package/types/feedback/src/style.eox.d.ts +2 -0
  71. package/types/{style.eox.d.ts.map → feedback/src/style.eox.d.ts.map} +1 -1
  72. package/types/jsonform/src/custom-inputs/buttons.d.ts +20 -0
  73. package/types/jsonform/src/custom-inputs/buttons.d.ts.map +1 -0
  74. package/types/jsonform/src/custom-inputs/index.d.ts +5 -0
  75. package/types/jsonform/src/custom-inputs/index.d.ts.map +1 -0
  76. package/types/jsonform/src/custom-inputs/minmax.d.ts +16 -0
  77. package/types/jsonform/src/custom-inputs/minmax.d.ts.map +1 -0
  78. package/types/jsonform/src/custom-inputs/spatial/editor.d.ts +19 -0
  79. package/types/jsonform/src/custom-inputs/spatial/editor.d.ts.map +1 -0
  80. package/types/jsonform/src/custom-inputs/spatial/index.d.ts +3 -0
  81. package/types/jsonform/src/custom-inputs/spatial/index.d.ts.map +1 -0
  82. package/types/jsonform/src/custom-inputs/spatial/utils.d.ts +22 -0
  83. package/types/jsonform/src/custom-inputs/spatial/utils.d.ts.map +1 -0
  84. package/types/jsonform/src/custom-inputs/spatial/validator.d.ts +16 -0
  85. package/types/jsonform/src/custom-inputs/spatial/validator.d.ts.map +1 -0
  86. package/types/jsonform/src/enums/editor.d.ts +11 -0
  87. package/types/jsonform/src/enums/editor.d.ts.map +1 -0
  88. package/types/jsonform/src/enums/index.d.ts +4 -0
  89. package/types/jsonform/src/enums/index.d.ts.map +1 -0
  90. package/types/jsonform/src/enums/stories.d.ts +38 -0
  91. package/types/jsonform/src/enums/stories.d.ts.map +1 -0
  92. package/types/jsonform/src/enums/test.d.ts +4 -0
  93. package/types/jsonform/src/enums/test.d.ts.map +1 -0
  94. package/types/jsonform/src/helpers/editor.d.ts +18 -0
  95. package/types/jsonform/src/helpers/editor.d.ts.map +1 -0
  96. package/types/jsonform/src/helpers/index.d.ts +2 -0
  97. package/types/jsonform/src/helpers/index.d.ts.map +1 -0
  98. package/types/jsonform/src/main.d.ts +157 -0
  99. package/types/jsonform/src/main.d.ts.map +1 -0
  100. package/types/jsonform/src/style.d.ts +2 -0
  101. package/types/jsonform/src/style.d.ts.map +1 -0
  102. package/types/jsonform/src/style.eox.d.ts +2 -0
  103. package/types/jsonform/src/style.eox.d.ts.map +1 -0
  104. package/types/map/src/components/compare.d.ts +31 -0
  105. package/types/map/src/components/compare.d.ts.map +1 -0
  106. package/types/map/src/components/tooltip.d.ts +41 -0
  107. package/types/map/src/components/tooltip.d.ts.map +1 -0
  108. package/types/map/src/controls/controls.d.ts +21 -0
  109. package/types/map/src/controls/controls.d.ts.map +1 -0
  110. package/types/map/src/controls/geo-location.d.ts +41 -0
  111. package/types/map/src/controls/geo-location.d.ts.map +1 -0
  112. package/types/map/src/controls/loading-indicator.d.ts +20 -0
  113. package/types/map/src/controls/loading-indicator.d.ts.map +1 -0
  114. package/types/map/src/custom/layers/MapboxStyle.d.ts +13 -0
  115. package/types/map/src/custom/layers/MapboxStyle.d.ts.map +1 -0
  116. package/types/map/src/custom/sources/Cluster.d.ts +20 -0
  117. package/types/map/src/custom/sources/Cluster.d.ts.map +1 -0
  118. package/types/map/src/custom/sources/FlatGeoBuf.d.ts +28 -0
  119. package/types/map/src/custom/sources/FlatGeoBuf.d.ts.map +1 -0
  120. package/types/map/src/custom/sources/WMTSCapabilities.d.ts +35 -0
  121. package/types/map/src/custom/sources/WMTSCapabilities.d.ts.map +1 -0
  122. package/types/map/src/enums/index.d.ts +2 -0
  123. package/types/map/src/enums/index.d.ts.map +1 -0
  124. package/types/map/src/enums/map.d.ts +5 -0
  125. package/types/map/src/enums/map.d.ts.map +1 -0
  126. package/types/map/src/helpers/add-new-feature.d.ts +15 -0
  127. package/types/map/src/helpers/add-new-feature.d.ts.map +1 -0
  128. package/types/map/src/helpers/cancel-animation.d.ts +7 -0
  129. package/types/map/src/helpers/cancel-animation.d.ts.map +1 -0
  130. package/types/map/src/helpers/center.d.ts +12 -0
  131. package/types/map/src/helpers/center.d.ts.map +1 -0
  132. package/types/map/src/helpers/cluster-explode.d.ts +38 -0
  133. package/types/map/src/helpers/cluster-explode.d.ts.map +1 -0
  134. package/types/map/src/helpers/coordinates-roughly-equals.d.ts +12 -0
  135. package/types/map/src/helpers/coordinates-roughly-equals.d.ts.map +1 -0
  136. package/types/map/src/helpers/draw.d.ts +22 -0
  137. package/types/map/src/helpers/draw.d.ts.map +1 -0
  138. package/types/map/src/helpers/generate.d.ts +32 -0
  139. package/types/map/src/helpers/generate.d.ts.map +1 -0
  140. package/types/map/src/helpers/index.d.ts +17 -0
  141. package/types/map/src/helpers/index.d.ts.map +1 -0
  142. package/types/map/src/helpers/interactions.d.ts +16 -0
  143. package/types/map/src/helpers/interactions.d.ts.map +1 -0
  144. package/types/map/src/helpers/layer.d.ts +24 -0
  145. package/types/map/src/helpers/layer.d.ts.map +1 -0
  146. package/types/map/src/helpers/parse-feature.d.ts +8 -0
  147. package/types/map/src/helpers/parse-feature.d.ts.map +1 -0
  148. package/types/map/src/helpers/parse-text.d.ts +45 -0
  149. package/types/map/src/helpers/parse-text.d.ts.map +1 -0
  150. package/types/map/src/helpers/register-projection-from-code.d.ts +8 -0
  151. package/types/map/src/helpers/register-projection-from-code.d.ts.map +1 -0
  152. package/types/map/src/helpers/register-projection.d.ts +11 -0
  153. package/types/map/src/helpers/register-projection.d.ts.map +1 -0
  154. package/types/map/src/helpers/select.d.ts +95 -0
  155. package/types/map/src/helpers/select.d.ts.map +1 -0
  156. package/types/map/src/helpers/tile-grid.d.ts +10 -0
  157. package/types/map/src/helpers/tile-grid.d.ts.map +1 -0
  158. package/types/map/src/helpers/transform.d.ts +19 -0
  159. package/types/map/src/helpers/transform.d.ts.map +1 -0
  160. package/types/map/src/layers.d.ts +125 -0
  161. package/types/map/src/layers.d.ts.map +1 -0
  162. package/types/map/src/main.d.ts +459 -0
  163. package/types/map/src/main.d.ts.map +1 -0
  164. package/types/map/src/methods/map/add-update-layer.d.ts +13 -0
  165. package/types/map/src/methods/map/add-update-layer.d.ts.map +1 -0
  166. package/types/map/src/methods/map/animate-to-state.d.ts +7 -0
  167. package/types/map/src/methods/map/animate-to-state.d.ts.map +1 -0
  168. package/types/map/src/methods/map/first-updated.d.ts +9 -0
  169. package/types/map/src/methods/map/first-updated.d.ts.map +1 -0
  170. package/types/map/src/methods/map/getters.d.ts +22 -0
  171. package/types/map/src/methods/map/getters.d.ts.map +1 -0
  172. package/types/map/src/methods/map/index.d.ts +7 -0
  173. package/types/map/src/methods/map/index.d.ts.map +1 -0
  174. package/types/map/src/methods/map/remove.d.ts +22 -0
  175. package/types/map/src/methods/map/remove.d.ts.map +1 -0
  176. package/types/map/src/methods/map/setters.d.ts +82 -0
  177. package/types/map/src/methods/map/setters.d.ts.map +1 -0
  178. package/types/map/src/plugins/globe/index.d.ts +6 -0
  179. package/types/map/src/plugins/globe/index.d.ts.map +1 -0
  180. package/types/map/src/plugins/globe/methods.d.ts +8 -0
  181. package/types/map/src/plugins/globe/methods.d.ts.map +1 -0
  182. package/types/map/src/plugins/globe/openglobus.d.ts +16 -0
  183. package/types/map/src/plugins/globe/openglobus.d.ts.map +1 -0
  184. package/types/map/src/types.d.ts +178 -0
  185. package/types/map/src/types.d.ts.map +1 -0
  186. package/types/feedback-button.d.ts.map +0 -1
  187. package/types/main.d.ts +0 -25
  188. package/types/main.d.ts.map +0 -1
  189. /package/types/{style.eox.d.ts → drawtools/src/style.eox.d.ts} +0 -0
  190. /package/types/{enums → feedback/src/enums}/index.d.ts +0 -0
  191. /package/types/{enums → feedback/src/enums}/test.d.ts +0 -0
  192. /package/types/{style.d.ts → feedback/src/style.d.ts} +0 -0
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "name": "@eox/feedback",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git@github.com:EOX-A/EOxElements.git"
8
+ },
5
9
  "devDependencies": {
6
- "vite": "^6.0.3"
10
+ "vite": "^7.1.12"
7
11
  },
8
12
  "dependencies": {
9
13
  "@eox/elements-utils": "^1.1.0",
10
- "@eox/ui": "^0.3.6",
14
+ "@eox/ui": "^0.5.0",
11
15
  "region-screenshot-js": "^1.1.0"
12
16
  },
13
17
  "files": [
@@ -32,5 +36,8 @@
32
36
  "prepack": "npm run types:generate",
33
37
  "build": "vite build",
34
38
  "watch": "vite build --watch"
39
+ },
40
+ "peerDependencies": {
41
+ "@eox/jsonform": "*"
35
42
  }
36
43
  }
@@ -15,9 +15,31 @@ export class EOxFeedbackButton extends HTMLElement {
15
15
  super();
16
16
  this.attachShadow({ mode: "open" });
17
17
 
18
+ /**
19
+ * @type {import("./main").EOxFeedback}
20
+ */
18
21
  this.modal = null;
19
22
 
20
23
  this.position = "top-right";
24
+
25
+ this._schema = null;
26
+ }
27
+
28
+ /**
29
+ * @returns {import("@eox/jsonform").JsonSchema|null}
30
+ */
31
+ get schema() {
32
+ return this._schema;
33
+ }
34
+
35
+ /**
36
+ * @param {import("@eox/jsonform").JsonSchema|null} newSchema
37
+ */
38
+ set schema(newSchema) {
39
+ this._schema = newSchema;
40
+ if (this.modal) {
41
+ this.modal.schema = this._schema;
42
+ }
21
43
  }
22
44
 
23
45
  attributeChangedCallback(name, oldValue, newValue) {
@@ -44,10 +66,15 @@ export class EOxFeedbackButton extends HTMLElement {
44
66
 
45
67
  onButtonClick() {
46
68
  if (!this.modal) {
47
- this.modal = document.createElement("eox-feedback");
69
+ this.modal = /** @type {import("./main").EOxFeedback} */ (
70
+ document.createElement("eox-feedback")
71
+ );
48
72
  if (this.getAttribute("unstyled") !== null) {
49
73
  this.modal.setAttribute("unstyled", this.getAttribute("unstyled"));
50
74
  }
75
+ if (this.schema) {
76
+ this.modal.schema = this.schema;
77
+ }
51
78
  document.body.appendChild(this.modal);
52
79
  this.modal.addEventListener("close", () => (this.modal = null));
53
80
  } else {
package/src/main.js CHANGED
@@ -4,8 +4,17 @@ import { styleEOX } from "./style.eox";
4
4
  import "./feedback-button.js";
5
5
 
6
6
  /**
7
+ * The `eox-feedback` element provides a modal dialog for collecting user feedback. It supports screenshot capture, customizable endpoint, and flexible styling.
8
+ * The feedback modal (`<eox-feedback></eox-feedback>`) can be included in the DOM directly or via a floating button (`<eox-feedback-button></eox-feedback-button>`), which can be positioned in any corner of the viewport.
9
+ *
10
+ * @element eox-feedback
11
+ *
7
12
  * @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.
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.
9
18
  *
10
19
  * @fires close - The modal was closed.
11
20
  * @fires submit - The feedback was submitted. The `CustomEvent.detail` contains the FormData object.
@@ -17,19 +26,75 @@ export class EOxFeedback extends HTMLElement {
17
26
  super();
18
27
  this.attachShadow({ mode: "open" });
19
28
 
29
+ /** @private */
20
30
  this.includeScreenshot = null;
31
+ /** @private */
21
32
  this.areaSelection = null;
22
33
 
34
+ /** @private */
23
35
  this.regionScreenshot = null;
24
36
 
37
+ /** @private */
25
38
  this.screenShotFile = null;
26
39
 
40
+ /** @private */
41
+ this._endpoint = null;
42
+
43
+ /** @private */
44
+ this._schema = null;
45
+
46
+ /** @private */
47
+ this._submitted = false;
48
+ }
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
+ */
71
+ get schema() {
72
+ return this._schema;
73
+ }
74
+
75
+ /**
76
+ * @param {import("@eox/jsonform").JsonSchema|null} newSchema
77
+ */
78
+ set schema(newSchema) {
79
+ this._schema = newSchema;
80
+ this.render();
81
+ }
82
+
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
+ }
90
+ }
91
+
92
+ connectedCallback() {
27
93
  this.endpoint =
94
+ this.endpoint ||
28
95
  this.getAttribute("endpoint") ||
29
96
  document.querySelector("eox-feedback-button")?.getAttribute("endpoint");
30
- }
31
97
 
32
- connectedCallback() {
33
98
  this.render();
34
99
  this.shadowRoot
35
100
  .querySelector("input[type=checkbox]")
@@ -40,9 +105,17 @@ export class EOxFeedback extends HTMLElement {
40
105
  this.shadowRoot
41
106
  .querySelector("button#cancel")
42
107
  .addEventListener("click", () => this.onCancel());
43
- this.shadowRoot
44
- .querySelector("textarea")
45
- .addEventListener("input", (e) => this.onTextInput(e));
108
+
109
+ const jsonForm = this.shadowRoot.querySelector("eox-jsonform");
110
+ if (jsonForm) {
111
+ jsonForm.addEventListener("change", () => this.onJsonFormChange());
112
+ }
113
+
114
+ const textarea = this.shadowRoot.querySelector("textarea#message");
115
+ if (textarea) {
116
+ textarea.addEventListener("input", () => this.onTextareaInput());
117
+ }
118
+
46
119
  document.addEventListener("keyup", (e) => this.onKeyboardInput(e));
47
120
  }
48
121
 
@@ -56,36 +129,60 @@ export class EOxFeedback extends HTMLElement {
56
129
  this.shadowRoot
57
130
  .querySelector("button#cancel")
58
131
  .removeEventListener("click", () => this.onCancel());
59
- this.shadowRoot
60
- .querySelector("textarea")
61
- .removeEventListener("input", (e) => this.onTextInput(e));
132
+
133
+ const jsonForm = this.shadowRoot.querySelector("eox-jsonform");
134
+ if (jsonForm) {
135
+ jsonForm.removeEventListener("change", () => this.onJsonFormChange());
136
+ }
137
+
138
+ const textarea = this.shadowRoot.querySelector("textarea#message");
139
+ if (textarea) {
140
+ textarea.removeEventListener("input", () => this.onTextareaInput());
141
+ }
142
+
62
143
  document.removeEventListener("keyup", (e) => this.onKeyboardInput(e));
63
144
  }
64
145
 
146
+ /** @private */
65
147
  onKeyboardInput(e) {
66
148
  if (e.keyCode === 27) {
67
149
  this.onCancel();
68
150
  }
69
151
  if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
70
- if (this.shadowRoot.querySelector("textarea").value.length > 0) {
152
+ const submitButton = this.shadowRoot.querySelector("button#submit");
153
+ if (!submitButton.classList.contains("disabled")) {
71
154
  this.onSubmit();
72
155
  }
73
156
  }
74
157
  }
75
158
 
76
- onOverlayDraw(e) {
77
- this.areaSelection = e.detail;
78
- }
79
-
80
- onTextInput(e) {
159
+ /** @private */
160
+ onTextareaInput() {
81
161
  const submitButton = this.shadowRoot.querySelector("button#submit");
82
- if (e.target.value.length > 0) {
162
+ const textarea = this.shadowRoot.querySelector("textarea#message");
163
+ if (/** @type {HTMLTextAreaElement} */ (textarea).value.length >= 10) {
83
164
  submitButton.classList.remove("disabled");
84
165
  } else {
85
166
  submitButton.classList.add("disabled");
86
167
  }
87
168
  }
88
169
 
170
+ /** @private */
171
+ onJsonFormChange() {
172
+ /** @type {import("@eox/jsonform").EOxJSONForm} */
173
+ const jsonForm = this.shadowRoot.querySelector("eox-jsonform");
174
+ const submitButton = this.shadowRoot.querySelector("button#submit");
175
+ if (jsonForm.editor) {
176
+ const errors = jsonForm.editor.validate();
177
+ if (errors.length === 0) {
178
+ submitButton.classList.remove("disabled");
179
+ } else {
180
+ submitButton.classList.add("disabled");
181
+ }
182
+ }
183
+ }
184
+
185
+ /** @private */
89
186
  async onToggleScreenshot(e) {
90
187
  this.includeScreenshot = e.target.checked;
91
188
 
@@ -105,7 +202,6 @@ export class EOxFeedback extends HTMLElement {
105
202
  return;
106
203
  }
107
204
 
108
- const inputField = this.shadowRoot.querySelector("textarea");
109
205
  const submitButton = this.shadowRoot.querySelector("button#submit");
110
206
  submitButton.classList.add("disabled");
111
207
 
@@ -117,7 +213,16 @@ export class EOxFeedback extends HTMLElement {
117
213
  if (!(checkbox instanceof HTMLInputElement)) return;
118
214
  checkbox.checked = false;
119
215
  this.includeScreenshot = false;
120
- if (inputField.value.length > 0) {
216
+
217
+ const jsonForm = this.shadowRoot.querySelector("eox-jsonform");
218
+ const textarea = this.shadowRoot.querySelector("textarea#message");
219
+
220
+ if (jsonForm) {
221
+ submitButton.classList.remove("disabled");
222
+ } else if (
223
+ textarea &&
224
+ /** @type {HTMLTextAreaElement} */ (textarea).value.length >= 10
225
+ ) {
121
226
  submitButton.classList.remove("disabled");
122
227
  }
123
228
  });
@@ -145,6 +250,7 @@ export class EOxFeedback extends HTMLElement {
145
250
  });
146
251
  }
147
252
 
253
+ /** @private */
148
254
  async onSubmit() {
149
255
  const container = this.shadowRoot.querySelector("article > div");
150
256
  const form = this.shadowRoot.querySelector("#form");
@@ -158,10 +264,39 @@ export class EOxFeedback extends HTMLElement {
158
264
  requestBody.append("file", this.screenShotFile);
159
265
  }
160
266
 
161
- requestBody.append(
162
- "message",
163
- this.shadowRoot.querySelector("textarea").value,
164
- );
267
+ /** @type {import("@eox/jsonform").EOxJSONForm} */
268
+ const jsonForm = this.shadowRoot.querySelector("eox-jsonform");
269
+ const textarea = this.shadowRoot.querySelector("textarea#message");
270
+
271
+ if (jsonForm) {
272
+ this._submitted = true;
273
+ if (jsonForm.editor) {
274
+ jsonForm.editor.options.show_errors = "always";
275
+
276
+ // Remove the style that hides errors
277
+ if (jsonForm.shadowRoot) {
278
+ const style = jsonForm.shadowRoot.querySelector("#hide-errors");
279
+ if (style) {
280
+ style.remove();
281
+ }
282
+ }
283
+
284
+ const errors = jsonForm.editor.validate();
285
+ if (errors.length > 0) {
286
+ jsonForm.editor.showValidationErrors(errors);
287
+ return;
288
+ }
289
+ }
290
+ const value = jsonForm.value;
291
+ Object.keys(value).forEach((key) => {
292
+ requestBody.append(key, value[key]);
293
+ });
294
+ } else if (textarea) {
295
+ requestBody.append(
296
+ "message",
297
+ /** @type {HTMLTextAreaElement} */ (textarea).value,
298
+ );
299
+ }
165
300
 
166
301
  requestBody.append("userAgent", window.navigator.userAgent);
167
302
 
@@ -197,6 +332,7 @@ export class EOxFeedback extends HTMLElement {
197
332
  }, 4000);
198
333
  }
199
334
 
335
+ /** @private */
200
336
  onCancel() {
201
337
  if (this.regionScreenshot) {
202
338
  this.regionScreenshot.close();
@@ -205,11 +341,39 @@ export class EOxFeedback extends HTMLElement {
205
341
  this.dispatchEvent(new Event("close"));
206
342
  }
207
343
 
344
+ /** @private */
208
345
  render() {
209
346
  /**
210
347
  * @type {import("./feedback-button").EOxFeedbackButton}
211
348
  */
212
349
  const feedbackButton = document.querySelector("eox-feedback-button");
350
+
351
+ const hasSchema = !!this.schema;
352
+ const hasJsonForm = !!customElements.get("eox-jsonform");
353
+
354
+ let formContent = "";
355
+
356
+ if (hasSchema) {
357
+ if (hasJsonForm) {
358
+ formContent = `<eox-jsonform></eox-jsonform>`;
359
+ } else {
360
+ console.error(
361
+ "eox-feedback: Schema provided but eox-jsonform not registered. Please import @eox/jsonform.",
362
+ );
363
+ formContent = `<p style="color: red; padding: 1rem;">Error: Schema provided but eox-jsonform not available.</p>`;
364
+ }
365
+ } else {
366
+ formContent = `
367
+ <div class="field textarea border">
368
+ <textarea id="message" placeholder="${
369
+ !this.endpoint
370
+ ? "Missing endpoint attribute!"
371
+ : "Type your feedback here! Also include some contact info if you'd like us to reach out to you."
372
+ }"></textarea>
373
+ </div>
374
+ `;
375
+ }
376
+
213
377
  this.shadowRoot.innerHTML = `
214
378
  <style>
215
379
  ${style}
@@ -263,19 +427,25 @@ export class EOxFeedback extends HTMLElement {
263
427
  </div>
264
428
  </nav>
265
429
  <div id="screenshot" class="middle-align center-align"></div>
266
- <div class="field textarea border">
267
- <textarea placeholder="${!this.endpoint ? "Missing endpoint attribute!" : "Type your feedback here! Also include some contact info if you'd like us to reach out to you."}"></textarea>
268
- </div>
430
+ ${formContent}
269
431
  <nav>
270
432
  <progress class="circle small hidden"></progress>
271
433
  <div class="max"></div>
272
434
  <button id="cancel" class="border">Cancel</button>
273
- <button id="submit" class="disabled">Submit</button>
435
+ <button id="submit" class="${
436
+ hasSchema && hasJsonForm ? "" : "disabled"
437
+ }">Submit</button>
274
438
  </nav>
275
439
  </div>
276
440
  </div>
277
441
  </article>
278
442
  `;
443
+
444
+ if (hasSchema && hasJsonForm) {
445
+ /** @type {import("@eox/jsonform").EOxJSONForm} */
446
+ const jsonForm = this.shadowRoot.querySelector("eox-jsonform");
447
+ jsonForm.schema = this.schema;
448
+ }
279
449
  }
280
450
  }
281
451
 
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Controller component for drawing features
3
+ *
4
+ * @element eox-drawtools-controller
5
+ */
6
+ export class EOxDrawToolsController extends LitElement {
7
+ static properties: {
8
+ multipleFeatures: {
9
+ attribute: boolean;
10
+ type: BooleanConstructor;
11
+ };
12
+ drawnFeatures: {
13
+ attribute: boolean;
14
+ state: boolean;
15
+ type: ArrayConstructor;
16
+ };
17
+ currentlyDrawing: {
18
+ attribute: boolean;
19
+ state: boolean;
20
+ type: BooleanConstructor;
21
+ };
22
+ drawFunc: {
23
+ attribute: boolean;
24
+ type: ObjectConstructor;
25
+ };
26
+ select: {
27
+ type: BooleanConstructor;
28
+ };
29
+ importFeatures: {
30
+ attribute: string;
31
+ type: BooleanConstructor;
32
+ };
33
+ showEditor: {
34
+ attribute: string;
35
+ type: BooleanConstructor;
36
+ };
37
+ geoJSON: {
38
+ attribute: string;
39
+ type: StringConstructor;
40
+ };
41
+ type: {
42
+ attribute: string;
43
+ type: StringConstructor;
44
+ };
45
+ unstyled: {
46
+ type: BooleanConstructor;
47
+ };
48
+ };
49
+ /**
50
+ * Allow adding more than one feature at a time
51
+ */
52
+ multipleFeatures: boolean;
53
+ /**
54
+ * The array of drawn native OpenLayers features. Normally includes only one feature,
55
+ * until multiple feature drawing is enabled.
56
+ *
57
+ * @type Array<import("ol").Feature>
58
+ */
59
+ drawnFeatures: Array<import("ol").Feature>;
60
+ /**
61
+ * Allow import features using drag-drop and upload button
62
+ * @type Boolean
63
+ */
64
+ importFeatures: boolean;
65
+ /**
66
+ * Show geo-json editor for draw tool
67
+ * @type Boolean
68
+ */
69
+ showEditor: boolean;
70
+ /**
71
+ * Whether the user is currently in the process of drawing or not
72
+ */
73
+ currentlyDrawing: boolean;
74
+ /**
75
+ * List of draw function object like start, discard etc.
76
+ */
77
+ drawFunc: any;
78
+ /**
79
+ * Parsed and Stringify Geo JSON
80
+ * @type String
81
+ */
82
+ geoJSON: string;
83
+ /**
84
+ * Type of the drawn feature
85
+ * @type {"Polygon" | "Point" | "LineString" | "Circle" | "Box"}
86
+ */
87
+ type: "Polygon" | "Point" | "LineString" | "Circle" | "Box";
88
+ /**
89
+ * Render the element without additional styles
90
+ */
91
+ unstyled: boolean;
92
+ /**
93
+ *
94
+ */
95
+ select: boolean;
96
+ /**
97
+ * Updates button states based on conditions
98
+ */
99
+ updateButtonStates(): void;
100
+ /**
101
+ * Overrides createRenderRoot to handle shadow DOM
102
+ */
103
+ createRenderRoot(): this;
104
+ render(): import("lit-html").TemplateResult<1>;
105
+ #private;
106
+ }
107
+ import { LitElement } from "lit";
108
+ //# sourceMappingURL=controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../../../drawtools/src/components/controller.js"],"names":[],"mappings":"AAKA;;;;GAIG;AACH;IAEE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAWE;IAeA;;OAEG;IACH,0BAA6B;IAE7B;;;;;OAKG;IACH,eAFS,KAAK,CAAC,OAAO,IAAI,EAAE,OAAO,CAAC,CAEb;IAEvB;;;OAGG;IACH,wBAA2B;IAE3B;;;OAGG;IACH,oBAAuB;IAEvB;;OAEG;IACH,0BAA6B;IAE7B;;OAEG;IACH,cAAoB;IAEpB;;;OAGG;IACH,gBAAiB;IAEjB;;;OAGG;IACH,MAFU,SAAS,GAAG,OAAO,GAAG,YAAY,GAAG,QAAQ,GAAG,KAAK,CAE1C;IAErB;;OAEG;IACH,kBAAqB;IAErB;;OAEG;IACH,gBAAmB;IAGrB;;OAEG;IACH,2BAKC;IAED;;OAEG;IACH,yBAEC;IAED,+CA0NC;;CACF;2BA5UyC,KAAK"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Display list of features
3
+ *
4
+ * @element eox-drawtools-list
5
+ */
6
+ export class EOxDrawToolsList extends LitElement {
7
+ static properties: {
8
+ eoxDrawTools: {
9
+ attribute: boolean;
10
+ state: boolean;
11
+ };
12
+ eoxMap: {
13
+ attribute: boolean;
14
+ state: boolean;
15
+ };
16
+ olMap: {
17
+ attribute: boolean;
18
+ state: boolean;
19
+ };
20
+ draw: {
21
+ attribute: boolean;
22
+ state: boolean;
23
+ };
24
+ drawLayer: {
25
+ attribute: boolean;
26
+ state: boolean;
27
+ };
28
+ drawnFeatures: {
29
+ attribute: boolean;
30
+ state: boolean;
31
+ type: ArrayConstructor;
32
+ };
33
+ featureName: {
34
+ attribute: boolean;
35
+ state: boolean;
36
+ type: StringConstructor;
37
+ };
38
+ featureNameKey: {
39
+ attribute: boolean;
40
+ state: boolean;
41
+ type: StringConstructor;
42
+ };
43
+ modify: {
44
+ attribute: boolean;
45
+ state: boolean;
46
+ };
47
+ unstyled: {
48
+ type: BooleanConstructor;
49
+ };
50
+ };
51
+ /**
52
+ * @type {import("@eox/map").EOxMap["selectInteractions"][string]}
53
+ */
54
+ hoverInteraction: import("@eox/map").EOxMap["selectInteractions"][string];
55
+ /**
56
+ * @type {import("@eox/map").EOxMap["selectInteractions"][string]}
57
+ */
58
+ clickInteraction: import("@eox/map").EOxMap["selectInteractions"][string];
59
+ /**
60
+ * @type string | number
61
+ */
62
+ hoverId: string | number;
63
+ /**
64
+ * @type string | number
65
+ */
66
+ clickId: string | number;
67
+ /**
68
+ * @type import("../main").EOxDrawTools;
69
+ */
70
+ eoxDrawTools: import("../main").EOxDrawTools;
71
+ /**
72
+ * @type import("@eox/map").EOxMap
73
+ */
74
+ eoxMap: import("@eox/map").EOxMap;
75
+ /**
76
+ * @type import("ol").Map
77
+ */
78
+ olMap: import("ol").Map;
79
+ /**
80
+ * The current native OpenLayers `draw` interaction
81
+ * @type import("ol/interaction").Draw
82
+ */
83
+ draw: import("ol/interaction").Draw;
84
+ /**
85
+ * The current native OpenLayers draw `layer`
86
+ * @type import("ol/layer").Vector<import("ol/source").Vector>
87
+ */
88
+ drawLayer: import("ol/layer").Vector<import("ol/source").Vector>;
89
+ /**
90
+ * The array of drawn native OpenLayers features. Normally includes only one feature,
91
+ * until multiple feature drawing is enabled.
92
+ *
93
+ * @type Array<import("ol").Feature>
94
+ */
95
+ drawnFeatures: Array<import("ol").Feature>;
96
+ /**
97
+ * Default display name for features
98
+ */
99
+ featureName: string;
100
+ /**
101
+ * The key of the property to display in the feature list.
102
+ */
103
+ featureNameKey: any;
104
+ /**
105
+ * The current native OpenLayers `modify` interaction
106
+ * @type import("ol/interaction").Modify
107
+ */
108
+ modify: import("ol/interaction").Modify;
109
+ /**
110
+ * Render the element without additional styles
111
+ */
112
+ unstyled: boolean;
113
+ /**
114
+ * Handles the deletion of an individual feature.
115
+ *
116
+ * @param {Event & { target: HTMLButtonElement }} evt - Event object containing button target.
117
+ */
118
+ _handleDelete(evt: Event & {
119
+ target: HTMLButtonElement;
120
+ }): void;
121
+ /**
122
+ * Handles the selection and deselection of a feature from the list.
123
+ *
124
+ * @param {import("ol").Feature} feature - The selected feature.
125
+ */
126
+ _handleFeatureSelectAndDeselect(feature: import("ol").Feature): void;
127
+ /**
128
+ *
129
+ * @param {number | string | undefined} featureId - The ID of the feature to hover.
130
+ * @param {Boolean} mouseOut - Flag indicating mouse out event.
131
+ */
132
+ _handleHoverFeature(featureId: number | string | undefined, mouseOut?: boolean): void;
133
+ /**
134
+ * Initiates initial settings and event triggers upon the component's first update.
135
+ */
136
+ firstUpdated(): void;
137
+ /**
138
+ * Overrides createRenderRoot to handle shadow DOM.
139
+ */
140
+ createRenderRoot(): this;
141
+ render(): import("lit-html").TemplateResult<1>;
142
+ }
143
+ import { LitElement } from "lit";
144
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../../drawtools/src/components/list.js"],"names":[],"mappings":"AASA;;;;GAIG;AACH;IACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAWE;IAEF;;OAEG;IACH,kBAFU,OAAO,UAAU,EAAE,MAAM,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAEhD;IAEjB;;OAEG;IACH,kBAFU,OAAO,UAAU,EAAE,MAAM,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAEhD;IAEjB;;OAEG;IACH,SAFS,MAAM,GAAG,MAAM,CAEhB;IAER;;OAEG;IACH,SAFS,MAAM,GAAG,MAAM,CAEhB;IAKN;;OAEG;IACH,cAFS,OAAO,SAAS,EAAE,YAAY,CAEf;IAExB;;OAEG;IACH,QAFS,OAAO,UAAU,EAAE,MAAM,CAEhB;IAElB;;OAEG;IACH,OAFS,OAAO,IAAI,EAAE,GAAG,CAER;IAEjB;;;OAGG;IAEH,MAHS,OAAO,gBAAgB,EAAE,IAAI,CAGtB;IAEhB;;;OAGG;IAEH,WAHS,OAAO,UAAU,EAAE,MAAM,CAAC,OAAO,WAAW,EAAE,MAAM,CAAC,CAGzC;IAErB;;;;;OAKG;IACH,eAFS,KAAK,CAAC,OAAO,IAAI,EAAE,OAAO,CAAC,CAEb;IAEvB;;OAEG;IACH,oBAA4B;IAE5B;;OAEG;IACH,oBAA0B;IAE1B;;;OAGG;IAEH,QAHS,OAAO,gBAAgB,EAAE,MAAM,CAGtB;IAElB;;OAEG;IACH,kBAAqB;IAGvB;;;;OAIG;IACH,mBAFW,KAAK,GAAG;QAAE,MAAM,EAAE,iBAAiB,CAAA;KAAE,QAK/C;IAED;;;;OAIG;IACH,yCAFW,OAAO,IAAI,EAAE,OAAO,QAI9B;IAED;;;;OAIG;IACH,+BAHW,MAAM,GAAG,MAAM,GAAG,SAAS,4BAKrC;IAED;;OAEG;IACH,qBAEC;IAED;;OAEG;IACH,yBAEC;IAED,+CAwEC;CACF;2BAlOyC,KAAK"}
@@ -0,0 +1,9 @@
1
+ export namespace FIT_OPTIONS {
2
+ let duration: number;
3
+ let padding: number[];
4
+ }
5
+ export namespace DUMMY_GEO_JSON {
6
+ let type: string;
7
+ let features: any[];
8
+ }
9
+ //# sourceMappingURL=draw.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draw.d.ts","sourceRoot":"","sources":["../../../../../drawtools/src/enums/draw.js"],"names":[],"mappings":""}