@eox/layercontrol 0.29.1 → 1.0.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 (78) hide show
  1. package/dist/eox-layercontrol.js +3001 -2866
  2. package/dist/eox-layercontrol.umd.cjs +626 -565
  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/add-layers.js +78 -178
  9. package/src/components/layer-config.js +22 -3
  10. package/src/components/layer-group.js +38 -17
  11. package/src/components/layer-legend.js +7 -4
  12. package/src/components/layer-list.js +27 -19
  13. package/src/components/layer-tools.js +60 -118
  14. package/src/components/layer.js +215 -59
  15. package/src/components/optional-list.js +32 -25
  16. package/src/components/tools-items.js +34 -31
  17. package/src/enums/index.js +1 -0
  18. package/src/enums/stories/index.js +4 -2
  19. package/src/helpers/create-sortable.js +4 -1
  20. package/src/helpers/get-layer-type.js +2 -1
  21. package/src/helpers/index.js +1 -0
  22. package/src/helpers/layer-tools.js +75 -13
  23. package/src/main.js +36 -6
  24. package/types/layercontrol/src/components/add-layers.d.ts.map +1 -1
  25. package/types/layercontrol/src/components/layer-config.d.ts.map +1 -1
  26. package/types/layercontrol/src/components/layer-group.d.ts.map +1 -1
  27. package/types/layercontrol/src/components/layer-legend.d.ts.map +1 -1
  28. package/types/layercontrol/src/components/layer-list.d.ts.map +1 -1
  29. package/types/layercontrol/src/components/layer-tools.d.ts +8 -4
  30. package/types/layercontrol/src/components/layer-tools.d.ts.map +1 -1
  31. package/types/layercontrol/src/components/layer.d.ts +9 -0
  32. package/types/layercontrol/src/components/layer.d.ts.map +1 -1
  33. package/types/layercontrol/src/components/optional-list.d.ts.map +1 -1
  34. package/types/layercontrol/src/components/tools-items.d.ts.map +1 -1
  35. package/types/layercontrol/src/enums/index.d.ts +1 -1
  36. package/types/layercontrol/src/enums/stories/index.d.ts +1 -0
  37. package/types/layercontrol/src/enums/stories/index.d.ts.map +1 -1
  38. package/types/layercontrol/src/helpers/create-sortable.d.ts.map +1 -1
  39. package/types/layercontrol/src/helpers/get-layer-type.d.ts.map +1 -1
  40. package/types/layercontrol/src/helpers/index.d.ts +1 -1
  41. package/types/layercontrol/src/helpers/layer-tools.d.ts +13 -3
  42. package/types/layercontrol/src/helpers/layer-tools.d.ts.map +1 -1
  43. package/types/layercontrol/src/main.d.ts.map +1 -1
  44. package/types/map/src/components/compare.d.ts +2 -2
  45. package/types/map/src/components/compare.d.ts.map +1 -1
  46. package/types/map/src/components/tooltip.d.ts +7 -2
  47. package/types/map/src/components/tooltip.d.ts.map +1 -1
  48. package/types/map/src/controls/controls.d.ts +0 -6
  49. package/types/map/src/controls/controls.d.ts.map +1 -1
  50. package/types/map/src/controls/geo-location.d.ts +3 -3
  51. package/types/map/src/controls/geo-location.d.ts.map +1 -1
  52. package/types/map/src/controls/loading-indicator.d.ts +1 -1
  53. package/types/map/src/controls/loading-indicator.d.ts.map +1 -1
  54. package/types/map/src/custom/sources/FlatGeoBuf.d.ts +27 -0
  55. package/types/map/src/custom/sources/FlatGeoBuf.d.ts.map +1 -0
  56. package/types/map/src/custom/sources/WMTSCapabilities.d.ts +35 -0
  57. package/types/map/src/custom/sources/WMTSCapabilities.d.ts.map +1 -0
  58. package/types/map/src/helpers/add-new-feature.d.ts +2 -1
  59. package/types/map/src/helpers/add-new-feature.d.ts.map +1 -1
  60. package/types/map/src/helpers/generate.d.ts +5 -4
  61. package/types/map/src/helpers/generate.d.ts.map +1 -1
  62. package/types/map/src/helpers/interactions.d.ts.map +1 -1
  63. package/types/map/src/helpers/parse-text.d.ts +3 -1
  64. package/types/map/src/helpers/parse-text.d.ts.map +1 -1
  65. package/types/map/src/helpers/select.d.ts +5 -5
  66. package/types/map/src/helpers/select.d.ts.map +1 -1
  67. package/types/map/src/helpers/tile-grid.d.ts +2 -2
  68. package/types/map/src/helpers/tile-grid.d.ts.map +1 -1
  69. package/types/map/src/layers.d.ts +116 -0
  70. package/types/map/src/layers.d.ts.map +1 -0
  71. package/types/map/src/main.d.ts +7 -7
  72. package/types/map/src/main.d.ts.map +1 -1
  73. package/types/map/src/methods/map/add-update-layer.d.ts +2 -2
  74. package/types/map/src/methods/map/add-update-layer.d.ts.map +1 -1
  75. package/types/map/src/methods/map/setters.d.ts +2 -2
  76. package/types/map/src/methods/map/setters.d.ts.map +1 -1
  77. package/types/map/src/types.d.ts +28 -38
  78. package/types/map/src/types.d.ts.map +1 -1
@@ -3,20 +3,18 @@ import { unsafeHTML } from "lit/directives/unsafe-html.js";
3
3
  import { map } from "lit/directives/map.js";
4
4
  import { when } from "lit/directives/when.js";
5
5
  import { live } from "lit/directives/live.js";
6
+ import eoxStyle from "@eox/ui/style.css?inline";
6
7
  import "./layer-config";
7
8
  import "./layer-datetime";
8
9
  import "./layer-legend";
9
10
  import "./tools-items";
10
- import button from "@eox/elements-utils/styles/dist/button.style";
11
- import radio from "@eox/elements-utils/styles/dist/radio.style";
12
- import checkbox from "@eox/elements-utils/styles/dist/checkbox.style";
13
- import slider from "@eox/elements-utils/styles/dist/slider.style";
14
11
  import {
15
12
  Button,
16
13
  _parseActions,
17
14
  _parseTools,
18
15
  removeButton,
19
16
  sortButton,
17
+ getToolsIcon,
20
18
  } from "../helpers";
21
19
 
22
20
  /**
@@ -34,6 +32,7 @@ export class EOxLayerControlLayerTools extends LitElement {
34
32
  unstyled: { type: Boolean },
35
33
  noShadow: { type: Boolean },
36
34
  toolsAsList: { type: Boolean },
35
+ embedded: { state: true },
37
36
  };
38
37
 
39
38
  constructor() {
@@ -74,6 +73,15 @@ export class EOxLayerControlLayerTools extends LitElement {
74
73
  * @type {Boolean}
75
74
  */
76
75
  this.toolsAsList = false;
76
+
77
+ /**
78
+ * Determine if tools are embedded in layercontrol or stand-alone
79
+ *
80
+ * @type {Boolean}
81
+ */
82
+ setTimeout(() => {
83
+ this.embedded = this.parentElement?.tagName === "EOX-LAYERCONTROL-LAYER";
84
+ });
77
85
  }
78
86
 
79
87
  /**
@@ -84,10 +92,10 @@ export class EOxLayerControlLayerTools extends LitElement {
84
92
  }
85
93
 
86
94
  // Initializes '_removeButton' invoking 'removeButton' function with 'this' context.
87
- _removeButton = () => removeButton(this);
95
+ _removeButton = (icon) => removeButton(this, icon);
88
96
 
89
97
  // Initializes '_sortButton' invoking 'sortButton' function with 'unstyled' property as a parameter.
90
- _sortButton = () => sortButton(this.unstyled);
98
+ _sortButton = (icon) => sortButton(this, icon, this.unstyled);
91
99
 
92
100
  /**
93
101
  * Initializes '_button' as a function accepting 'tool' parameter to generate a Button.
@@ -96,24 +104,30 @@ export class EOxLayerControlLayerTools extends LitElement {
96
104
  * @param {string} tool - Tool parameter for Button generation.
97
105
  * @returns {import("lit").HTMLTemplateResult} - The generated Button element.
98
106
  */
99
- _button = (tool) => Button(tool, this.unstyled);
107
+ _button = (tool, icon) => Button(tool, icon, this.unstyled);
100
108
 
101
- _getDefaultTools = () => {
109
+ _getDefaultTools = (icons) => {
102
110
  return html`
103
111
  <div slot="info-content">
104
112
  ${unsafeHTML(this.layer.get("description"))}
105
113
  </div>
106
114
  <div slot="opacity-content">
107
- <!-- Input for opacity -->
108
- <input
109
- type="range"
110
- min="0"
111
- max="1"
112
- step="0.01"
113
- value=${live(this.layer?.getOpacity())}
114
- @input=${(/** @type {{ target: { value: string; }; }} */ evt) =>
115
- this.layer.setOpacity(parseFloat(evt.target.value))}
116
- />
115
+ <div class="row">
116
+ <!-- Input for opacity -->
117
+ <input
118
+ type="range"
119
+ min="0"
120
+ max="1"
121
+ step="0.01"
122
+ value=${live(this.layer?.getOpacity())}
123
+ class="tiny max"
124
+ @input=${(/** @type {{ target: { value: string; }; }} */ evt) => {
125
+ this.layer.setOpacity(parseFloat(evt.target.value));
126
+ this.requestUpdate();
127
+ }}
128
+ />
129
+ <span class="small-text" style="width: 30px; text-align: right">${Math.round(this.layer?.getOpacity() * 100)}%</span>
130
+ </div class="row">
117
131
  </div>
118
132
  <div slot="config-content">
119
133
  <!-- Layer configuration -->
@@ -163,8 +177,8 @@ export class EOxLayerControlLayerTools extends LitElement {
163
177
  `,
164
178
  )}
165
179
  </div>
166
- <div slot="remove-icon">${this._removeButton()}</div>
167
- <div slot="sort-icon">${this._sortButton()}</div>
180
+ <div slot="remove-icon">${this._removeButton(icons.remove)}</div>
181
+ <div slot="sort-icon">${this._sortButton(icons.sort)}</div>
168
182
  `;
169
183
  };
170
184
 
@@ -174,12 +188,12 @@ export class EOxLayerControlLayerTools extends LitElement {
174
188
  const tools = _parseTools(this.tools, this.layer);
175
189
 
176
190
  // Determine the single action element if only one action is present
177
- const singleActionEle = this[`_${actions?.[0]}Button`]
178
- ? this[`_${actions?.[0]}Button`]()
179
- : nothing;
191
+ // const singleActionEle = this[`_${actions?.[0]}Button`]
192
+ // ? this[`_${actions?.[0]}Button`](getToolsIcon()[actions?.[0]])
193
+ // : nothing;
180
194
 
181
195
  // Determine icon class based on the number of tools
182
- const iconClass = this.tools?.length === 1 ? `${this.tools[0]}-icon` : "";
196
+ // const iconClass = this.tools?.length === 1 ? `${this.tools[0]}-icon` : "";
183
197
 
184
198
  // Determine the number of actions and tools for conditional rendering
185
199
  const actionsLen = actions?.length;
@@ -194,20 +208,15 @@ export class EOxLayerControlLayerTools extends LitElement {
194
208
  actionsLen + toolsLen > 0,
195
209
  () => html`
196
210
  ${when(
197
- actionsLen === 1 && toolsLen === 0,
198
- () => html`
199
- <div class="single-action-container">
200
- <div class="single-action">${singleActionEle}</div>
201
- </div>
202
- `,
211
+ !(actionsLen === 1 && toolsLen === 0),
203
212
  () => html`
204
213
  <details
205
214
  class="tools"
206
- open=${this.layer.get("layerControlToolsExpand") || nothing}
215
+ open=${this.embedded === false
216
+ ? true
217
+ : this.layer.get("layerControlToolsExpand") || nothing}
207
218
  >
208
- <summary>
209
- <button class="icon ${iconClass}">Tools</button>
210
- </summary>
219
+ <summary></summary>
211
220
  <eox-layercontrol-tools-items
212
221
  class="${this.toolsAsList ? "tools-list" : "tools-tab"}"
213
222
  .noShadow=${false}
@@ -217,9 +226,11 @@ export class EOxLayerControlLayerTools extends LitElement {
217
226
  .toolsAsList=${this.toolsAsList}
218
227
  >
219
228
  <!-- Rendering tabs and content -->
220
- ${map(tools, (tool) => this._button(tool))}
229
+ ${map(tools, (tool) =>
230
+ this._button(tool, getToolsIcon()[tool]),
231
+ )}
221
232
  <!-- Including default tools -->
222
- ${this._getDefaultTools()}
233
+ ${this._getDefaultTools(getToolsIcon())}
223
234
  </eox-layercontrol-tools-items>
224
235
  </details>
225
236
  `,
@@ -232,116 +243,42 @@ export class EOxLayerControlLayerTools extends LitElement {
232
243
  #styleBasic = ``;
233
244
 
234
245
  #styleEOX = `
235
- ${button}
236
- ${radio}
237
- ${checkbox}
238
- ${slider}
246
+ ${!this.embedded ? eoxStyle : ""}
239
247
  .drag-handle {
240
- cursor: n-resize;
248
+ -webkit-user-drag: element;
249
+ user-select: none;
241
250
  }
242
251
  .single-action-container,
243
252
  details.tools {
244
253
  position: relative;
245
254
  }
246
- eox-layercontrol-layer details summary::before {
247
- content: "";
248
- }
249
- details.tools[open] {
250
- /*border-top: 1px solid #0041703a;*/
251
- }
252
255
  .single-action {
253
256
  position: relative;
254
257
  }
255
- details.tools summary .icon {
258
+ details.tools summary button {
256
259
  pointer-events: none;
257
260
  }
258
261
  .single-action,
259
262
  details.tools summary {
260
263
  position: absolute;
261
- right: 0;
262
- top: -24px;
264
+ right: 1.5rem;
265
+ top: -32px;
263
266
  height: 24px;
264
267
  cursor: pointer;
265
268
  display: var(--layer-tools-button-visibility);
266
269
  }
267
- .single-action .icon::before,
268
- details.tools summary .icon::before {
269
- content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23004170' viewBox='0 0 24 24'%3E%3Ctitle%3Edots-vertical%3C/title%3E%3Cpath d='M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z' /%3E%3C/svg%3E");
270
- }
271
270
  .single-action,
272
- details.tools summary,
273
- eox-layercontrol-tools-items button.icon {
271
+ details.tools summary {
274
272
  transition: opacity .2s;
275
273
  }
276
274
  .single-action,
277
275
  details.tools summary {
278
276
  opacity: .5;
279
277
  }
280
- eox-layercontrol-tools-items button.icon {
281
- opacity: .7;
282
- }
283
- eox-layercontrol-tools-items.tools-list button.icon {
284
- cursor: auto;
285
- }
286
278
  .single-action:hover,
287
- details.tools summary:hover,
288
- eox-layercontrol-tools-items button.icon:hover {
279
+ details.tools summary:hover {
289
280
  opacity: 1;
290
281
  }
291
- eox-layercontrol-tools-items.tools-list button.icon:hover {
292
- opacity: .7;
293
- }
294
- .tools-placeholder,
295
- .single-action .icon,
296
- .single-action .icon::before,
297
- details.tools summary .icon,
298
- details.tools summary .icon::before {
299
- height: 16px;
300
- width: 16px;
301
- margin-right: var(--padding);
302
- }
303
- eox-layercontrol-tools-items button.icon,
304
- eox-layercontrol-tools-items .button.icon {
305
- display: flex;
306
- justify-content: center;
307
- }
308
- eox-layercontrol-tools-items.tools-list button.icon,
309
- eox-layercontrol-tools-items.tools-list .button.icon {
310
- margin-left: -6px;
311
- }
312
- eox-layercontrol-tools-items button.icon::before,
313
- eox-layercontrol-tools-items .button.icon::before {
314
- width: 16px;
315
- height: 16px;
316
- }
317
- details.tools summary .info-icon,
318
- button.icon[slot=info-icon]::before {
319
- content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23004170' viewBox='0 0 24 24'%3E%3Ctitle%3Einformation-outline%3C/title%3E%3Cpath d='M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z' /%3E%3C/svg%3E");
320
- }
321
- details.tools summary .opacity-icon,
322
- button.icon[slot=opacity-icon]::before {
323
- content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23004170' viewBox='0 0 24 24'%3E%3Ctitle%3Eopacity%3C/title%3E%3Cpath d='M17.66,8L12,2.35L6.34,8C4.78,9.56 4,11.64 4,13.64C4,15.64 4.78,17.75 6.34,19.31C7.9,20.87 9.95,21.66 12,21.66C14.05,21.66 16.1,20.87 17.66,19.31C19.22,17.75 20,15.64 20,13.64C20,11.64 19.22,9.56 17.66,8M6,14C6,12 6.62,10.73 7.76,9.6L12,5.27L16.24,9.65C17.38,10.77 18,12 18,14H6Z' /%3E%3C/svg%3E");
324
- }
325
- details.tools summary .config-icon,
326
- button.icon[slot=config-icon]::before {
327
- content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23004170' viewBox='0 0 24 24'%3E%3Ctitle%3Etune%3C/title%3E%3Cpath d='M3,17V19H9V17H3M3,5V7H13V5H3M13,21V19H21V17H13V15H11V21H13M7,9V11H3V13H7V15H9V9H7M21,13V11H11V13H21M15,9H17V7H21V5H17V3H15V9Z' /%3E%3C/svg%3E");
328
- }
329
- details.tools summary .datetime-icon,
330
- button.icon[slot=datetime-icon]::before {
331
- content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ctitle%3Eclock-outline%3C/title%3E%3Cpath d='M12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22C6.47,22 2,17.5 2,12A10,10 0 0,1 12,2M12.5,7V12.25L17,14.92L16.25,16.15L11,13V7H12.5Z' /%3E%3C/svg%3E");
332
- }
333
- details.tools summary .legend-icon,
334
- button.icon[slot=legend-icon]::before {
335
- content: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Ctitle%3Emap-legend%3C%2Ftitle%3E%3Cpath%20d%3D%22M9%2C3L3.36%2C4.9C3.15%2C4.97%203%2C5.15%203%2C5.38V20.5A0.5%2C0.5%200%200%2C0%203.5%2C21L3.66%2C20.97L9%2C18.9L15%2C21L20.64%2C19.1C20.85%2C19.03%2021%2C18.85%2021%2C18.62V3.5A0.5%2C0.5%200%200%2C0%2020.5%2C3L20.34%2C3.03L15%2C5.1L9%2C3M8%2C5.45V17.15L5%2C18.31V6.46L8%2C5.45M10%2C5.47L14%2C6.87V18.53L10%2C17.13V5.47M19%2C5.7V17.54L16%2C18.55V6.86L19%2C5.7M7.46%2C6.3L5.57%2C6.97V9.12L7.46%2C8.45V6.3M7.46%2C9.05L5.57%2C9.72V11.87L7.46%2C11.2V9.05M7.46%2C11.8L5.57%2C12.47V14.62L7.46%2C13.95V11.8M7.46%2C14.55L5.57%2C15.22V17.37L7.46%2C16.7V14.55Z%22%20%2F%3E%3C%2Fsvg%3E");
336
- }
337
- .single-action .remove-icon::before,
338
- [slot=remove-icon] button.icon::before {
339
- content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23ff0000' viewBox='0 0 24 24'%3E%3Ctitle%3Edelete-outline%3C/title%3E%3Cpath d='M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19M8,9H16V19H8V9M15.5,4L14.5,3H9.5L8.5,4H5V6H19V4H15.5Z' /%3E%3C/svg%3E");
340
- }
341
- .single-action .sort-icon::before,
342
- [slot=sort-icon] .button.icon::before {
343
- content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23004170' viewBox='0 0 24 24'%3E%3Ctitle%3Edrag-horizontal-variant%3C/title%3E%3Cpath d='M21 11H3V9H21V11M21 13H3V15H21V13Z' /%3E%3C/svg%3E");
344
- }
345
282
  [slot=info-content],
346
283
  [slot=opacity-content],
347
284
  [slot=config-content],
@@ -352,6 +289,11 @@ export class EOxLayerControlLayerTools extends LitElement {
352
289
  [slot=info-content] * {
353
290
  max-width: 100%;
354
291
  }
292
+ /*eox-layercontrol-layerconfig {
293
+ border: 1px solid var(--outline-variant);
294
+ padding: .5rem !important;
295
+ display: block;
296
+ }*/
355
297
  `;
356
298
  }
357
299
 
@@ -1,9 +1,15 @@
1
- import { LitElement, html } from "lit";
1
+ import { LitElement, html, nothing } from "lit";
2
2
  import { when } from "lit/directives/when.js";
3
3
  import { live } from "lit/directives/live.js";
4
4
  import "./layer-tools";
5
- import checkbox from "@eox/elements-utils/styles/dist/checkbox.style";
6
5
  import { firstUpdatedMethod, inputClickMethod } from "../methods/layer";
6
+ import {
7
+ getToolsIcon,
8
+ _parseActions,
9
+ _parseTools,
10
+ removeButton,
11
+ sortButton,
12
+ } from "../helpers/layer-tools";
7
13
 
8
14
  /**
9
15
  * `EOxLayerControlLayer` represents a custom web component managing individual layers within the EOxLayerControl system.
@@ -16,6 +22,7 @@ export class EOxLayerControlLayer extends LitElement {
16
22
  // Define static properties for the component
17
23
  static properties = {
18
24
  layer: { attribute: false },
25
+ layerType: { attribute: false },
19
26
  map: { attribute: false, state: true },
20
27
  titleProperty: { attribute: "title-property", type: String },
21
28
  showLayerZoomState: { attribute: "show-layer-zoom-state", type: Boolean },
@@ -43,6 +50,13 @@ export class EOxLayerControlLayer extends LitElement {
43
50
  */
44
51
  this.layer = null;
45
52
 
53
+ /**
54
+ * The type of the layer, which can be a string representing the layer type.
55
+ *
56
+ * @type {string|undefined} - The inferred layer type: "group", "draw", "vector", "raster", or undefined if not determinable.
57
+ */
58
+ this.layerType = undefined;
59
+
46
60
  /**
47
61
  * The native OL map
48
62
  *
@@ -154,7 +168,23 @@ export class EOxLayerControlLayer extends LitElement {
154
168
  : "checkbox";
155
169
 
156
170
  // Check if tools are available for the layer
157
- const isToolsAvail = this.tools?.length > 0;
171
+ const isActionAvail = _parseActions(this.tools, this.layer)?.length > 0;
172
+
173
+ // Check if tools are available for the layer
174
+ const isToolsAvail = _parseTools(this.tools, this.layer)?.length > 0;
175
+
176
+ // Check if eox-layercontrol-layer-tools is available in the DOM elsewhere for external tools,
177
+ // otherwise render inside layercontrol
178
+ const externalTools = document.querySelector(
179
+ "eox-layercontrol-layer-tools",
180
+ );
181
+ if (externalTools) {
182
+ Object.assign(externalTools, {
183
+ layer: this.layer,
184
+ tools: this.tools,
185
+ toolsAsList: this.toolsAsList,
186
+ });
187
+ }
158
188
 
159
189
  return html`
160
190
  <style>
@@ -165,30 +195,151 @@ export class EOxLayerControlLayer extends LitElement {
165
195
  this.layer,
166
196
  () => html`
167
197
  <!-- Render the layer -->
168
- <div class="layer ${visibilityClass} ${layerZoomStateClass}">
169
- <label class="drag-handle ${disableClass}">
170
- <!-- Input element for layer visibility -->
198
+ <nav
199
+ class="layer ${disableClass} ${visibilityClass} ${layerZoomStateClass} responsive tiny-space"
200
+ >
201
+ ${when(!this.unstyled, () => {
202
+ if (this.#getLayer("color")) {
203
+ return html`
204
+ <i class="small" style="color: ${this.#getLayer("color")}">
205
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
206
+ <title>square-rounded</title>
207
+ <path
208
+ d="M8 3H16C18.76 3 21 5.24 21 8V16C21 18.76 18.76 21 16 21H8C5.24 21 3 18.76 3 16V8C3 5.24 5.24 3 8 3Z"
209
+ />
210
+ </svg>
211
+ </i>
212
+ `;
213
+ }
214
+ switch (this.layerType) {
215
+ case "group":
216
+ // handled in layer group component
217
+ return html` <i class="small"> </i> `;
218
+ case "draw":
219
+ return html`
220
+ <i class="small grey-text">
221
+ <svg
222
+ xmlns="http://www.w3.org/2000/svg"
223
+ viewBox="0 0 24 24"
224
+ >
225
+ <title>vector-square-edit</title>
226
+ <path
227
+ d="M22.7 14.4L21.7 15.4L19.6 13.3L20.6 12.3C20.8 12.1 21.2 12.1 21.4 12.3L22.7 13.6C22.9 13.8 22.9 14.1 22.7 14.4M13 19.9L19.1 13.8L21.2 15.9L15.1 22H13V19.9M11 19.9V19.1L11.6 18.5L12.1 18H8V16H6V8H8V6H16V8H18V12.1L19.1 11L19.3 10.8C19.5 10.6 19.8 10.4 20.1 10.3V8H22.1V2H16.1V4H8V2H2V8H4V16H2V22H8V20L11 19.9M18 4H20V6H18V4M4 4H6V6H4V4M6 20H4V18H6V20Z"
228
+ />
229
+ </svg>
230
+ </i>
231
+ `;
232
+ case "vector":
233
+ return html`
234
+ <i class="small grey-text">
235
+ <svg
236
+ xmlns="http://www.w3.org/2000/svg"
237
+ viewBox="0 0 24 24"
238
+ >
239
+ <title>vector-polygon</title>
240
+ <path
241
+ d="M2,2V8H4.28L5.57,16H4V22H10V20.06L15,20.05V22H21V16H19.17L20,9H22V3H16V6.53L14.8,8H9.59L8,5.82V2M4,4H6V6H4M18,5H20V7H18M6.31,8H7.11L9,10.59V14H15V10.91L16.57,9H18L17.16,16H15V18.06H10V16H7.6M11,10H13V12H11M6,18H8V20H6M17,18H19V20H17"
242
+ />
243
+ </svg>
244
+ </i>
245
+ `;
246
+ case "raster":
247
+ return html`
248
+ <i class="small grey-text">
249
+ <svg
250
+ xmlns="http://www.w3.org/2000/svg"
251
+ viewBox="0 0 24 24"
252
+ >
253
+ <title>checkerboard</title>
254
+ <path
255
+ d="M2 2V22H22V2H2M20 12H16V16H20V20H16V16H12V20H8V16H4V12H8V8H4V4H8V8H12V4H16V8H20V12M16 8V12H12V8H16M12 12V16H8V12H12Z"
256
+ />
257
+ </svg>
258
+ </i>
259
+ `;
260
+ default:
261
+ return html` <i class="small grey-text"> </i> `;
262
+ }
263
+ })}
264
+
265
+ <!-- Layer title -->
266
+ <div class="max truncate drag-handle ${disableClass}">
267
+ <span class="layertitle truncate"
268
+ >${this.#getLayer(this.titleProperty)}</span
269
+ >
270
+ </div>
271
+
272
+ ${when(
273
+ isToolsAvail,
274
+ () => html`
275
+ <button
276
+ class="transparent square primary-text small action tools ${this
277
+ .tools.length === 1
278
+ ? this.tools[0]
279
+ : "dots"}"
280
+ @click=${() => {
281
+ const toolsDetails = this.renderRoot
282
+ .querySelector("eox-layercontrol-layer-tools")
283
+ ?.querySelector("details");
284
+ // Toggle tools details open/close
285
+ toolsDetails.open = !toolsDetails.open;
286
+ }}
287
+ >
288
+ <i class="small">
289
+ ${getToolsIcon()[
290
+ this.tools.length > 1 ? "dots" : this.tools[0]
291
+ ]}
292
+ </i>
293
+ <!--<div class="tooltip top" style="pointer-events: none">Tools</div>-->
294
+ </button>
295
+ `,
296
+ )}
297
+ ${when(!isToolsAvail && isActionAvail, () =>
298
+ this.tools[0] === "remove"
299
+ ? removeButton(this, getToolsIcon()[this.tools[0]])
300
+ : sortButton(this, getToolsIcon()[this.tools[0]], false),
301
+ )}
302
+
303
+ <!-- Input element for layer visibility -->
304
+ <label
305
+ class="${disableClass} ${inputType} icon square primary-text action visibility small"
306
+ >
171
307
  <input
172
308
  type=${inputType}
173
309
  .checked=${live(visibility)}
174
310
  @click=${this.#handleInputClick}
311
+ disabled=${disableClass || nothing}
175
312
  />
176
-
177
- <!-- Layer title -->
178
- <span
179
- class="title ${this.#getLayer("color") ? "color-swatch" : ""}"
180
- style="--layer-color: ${this.#getLayer("color")}"
181
- >
182
- ${this.#getLayer(this.titleProperty)}
313
+ <span>
314
+ <i>
315
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
316
+ <title>eye-off-outline</title>
317
+ <path
318
+ d="M2,5.27L3.28,4L20,20.72L18.73,22L15.65,18.92C14.5,19.3 13.28,19.5 12,19.5C7,19.5 2.73,16.39 1,12C1.69,10.24 2.79,8.69 4.19,7.46L2,5.27M12,9A3,3 0 0,1 15,12C15,12.35 14.94,12.69 14.83,13L11,9.17C11.31,9.06 11.65,9 12,9M12,4.5C17,4.5 21.27,7.61 23,12C22.18,14.08 20.79,15.88 19,17.19L17.58,15.76C18.94,14.82 20.06,13.54 20.82,12C19.17,8.64 15.76,6.5 12,6.5C10.91,6.5 9.84,6.68 8.84,7L7.3,5.47C8.74,4.85 10.33,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C12.69,17.5 13.37,17.43 14,17.29L11.72,15C10.29,14.85 9.15,13.71 9,12.28L5.6,8.87C4.61,9.72 3.78,10.78 3.18,12Z"
319
+ />
320
+ </svg>
321
+ </i>
322
+ <i>
323
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
324
+ <title>eye</title>
325
+ <path
326
+ d="M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9M12,17A5,5 0 0,1 7,12A5,5 0 0,1 12,7A5,5 0 0,1 17,12A5,5 0 0,1 12,17M12,4.5C7,4.5 2.73,7.61 1,12C2.73,16.39 7,19.5 12,19.5C17,19.5 21.27,16.39 23,12C21.27,7.61 17,4.5 12,4.5Z"
327
+ />
328
+ </svg>
329
+ </i>
183
330
  </span>
184
- ${when(
185
- isToolsAvail,
186
- () => html`<span class="tools-placeholder"></span>`,
187
- )}
331
+ <!--<div class="tooltip top" style="pointer-events: none">${visibility
332
+ ? "Hide"
333
+ : "Show"}</div>-->
188
334
  </label>
189
- </div>
335
+ </nav>
336
+ `,
337
+ )}
190
338
 
191
- <!-- Render layer tools -->
339
+ <!-- Render layer tools -->
340
+ ${when(
341
+ isToolsAvail && !externalTools,
342
+ () => html`
192
343
  <eox-layercontrol-layer-tools
193
344
  .noShadow=${true}
194
345
  .layer=${this.layer}
@@ -203,63 +354,68 @@ export class EOxLayerControlLayer extends LitElement {
203
354
 
204
355
  #styleBasic = ``;
205
356
  #styleEOX = `
206
- ${checkbox}
207
357
  eox-layercontrol-layer {
208
358
  width: 100%;
209
359
  position: relative;
210
360
  }
361
+ eox-layercontrol-layer nav {
362
+ height: 32px;
363
+ margin-block-start: 0 !important;
364
+ }
365
+ eox-layercontrol-layer > nav > .action.tools {
366
+ display: var(--layer-tools-button-visibility);
367
+ }
368
+ eox-layercontrol-layer .action.tools.dots {
369
+ transition: rotate 0s;
370
+ }
371
+ eox-layercontrol-layer:has(eox-layercontrol-layer-tools > details[open]) .action.tools.dots {
372
+ transform: rotate(180deg);
373
+ }
374
+ eox-layercontrol-layer > nav > .action.visibility {
375
+ padding: .3rem;
376
+ transform: translateX(.3rem);
377
+ }
378
+ @media (pointer:fine) {
379
+ eox-layercontrol-layer:not(:hover) > nav > .action {
380
+ display: var(--layer-toggle-button-visibility);
381
+ }
382
+ }
383
+ eox-layercontrol-layer nav:has(.action input[type=checkbox]:not(:checked)),
384
+ eox-layercontrol-layer nav:has(.action input[type=radio]:not(:checked)),
385
+ eox-layercontrol-layer:has(.action input[type=checkbox]:not(:checked)) eox-layercontrol-layer-tools,
386
+ eox-layercontrol-layer:has(.action input[type=radio]:not(:checked)) eox-layercontrol-layer-tools,
387
+ eox-layercontrol-layer-group:has(summary .action input[type=checkbox]:not(:checked)) eox-layercontrol-layer-list,
388
+ eox-layercontrol-layer-group:has(summary .action input[type=radio]:not(:checked)) eox-layercontrol-layer-list,
389
+ eox-layercontrol-layer-group:has(summary .action input[type=checkbox]:not(:checked)) .arrow-container,
390
+ eox-layercontrol-layer-group:has(summary .action input[type=radio]:not(:checked)) .arrow-container,
391
+ eox-layercontrol-layer-group:has(summary .action input[type=checkbox]:not(:checked)) eox-layercontrol-layer-tools,
392
+ eox-layercontrol-layer-group:has(summary .action input[type=radio]:not(:checked)) eox-layercontrol-layer-tools {
393
+ opacity: .5;
394
+ }
395
+ .tooltip {
396
+ opacity: 1;
397
+ }
211
398
  .layer input[type=checkbox],
212
399
  .layer input[type=radio] {
213
400
  display: var(--layer-input-visibility);
214
401
  }
215
402
  .layer.zoom-state-invisible {
216
- background: #d2e2ee;
217
- opacity: 0.3;
403
+ opacity: 0.5;
218
404
  }
219
405
  .layer {
220
- width: 100%;
221
- align-items: center;
222
- justify-content: space-between;
223
406
  padding: var(--padding-vertical) 0;
224
407
  display: var(--layer-visibility);
408
+ user-select: none;
225
409
  }
226
- label, span {
227
- display: flex;
228
- align-items: center;
229
- cursor: pointer;
230
- }
231
- .title {
410
+ .layertitle {
232
411
  display: var(--layer-title-visibility);
233
412
  }
234
- [data-type] .title::before {
235
- width: 20px;
236
- min-width: 20px;
237
- height: 20px;
238
- margin-right: 6px;
239
- display: var(--layer-type-visibility);
240
- }
241
- [data-type] .title.color-swatch::before {
242
- background: var(--layer-color);
243
- border-radius: 3px;
244
- content: "" !important;
245
- width: 16px;
246
- min-width: 16px;
247
- height: 16px;
248
- }
249
- [data-type=group] .title::before {
250
- content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%230041703a' viewBox='0 0 24 24'%3E%3Ctitle%3Efolder-outline%3C/title%3E%3Cpath d='M20,18H4V8H20M20,6H12L10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6Z' /%3E%3C/svg%3E");
251
- }
252
- [data-type=group] > eox-layercontrol-layer-group > details[open] > summary > eox-layercontrol-layer > .layer > label > .title::before {
253
- content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%230041703a' viewBox='0 0 24 24'%3E%3Ctitle%3Efolder-open-outline%3C/title%3E%3Cpath d='M6.1,10L4,18V8H21A2,2 0 0,0 19,6H12L10,4H4A2,2 0 0,0 2,6V18A2,2 0 0,0 4,20H19C19.9,20 20.7,19.4 20.9,18.5L23.2,10H6.1M19,18H6L7.6,12H20.6L19,18Z' /%3E%3C/svg%3E");
254
- }
255
- [data-type=raster] .title::before {
256
- content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%230041703a' viewBox='0 0 24 24'%3E%3Ctitle%3Echeckerboard%3C/title%3E%3Cpath d='M2 2V22H22V2H2M20 12H16V16H20V20H16V16H12V20H8V16H4V12H8V8H4V4H8V8H12V4H16V8H20V12M16 8V12H12V8H16M12 12V16H8V12H12Z' /%3E%3C/svg%3E");
257
- }
258
- [data-type=vector] .title::before {
259
- content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%230041703a' viewBox='0 0 24 24'%3E%3Ctitle%3Eshape-outline%3C/title%3E%3Cpath d='M11,13.5V21.5H3V13.5H11M9,15.5H5V19.5H9V15.5M12,2L17.5,11H6.5L12,2M12,5.86L10.08,9H13.92L12,5.86M17.5,13C20,13 22,15 22,17.5C22,20 20,22 17.5,22C15,22 13,20 13,17.5C13,15 15,13 17.5,13M17.5,15A2.5,2.5 0 0,0 15,17.5A2.5,2.5 0 0,0 17.5,20A2.5,2.5 0 0,0 20,17.5A2.5,2.5 0 0,0 17.5,15Z' /%3E%3C/svg%3E");
413
+ .drag-handle {
414
+ -webkit-user-drag: element;
415
+ user-select: none;
260
416
  }
261
- [data-type=draw] .title::before {
262
- content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%230041703a' viewBox='0 0 24 24'%3E%3Ctitle%3Evector-square-edit%3C/title%3E%3Cpath d='M22.7 14.4L21.7 15.4L19.6 13.3L20.6 12.3C20.8 12.1 21.2 12.1 21.4 12.3L22.7 13.6C22.9 13.8 22.9 14.1 22.7 14.4M13 19.9L19.1 13.8L21.2 15.9L15.1 22H13V19.9M11 19.9V19.1L11.6 18.5L12.1 18H8V16H6V8H8V6H16V8H18V12.1L19.1 11L19.3 10.8C19.5 10.6 19.8 10.4 20.1 10.3V8H22.1V2H16.1V4H8V2H2V8H4V16H2V22H8V20L11 19.9M18 4H20V6H18V4M4 4H6V6H4V4M6 20H4V18H6V20Z' /%3E%3C/svg%3E");
417
+ :is(.checkbox,.radio)>span:after {
418
+ transition: none !important;
263
419
  }
264
420
  `;
265
421
  }