@eox/layercontrol 1.10.0 → 1.11.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 (73) hide show
  1. package/dist/eox-layercontrol.js +995 -835
  2. package/dist/eox-layercontrol.umd.cjs +148 -143
  3. package/package.json +5 -5
  4. package/src/components/add-layers.js +6 -6
  5. package/src/components/layer-config.js +35 -23
  6. package/src/components/layer-datetime.js +36 -7
  7. package/src/components/layer-group.js +9 -9
  8. package/src/components/layer-legend.js +3 -3
  9. package/src/components/layer-list.js +9 -9
  10. package/src/components/layer-tools.js +44 -9
  11. package/src/components/layer.js +38 -15
  12. package/src/components/optional-list.js +5 -5
  13. package/src/components/tools-items.js +12 -6
  14. package/src/helpers/clean-json-input.js +1 -1
  15. package/src/helpers/create-sortable.js +8 -0
  16. package/src/helpers/get-legend-config.js +16 -1
  17. package/src/helpers/handle-datetime-update.js +43 -15
  18. package/src/helpers/is-layer-visible-based-on-zoom-state.js +2 -2
  19. package/src/helpers/is-layer-zoom-state-req.js +2 -2
  20. package/src/helpers/layer-tools.js +1 -1
  21. package/src/helpers/update-geozarr-band.js +18 -126
  22. package/src/helpers/update-url.js +3 -3
  23. package/src/main.js +33 -17
  24. package/src/methods/add-layer/add-layer.js +7 -0
  25. package/src/methods/add-layer/wms-search-url.js +1 -1
  26. package/src/methods/layer/first-updated.js +47 -26
  27. package/src/methods/layer-config/apply-updated-styles.js +8 -5
  28. package/src/methods/layer-config/data-change.js +1 -1
  29. package/src/methods/optional-list/add-to-list.js +1 -1
  30. package/types/components/add-layers.d.ts +6 -6
  31. package/types/components/add-layers.d.ts.map +1 -1
  32. package/types/components/layer-config.d.ts +3 -3
  33. package/types/components/layer-config.d.ts.map +1 -1
  34. package/types/components/layer-datetime.d.ts +3 -3
  35. package/types/components/layer-datetime.d.ts.map +1 -1
  36. package/types/components/layer-group.d.ts +9 -9
  37. package/types/components/layer-group.d.ts.map +1 -1
  38. package/types/components/layer-legend.d.ts +3 -3
  39. package/types/components/layer-legend.d.ts.map +1 -1
  40. package/types/components/layer-list.d.ts +9 -9
  41. package/types/components/layer-list.d.ts.map +1 -1
  42. package/types/components/layer-tools.d.ts +6 -6
  43. package/types/components/layer-tools.d.ts.map +1 -1
  44. package/types/components/layer.d.ts +9 -14
  45. package/types/components/layer.d.ts.map +1 -1
  46. package/types/components/optional-list.d.ts +5 -5
  47. package/types/components/optional-list.d.ts.map +1 -1
  48. package/types/components/tools-items.d.ts +5 -5
  49. package/types/components/tools-items.d.ts.map +1 -1
  50. package/types/helpers/clean-json-input.d.ts +1 -1
  51. package/types/helpers/clean-json-input.d.ts.map +1 -1
  52. package/types/helpers/create-sortable.d.ts.map +1 -1
  53. package/types/helpers/get-legend-config.d.ts.map +1 -1
  54. package/types/helpers/handle-datetime-update.d.ts +11 -2
  55. package/types/helpers/handle-datetime-update.d.ts.map +1 -1
  56. package/types/helpers/is-layer-visible-based-on-zoom-state.d.ts +2 -2
  57. package/types/helpers/is-layer-visible-based-on-zoom-state.d.ts.map +1 -1
  58. package/types/helpers/is-layer-zoom-state-req.d.ts +2 -2
  59. package/types/helpers/is-layer-zoom-state-req.d.ts.map +1 -1
  60. package/types/helpers/update-geozarr-band.d.ts +3 -21
  61. package/types/helpers/update-geozarr-band.d.ts.map +1 -1
  62. package/types/helpers/update-url.d.ts +4 -4
  63. package/types/helpers/update-url.d.ts.map +1 -1
  64. package/types/main.d.ts +15 -11
  65. package/types/main.d.ts.map +1 -1
  66. package/types/methods/add-layer/add-layer.d.ts.map +1 -1
  67. package/types/methods/add-layer/wms-search-url.d.ts +1 -1
  68. package/types/methods/add-layer/wms-search-url.d.ts.map +1 -1
  69. package/types/methods/layer/first-updated.d.ts +3 -2
  70. package/types/methods/layer/first-updated.d.ts.map +1 -1
  71. package/types/methods/layer-config/apply-updated-styles.d.ts +2 -2
  72. package/types/methods/layer-config/apply-updated-styles.d.ts.map +1 -1
  73. package/types/methods/layer-config/data-change.d.ts +1 -1
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@eox/layercontrol",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git@github.com:EOX-A/EOxElements.git"
8
8
  },
9
9
  "devDependencies": {
10
- "@eox/jsonform": "*",
11
- "@eox/map": "*",
10
+ "@eox/jsonform": "1.15.0",
11
+ "@eox/map": "2.11.0",
12
12
  "@types/lodash.throttle": "^4.1.9",
13
13
  "@types/sortablejs": "^1.15.1",
14
14
  "ol": "^10.11.0",
15
- "vite": "^8.2.2"
15
+ "vite": "^8.3.5"
16
16
  },
17
17
  "engines": {
18
18
  "npm": ">=8.0.0",
@@ -42,7 +42,7 @@
42
42
  "watch": "vite build --watch"
43
43
  },
44
44
  "dependencies": {
45
- "@eox/elements-utils": "^1.2.0",
45
+ "@eox/elements-utils": "^1.3.0",
46
46
  "@eox/ui": "^1.1.0",
47
47
  "color-legend-element": "^1.5.0",
48
48
  "lit": "^3.3.3",
@@ -19,7 +19,7 @@ import {
19
19
  * to validate and process the input for adding layers dynamically to the map.
20
20
  *
21
21
  * @element eox-layercontrol-add-layers
22
- * @extends LitElement
22
+ * @augments LitElement
23
23
  */
24
24
  export class EOxLayerControlAddLayers extends LitElement {
25
25
  // Define static properties for the component
@@ -32,14 +32,14 @@ export class EOxLayerControlAddLayers extends LitElement {
32
32
  /**
33
33
  * State for URL Input for WMS/XYZ URLs
34
34
  *
35
- * @type {String}
35
+ * @type {string}
36
36
  */
37
37
  urlInput = null;
38
38
 
39
39
  /**
40
40
  * State for JSON Textarea - For EOxMap JSON
41
41
  *
42
- * @type {String}
42
+ * @type {string}
43
43
  */
44
44
  jsonInput = null;
45
45
 
@@ -53,7 +53,7 @@ export class EOxLayerControlAddLayers extends LitElement {
53
53
  /**
54
54
  * Loader state when search is triggered
55
55
  *
56
- * @type {Boolean}
56
+ * @type {boolean}
57
57
  */
58
58
  searchLoad = false;
59
59
 
@@ -77,14 +77,14 @@ export class EOxLayerControlAddLayers extends LitElement {
77
77
  /**
78
78
  * Render the element without additional styles
79
79
  *
80
- * @type {Boolean}
80
+ * @type {boolean}
81
81
  */
82
82
  this.unstyled = false;
83
83
 
84
84
  /**
85
85
  * Renders the element without a shadow root
86
86
  *
87
- * @type {Boolean}
87
+ * @type {boolean}
88
88
  */
89
89
  this.noShadow = false;
90
90
  }
@@ -1,5 +1,6 @@
1
1
  import { LitElement, html, css } from "lit";
2
2
  import { getLegendConfig, getStartVals, getGeoZarrBandRange } from "../helpers";
3
+ import { syncMinMaxFormValues } from "@eox/elements-utils";
3
4
  import { dataChangeMethod, applyUpdatedStyles } from "../methods/layer-config";
4
5
  import { when } from "lit/directives/when.js";
5
6
  import _throttle from "lodash.throttle";
@@ -18,7 +19,7 @@ import "./layer-legend";
18
19
  *
19
20
  *
20
21
  * @element eox-layercontrol-layerconfig
21
- * @extends LitElement
22
+ * @augments LitElement
22
23
  */
23
24
  export class EOxLayerControlLayerConfig extends LitElement {
24
25
  // Define static properties for the component
@@ -66,14 +67,14 @@ export class EOxLayerControlLayerConfig extends LitElement {
66
67
  /**
67
68
  * Render the element without additional styles
68
69
  *
69
- * @type {Boolean}
70
+ * @type {boolean}
70
71
  */
71
72
  this.unstyled = false;
72
73
 
73
74
  /**
74
75
  * Renders the element without a shadow root
75
76
  *
76
- * @type {Boolean}
77
+ * @type {boolean}
77
78
  */
78
79
  this.noShadow = false;
79
80
 
@@ -129,6 +130,10 @@ export class EOxLayerControlLayerConfig extends LitElement {
129
130
 
130
131
  #layerPropertyChangeListener = (e) => {
131
132
  const propEvent = /** @type {import("ol/Object").ObjectEvent} */ (e);
133
+ if (propEvent.key === "source") {
134
+ // remove outdated function
135
+ this.#originalTileUrlFunction = undefined;
136
+ }
132
137
  if (propEvent.key === "layerConfig") {
133
138
  this.layerConfig = this.layer.get("layerConfig");
134
139
  const freshStartVals = getStartVals(this.layer, this.layerConfig) || {};
@@ -139,15 +144,15 @@ export class EOxLayerControlLayerConfig extends LitElement {
139
144
 
140
145
  if (
141
146
  this.layerConfig?.min !== undefined &&
142
- (isAutofill || schemaProps?.min !== undefined)
143
- ) {
144
- this.#data.min = this.layerConfig.min;
145
- }
146
- if (
147
- this.layerConfig?.max !== undefined &&
148
- (isAutofill || schemaProps?.max !== undefined)
147
+ this.layerConfig?.max !== undefined
149
148
  ) {
150
- this.#data.max = this.layerConfig.max;
149
+ syncMinMaxFormValues(
150
+ this.#data,
151
+ schemaProps,
152
+ this.layerConfig.min,
153
+ this.layerConfig.max,
154
+ isAutofill,
155
+ );
151
156
  }
152
157
  const activeVar =
153
158
  this.layer.get("_lastVariable") ||
@@ -210,6 +215,7 @@ export class EOxLayerControlLayerConfig extends LitElement {
210
215
  * @param {{ detail: Record<string, any>; }} e
211
216
  */
212
217
  async #handleDataChange(e) {
218
+ const isUser = Boolean(/** @type {any} */ (e)?.isUser);
213
219
  const prevVar =
214
220
  this.#data?.variable ??
215
221
  this.#data?.band ??
@@ -230,14 +236,8 @@ export class EOxLayerControlLayerConfig extends LitElement {
230
236
  String(currentVar),
231
237
  this.layerConfig,
232
238
  );
233
- if (e.detail) {
234
- if ("min" in e.detail || this.layerConfig?.min !== undefined) {
235
- e.detail.min = targetMin;
236
- }
237
- if ("max" in e.detail || this.layerConfig?.max !== undefined) {
238
- e.detail.max = targetMax;
239
- }
240
- }
239
+ const schemaProps = this.layerConfig?.schema?.properties;
240
+ syncMinMaxFormValues(e.detail, schemaProps, targetMin, targetMax);
241
241
  }
242
242
 
243
243
  this.#data = { ...e.detail };
@@ -315,6 +315,7 @@ export class EOxLayerControlLayerConfig extends LitElement {
315
315
  detail: {
316
316
  jsonformValue: this.#data,
317
317
  layer: this.layer,
318
+ isUser,
318
319
  },
319
320
  }),
320
321
  );
@@ -334,19 +335,25 @@ export class EOxLayerControlLayerConfig extends LitElement {
334
335
  render() {
335
336
  // Fetch initial values for the layer and its configuration
336
337
  const freshStartVals = getStartVals(this.layer, this.layerConfig) || {};
337
- this.#startVals = { ...freshStartVals, ...this.#data };
338
+ const startVals = { ...freshStartVals, ...this.#data };
338
339
  const schemaProps = this.layerConfig?.schema?.properties;
339
340
  const isAutofill =
340
341
  this.layerConfig?.autofill === true ||
341
342
  this.layerConfig?.schema?.autofill === true;
342
343
  if (schemaProps && !isAutofill) {
343
344
  const allowedKeys = new Set(Object.keys(schemaProps));
344
- for (const k of Object.keys(this.#startVals)) {
345
+ for (const k of Object.keys(startVals)) {
345
346
  if (!allowedKeys.has(k)) {
346
- delete this.#startVals[k];
347
+ delete startVals[k];
347
348
  }
348
349
  }
349
350
  }
351
+ // without start values, null lets eox-jsonform build the form from the schema defaults
352
+ const nextStartVals = Object.keys(startVals).length ? startVals : null;
353
+ // a new object on every render makes eox-jsonform reset the form to it
354
+ if (JSON.stringify(nextStartVals) !== JSON.stringify(this.#startVals)) {
355
+ this.#startVals = nextStartVals;
356
+ }
350
357
  this.#data = { ...this.#startVals };
351
358
  if (!customElements.get("eox-jsonform")) {
352
359
  console.error("Please import @eox/jsonform in order to use layerconfig");
@@ -389,7 +396,12 @@ export class EOxLayerControlLayerConfig extends LitElement {
389
396
  .options=${options}
390
397
  .noShadow=${true}
391
398
  .customEditorInterfaces=${this.customEditorInterfaces}
392
- @change=${this.throttleDataChange}
399
+ @change=${(/** @type {CustomEvent} */ e) => {
400
+ this.throttleDataChange(e);
401
+ }}
402
+ @eox:activity=${(/** @type {CustomEvent} */ e) => {
403
+ e.stopPropagation();
404
+ }}
393
405
  ></eox-jsonform>
394
406
  `,
395
407
  )}
@@ -1,5 +1,7 @@
1
1
  import { LitElement, html } from "lit";
2
2
  import { when } from "lit/directives/when.js";
3
+ import _debounce from "lodash.debounce";
4
+ import { updateLayerSlice } from "../helpers/handle-datetime-update";
3
5
 
4
6
  /**
5
7
  * `EOxLayerControlLayerDatetime` is a component that handles date time options for layers using eox-timecontrol.
@@ -7,7 +9,7 @@ import { when } from "lit/directives/when.js";
7
9
  *
8
10
  *
9
11
  * @element eox-layercontrol-layer-datetime
10
- * @extends LitElement
12
+ * @augments LitElement
11
13
  */
12
14
  export class EOxLayerControlLayerDatetime extends LitElement {
13
15
  // Define static properties for the component
@@ -24,14 +26,14 @@ export class EOxLayerControlLayerDatetime extends LitElement {
24
26
  /**
25
27
  * Render the element without additional styles
26
28
  *
27
- * @type {Boolean}
29
+ * @type {boolean}
28
30
  */
29
31
  this.unstyled = false;
30
32
 
31
33
  /**
32
34
  * Renders the element without a shadow root
33
35
  *
34
- * @type {Boolean}
36
+ * @type {boolean}
35
37
  */
36
38
  this.noShadow = false;
37
39
 
@@ -67,13 +69,22 @@ export class EOxLayerControlLayerDatetime extends LitElement {
67
69
  return this.noShadow ? this : super.createRenderRoot();
68
70
  }
69
71
 
72
+ disconnectedCallback() {
73
+ // runs a pending slice update before removal
74
+ this.#updateSlice.flush();
75
+ super.disconnectedCallback();
76
+ }
77
+
78
+ #updateSlice = _debounce(updateLayerSlice, 300);
79
+
70
80
  /**
71
81
  * Handles timecontrol Stepchange &
72
82
  * triggers `datetime:updated` event on step change
73
83
  *
74
- * @param {CustomEvent<{date:string[]}>} evt
84
+ * @param {CustomEvent<{date:string[]}> & { isUser?: boolean }} evt
75
85
  **/
76
86
  #handleStepChange(evt) {
87
+ evt.stopPropagation();
77
88
  const dateObj = new Date(evt.detail.date[0]);
78
89
 
79
90
  // Check if configuration implies datetime (ISO strings)
@@ -89,19 +100,36 @@ export class EOxLayerControlLayerDatetime extends LitElement {
89
100
  `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
90
101
  currentStep = formatDate(dateObj);
91
102
  }
92
- if (currentStep === this.layerDatetime.currentStep) {
103
+ const previousStep = this.layerDatetime.currentStep;
104
+ // TimeControl normalizes to seconds, but the configured step may include milliseconds.
105
+ if (
106
+ currentStep === previousStep ||
107
+ (isDatetimeConfig &&
108
+ typeof previousStep === "string" &&
109
+ Math.floor(dateObj.getTime() / 1000) ===
110
+ Math.floor(Date.parse(previousStep) / 1000))
111
+ ) {
93
112
  return;
94
113
  }
95
114
 
96
- this.dispatchEvent(
115
+ const event = Object.assign(
97
116
  new CustomEvent("datetime:updated", {
98
117
  bubbles: true,
118
+ composed: true,
99
119
  detail: {
100
120
  datetime: currentStep,
101
121
  layer: this.layer,
102
122
  },
103
123
  }),
124
+ { isUser: evt.isUser === true },
104
125
  );
126
+ /**
127
+ * Fires datetime:updated with the selected datetime and layer.
128
+ * Forwards user attribution synchronously without emitting child activity.
129
+ */
130
+ this.dispatchEvent(event);
131
+
132
+ this.#updateSlice(this.layer, currentStep);
105
133
 
106
134
  this.layerDatetime.currentStep = currentStep;
107
135
  this.requestUpdate();
@@ -122,7 +150,7 @@ export class EOxLayerControlLayerDatetime extends LitElement {
122
150
  ${!this.unstyled && this.#styleEOX}
123
151
  </style>
124
152
  ${when(
125
- this.layerDatetime,
153
+ this.layerDatetime?.controlValues,
126
154
  () => html`
127
155
  <eox-timecontrol
128
156
  .initDate=${this.layerDatetime.currentStep
@@ -138,6 +166,7 @@ export class EOxLayerControlLayerDatetime extends LitElement {
138
166
  },
139
167
  ]}
140
168
  @select=${this.#handleStepChange}
169
+ @eox:activity=${(/** @type {Event} */ e) => e.stopPropagation()}
141
170
  .showUTC=${this.layerDatetime.showUTC || false}
142
171
  >
143
172
  <eox-timecontrol-date
@@ -9,7 +9,7 @@ import "./layer-list";
9
9
  * Handles rendering a layer control group with expandable details containing layers.
10
10
  *
11
11
  * @element eox-layercontrol-layer-group
12
- * @extends LitElement
12
+ * @augments LitElement
13
13
  */
14
14
  export class EOxLayerControlLayerGroup extends LitElement {
15
15
  // Define static properties for the component
@@ -46,7 +46,7 @@ export class EOxLayerControlLayerGroup extends LitElement {
46
46
  /**
47
47
  * The layer id property
48
48
  *
49
- * @type {String}
49
+ * @type {string}
50
50
  */
51
51
  this.idProperty = "id";
52
52
 
@@ -60,14 +60,14 @@ export class EOxLayerControlLayerGroup extends LitElement {
60
60
  /**
61
61
  * The layer title property
62
62
  *
63
- * @type {String}
63
+ * @type {string}
64
64
  */
65
65
  this.titleProperty = "title";
66
66
 
67
67
  /**
68
68
  * Show layer state based on zoom level or not
69
69
  *
70
- * @type {Boolean}
70
+ * @type {boolean}
71
71
  */
72
72
  this.showLayerZoomState = false;
73
73
 
@@ -81,35 +81,35 @@ export class EOxLayerControlLayerGroup extends LitElement {
81
81
  /**
82
82
  * Render the element without additional styles
83
83
  *
84
- * @type {Boolean}
84
+ * @type {boolean}
85
85
  */
86
86
  this.unstyled = false;
87
87
 
88
88
  /**
89
89
  * Renders the element without a shadow root
90
90
  *
91
- * @type {Boolean}
91
+ * @type {boolean}
92
92
  */
93
93
  this.noShadow = false;
94
94
 
95
95
  /**
96
96
  * If enabled, the tools section will be rendered as list.
97
97
  *
98
- * @type {Boolean}
98
+ * @type {boolean}
99
99
  */
100
100
  this.toolsAsList = false;
101
101
 
102
102
  /**
103
103
  * If enabled, toggling the layer visibility will also open/close the layer tools.
104
104
  *
105
- * @type {Boolean}
105
+ * @type {boolean}
106
106
  */
107
107
  this.toolsAutoExpand = false;
108
108
 
109
109
  /**
110
110
  * If enabled, exclusive layers (marked with the property `layerControlExclusive`) will be globally exclusive (default: exclusive within their layer group).
111
111
  *
112
- * @type {Boolean}
112
+ * @type {boolean}
113
113
  */
114
114
  this.globallyExclusiveLayers = false;
115
115
 
@@ -21,7 +21,7 @@ import { ifDefined } from "lit/directives/if-defined.js";
21
21
  * `EOxLayerControlLayerLegend` is a component that handles creating a legend from a range of colors & the domain of the color values.
22
22
  *
23
23
  * @element eox-layercontrol-layer-datetime
24
- * @extends LitElement
24
+ * @augments LitElement
25
25
  */
26
26
  export class EOxLayerControlLayerLegend extends LitElement {
27
27
  // Define static properties for the component
@@ -38,14 +38,14 @@ export class EOxLayerControlLayerLegend extends LitElement {
38
38
  /**
39
39
  * Render the element without additional styles
40
40
  *
41
- * @type {Boolean}
41
+ * @type {boolean}
42
42
  */
43
43
  this.unstyled = false;
44
44
 
45
45
  /**
46
46
  * Renders the element without a shadow root
47
47
  *
48
- * @type {Boolean}
48
+ * @type {boolean}
49
49
  */
50
50
  this.noShadow = false;
51
51
 
@@ -9,7 +9,7 @@ import { firstUpdatedMethod } from "../methods/layer-list";
9
9
  * EOxLayerControlLayerList: Manages a list of layers within the EOx Layer Control.
10
10
  *
11
11
  * @element eox-layercontrol-layer-list
12
- * @extends LitElement
12
+ * @augments LitElement
13
13
  */
14
14
  export class EOxLayerControlLayerList extends LitElement {
15
15
  // Define static properties for the component
@@ -38,7 +38,7 @@ export class EOxLayerControlLayerList extends LitElement {
38
38
  /**
39
39
  * The layer id property
40
40
  *
41
- * @type {String}
41
+ * @type {string}
42
42
  */
43
43
  this.idProperty = "id";
44
44
 
@@ -68,49 +68,49 @@ export class EOxLayerControlLayerList extends LitElement {
68
68
  /**
69
69
  * The layer title property
70
70
  *
71
- * @type {String}
71
+ * @type {string}
72
72
  */
73
73
  this.titleProperty = "title";
74
74
 
75
75
  /**
76
76
  * Show layer state based on zoom level or not
77
77
  *
78
- * @type {Boolean}
78
+ * @type {boolean}
79
79
  */
80
80
  this.showLayerZoomState = false;
81
81
 
82
82
  /**
83
83
  * Render the element without additional styles
84
84
  *
85
- * @type {Boolean}
85
+ * @type {boolean}
86
86
  */
87
87
  this.unstyled = false;
88
88
 
89
89
  /**
90
90
  * Renders the element without a shadow root
91
91
  *
92
- * @type {Boolean}
92
+ * @type {boolean}
93
93
  */
94
94
  this.noShadow = false;
95
95
 
96
96
  /**
97
97
  * If enabled, the tools section will be rendered as list.
98
98
  *
99
- * @type {Boolean}
99
+ * @type {boolean}
100
100
  */
101
101
  this.toolsAsList = false;
102
102
 
103
103
  /**
104
104
  * If enabled, toggling the layer visibility will also open/close the layer tools.
105
105
  *
106
- * @type {Boolean}
106
+ * @type {boolean}
107
107
  */
108
108
  this.toolsAutoExpand = false;
109
109
 
110
110
  /**
111
111
  * If enabled, exclusive layers (marked with the property `layerControlExclusive`) will be globally exclusive (default: exclusive within their layer group).
112
112
  *
113
- * @type {Boolean}
113
+ * @type {boolean}
114
114
  */
115
115
  this.globallyExclusiveLayers = false;
116
116
 
@@ -1,4 +1,5 @@
1
1
  import { LitElement, html } from "lit";
2
+ import { emitActivity, findHost } from "@eox/elements-utils";
2
3
  import { unsafeHTML } from "lit/directives/unsafe-html.js";
3
4
  import { map } from "lit/directives/map.js";
4
5
  import { when } from "lit/directives/when.js";
@@ -23,7 +24,7 @@ import {
23
24
  * Manages rendering tools and actions such as remove, sort, information display, layer configuration, and opacity adjustment.
24
25
  *
25
26
  * @element eox-layercontrol-layer-tools
26
- * @extends LitElement
27
+ * @augments LitElement
27
28
  */
28
29
  export class EOxLayerControlLayerTools extends LitElement {
29
30
  // Define static properties for the component
@@ -64,42 +65,42 @@ export class EOxLayerControlLayerTools extends LitElement {
64
65
  /**
65
66
  * Render the element without additional styles
66
67
  *
67
- * @type {Boolean}
68
+ * @type {boolean}
68
69
  */
69
70
  this.unstyled = false;
70
71
 
71
72
  /**
72
73
  * Renders the element without a shadow root
73
74
  *
74
- * @type {Boolean}
75
+ * @type {boolean}
75
76
  */
76
77
  this.noShadow = false;
77
78
 
78
79
  /**
79
80
  * If enabled, the tools section will be rendered as list.
80
81
  *
81
- * @type {Boolean}
82
+ * @type {boolean}
82
83
  */
83
84
  this.toolsAsList = false;
84
85
 
85
86
  /**
86
87
  * If enabled, the tools section will be opened.
87
88
  *
88
- * @type {Boolean}
89
+ * @type {boolean}
89
90
  */
90
91
  this.open = false;
91
92
 
92
93
  /**
93
94
  * If enabled, toggling the layer visibility will also open/close the layer tools.
94
95
  *
95
- * @type {Boolean}
96
+ * @type {boolean}
96
97
  */
97
98
  this.toolsAutoExpand = false;
98
99
 
99
100
  /**
100
101
  * Determine if tools are embedded in layercontrol or stand-alone
101
102
  *
102
- * @type {Boolean}
103
+ * @type {boolean}
103
104
  */
104
105
  setTimeout(() => {
105
106
  const parent =
@@ -177,6 +178,7 @@ export class EOxLayerControlLayerTools extends LitElement {
177
178
  detail: {
178
179
  jsonformValue: evt.detail.jsonformValue,
179
180
  layer: evt.detail.layer,
181
+ isUser: evt.detail.isUser,
180
182
  },
181
183
  }),
182
184
  );
@@ -216,6 +218,20 @@ export class EOxLayerControlLayerTools extends LitElement {
216
218
  this.layer.setOpacity(parseFloat(evt.target.value));
217
219
  this.requestUpdate();
218
220
  }}
221
+ @change=${(
222
+ /** @type {Event & { target: { value: string; }; }} */ evt,
223
+ ) => {
224
+ const root = findHost(this, "eox-layercontrol") || this;
225
+ emitActivity(
226
+ root,
227
+ "change:opacity",
228
+ {
229
+ layer: this.layer?.get("id") || this.layer?.get("name"),
230
+ opacity: parseFloat(evt.target.value),
231
+ },
232
+ evt,
233
+ );
234
+ }}
219
235
  />
220
236
  <span class="small-text" style="width: 30px; text-align: right">${Math.round(this.layer?.getOpacity() * 100)}%</span>
221
237
  </div class="row">
@@ -277,6 +293,8 @@ export class EOxLayerControlLayerTools extends LitElement {
277
293
  `;
278
294
  };
279
295
 
296
+ #userClickedToolsSummary = false;
297
+
280
298
  render() {
281
299
  // Obtain actions and tools based on this.tools and this.layer
282
300
  const actions = _parseActions(this.tools, this.layer);
@@ -309,12 +327,29 @@ export class EOxLayerControlLayerTools extends LitElement {
309
327
  class="tools"
310
328
  .open=${live(this.open)}
311
329
  @toggle=${(
312
- /** @type {{ target: { open: boolean; }; }} */ evt,
330
+ /** @type {Event & { target: { open: boolean; }; }} */ evt,
313
331
  ) => {
314
332
  this.open = evt.target.open;
333
+ if (this.#userClickedToolsSummary) {
334
+ this.#userClickedToolsSummary = false;
335
+ const root = findHost(this, "eox-layercontrol") || this;
336
+ emitActivity(
337
+ root,
338
+ "toggle:tools",
339
+ {
340
+ layer: this.layer?.get("id") || this.layer?.get("name"),
341
+ open: this.open,
342
+ },
343
+ evt,
344
+ );
345
+ }
315
346
  }}
316
347
  >
317
- <summary></summary>
348
+ <summary
349
+ @click=${() => {
350
+ this.#userClickedToolsSummary = true;
351
+ }}
352
+ ></summary>
318
353
  <eox-layercontrol-tools-items
319
354
  class="${this.toolsAsList ? "tools-list" : "tools-tab"}"
320
355
  .noShadow=${false}