@eox/drawtools 0.15.0 → 1.1.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.
Files changed (46) hide show
  1. package/dist/eox-drawtools.js +3031 -2905
  2. package/dist/eox-drawtools.umd.cjs +214 -106
  3. package/dist/material-symbols-outlined.woff2 +0 -0
  4. package/dist/material-symbols-rounded.woff2 +0 -0
  5. package/dist/material-symbols-sharp.woff2 +0 -0
  6. package/dist/material-symbols-subset.woff2 +0 -0
  7. package/package.json +4 -3
  8. package/src/components/controller.js +156 -18
  9. package/src/components/list.js +38 -23
  10. package/src/enums/test.js +1 -0
  11. package/src/main.js +7 -2
  12. package/src/methods/draw/init-layer.js +23 -8
  13. package/src/methods/draw/start-drawing.js +9 -0
  14. package/src/methods/list/delete-feature.js +2 -1
  15. package/src/style.eox.js +13 -41
  16. package/types/drawtools/src/components/controller.d.ts +9 -0
  17. package/types/drawtools/src/components/controller.d.ts.map +1 -1
  18. package/types/drawtools/src/components/list.d.ts.map +1 -1
  19. package/types/drawtools/src/enums/test.d.ts +1 -0
  20. package/types/drawtools/src/main.d.ts.map +1 -1
  21. package/types/drawtools/src/methods/draw/init-layer.d.ts.map +1 -1
  22. package/types/drawtools/src/methods/draw/start-drawing.d.ts.map +1 -1
  23. package/types/drawtools/src/methods/list/delete-feature.d.ts +1 -1
  24. package/types/drawtools/src/methods/list/delete-feature.d.ts.map +1 -1
  25. package/types/drawtools/src/style.eox.d.ts +1 -1
  26. package/types/drawtools/src/style.eox.d.ts.map +1 -1
  27. package/types/map/src/components/compare.d.ts.map +1 -1
  28. package/types/map/src/components/tooltip.d.ts.map +1 -1
  29. package/types/map/src/controls/geo-location.d.ts.map +1 -1
  30. package/types/map/src/custom/sources/Cluster.d.ts +20 -0
  31. package/types/map/src/custom/sources/Cluster.d.ts.map +1 -0
  32. package/types/map/src/helpers/cluster-explode.d.ts +38 -0
  33. package/types/map/src/helpers/cluster-explode.d.ts.map +1 -0
  34. package/types/map/src/helpers/generate.d.ts.map +1 -1
  35. package/types/map/src/helpers/index.d.ts +1 -0
  36. package/types/map/src/helpers/select.d.ts +1 -1
  37. package/types/map/src/helpers/select.d.ts.map +1 -1
  38. package/types/map/src/helpers/tile-grid.d.ts +3 -7
  39. package/types/map/src/helpers/tile-grid.d.ts.map +1 -1
  40. package/types/map/src/layers.d.ts +3 -2
  41. package/types/map/src/layers.d.ts.map +1 -1
  42. package/types/map/src/main.d.ts +1 -1
  43. package/types/map/src/main.d.ts.map +1 -1
  44. package/types/map/src/methods/map/setters.d.ts.map +1 -1
  45. package/types/map/src/types.d.ts +14 -1
  46. package/types/map/src/types.d.ts.map +1 -1
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@eox/drawtools",
3
- "version": "0.15.0",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "devDependencies": {
6
- "@eox/map": "^1.19.3",
6
+ "@eox/map": "*",
7
7
  "vite": "^6.0.3"
8
8
  },
9
9
  "engines": {
@@ -34,7 +34,8 @@
34
34
  "watch": "vite build --watch"
35
35
  },
36
36
  "dependencies": {
37
- "@eox/elements-utils": "^0.1.5",
37
+ "@eox/elements-utils": "^1.0.0",
38
+ "@eox/ui": "^0.3.6",
38
39
  "lit": "^3.2.0",
39
40
  "ol": "^10.4.0"
40
41
  }
@@ -1,7 +1,5 @@
1
1
  import { LitElement, html, nothing } from "lit";
2
2
  import { updateButtonStatesMethod } from "../methods/controller";
3
- import buttonStyle from "@eox/elements-utils/styles/dist/button.style";
4
- import inputStyle from "@eox/elements-utils/styles/dist/input.style";
5
3
  import { copyTextToClipboard } from "../helpers/index.js";
6
4
  import { when } from "lit/directives/when.js";
7
5
 
@@ -21,6 +19,7 @@ export class EOxDrawToolsController extends LitElement {
21
19
  importFeatures: { attribute: "import-features", type: Boolean },
22
20
  showEditor: { attribute: "show-editor", type: Boolean },
23
21
  geoJSON: { attribute: "geo-json", type: String },
22
+ type: { attribute: "type", type: String },
24
23
  unstyled: { type: Boolean },
25
24
  };
26
25
 
@@ -78,6 +77,12 @@ export class EOxDrawToolsController extends LitElement {
78
77
  */
79
78
  this.geoJSON = "";
80
79
 
80
+ /**
81
+ * Type of the drawn feature
82
+ * @type {"Polygon" | "Point" | "LineString" | "Circle" | "Box"}
83
+ */
84
+ this.type = "Polygon";
85
+
81
86
  /**
82
87
  * Render the element without additional styles
83
88
  */
@@ -110,35 +115,156 @@ export class EOxDrawToolsController extends LitElement {
110
115
  this.updateButtonStates();
111
116
  const drawLabel = this.currentlyDrawing ? "drawing" : "draw";
112
117
 
118
+ const shapeIcons = {
119
+ Polygon: html`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
120
+ <title>shape-polygon-plus</title>
121
+ <path
122
+ d="M17,15.7V13H19V17L10,21L3,14L7,5H11V7H8.3L5.4,13.6L10.4,18.6L17,15.7M22,5V7H19V10H17V7H14V5H17V2H19V5H22Z"
123
+ />
124
+ </svg>`,
125
+ Point: html`
126
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
127
+ <title>vector-point-plus</title>
128
+ <path
129
+ d="M9 9V15H15V9H9M11 11H13V13H11V11M18 15V18H15V20H18V23H20V20H23V18H20V15H18Z"
130
+ />
131
+ </svg>
132
+ `,
133
+ Circle: html`
134
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
135
+ <title>shape-circle-plus</title>
136
+ <path
137
+ d="M11,19A6,6 0 0,0 17,13H19A8,8 0 0,1 11,21A8,8 0 0,1 3,13A8,8 0 0,1 11,5V7A6,6 0 0,0 5,13A6,6 0 0,0 11,19M19,5H22V7H19V10H17V7H14V5H17V2H19V5Z"
138
+ />
139
+ </svg>
140
+ `,
141
+ LineString: html`
142
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
143
+ <title>vector-polyline-plus</title>
144
+ <path
145
+ d="M2 3V9H4.95L6.95 15H6V21H12V16.41L17.41 11H22V5H16V9.57L10.59 15H9.06L7.06 9H8V3H2M4 5H6V7H4V5M18 7H20V9H18V7M18 15V18H15V20H18V23H20V20H23V18H20V15H18M8 17H10V19H8V17Z"
146
+ />
147
+ </svg>
148
+ `,
149
+ Box: html`
150
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
151
+ <title>shape-rectangle-plus</title>
152
+ <path
153
+ d="M19,6H22V8H19V11H17V8H14V6H17V3H19V6M17,17V14H19V19H3V6H11V8H5V17H17Z"
154
+ />
155
+ </svg>
156
+ `,
157
+ };
158
+ const pointerIcon = html`<svg
159
+ xmlns="http://www.w3.org/2000/svg"
160
+ viewBox="0 0 24 24"
161
+ >
162
+ <title>cursor-default-click</title>
163
+ <path
164
+ d="M10.76,8.69A0.76,0.76 0 0,0 10,9.45V20.9C10,21.32 10.34,21.66 10.76,21.66C10.95,21.66 11.11,21.6 11.24,21.5L13.15,19.95L14.81,23.57C14.94,23.84 15.21,24 15.5,24C15.61,24 15.72,24 15.83,23.92L18.59,22.64C18.97,22.46 19.15,22 18.95,21.63L17.28,18L19.69,17.55C19.85,17.5 20,17.43 20.12,17.29C20.39,16.97 20.35,16.5 20,16.21L11.26,8.86L11.25,8.87C11.12,8.76 10.95,8.69 10.76,8.69M15,10V8H20V10H15M13.83,4.76L16.66,1.93L18.07,3.34L15.24,6.17L13.83,4.76M10,0H12V5H10V0M3.93,14.66L6.76,11.83L8.17,13.24L5.34,16.07L3.93,14.66M3.93,3.34L5.34,1.93L8.17,4.76L6.76,6.17L3.93,3.34M7,10H2V8H7V10"
165
+ />
166
+ </svg>`;
167
+ const discardIcon = html`<svg
168
+ xmlns="http://www.w3.org/2000/svg"
169
+ viewBox="0 0 24 24"
170
+ >
171
+ <title>trash-can-outline</title>
172
+ <path
173
+ d="M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M7,6H17V19H7V6M9,8V17H11V8H9M13,8V17H15V8H13Z"
174
+ />
175
+ </svg>`;
176
+ const editIcon = html`<svg
177
+ xmlns="http://www.w3.org/2000/svg"
178
+ viewBox="0 0 24 24"
179
+ >
180
+ <title>pencil-outline</title>
181
+ <path
182
+ d="M14.06,9L15,9.94L5.92,19H5V18.08L14.06,9M17.66,3C17.41,3 17.15,3.1 16.96,3.29L15.13,5.12L18.88,8.87L20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18.17,3.09 17.92,3 17.66,3M14.06,6.19L3,17.25V21H6.75L17.81,9.94L14.06,6.19Z"
183
+ />
184
+ </svg>`;
185
+ const importIcon = html`<svg
186
+ xmlns="http://www.w3.org/2000/svg"
187
+ viewBox="0 0 24 24"
188
+ >
189
+ <title>import</title>
190
+ <path
191
+ d="M14,12L10,8V11H2V13H10V16M20,18V6C20,4.89 19.1,4 18,4H6A2,2 0 0,0 4,6V9H6V6H18V18H6V15H4V18A2,2 0 0,0 6,20H18A2,2 0 0,0 20,18Z"
192
+ />
193
+ </svg>`;
194
+ const copyIcon = html`<svg
195
+ xmlns="http://www.w3.org/2000/svg"
196
+ viewBox="0 0 24 24"
197
+ >
198
+ <title>content-copy</title>
199
+ <path
200
+ d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"
201
+ />
202
+ </svg>`;
203
+
113
204
  return html`
114
- <style>
115
- ${!this.unstyled && buttonStyle}
116
- ${!this.unstyled && inputStyle}
117
- </style>
118
- <div class="wrap-btn">
205
+ <nav>
119
206
  <slot></slot>
120
- <div>
207
+ <div class="max">
121
208
  <!-- Draw Button -->
122
209
  <button
123
210
  data-cy="drawBtn"
124
- class="${this.select ? "pointer" : "polygon"} icon"
211
+ class="transparent square primary-text no-margin small"
212
+ title="${this.unstyled ? (this.select ? "Select" : "Draw") : ""}"
125
213
  ?disabled="${this.#drawDisabled || nothing}"
126
214
  @click="${() => this.drawFunc.start()}"
127
215
  >
128
- ${drawLabel}
216
+ ${this.unstyled
217
+ ? drawLabel
218
+ : html`
219
+ <i class="small"
220
+ >${this.select ? pointerIcon : shapeIcons[this.type]}</i
221
+ >
222
+ <div class="tooltip bottom">
223
+ ${this.select ? "Select" : "Draw"}
224
+ </div>
225
+ `}
129
226
  </button>
130
227
 
131
228
  <!-- Discard Button -->
132
229
  <button
133
230
  data-cy="discardBtn"
134
- class="discard icon"
231
+ class="transparent square error-text no-margin small"
232
+ title="${this.unstyled ? "Discard" : ""}"
135
233
  ?disabled="${this.#discardDisabled || nothing}"
136
234
  @click="${() => this.drawFunc.discard()}"
137
235
  >
138
- discard
236
+ ${this.unstyled
237
+ ? "discard"
238
+ : html`
239
+ <i class="small">${discardIcon}</i>
240
+ <div class="tooltip bottom">Discard</div>
241
+ `}
139
242
  </button>
140
243
  </div>
141
244
 
245
+ <!-- Editor Button -->
246
+ ${when(
247
+ this.showEditor,
248
+ () => html`
249
+ <button
250
+ data-cy="editorBtn"
251
+ class="transparent circle primary-text no-margin small"
252
+ title="${this.unstyled ? "Edit features" : ""}"
253
+ @click=${() =>
254
+ this.renderRoot
255
+ .querySelector("#editor")
256
+ .classList.toggle("hidden")}
257
+ >
258
+ ${this.unstyled
259
+ ? "import"
260
+ : html`
261
+ <i class="small">${editIcon}</i>
262
+ <div class="tooltip bottom">Edit features</div>
263
+ `}
264
+ </button>
265
+ `,
266
+ )}
267
+
142
268
  <!-- Import Button -->
143
269
  ${when(
144
270
  this.importFeatures,
@@ -154,25 +280,32 @@ export class EOxDrawToolsController extends LitElement {
154
280
  <!-- Main Import Button -->
155
281
  <button
156
282
  data-cy="importBtn"
157
- class="import icon"
283
+ class="transparent circle primary-text no-margin small"
284
+ title="${this.unstyled ? "Import features" : ""}"
158
285
  @click=${() =>
159
286
  /**@type {HTMLElement}*/ (
160
287
  this.querySelector("#import-file")
161
288
  ).click()}
162
289
  >
163
- import
290
+ ${this.unstyled
291
+ ? "import"
292
+ : html`
293
+ <i class="small">${importIcon}</i>
294
+ <div class="tooltip bottom">Import features</div>
295
+ `}
164
296
  </button>
165
297
  `,
166
298
  )}
167
- </div>
299
+ </nav>
168
300
 
169
301
  <!-- Geo JSON Wrapper -->
170
302
  ${when(
171
303
  this.showEditor,
172
304
  () => html`
173
- <div class="json-wrapper">
305
+ <div id="editor" class="field textarea border extra hidden">
174
306
  <!-- Geo JSON Editor -->
175
307
  <textarea
308
+ style="font-family: monospace; font-size: small; line-height: 1.4; padding: 0.4rem;"
176
309
  @drop=${this.drawFunc.import}
177
310
  @input=${this.drawFunc.editor}
178
311
  .value=${this.geoJSON}
@@ -181,10 +314,15 @@ export class EOxDrawToolsController extends LitElement {
181
314
  <!-- Geo JSON Copy Button -->
182
315
  <button
183
316
  data-cy="copyBtn"
184
- class="icon-copy"
317
+ class="circle absolute bottom right medium-margin"
185
318
  @click=${() => copyTextToClipboard(this.geoJSON)}
186
319
  >
187
- ${this.unstyled ? "copy" : nothing}
320
+ ${this.unstyled
321
+ ? "copy"
322
+ : html`
323
+ <i class="tiny">${copyIcon}</i>
324
+ <div class="tooltip top">Copy</div>
325
+ `}
188
326
  </button>
189
327
  </div>
190
328
  `,
@@ -6,7 +6,6 @@ import {
6
6
  hoverFeatureMethod,
7
7
  selectAndDeselectFeatureMethod,
8
8
  } from "../methods/list";
9
- import listStyle from "@eox/elements-utils/styles/dist/list.style";
10
9
 
11
10
  /**
12
11
  * Display list of features
@@ -116,7 +115,7 @@ export class EOxDrawToolsList extends LitElement {
116
115
  * @param {Event & { target: HTMLButtonElement }} evt - Event object containing button target.
117
116
  */
118
117
  _handleDelete(evt) {
119
- deleteFeatureMethod(evt, this);
118
+ deleteFeatureMethod(evt, this, this.eoxDrawTools);
120
119
  this.dispatchEvent(new CustomEvent("changed", { bubbles: true }));
121
120
  }
122
121
 
@@ -157,11 +156,18 @@ export class EOxDrawToolsList extends LitElement {
157
156
  this.hoverId = this.hoverInteraction?.selectedFids[0];
158
157
  this.clickId = this.clickInteraction?.selectedFids[0];
159
158
 
159
+ const discardIcon = html`<svg
160
+ xmlns="http://www.w3.org/2000/svg"
161
+ viewBox="0 0 24 24"
162
+ >
163
+ <title>trash-can-outline</title>
164
+ <path
165
+ d="M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M7,6H17V19H7V6M9,8V17H11V8H9M13,8V17H15V8H13Z"
166
+ />
167
+ </svg>`;
168
+
160
169
  return html`
161
- <style>
162
- ${!this.unstyled && listStyle}
163
- </style>
164
- <ul class="list-wrap">
170
+ <ul class="list no-space">
165
171
  ${this.drawnFeatures.map((feature, i) => {
166
172
  // Determine feature number and ID
167
173
  const featureNumber = i + 1;
@@ -172,9 +178,19 @@ export class EOxDrawToolsList extends LitElement {
172
178
  // Check if the feature is hovered or clicked
173
179
  const isFeatureHovered = this.hoverId === featureId;
174
180
  const isFeatureClicked = this.clickId === featureId;
175
- const isSelected = isFeatureHovered || isFeatureClicked;
176
- const selectionClass = isSelected ? "selected" : nothing;
177
- const propertyName = feature.get(this.featureNameKey);
181
+ const selectionClass = isFeatureHovered
182
+ ? "surface-container-low"
183
+ : isFeatureClicked
184
+ ? "fill"
185
+ : nothing;
186
+
187
+ const pathParts = this.featureNameKey?.split(".");
188
+ const propertyName =
189
+ feature.get(this.featureNameKey) ||
190
+ pathParts?.reduce((obj, part) => obj?.[part], {
191
+ ...feature.getProperties(),
192
+ });
193
+
178
194
  const title = propertyName
179
195
  ? propertyName
180
196
  : `${this.featureName} ${featureNumber}`;
@@ -183,25 +199,24 @@ export class EOxDrawToolsList extends LitElement {
183
199
  featureNumber,
184
200
  html`
185
201
  <li
186
- class="${selectionClass}"
202
+ class="${selectionClass} no-round"
187
203
  @mouseover=${() => this._handleHoverFeature(featureId)}
188
204
  @mouseout=${() => this._handleHoverFeature(featureId, true)}
205
+ @click="${() => this._handleFeatureSelectAndDeselect(feature)}"
189
206
  >
190
- <div
191
- class="list"
192
- @click="${() =>
193
- this._handleFeatureSelectAndDeselect(feature)}"
194
- >
207
+ <div class="max">
195
208
  <span class="title">${title}</span>
196
- <button
197
- index=${i}
198
- data-cy="deleteFeatureBtn"
199
- class="icon smallest discard"
200
- @click="${this._handleDelete}"
201
- >
202
- x
203
- </button>
204
209
  </div>
210
+ <button
211
+ index=${i}
212
+ data-cy="deleteFeatureBtn"
213
+ class="transparent square small error-text front"
214
+ @click="${this._handleDelete}"
215
+ >
216
+ ${this.unstyled
217
+ ? "x"
218
+ : html`<i class="small">${discardIcon}</i>`}
219
+ </button>
205
220
  </li>
206
221
  `,
207
222
  );
package/src/enums/test.js CHANGED
@@ -2,6 +2,7 @@ export const TEST_SELECTORS = {
2
2
  drawTools: "eox-drawtools",
3
3
  controller: "eox-drawtools-controller",
4
4
  drawBtn: "[data-cy='drawBtn']",
5
+ editorBtn: "[data-cy='editorBtn']",
5
6
  copyBtn: "[data-cy='copyBtn']",
6
7
  discardBtn: "[data-cy='discardBtn']",
7
8
  list: "eox-drawtools-list",
package/src/main.js CHANGED
@@ -10,7 +10,6 @@ import {
10
10
  createSelectHandler,
11
11
  handleLayerId,
12
12
  } from "./methods/draw";
13
- import mainStyle from "@eox/elements-utils/styles/dist/main.style";
14
13
  import { DUMMY_GEO_JSON } from "./enums/index.js";
15
14
  import {
16
15
  initMapDragDropImport,
@@ -356,10 +355,15 @@ export class EOxDrawTools extends LitElement {
356
355
  return html`
357
356
  <style>
358
357
  :host { display: block; }
359
- ${!this.unstyled && mainStyle}
360
358
  ${!this.unstyled && styleEOX}
361
359
  </style>
362
360
 
361
+ <div class="drawtitle">
362
+ <slot name="drawtitle"
363
+ ><p><strong>Draw</strong></p></slot
364
+ >
365
+ </div>
366
+
363
367
  <!-- Controller Component -->
364
368
  <eox-drawtools-controller
365
369
  .drawFunc=${{
@@ -377,6 +381,7 @@ export class EOxDrawTools extends LitElement {
377
381
  .importFeatures=${this.importFeatures}
378
382
  .showEditor=${this.showEditor}
379
383
  .geoJSON=${this.#geoJSON}
384
+ .type=${this.type}
380
385
  ></eox-drawtools-controller>
381
386
 
382
387
  <!-- List Component -->
@@ -16,6 +16,8 @@ const initLayerMethod = (EoxDrawTool, multipleFeatures) => {
16
16
 
17
17
  const OlMap = EoxMap.map;
18
18
 
19
+ const primaryColor = "0, 65, 112";
20
+
19
21
  EoxDrawTool.drawLayer = EoxMap.addOrUpdateLayer({
20
22
  zIndex: 100,
21
23
  type: "Vector",
@@ -28,7 +30,13 @@ const initLayerMethod = (EoxDrawTool, multipleFeatures) => {
28
30
  source: {
29
31
  type: "Vector",
30
32
  },
31
- style: EoxDrawTool.featureStyles?.["layer"],
33
+ style: EoxDrawTool.featureStyles?.["layer"] || {
34
+ "fill-color": `rgba(${primaryColor}, 0.1)`,
35
+ "stroke-color": `rgba(${primaryColor}, 1)`,
36
+ "stroke-width": 2,
37
+ "circle-radius": 5,
38
+ "circle-fill-color": `rgba(${primaryColor}, 1)`,
39
+ },
32
40
  interactions: [
33
41
  {
34
42
  type: "draw",
@@ -38,7 +46,14 @@ const initLayerMethod = (EoxDrawTool, multipleFeatures) => {
38
46
  type: EoxDrawTool.type,
39
47
  modify: EoxDrawTool.allowModify,
40
48
  stopClick: true,
41
- style: EoxDrawTool.featureStyles?.["layer"],
49
+ style: EoxDrawTool.featureStyles?.["layer"] || {
50
+ "fill-color": `rgba(${primaryColor}, 0.1)`,
51
+ "stroke-color": `rgba(${primaryColor}, 1)`,
52
+ "stroke-width": 1,
53
+ "stroke-line-dash": [7, 3],
54
+ "circle-radius": 5,
55
+ "circle-fill-color": `rgba(${primaryColor}, 1)`,
56
+ },
42
57
  },
43
58
  },
44
59
  {
@@ -47,9 +62,9 @@ const initLayerMethod = (EoxDrawTool, multipleFeatures) => {
47
62
  id: "SelectLayerHoverInteraction",
48
63
  condition: "pointermove",
49
64
  style: EoxDrawTool.featureStyles?.["hover"] || {
50
- "fill-color": "rgba(51, 153, 204,0.5)",
51
- "stroke-color": "#3399CC",
52
- "stroke-width": 2.5,
65
+ "fill-color": `rgba(${primaryColor}, 0.2)`,
66
+ "stroke-color": `rgba(${primaryColor}, 1)`,
67
+ "stroke-width": 2,
53
68
  },
54
69
  tooltip: false,
55
70
  },
@@ -61,9 +76,9 @@ const initLayerMethod = (EoxDrawTool, multipleFeatures) => {
61
76
  condition: "click",
62
77
  panIn: true,
63
78
  style: EoxDrawTool.featureStyles?.["click"] || {
64
- "fill-color": "rgba(51, 153, 204,0.5)",
65
- "stroke-color": "#3399CC",
66
- "stroke-width": 2.5,
79
+ "fill-color": `rgba(${primaryColor}, 0.2)`,
80
+ "stroke-color": `rgba(${primaryColor}, 1)`,
81
+ "stroke-width": 2,
67
82
  },
68
83
  },
69
84
  },
@@ -23,6 +23,15 @@ const startDrawingMethod = (EoxDrawTool) => {
23
23
  initializeDrawing();
24
24
  // Update the drawing status
25
25
  updateDrawingStatus();
26
+
27
+ // Abort drawing on Esc key
28
+ document.addEventListener("keydown", ({ key }) => {
29
+ if (key === "Escape" && EoxDrawTool.currentlyDrawing) {
30
+ EoxDrawTool.draw.setActive(false);
31
+ EoxDrawTool.currentlyDrawing = false;
32
+ EoxDrawTool.requestUpdate();
33
+ }
34
+ });
26
35
  };
27
36
 
28
37
  export default startDrawingMethod;
@@ -4,7 +4,7 @@
4
4
  * @param {Event & { target: HTMLButtonElement }} evt - Event object containing button target.
5
5
  * @param {import("../../components/list").EOxDrawToolsList} EoxDrawToolList - The list of drawn features.
6
6
  */
7
- const deleteFeatureMethod = (evt, EoxDrawToolList) => {
7
+ const deleteFeatureMethod = (evt, EoxDrawToolList, EoxDrawTool) => {
8
8
  evt.stopPropagation();
9
9
 
10
10
  // Extract the index of the feature to delete from the button's attribute
@@ -16,6 +16,7 @@ const deleteFeatureMethod = (evt, EoxDrawToolList) => {
16
16
  // Remove the feature from the draw layer and update the drawnFeatures array
17
17
  EoxDrawToolList.drawLayer.getSource().removeFeature(feature);
18
18
  EoxDrawToolList.drawnFeatures.splice(index, 1);
19
+ EoxDrawTool.emitDrawnFeatures();
19
20
 
20
21
  // Request an update to reflect the changes
21
22
  EoxDrawToolList.requestUpdate();
package/src/style.eox.js CHANGED
@@ -1,46 +1,18 @@
1
+ import eoxStyle from "@eox/ui/style.css?inline";
2
+ import { addCommonStylesheet } from "@eox/elements-utils";
3
+
4
+ addCommonStylesheet();
5
+
1
6
  export const styleEOX = `
2
- button.discard:before {
3
- content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23FF5252' viewBox='0 0 24 24'%3E%3Ctitle%3Etrash-can-outline%3C/title%3E%3Cpath d='M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M7,6H17V19H7V6M9,8V17H11V8H9M13,8V17H15V8H13Z' /%3E%3C/svg%3E")
7
+ ${eoxStyle}
8
+ :host {
9
+ --padding: 0.5rem;
4
10
  }
5
- button.pointer:before {
6
- content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23004170' viewBox='0 0 24 24'%3E%3Ctitle%3Ecursor-default-click%3C/title%3E%3Cpath d='M10.76,8.69A0.76,0.76 0 0,0 10,9.45V20.9C10,21.32 10.34,21.66 10.76,21.66C10.95,21.66 11.11,21.6 11.24,21.5L13.15,19.95L14.81,23.57C14.94,23.84 15.21,24 15.5,24C15.61,24 15.72,24 15.83,23.92L18.59,22.64C18.97,22.46 19.15,22 18.95,21.63L17.28,18L19.69,17.55C19.85,17.5 20,17.43 20.12,17.29C20.39,16.97 20.35,16.5 20,16.21L11.26,8.86L11.25,8.87C11.12,8.76 10.95,8.69 10.76,8.69M15,10V8H20V10H15M13.83,4.76L16.66,1.93L18.07,3.34L15.24,6.17L13.83,4.76M10,0H12V5H10V0M3.93,14.66L6.76,11.83L8.17,13.24L5.34,16.07L3.93,14.66M3.93,3.34L5.34,1.93L8.17,4.76L6.76,6.17L3.93,3.34M7,10H2V8H7V10' /%3E%3C/svg%3E");
11
+ .drawtitle {
12
+ padding-left: var(--padding);
13
+ padding-right: var(--padding);
7
14
  }
8
- button.polygon:before {
9
- content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23004170' viewBox='0 0 24 24'%3E%3Ctitle%3Eshape-polygon-plus%3C/title%3E%3Cpath d='M17,15.7V13H19V17L10,21L3,14L7,5H11V7H8.3L5.4,13.6L10.4,18.6L17,15.7M22,5V7H19V10H17V7H14V5H17V2H19V5H22Z' /%3E%3C/svg%3E");
15
+ .hidden {
16
+ display: none;
10
17
  }
11
- button.import:before {
12
- content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ctitle%3Eupload%3C/title%3E%3Cpath fill='%23004170' d='M9,16V10H5L12,3L19,10H15V16H9M5,20V18H19V20H5Z' /%3E%3C/svg%3E");
13
- }
14
- .wrap-btn {
15
- display: flex;
16
- justify-content: space-between;
17
- }
18
- eox-drawtools-list {
19
- width: 100%;
20
- }
21
- .json-wrapper {
22
- margin: 0.4rem 0rem;
23
- padding: 0.75rem;
24
- background: var(--secondary-color-hover);
25
- position: relative;
26
- }
27
- .json-wrapper textarea {
28
- height: 200px;
29
- }
30
- .icon-copy {
31
- position: absolute;
32
- bottom: 26px;
33
- right: 26px;
34
- border-radius: 4px;
35
- height: 26px;
36
- padding: 4px 6px;
37
- }
38
- .icon-copy:before {
39
- width: 14px;
40
- min-width: 14px;
41
- height: 14px;
42
- display: flex margin-right: 6px;
43
- color: white;
44
- content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ctitle%3Econtent-copy%3C/title%3E%3Cpath d='M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z' fill='white' /%3E%3C/svg%3E")
45
- }
46
18
  `;
@@ -38,6 +38,10 @@ export class EOxDrawToolsController extends LitElement {
38
38
  attribute: string;
39
39
  type: StringConstructor;
40
40
  };
41
+ type: {
42
+ attribute: string;
43
+ type: StringConstructor;
44
+ };
41
45
  unstyled: {
42
46
  type: BooleanConstructor;
43
47
  };
@@ -76,6 +80,11 @@ export class EOxDrawToolsController extends LitElement {
76
80
  * @type String
77
81
  */
78
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";
79
88
  /**
80
89
  * Render the element without additional styles
81
90
  */
@@ -1 +1 @@
1
- {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../../src/components/controller.js"],"names":[],"mappings":"AAOA;;;;GAIG;AACH;IAEE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAUE;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;;OAEG;IACH,kBAAqB;IAErB;;OAEG;IACH,gBAAmB;IAGrB;;OAEG;IACH,2BAKC;IAED;;OAEG;IACH,yBAEC;IAED,+CAoFC;;CACF;2BAjMyC,KAAK"}
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../../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;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AEG;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"}
@@ -2,6 +2,7 @@ export namespace TEST_SELECTORS {
2
2
  let drawTools: string;
3
3
  let controller: string;
4
4
  let drawBtn: string;
5
+ let editorBtn: string;
5
6
  let copyBtn: string;
6
7
  let discardBtn: string;
7
8
  let list: string;
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/main.js"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH;IAEE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAwBC;IA6BC;;OAEG;IACH,qBAAwB;IAExB;;;;;OAKG;IACH,KAFU,SAAO,WAAW,CAER;IAEpB;;OAEG;IACH,0BAA6B;IAE7B;;;OAGG;IACH,MAFS,OAAO,gBAAgB,EAAE,IAAI,GAAG,OAAO,UAAU,EAAE,MAAM,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAEhF;IAEhB;;;OAGG;IAEH,WAHS,OAAO,iBAAiB,EAAE,OAAO,CAGrB;IA6GvB;;;OAGG;IACH,2BAGC;IAED,sBAEC;IAjHC;;;OAGG;IACH,eAFS,KAAK,CAAC,OAAO,IAAI,EAAE,OAAO,CAAC,CAEb;IAEvB;;OAEG;IACH,oBAA4B;IAE5B;;OAEG;IACH,oBAA0B;IAE1B;;;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OAEG;IACH,qBAEC;IAED;;;OAGG;IACH,uBAEC;IAED;;;;OAIG;IACH,0BAJW,MAAM,oBACN,OAAO,YACP,OAAO,QAcjB;IAED;;OAEG;IACH,uBAFW,SAAS,QAInB;IAED;;OAEG;IACH,oBAEC;IAED;;OAEG;IACH,sBAMC;IAED;;OAEG;IACH,0BAaC;IASD;;;;OAIG;IACH,qBAUC;IAcD,6CAIC;IARD,wCAEC;IAVD,sCAMC;IAiBD,+CAqDC;;CACF;2BAvZyC,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"init-layer.d.ts","sourceRoot":"","sources":["../../../../../src/methods/draw/init-layer.js"],"names":[],"mappings":";AAIA;;;;;;GAMG;AACH,8CAJW,OAAO,YAAY,EAAE,YAAY,8BAE/B;IAAC,MAAM,EAAE,OAAO,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,IAAI,EAAE,GAAG,CAAA;CAAC,CA+ExE"}
1
+ {"version":3,"file":"init-layer.d.ts","sourceRoot":"","sources":["../../../../../src/methods/draw/init-layer.js"],"names":[],"mappings":";AAIA;;;;;;GAMG;AACH,8CAJW,OAAO,YAAY,EAAE,YAAY,8BAE/B;IAAC,MAAM,EAAE,OAAO,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,IAAI,EAAE,GAAG,CAAA;CAAC,CA8FxE"}
@@ -1 +1 @@
1
- {"version":3,"file":"start-drawing.d.ts","sourceRoot":"","sources":["../../../../../src/methods/draw/start-drawing.js"],"names":[],"mappings":";AAAA;;;;;GAKG;AACH,iDAFW,OAAO,YAAY,EAAE,YAAY,QAqB3C"}
1
+ {"version":3,"file":"start-drawing.d.ts","sourceRoot":"","sources":["../../../../../src/methods/draw/start-drawing.js"],"names":[],"mappings":";AAAA;;;;;GAKG;AACH,iDAFW,OAAO,YAAY,EAAE,YAAY,QA8B3C"}