@vaadin/bundles 25.3.0-alpha13 → 25.3.0-alpha14

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 (105) hide show
  1. package/node_modules_vaadin_map_node_modules_ol_control_MousePosition_js.js +6 -6
  2. package/node_modules_vaadin_map_node_modules_ol_control_MousePosition_js.js.map +1 -1
  3. package/node_modules_vaadin_map_node_modules_ol_control_ZoomToExtent_js.js +10 -1
  4. package/node_modules_vaadin_map_node_modules_ol_control_ZoomToExtent_js.js.map +1 -1
  5. package/node_modules_vaadin_map_node_modules_ol_events_SnapEvent_js.js +5 -0
  6. package/node_modules_vaadin_map_node_modules_ol_events_SnapEvent_js.js.map +1 -1
  7. package/node_modules_vaadin_map_node_modules_ol_featureloader_js.js +9 -8
  8. package/node_modules_vaadin_map_node_modules_ol_featureloader_js.js.map +1 -1
  9. package/node_modules_vaadin_map_node_modules_ol_geom_GeometryCollection_js.js +1 -1
  10. package/node_modules_vaadin_map_node_modules_ol_geom_GeometryCollection_js.js.map +1 -1
  11. package/node_modules_vaadin_map_node_modules_ol_geom_flat_clip_js.js +172 -0
  12. package/node_modules_vaadin_map_node_modules_ol_geom_flat_clip_js.js.map +1 -0
  13. package/node_modules_vaadin_map_node_modules_ol_geom_flat_length_js-_95bd5.js +58 -0
  14. package/node_modules_vaadin_map_node_modules_ol_geom_flat_length_js-_95bd5.js.map +1 -0
  15. package/{node_modules_vaadin_map_node_modules_ol_render_VectorContext_js-node_modules_vaadin_map_node_-a1378d.js → node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js-node_modules_vaadin_map_node_-304640.js} +244 -5
  16. package/node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js-node_modules_vaadin_map_node_-304640.js.map +1 -0
  17. package/node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js-node_modules_vaadin_map_node_-7a9288.js +383 -0
  18. package/node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js-node_modules_vaadin_map_node_-7a9288.js.map +1 -0
  19. package/node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js.js +243 -0
  20. package/node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js.js.map +1 -0
  21. package/node_modules_vaadin_map_node_modules_ol_geom_flat_textpath_js.js +18 -5
  22. package/node_modules_vaadin_map_node_modules_ol_geom_flat_textpath_js.js.map +1 -1
  23. package/node_modules_vaadin_map_node_modules_ol_interaction_DragAndDrop_js.js +8 -8
  24. package/node_modules_vaadin_map_node_modules_ol_interaction_DragAndDrop_js.js.map +1 -1
  25. package/{node_modules_vaadin_map_node_modules_ol_render_VectorContext_js-_279c0.js → node_modules_vaadin_map_node_modules_ol_render_VectorContext_js.js} +2 -2
  26. package/node_modules_vaadin_map_node_modules_ol_render_VectorContext_js.js.map +1 -0
  27. package/node_modules_vaadin_map_node_modules_ol_render_canvas_LineStringBuilder_js.js +17 -7
  28. package/node_modules_vaadin_map_node_modules_ol_render_canvas_LineStringBuilder_js.js.map +1 -1
  29. package/node_modules_vaadin_map_node_modules_ol_render_canvas_ZIndexContext_js-_abc10.js +18 -15
  30. package/node_modules_vaadin_map_node_modules_ol_render_canvas_ZIndexContext_js-_abc10.js.map +1 -1
  31. package/node_modules_vaadin_map_node_modules_ol_render_canvas_ZIndexContext_js-_abc11.js +18 -15
  32. package/node_modules_vaadin_map_node_modules_ol_render_canvas_ZIndexContext_js-_abc11.js.map +1 -1
  33. package/node_modules_vaadin_map_node_modules_ol_renderer_Layer_js.js +21 -1
  34. package/node_modules_vaadin_map_node_modules_ol_renderer_Layer_js.js.map +1 -1
  35. package/node_modules_vaadin_map_node_modules_ol_source_Source_js.js +34 -3
  36. package/node_modules_vaadin_map_node_modules_ol_source_Source_js.js.map +1 -1
  37. package/package.json +135 -135
  38. package/vaadin-bundle.json +1824 -1812
  39. package/vaadin.js +2725 -1726
  40. package/vaadin.js.map +1 -1
  41. package/vendors-node_modules_vaadin_map_node_modules_ol_Feature_js.js +30 -16
  42. package/vendors-node_modules_vaadin_map_node_modules_ol_Feature_js.js.map +1 -1
  43. package/vendors-node_modules_vaadin_map_node_modules_ol_Overlay_js.js +6 -6
  44. package/vendors-node_modules_vaadin_map_node_modules_ol_Overlay_js.js.map +1 -1
  45. package/vendors-node_modules_vaadin_map_node_modules_ol_control_FullScreen_js.js +7 -7
  46. package/vendors-node_modules_vaadin_map_node_modules_ol_control_FullScreen_js.js.map +1 -1
  47. package/vendors-node_modules_vaadin_map_node_modules_ol_control_OverviewMap_js.js +1 -1
  48. package/vendors-node_modules_vaadin_map_node_modules_ol_control_OverviewMap_js.js.map +1 -1
  49. package/vendors-node_modules_vaadin_map_node_modules_ol_control_ScaleLine_js.js +6 -6
  50. package/vendors-node_modules_vaadin_map_node_modules_ol_control_ScaleLine_js.js.map +1 -1
  51. package/vendors-node_modules_vaadin_map_node_modules_ol_control_ZoomSlider_js.js +1 -1
  52. package/vendors-node_modules_vaadin_map_node_modules_ol_control_ZoomSlider_js.js.map +1 -1
  53. package/vendors-node_modules_vaadin_map_node_modules_ol_control_js.js +34 -25
  54. package/vendors-node_modules_vaadin_map_node_modules_ol_control_js.js.map +1 -1
  55. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Draw_js.js +146 -943
  56. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Draw_js.js.map +1 -1
  57. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Extent_js.js +111 -34
  58. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Extent_js.js.map +1 -1
  59. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Link_js.js +3 -3
  60. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Link_js.js.map +1 -1
  61. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Modify_js.js +1055 -219
  62. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Modify_js.js.map +1 -1
  63. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Select_js.js +129 -57
  64. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Select_js.js.map +1 -1
  65. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Snap_js.js +74 -80
  66. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Snap_js.js.map +1 -1
  67. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Translate_js.js +11 -11
  68. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Translate_js.js.map +1 -1
  69. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_js.js +54 -54
  70. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_js.js.map +1 -1
  71. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_tracing_js.js +801 -0
  72. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_tracing_js.js.map +1 -0
  73. package/vendors-node_modules_vaadin_map_node_modules_ol_render_Feature_js.js +36 -20
  74. package/vendors-node_modules_vaadin_map_node_modules_ol_render_Feature_js.js.map +1 -1
  75. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_BuilderGroup_js.js +17 -279
  76. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_BuilderGroup_js.js.map +1 -1
  77. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Builder_js.js +16 -7
  78. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Builder_js.js.map +1 -1
  79. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_ExecutorGroup_js.js +53 -17
  80. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_ExecutorGroup_js.js.map +1 -1
  81. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Executor_js.js +336 -38
  82. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Executor_js.js.map +1 -1
  83. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Immediate_js.js +75 -42
  84. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Immediate_js.js.map +1 -1
  85. package/{node_modules_vaadin_map_node_modules_ol_render_canvas_PolygonBuilder_js.js → vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_PolygonBuilder_js.js} +77 -11
  86. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_PolygonBuilder_js.js.map +1 -0
  87. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_TextBuilder_js.js +210 -16
  88. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_TextBuilder_js.js.map +1 -1
  89. package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_canvas_Layer_js.js +88 -32
  90. package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_canvas_Layer_js.js.map +1 -1
  91. package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_canvas_VectorLayer_js.js +62 -22
  92. package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_canvas_VectorLayer_js.js.map +1 -1
  93. package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_vector_js.js +2 -2
  94. package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_vector_js.js.map +1 -1
  95. package/vendors-node_modules_vaadin_map_node_modules_ol_source_Vector_js.js +135 -81
  96. package/vendors-node_modules_vaadin_map_node_modules_ol_source_Vector_js.js.map +1 -1
  97. package/node_modules_vaadin_map_node_modules_ol_render_VectorContext_js-_279c0.js.map +0 -1
  98. package/node_modules_vaadin_map_node_modules_ol_render_VectorContext_js-_279c1.js +0 -144
  99. package/node_modules_vaadin_map_node_modules_ol_render_VectorContext_js-_279c1.js.map +0 -1
  100. package/node_modules_vaadin_map_node_modules_ol_render_VectorContext_js-node_modules_vaadin_map_node_-a1378d.js.map +0 -1
  101. package/node_modules_vaadin_map_node_modules_ol_render_canvas_PolygonBuilder_js.js.map +0 -1
  102. package/node_modules_vaadin_map_node_modules_ol_style_js.js +0 -48
  103. package/node_modules_vaadin_map_node_modules_ol_style_js.js.map +0 -1
  104. package/vendors-node_modules_vaadin_map_node_modules_ol_geom_js-node_modules_vaadin_map_node_modules_-f0f4bb.js +0 -769
  105. package/vendors-node_modules_vaadin_map_node_modules_ol_geom_js-node_modules_vaadin_map_node_modules_-f0f4bb.js.map +0 -1
@@ -13,14 +13,13 @@ __webpack_require__.r(__webpack_exports__);
13
13
  /* harmony export */ });
14
14
  /* harmony import */ var _Collection_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Collection.js */ "./node_modules/@vaadin/map/node_modules/ol/Collection.js");
15
15
  /* harmony import */ var _CollectionEventType_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../CollectionEventType.js */ "./node_modules/@vaadin/map/node_modules/ol/CollectionEventType.js");
16
- /* harmony import */ var _Feature_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Feature.js */ "./node_modules/@vaadin/map/node_modules/ol/Feature.js");
17
- /* harmony import */ var _array_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../array.js */ "./node_modules/@vaadin/map/node_modules/ol/array.js");
16
+ /* harmony import */ var _Feature_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Feature.js */ "./node_modules/@vaadin/map/node_modules/ol/Feature.js");
17
+ /* harmony import */ var _array_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../array.js */ "./node_modules/@vaadin/map/node_modules/ol/array.js");
18
18
  /* harmony import */ var _events_Event_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../events/Event.js */ "./node_modules/@vaadin/map/node_modules/ol/events/Event.js");
19
19
  /* harmony import */ var _events_condition_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../events/condition.js */ "./node_modules/@vaadin/map/node_modules/ol/events/condition.js");
20
20
  /* harmony import */ var _functions_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../functions.js */ "./node_modules/@vaadin/map/node_modules/ol/functions.js");
21
21
  /* harmony import */ var _layer_Vector_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../layer/Vector.js */ "./node_modules/@vaadin/map/node_modules/ol/layer/Vector.js");
22
- /* harmony import */ var _obj_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../obj.js */ "./node_modules/@vaadin/map/node_modules/ol/obj.js");
23
- /* harmony import */ var _style_Style_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../style/Style.js */ "./node_modules/@vaadin/map/node_modules/ol/style/Style.js");
22
+ /* harmony import */ var _style_Style_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../style/Style.js */ "./node_modules/@vaadin/map/node_modules/ol/style/Style.js");
24
23
  /* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util.js */ "./node_modules/@vaadin/map/node_modules/ol/util.js");
25
24
  /* harmony import */ var _Interaction_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Interaction.js */ "./node_modules/@vaadin/map/node_modules/ol/interaction/Interaction.js");
26
25
  /**
@@ -38,7 +37,6 @@ __webpack_require__.r(__webpack_exports__);
38
37
 
39
38
 
40
39
 
41
-
42
40
  /**
43
41
  * @enum {string}
44
42
  */
@@ -54,7 +52,7 @@ const SelectEventType = {
54
52
  /**
55
53
  * A function that takes a {@link module:ol/Feature~Feature} and returns `true` if the feature may be
56
54
  * selected or `false` otherwise.
57
- * @typedef {function(import("../Feature.js").default, import("../layer/Layer.js").default<import("../source/Source").default>):boolean} FilterFunction
55
+ * @typedef {function(import("../Feature.js").default, import("../layer/Layer.js").default<import("../source/Source.js").default> | undefined):boolean} FilterFunction
58
56
  */
59
57
 
60
58
  /**
@@ -73,7 +71,7 @@ const SelectEventType = {
73
71
  * feature removes all from the selection.
74
72
  * See `toggle`, `add`, `remove` options for adding/removing extra features to/
75
73
  * from the selection.
76
- * @property {Array<import("../layer/Layer.js").default>|function(import("../layer/Layer.js").default<import("../source/Source").default>): boolean} [layers]
74
+ * @property {Array<import("../layer/Layer.js").default>|function(import("../layer/Layer.js").default<import("../source/Source.js").default>): boolean} [layers]
77
75
  * A list of layers from which features should be selected. Alternatively, a
78
76
  * filter function can be provided. The function will be called for each layer
79
77
  * in the map and should return `true` for layers that you want to be
@@ -160,11 +158,11 @@ const originalFeatureStyles = {};
160
158
 
161
159
  /***
162
160
  * @template Return
163
- * @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
164
- * import("../Observable").OnSignature<import("../ObjectEventType").Types|
165
- * 'change:active', import("../Object").ObjectEvent, Return> &
166
- * import("../Observable").OnSignature<'select', SelectEvent, Return> &
167
- * import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("../ObjectEventType").Types|
161
+ * @typedef {import("../Observable.js").OnSignature<import("../Observable.js").EventTypes, import("../events/Event.js").default, Return> &
162
+ * import("../Observable.js").OnSignature<import("../ObjectEventType.js").Types|
163
+ * 'change:active', import("../Object.js").ObjectEvent, Return> &
164
+ * import("../Observable.js").OnSignature<'select', SelectEvent, Return> &
165
+ * import("../Observable.js").CombinedOnSignature<import("../Observable.js").EventTypes|import("../ObjectEventType.js").Types|
168
166
  * 'change:active'|'select', Return>} SelectOnSignature
169
167
  */
170
168
 
@@ -189,12 +187,12 @@ class Select extends _Interaction_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
189
187
  super();
190
188
 
191
189
  /***
192
- * @type {SelectOnSignature<import("../events").EventsKey>}
190
+ * @type {SelectOnSignature<import("../events.js").EventsKey>}
193
191
  */
194
192
  this.on;
195
193
 
196
194
  /***
197
- * @type {SelectOnSignature<import("../events").EventsKey>}
195
+ * @type {SelectOnSignature<import("../events.js").EventsKey>}
198
196
  */
199
197
  this.once;
200
198
 
@@ -274,7 +272,7 @@ class Select extends _Interaction_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
274
272
  */
275
273
  this.features_ = options.features || new _Collection_js__WEBPACK_IMPORTED_MODULE_4__["default"]();
276
274
 
277
- /** @type {function(import("../layer/Layer.js").default<import("../source/Source").default>): boolean} */
275
+ /** @type {function(import("../layer/Layer.js").default<import("../source/Source.js").default>): boolean} */
278
276
  let layerFilter;
279
277
  if (options.layers) {
280
278
  if (typeof options.layers === 'function') {
@@ -291,7 +289,7 @@ class Select extends _Interaction_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
291
289
 
292
290
  /**
293
291
  * @private
294
- * @type {function(import("../layer/Layer.js").default<import("../source/Source").default>): boolean}
292
+ * @type {function(import("../layer/Layer.js").default<import("../source/Source.js").default>): boolean}
295
293
  */
296
294
  this.layerFilter_ = layerFilter;
297
295
 
@@ -402,19 +400,7 @@ class Select extends _Interaction_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
402
400
  this.applySelectedStyle_(feature);
403
401
  }
404
402
  if (!this.getLayer(feature)) {
405
- const layer = /** @type {VectorLayer} */ (
406
- this.getMap()
407
- .getAllLayers()
408
- .find(function (layer) {
409
- if (
410
- layer instanceof _layer_Vector_js__WEBPACK_IMPORTED_MODULE_7__["default"] &&
411
- layer.getSource() &&
412
- layer.getSource().hasFeature(feature)
413
- ) {
414
- return layer;
415
- }
416
- })
417
- );
403
+ const layer = this.findLayerOfFeature_(feature);
418
404
  if (layer) {
419
405
  this.addFeatureLayerAssociation_(feature, layer);
420
406
  }
@@ -429,6 +415,29 @@ class Select extends _Interaction_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
429
415
  if (this.style_) {
430
416
  this.restorePreviousStyle_(evt.element);
431
417
  }
418
+ this.removeFeatureLayerAssociation_(evt.element);
419
+ }
420
+
421
+ /**
422
+ * @param {Feature} feature Feature of which to get the layer
423
+ * @return {VectorLayer} layer, if one was found.
424
+ * @private
425
+ */
426
+ findLayerOfFeature_(feature) {
427
+ const layer = /** @type {VectorLayer} */ (
428
+ this.getMap()
429
+ .getAllLayers()
430
+ .find(function (layer) {
431
+ if (
432
+ layer instanceof _layer_Vector_js__WEBPACK_IMPORTED_MODULE_7__["default"] &&
433
+ layer.getSource() &&
434
+ layer.getSource().hasFeature(feature)
435
+ ) {
436
+ return layer;
437
+ }
438
+ })
439
+ );
440
+ return layer;
432
441
  }
433
442
 
434
443
  /**
@@ -482,6 +491,82 @@ class Select extends _Interaction_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
482
491
  delete this.featureLayerAssociation_[(0,_util_js__WEBPACK_IMPORTED_MODULE_5__.getUid)(feature)];
483
492
  }
484
493
 
494
+ /**
495
+ * Try to select a feature as if it was clicked and `addCondition` evaluated to True.
496
+ * Unlike modifying `select.getFeatures()` directly, this respects the `filter` and `layers` options (except `multi`, which is ignored).
497
+ * The {@link module:ol/interaction/Select~SelectEvent} fired by this won't have a mapBrowserEvent property
498
+ * @param {Feature} feature The feature to select
499
+ * @return {boolean} True if the feature was selected
500
+ * @api
501
+ */
502
+ selectFeature(feature) {
503
+ const layer = this.findLayerOfFeature_(feature);
504
+ if (!this.layerFilter_(layer) || !this.filter_(feature, layer)) {
505
+ return false;
506
+ }
507
+ const features = this.getFeatures();
508
+ if (features.getArray().includes(feature)) {
509
+ return false;
510
+ }
511
+ this.addFeatureLayerAssociation_(feature, layer);
512
+ features.push(feature);
513
+ this.dispatchEvent(
514
+ new SelectEvent(SelectEventType.SELECT, [feature], [], undefined),
515
+ );
516
+ return true;
517
+ }
518
+
519
+ /**
520
+ * Try to deselect a feature as if it was clicked.
521
+ * Compared to `select.getFeatures().remove(feature)` this causes a SelectEvent.
522
+ * The {@link module:ol/interaction/Select~SelectEvent} fired by this won't have a mapBrowserEvent property
523
+ * @param {Feature} feature The feature to deselect
524
+ * @return {boolean} True if the feature was deselected
525
+ * @api
526
+ */
527
+ deselectFeature(feature) {
528
+ const features = this.getFeatures();
529
+ const index = features.getArray().indexOf(feature);
530
+ if (index === -1) {
531
+ return false;
532
+ }
533
+ features.removeAt(index);
534
+ this.dispatchEvent(
535
+ new SelectEvent(SelectEventType.SELECT, [], [feature], undefined),
536
+ );
537
+ return true;
538
+ }
539
+
540
+ /**
541
+ * Try to toggle a feature as if it was clicked and `toggleCondition` was True.
542
+ * Unlike modifying `select.getFeatures()` directly, this respects the `filter` and `layers` options (except `multi`, which is ignored).
543
+ * The {@link module:ol/interaction/Select~SelectEvent} fired by this won't have a mapBrowserEvent property
544
+ * @param {Feature} feature The feature to deselect
545
+ * @api
546
+ */
547
+ toggleFeature(feature) {
548
+ if (!this.deselectFeature(feature)) {
549
+ this.selectFeature(feature);
550
+ }
551
+ }
552
+
553
+ /**
554
+ * Deselect all features as if a user deselected them.
555
+ * Compared to `select.getFeatures().clear()` this causes a SelectEvent.
556
+ * The {@link module:ol/interaction/Select~SelectEvent} fired by this won't have a mapBrowserEvent property
557
+ * @api
558
+ */
559
+ clearSelection() {
560
+ const features = this.getFeatures();
561
+ if (features.getLength() !== 0) {
562
+ const deselected = features.getArray().slice(); // shallow copy
563
+ features.clear();
564
+ this.dispatchEvent(
565
+ new SelectEvent(SelectEventType.SELECT, [], deselected, undefined),
566
+ );
567
+ }
568
+ }
569
+
485
570
  /**
486
571
  * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may change the
487
572
  * selected state of features.
@@ -514,16 +599,10 @@ class Select extends _Interaction_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
514
599
  // Replace the currently selected feature(s) with the feature(s) at the
515
600
  // pixel, or clear the selected feature(s) if there is no feature at
516
601
  // the pixel.
517
- (0,_obj_js__WEBPACK_IMPORTED_MODULE_8__.clear)(this.featureLayerAssociation_);
518
602
  map.forEachFeatureAtPixel(
519
603
  mapBrowserEvent.pixel,
520
- /**
521
- * @param {import("../Feature.js").FeatureLike} feature Feature.
522
- * @param {import("../layer/Layer.js").default} layer Layer.
523
- * @return {boolean|undefined} Continue to iterate over the features.
524
- */
525
604
  (feature, layer) => {
526
- if (!(feature instanceof _Feature_js__WEBPACK_IMPORTED_MODULE_9__["default"]) || !this.filter_(feature, layer)) {
605
+ if (!(feature instanceof _Feature_js__WEBPACK_IMPORTED_MODULE_8__["default"]) || !this.filter_(feature, layer)) {
527
606
  return;
528
607
  }
529
608
  this.addFeatureLayerAssociation_(feature, layer);
@@ -535,15 +614,16 @@ class Select extends _Interaction_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
535
614
  hitTolerance: this.hitTolerance_,
536
615
  },
537
616
  );
617
+
538
618
  for (let i = features.getLength() - 1; i >= 0; --i) {
539
619
  const feature = features.item(i);
540
620
  const index = selected.indexOf(feature);
541
- if (index > -1) {
621
+ if (index === -1) {
622
+ features.removeAt(i);
623
+ deselected.push(feature);
624
+ } else {
542
625
  // feature is already selected
543
626
  selected.splice(index, 1);
544
- } else {
545
- features.remove(feature);
546
- deselected.push(feature);
547
627
  }
548
628
  }
549
629
  if (selected.length !== 0) {
@@ -553,26 +633,18 @@ class Select extends _Interaction_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
553
633
  // Modify the currently selected feature(s).
554
634
  map.forEachFeatureAtPixel(
555
635
  mapBrowserEvent.pixel,
556
- /**
557
- * @param {import("../Feature.js").FeatureLike} feature Feature.
558
- * @param {import("../layer/Layer.js").default} layer Layer.
559
- * @return {boolean|undefined} Continue to iterate over the features.
560
- */
561
636
  (feature, layer) => {
562
- if (!(feature instanceof _Feature_js__WEBPACK_IMPORTED_MODULE_9__["default"]) || !this.filter_(feature, layer)) {
637
+ if (!(feature instanceof _Feature_js__WEBPACK_IMPORTED_MODULE_8__["default"]) || !this.filter_(feature, layer)) {
563
638
  return;
564
639
  }
565
- if ((add || toggle) && !features.getArray().includes(feature)) {
640
+ const hasFeature = features.getArray().includes(feature);
641
+ if (hasFeature && (remove || toggle)) {
642
+ deselected.push(feature);
643
+ } else if (!hasFeature && (add || toggle)) {
566
644
  this.addFeatureLayerAssociation_(feature, layer);
567
645
  selected.push(feature);
568
- } else if (
569
- (remove || toggle) &&
570
- features.getArray().includes(feature)
571
- ) {
572
- deselected.push(feature);
573
- this.removeFeatureLayerAssociation_(feature);
574
646
  }
575
- return !this.multi_;
647
+ return !this.multi_; // stop if not multi
576
648
  },
577
649
  {
578
650
  layerFilter: this.layerFilter_,
@@ -602,9 +674,9 @@ class Select extends _Interaction_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
602
674
  * @return {import("../style/Style.js").StyleFunction} Styles.
603
675
  */
604
676
  function getDefaultStyleFunction() {
605
- const styles = (0,_style_Style_js__WEBPACK_IMPORTED_MODULE_10__.createEditingStyle)();
606
- (0,_array_js__WEBPACK_IMPORTED_MODULE_11__.extend)(styles['Polygon'], styles['LineString']);
607
- (0,_array_js__WEBPACK_IMPORTED_MODULE_11__.extend)(styles['GeometryCollection'], styles['LineString']);
677
+ const styles = (0,_style_Style_js__WEBPACK_IMPORTED_MODULE_9__.createEditingStyle)();
678
+ (0,_array_js__WEBPACK_IMPORTED_MODULE_10__.extend)(styles['Polygon'], styles['LineString']);
679
+ (0,_array_js__WEBPACK_IMPORTED_MODULE_10__.extend)(styles['GeometryCollection'], styles['LineString']);
608
680
 
609
681
  return function (feature) {
610
682
  if (!feature.getGeometry()) {
@@ -1 +1 @@
1
- {"version":3,"file":"vendors-node_modules_vaadin_map_node_modules_ol_interaction_Select_js.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAC0C;AACkB;AACxB;AACD;AACI;AACiC;AACnC;AACQ;AACb;AACqB;AACnB;AACS;;AAE3C;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,4BAA4B,iCAAiC;AAC7D;AACA,aAAa,4HAA4H;AACzI;;AAEA;AACA,aAAa,QAAQ;AACrB,cAAc,4CAA4C;AAC1D,iBAAiB,iDAAiD;AAClE;AACA,wBAAwB,uCAAuC;AAC/D;AACA,cAAc,4CAA4C;AAC1D,YAAY,iDAAiD;AAC7D;AACA;AACA,IAAI,6CAA6C;AACjD;AACA;AACA;AACA;AACA,cAAc,uIAAuI;AACrJ;AACA;AACA;AACA;AACA;AACA,cAAc,4CAA4C;AAC1D;AACA,SAAS,kCAAkC;AAC3C;AACA;AACA,cAAc,4CAA4C;AAC1D,iBAAiB,iDAAiD;AAClE;AACA,wBAAwB,uCAAuC;AAC/D;AACA,cAAc,4CAA4C;AAC1D,iBAAiB,iDAAiD;AAClE;AACA;AACA,IAAI,8CAA8C;AAClD;AACA;AACA;AACA,cAAc,SAAS;AACvB;AACA;AACA,cAAc,qBAAqB;AACnC;AACA;AACA;AACA,IAAI,sDAAsD;AAC1D,cAAc,gBAAgB;AAC9B,iBAAiB,iCAAiC;AAClD,IAAI,mCAAmC;AACvC;AACA,cAAc,QAAQ;AACtB;AACA;;AAEA;AACA;AACA,sBAAsB,2CAA2C;AACjE;AACA;AACO,0BAA0B,wDAAK;AACtC;AACA,aAAa,iBAAiB;AAC9B,aAAa,wCAAwC;AACrD,aAAa,wCAAwC;AACrD,aAAa,yCAAyC;AACtD,UAAU,gDAAgD;AAC1D;AACA;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,mBAAmB,gDAAgD;AACnE,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAU;AACV;AACA;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,0CAA0C;AAC1C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kDAAkD,mBAAmB;AACrE;AACA;AACA;AACA;AACA;AACA,qBAAqB,uDAAW;AAChC;AACA,aAAa,SAAS;AACtB;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;;AAEA;AACA,cAAc;AACd;AACA;;AAEA;AACA,cAAc;AACd;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA,8DAA8D,6DAAW;;AAEzE;AACA;AACA,cAAc;AACd;AACA,uEAAuE,uDAAK;;AAE5E;AACA;AACA,cAAc;AACd;AACA;AACA;AACA,QAAQ,uDAAK;;AAEb;AACA;AACA,cAAc;AACd;AACA;AACA;AACA,QAAQ,8DAAY;;AAEpB;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA,qDAAqD,+CAAI;;AAEzD;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA,6CAA6C,sDAAU;;AAEvD,eAAe,4FAA4F;AAC3G;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA,MAAM;AACN,oBAAoB,+CAAI;AACxB;;AAEA;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,aAAa,iCAAiC;AAC9C,aAAa,qCAAqC;AAClD;AACA;AACA;AACA,kCAAkC,gDAAM;AACxC;;AAEA;AACA;AACA,cAAc,qBAAqB;AACnC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,cAAc,QAAQ;AACtB;AACA;AACA;AACA;AACA;;AAEA;AACA,6BAA6B,uDAAuD;AACpF;AACA,aAAa,iCAAiC;AAC9C,cAAc,sCAAsC;AACpD;AACA;AACA;AACA,sBAAsB,sCAAsC;AAC5D,oCAAoC,gDAAM;AAC1C;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,kCAAkC;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,mEAAuB;AAC/B;AACA;AACA;AACA,QAAQ,sEAA0B;AAClC;AACA;;AAEA;AACA;AACA;AACA,MAAM;AACN;AACA,QAAQ,mEAAuB;AAC/B;AACA;AACA;AACA,QAAQ,sEAA0B;AAClC;AACA;AACA;AACA;;AAEA;AACA,aAAa,qDAAqD;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,aAAa;AAC5C;AACA;AACA;AACA;AACA,+BAA+B,wDAAW;AAC1C;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,qDAAqD;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc,4CAA4C;AAC1D;AACA;AACA;AACA;;AAEA;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA,gBAAgB,gDAAM;AACtB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA,0CAA0C,QAAQ;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,gBAAgB,gDAAM;AACtB;AACA;AACA;;AAEA;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA,yCAAyC,gDAAM;AAC/C;;AAEA;AACA,kBAAkB,mEAAmE;AACrF;AACA,aAAa,yCAAyC;AACtD,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;;AAEA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM,8CAAK;AACX;AACA;AACA;AACA,mBAAmB,qCAAqC;AACxD,mBAAmB,qCAAqC;AACxD,oBAAoB,mBAAmB;AACvC;AACA;AACA,mCAAmC,mDAAO;AAC1C;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA,6CAA6C,QAAQ;AACrD;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,mBAAmB,qCAAqC;AACxD,mBAAmB,qCAAqC;AACxD,oBAAoB,mBAAmB;AACvC;AACA;AACA,mCAAmC,mDAAO;AAC1C;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA,0CAA0C,QAAQ;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,YAAY,2CAA2C;AACvD;AACA;AACA,iBAAiB,oEAAkB;AACnC,EAAE,kDAAM;AACR,EAAE,kDAAM;;AAER;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iEAAe,MAAM,EAAC","sources":["webpack://@vaadin/bundles/./node_modules/@vaadin/map/node_modules/ol/interaction/Select.js"],"sourcesContent":["/**\n * @module ol/interaction/Select\n */\nimport Collection from '../Collection.js';\nimport CollectionEventType from '../CollectionEventType.js';\nimport Feature from '../Feature.js';\nimport {extend} from '../array.js';\nimport Event from '../events/Event.js';\nimport {never, shiftKeyOnly, singleClick} from '../events/condition.js';\nimport {TRUE} from '../functions.js';\nimport VectorLayer from '../layer/Vector.js';\nimport {clear} from '../obj.js';\nimport {createEditingStyle} from '../style/Style.js';\nimport {getUid} from '../util.js';\nimport Interaction from './Interaction.js';\n\n/**\n * @enum {string}\n */\nconst SelectEventType = {\n /**\n * Triggered when feature(s) has been (de)selected.\n * @event SelectEvent#select\n * @api\n */\n SELECT: 'select',\n};\n\n/**\n * A function that takes a {@link module:ol/Feature~Feature} and returns `true` if the feature may be\n * selected or `false` otherwise.\n * @typedef {function(import(\"../Feature.js\").default, import(\"../layer/Layer.js\").default<import(\"../source/Source\").default>):boolean} FilterFunction\n */\n\n/**\n * @typedef {Object} Options\n * @property {import(\"../events/condition.js\").Condition} [addCondition] A function\n * that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a\n * boolean to indicate whether that event should be handled.\n * By default, this is {@link module:ol/events/condition.never}. Use this if you\n * want to use different events for add and remove instead of `toggle`.\n * @property {import(\"../events/condition.js\").Condition} [condition] A function that\n * takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a\n * boolean to indicate whether that event should be handled. This is the event\n * for the selected features as a whole. By default, this is\n * {@link module:ol/events/condition.singleClick}. Clicking on a feature selects that\n * feature and removes any that were in the selection. Clicking outside any\n * feature removes all from the selection.\n * See `toggle`, `add`, `remove` options for adding/removing extra features to/\n * from the selection.\n * @property {Array<import(\"../layer/Layer.js\").default>|function(import(\"../layer/Layer.js\").default<import(\"../source/Source\").default>): boolean} [layers]\n * A list of layers from which features should be selected. Alternatively, a\n * filter function can be provided. The function will be called for each layer\n * in the map and should return `true` for layers that you want to be\n * selectable. If the option is absent, all visible layers will be considered\n * selectable.\n * @property {import(\"../style/Style.js\").StyleLike|null} [style]\n * Style for the selected features. By default the default edit style is used\n * (see {@link module:ol/style/Style~Style}). Set to `null` if this interaction should not apply\n * any style changes for selected features.\n * If set to a falsey value, the selected feature's style will not change.\n * @property {import(\"../events/condition.js\").Condition} [removeCondition] A function\n * that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a\n * boolean to indicate whether that event should be handled.\n * By default, this is {@link module:ol/events/condition.never}. Use this if you\n * want to use different events for add and remove instead of `toggle`.\n * @property {import(\"../events/condition.js\").Condition} [toggleCondition] A function\n * that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a\n * boolean to indicate whether that event should be handled. This is in addition\n * to the `condition` event. By default,\n * {@link module:ol/events/condition.shiftKeyOnly}, i.e. pressing `shift` as\n * well as the `condition` event, adds that feature to the current selection if\n * it is not currently selected, and removes it if it is. See `add` and `remove`\n * if you want to use different events instead of a toggle.\n * @property {boolean} [multi=false] A boolean that determines if the default\n * behaviour should select only single features or all (overlapping) features at\n * the clicked map position. The default of `false` means single select.\n * @property {Collection<Feature>} [features]\n * Collection where the interaction will place selected features. Optional. If\n * not set the interaction will create a collection. In any case the collection\n * used by the interaction is returned by\n * {@link module:ol/interaction/Select~Select#getFeatures}.\n * @property {FilterFunction} [filter] A function\n * that takes a {@link module:ol/Feature~Feature} and a\n * {@link module:ol/layer/Layer~Layer} and returns `true` if the feature may be\n * selected or `false` otherwise.\n * @property {number} [hitTolerance=0] Hit-detection tolerance. Pixels inside\n * the radius around the given position will be checked for features.\n */\n\n/**\n * @classdesc\n * Events emitted by {@link module:ol/interaction/Select~Select} instances are instances of\n * this type.\n */\nexport class SelectEvent extends Event {\n /**\n * @param {SelectEventType} type The event type.\n * @param {Array<import(\"../Feature.js\").default>} selected Selected features.\n * @param {Array<import(\"../Feature.js\").default>} deselected Deselected features.\n * @param {import(\"../MapBrowserEvent.js\").default} mapBrowserEvent Associated\n * {@link module:ol/MapBrowserEvent~MapBrowserEvent}.\n */\n constructor(type, selected, deselected, mapBrowserEvent) {\n super(type);\n\n /**\n * Selected features array.\n * @type {Array<import(\"../Feature.js\").default>}\n * @api\n */\n this.selected = selected;\n\n /**\n * Deselected features array.\n * @type {Array<import(\"../Feature.js\").default>}\n * @api\n */\n this.deselected = deselected;\n\n /**\n * Associated {@link module:ol/MapBrowserEvent~MapBrowserEvent}.\n * @type {import(\"../MapBrowserEvent.js\").default}\n * @api\n */\n this.mapBrowserEvent = mapBrowserEvent;\n }\n}\n\n/**\n * Original feature styles to reset to when features are no longer selected.\n * @type {Object<number, import(\"../style/Style.js\").default|Array<import(\"../style/Style.js\").default>|import(\"../style/Style.js\").StyleFunction>}\n */\nconst originalFeatureStyles = {};\n\n/***\n * @template Return\n * @typedef {import(\"../Observable\").OnSignature<import(\"../Observable\").EventTypes, import(\"../events/Event.js\").default, Return> &\n * import(\"../Observable\").OnSignature<import(\"../ObjectEventType\").Types|\n * 'change:active', import(\"../Object\").ObjectEvent, Return> &\n * import(\"../Observable\").OnSignature<'select', SelectEvent, Return> &\n * import(\"../Observable\").CombinedOnSignature<import(\"../Observable\").EventTypes|import(\"../ObjectEventType\").Types|\n * 'change:active'|'select', Return>} SelectOnSignature\n */\n\n/**\n * @classdesc\n * Interaction for selecting vector features. By default, selected features are\n * styled differently, so this interaction can be used for visual highlighting,\n * as well as selecting features for other actions, such as modification or\n * output. There are three ways of controlling which features are selected:\n * using the browser event as defined by the `condition` and optionally the\n * `toggle`, `add`/`remove`, and `multi` options; a `layers` filter; and a\n * further feature filter using the `filter` option.\n *\n * @fires SelectEvent\n * @api\n */\nclass Select extends Interaction {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n super();\n\n /***\n * @type {SelectOnSignature<import(\"../events\").EventsKey>}\n */\n this.on;\n\n /***\n * @type {SelectOnSignature<import(\"../events\").EventsKey>}\n */\n this.once;\n\n /***\n * @type {SelectOnSignature<void>}\n */\n this.un;\n\n options = options ? options : {};\n\n /**\n * @private\n */\n this.boundAddFeature_ = this.addFeature_.bind(this);\n\n /**\n * @private\n */\n this.boundRemoveFeature_ = this.removeFeature_.bind(this);\n\n /**\n * @private\n * @type {import(\"../events/condition.js\").Condition}\n */\n this.condition_ = options.condition ? options.condition : singleClick;\n\n /**\n * @private\n * @type {import(\"../events/condition.js\").Condition}\n */\n this.addCondition_ = options.addCondition ? options.addCondition : never;\n\n /**\n * @private\n * @type {import(\"../events/condition.js\").Condition}\n */\n this.removeCondition_ = options.removeCondition\n ? options.removeCondition\n : never;\n\n /**\n * @private\n * @type {import(\"../events/condition.js\").Condition}\n */\n this.toggleCondition_ = options.toggleCondition\n ? options.toggleCondition\n : shiftKeyOnly;\n\n /**\n * @private\n * @type {boolean}\n */\n this.multi_ = options.multi ? options.multi : false;\n\n /**\n * @private\n * @type {FilterFunction}\n */\n this.filter_ = options.filter ? options.filter : TRUE;\n\n /**\n * @private\n * @type {number}\n */\n this.hitTolerance_ = options.hitTolerance ? options.hitTolerance : 0;\n\n /**\n * @private\n * @type {import(\"../style/Style.js\").default|Array<import(\"../style/Style.js\").default>|import(\"../style/Style.js\").StyleFunction|null}\n */\n this.style_ =\n options.style !== undefined ? options.style : getDefaultStyleFunction();\n\n /**\n * @private\n * @type {Collection<Feature>}\n */\n this.features_ = options.features || new Collection();\n\n /** @type {function(import(\"../layer/Layer.js\").default<import(\"../source/Source\").default>): boolean} */\n let layerFilter;\n if (options.layers) {\n if (typeof options.layers === 'function') {\n layerFilter = options.layers;\n } else {\n const layers = options.layers;\n layerFilter = function (layer) {\n return layers.includes(layer);\n };\n }\n } else {\n layerFilter = TRUE;\n }\n\n /**\n * @private\n * @type {function(import(\"../layer/Layer.js\").default<import(\"../source/Source\").default>): boolean}\n */\n this.layerFilter_ = layerFilter;\n\n /**\n * An association between selected feature (key)\n * and layer (value)\n * @private\n * @type {Object<string, import(\"../layer/Layer.js\").default>}\n */\n this.featureLayerAssociation_ = {};\n }\n\n /**\n * @param {import(\"../Feature.js\").default} feature Feature.\n * @param {import(\"../layer/Layer.js\").default} layer Layer.\n * @private\n */\n addFeatureLayerAssociation_(feature, layer) {\n this.featureLayerAssociation_[getUid(feature)] = layer;\n }\n\n /**\n * Get the selected features.\n * @return {Collection<Feature>} Features collection.\n * @api\n */\n getFeatures() {\n return this.features_;\n }\n\n /**\n * Returns the Hit-detection tolerance.\n * @return {number} Hit tolerance in pixels.\n * @api\n */\n getHitTolerance() {\n return this.hitTolerance_;\n }\n\n /**\n * Returns the associated {@link module:ol/layer/Vector~VectorLayer vector layer} of\n * a selected feature.\n * @param {import(\"../Feature.js\").default} feature Feature\n * @return {import('../layer/Vector.js').default} Layer.\n * @api\n */\n getLayer(feature) {\n return /** @type {import('../layer/Vector.js').default} */ (\n this.featureLayerAssociation_[getUid(feature)]\n );\n }\n\n /**\n * Hit-detection tolerance. Pixels inside the radius around the given position\n * will be checked for features.\n * @param {number} hitTolerance Hit tolerance in pixels.\n * @api\n */\n setHitTolerance(hitTolerance) {\n this.hitTolerance_ = hitTolerance;\n }\n\n /**\n * Remove the interaction from its current map, if any, and attach it to a new\n * map, if any. Pass `null` to just remove the interaction from the current map.\n * @param {import(\"../Map.js\").default|null} map Map.\n * @api\n * @override\n */\n setMap(map) {\n const currentMap = this.getMap();\n if (currentMap && this.style_) {\n this.features_.forEach(this.restorePreviousStyle_.bind(this));\n }\n super.setMap(map);\n if (map) {\n this.features_.addEventListener(\n CollectionEventType.ADD,\n this.boundAddFeature_,\n );\n this.features_.addEventListener(\n CollectionEventType.REMOVE,\n this.boundRemoveFeature_,\n );\n\n if (this.style_) {\n this.features_.forEach(this.applySelectedStyle_.bind(this));\n }\n } else {\n this.features_.removeEventListener(\n CollectionEventType.ADD,\n this.boundAddFeature_,\n );\n this.features_.removeEventListener(\n CollectionEventType.REMOVE,\n this.boundRemoveFeature_,\n );\n }\n }\n\n /**\n * @param {import(\"../Collection.js\").CollectionEvent<Feature>} evt Event.\n * @private\n */\n addFeature_(evt) {\n const feature = evt.element;\n if (this.style_) {\n this.applySelectedStyle_(feature);\n }\n if (!this.getLayer(feature)) {\n const layer = /** @type {VectorLayer} */ (\n this.getMap()\n .getAllLayers()\n .find(function (layer) {\n if (\n layer instanceof VectorLayer &&\n layer.getSource() &&\n layer.getSource().hasFeature(feature)\n ) {\n return layer;\n }\n })\n );\n if (layer) {\n this.addFeatureLayerAssociation_(feature, layer);\n }\n }\n }\n\n /**\n * @param {import(\"../Collection.js\").CollectionEvent<Feature>} evt Event.\n * @private\n */\n removeFeature_(evt) {\n if (this.style_) {\n this.restorePreviousStyle_(evt.element);\n }\n }\n\n /**\n * @return {import(\"../style/Style.js\").StyleLike|null} Select style.\n */\n getStyle() {\n return this.style_;\n }\n\n /**\n * @param {Feature} feature Feature\n * @private\n */\n applySelectedStyle_(feature) {\n const key = getUid(feature);\n if (!(key in originalFeatureStyles)) {\n originalFeatureStyles[key] = feature.getStyle();\n }\n feature.setStyle(this.style_);\n }\n\n /**\n * @param {Feature} feature Feature\n * @private\n */\n restorePreviousStyle_(feature) {\n const interactions = this.getMap().getInteractions().getArray();\n for (let i = interactions.length - 1; i >= 0; --i) {\n const interaction = interactions[i];\n if (\n interaction !== this &&\n interaction instanceof Select &&\n interaction.getStyle() &&\n interaction.getFeatures().getArray().lastIndexOf(feature) !== -1\n ) {\n feature.setStyle(interaction.getStyle());\n return;\n }\n }\n\n const key = getUid(feature);\n feature.setStyle(originalFeatureStyles[key]);\n delete originalFeatureStyles[key];\n }\n\n /**\n * @param {Feature} feature Feature.\n * @private\n */\n removeFeatureLayerAssociation_(feature) {\n delete this.featureLayerAssociation_[getUid(feature)];\n }\n\n /**\n * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may change the\n * selected state of features.\n * @param {import(\"../MapBrowserEvent.js\").default} mapBrowserEvent Map browser event.\n * @return {boolean} `false` to stop event propagation.\n * @override\n */\n handleEvent(mapBrowserEvent) {\n if (!this.condition_(mapBrowserEvent)) {\n return true;\n }\n const add = this.addCondition_(mapBrowserEvent);\n const remove = this.removeCondition_(mapBrowserEvent);\n const toggle = this.toggleCondition_(mapBrowserEvent);\n const set = !add && !remove && !toggle;\n const map = mapBrowserEvent.map;\n const features = this.getFeatures();\n\n /**\n * @type {Array<Feature>}\n */\n const deselected = [];\n\n /**\n * @type {Array<Feature>}\n */\n const selected = [];\n\n if (set) {\n // Replace the currently selected feature(s) with the feature(s) at the\n // pixel, or clear the selected feature(s) if there is no feature at\n // the pixel.\n clear(this.featureLayerAssociation_);\n map.forEachFeatureAtPixel(\n mapBrowserEvent.pixel,\n /**\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {import(\"../layer/Layer.js\").default} layer Layer.\n * @return {boolean|undefined} Continue to iterate over the features.\n */\n (feature, layer) => {\n if (!(feature instanceof Feature) || !this.filter_(feature, layer)) {\n return;\n }\n this.addFeatureLayerAssociation_(feature, layer);\n selected.push(feature);\n return !this.multi_;\n },\n {\n layerFilter: this.layerFilter_,\n hitTolerance: this.hitTolerance_,\n },\n );\n for (let i = features.getLength() - 1; i >= 0; --i) {\n const feature = features.item(i);\n const index = selected.indexOf(feature);\n if (index > -1) {\n // feature is already selected\n selected.splice(index, 1);\n } else {\n features.remove(feature);\n deselected.push(feature);\n }\n }\n if (selected.length !== 0) {\n features.extend(selected);\n }\n } else {\n // Modify the currently selected feature(s).\n map.forEachFeatureAtPixel(\n mapBrowserEvent.pixel,\n /**\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {import(\"../layer/Layer.js\").default} layer Layer.\n * @return {boolean|undefined} Continue to iterate over the features.\n */\n (feature, layer) => {\n if (!(feature instanceof Feature) || !this.filter_(feature, layer)) {\n return;\n }\n if ((add || toggle) && !features.getArray().includes(feature)) {\n this.addFeatureLayerAssociation_(feature, layer);\n selected.push(feature);\n } else if (\n (remove || toggle) &&\n features.getArray().includes(feature)\n ) {\n deselected.push(feature);\n this.removeFeatureLayerAssociation_(feature);\n }\n return !this.multi_;\n },\n {\n layerFilter: this.layerFilter_,\n hitTolerance: this.hitTolerance_,\n },\n );\n for (let j = deselected.length - 1; j >= 0; --j) {\n features.remove(deselected[j]);\n }\n features.extend(selected);\n }\n if (selected.length > 0 || deselected.length > 0) {\n this.dispatchEvent(\n new SelectEvent(\n SelectEventType.SELECT,\n selected,\n deselected,\n mapBrowserEvent,\n ),\n );\n }\n return true;\n }\n}\n\n/**\n * @return {import(\"../style/Style.js\").StyleFunction} Styles.\n */\nfunction getDefaultStyleFunction() {\n const styles = createEditingStyle();\n extend(styles['Polygon'], styles['LineString']);\n extend(styles['GeometryCollection'], styles['LineString']);\n\n return function (feature) {\n if (!feature.getGeometry()) {\n return null;\n }\n return styles[feature.getGeometry().getType()];\n };\n}\n\nexport default Select;\n"],"names":[],"sourceRoot":""}
1
+ {"version":3,"file":"vendors-node_modules_vaadin_map_node_modules_ol_interaction_Select_js.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAC0C;AACkB;AACxB;AACD;AACI;AACiC;AACnC;AACQ;AACQ;AACnB;AACS;;AAE3C;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,4BAA4B,iCAAiC;AAC7D;AACA,aAAa,2IAA2I;AACxJ;;AAEA;AACA,aAAa,QAAQ;AACrB,cAAc,4CAA4C;AAC1D,iBAAiB,iDAAiD;AAClE;AACA,wBAAwB,uCAAuC;AAC/D;AACA,cAAc,4CAA4C;AAC1D,YAAY,iDAAiD;AAC7D;AACA;AACA,IAAI,6CAA6C;AACjD;AACA;AACA;AACA;AACA,cAAc,0IAA0I;AACxJ;AACA;AACA;AACA;AACA;AACA,cAAc,4CAA4C;AAC1D;AACA,SAAS,kCAAkC;AAC3C;AACA;AACA,cAAc,4CAA4C;AAC1D,iBAAiB,iDAAiD;AAClE;AACA,wBAAwB,uCAAuC;AAC/D;AACA,cAAc,4CAA4C;AAC1D,iBAAiB,iDAAiD;AAClE;AACA;AACA,IAAI,8CAA8C;AAClD;AACA;AACA;AACA,cAAc,SAAS;AACvB;AACA;AACA,cAAc,qBAAqB;AACnC;AACA;AACA;AACA,IAAI,sDAAsD;AAC1D,cAAc,gBAAgB;AAC9B,iBAAiB,iCAAiC;AAClD,IAAI,mCAAmC;AACvC;AACA,cAAc,QAAQ;AACtB;AACA;;AAEA;AACA;AACA,sBAAsB,2CAA2C;AACjE;AACA;AACO,0BAA0B,wDAAK;AACtC;AACA,aAAa,iBAAiB;AAC9B,aAAa,wCAAwC;AACrD,aAAa,wCAAwC;AACrD,aAAa,yCAAyC;AACtD,UAAU,gDAAgD;AAC1D;AACA;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,mBAAmB,gDAAgD;AACnE,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAU;AACV;AACA;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,0CAA0C;AAC1C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kDAAkD,mBAAmB;AACrE;AACA;AACA;AACA;AACA;AACA,qBAAqB,uDAAW;AAChC;AACA,aAAa,SAAS;AACtB;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;;AAEA;AACA,cAAc;AACd;AACA;;AAEA;AACA,cAAc;AACd;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA,8DAA8D,6DAAW;;AAEzE;AACA;AACA,cAAc;AACd;AACA,uEAAuE,uDAAK;;AAE5E;AACA;AACA,cAAc;AACd;AACA;AACA;AACA,QAAQ,uDAAK;;AAEb;AACA;AACA,cAAc;AACd;AACA;AACA;AACA,QAAQ,8DAAY;;AAEpB;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA,qDAAqD,+CAAI;;AAEzD;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA,6CAA6C,sDAAU;;AAEvD,eAAe,+FAA+F;AAC9G;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA,MAAM;AACN,oBAAoB,+CAAI;AACxB;;AAEA;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,aAAa,iCAAiC;AAC9C,aAAa,qCAAqC;AAClD;AACA;AACA;AACA,kCAAkC,gDAAM;AACxC;;AAEA;AACA;AACA,cAAc,qBAAqB;AACnC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,cAAc,QAAQ;AACtB;AACA;AACA;AACA;AACA;;AAEA;AACA,6BAA6B,uDAAuD;AACpF;AACA,aAAa,iCAAiC;AAC9C,cAAc,sCAAsC;AACpD;AACA;AACA;AACA,sBAAsB,sCAAsC;AAC5D,oCAAoC,gDAAM;AAC1C;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,kCAAkC;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,mEAAuB;AAC/B;AACA;AACA;AACA,QAAQ,sEAA0B;AAClC;AACA;;AAEA;AACA;AACA;AACA,MAAM;AACN;AACA,QAAQ,mEAAuB;AAC/B;AACA;AACA;AACA,QAAQ,sEAA0B;AAClC;AACA;AACA;AACA;;AAEA;AACA,aAAa,qDAAqD;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,qDAAqD;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,SAAS;AACtB,cAAc,aAAa;AAC3B;AACA;AACA;AACA,6BAA6B,aAAa;AAC1C;AACA;AACA;AACA;AACA,6BAA6B,wDAAW;AACxC;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA,cAAc,4CAA4C;AAC1D;AACA;AACA;AACA;;AAEA;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA,gBAAgB,gDAAM;AACtB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA,0CAA0C,QAAQ;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,gBAAgB,gDAAM;AACtB;AACA;AACA;;AAEA;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA,yCAAyC,gDAAM;AAC/C;;AAEA;AACA;AACA;AACA,UAAU,gDAAgD;AAC1D,aAAa,SAAS;AACtB,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,gDAAgD;AAC1D,aAAa,SAAS;AACtB,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,gDAAgD;AAC1D,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,gDAAgD;AAC1D;AACA;AACA;AACA;AACA;AACA,sDAAsD;AACtD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,kBAAkB,mEAAmE;AACrF;AACA,aAAa,yCAAyC;AACtD,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;;AAEA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,mDAAO;AAC1C;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;;AAEA,6CAA6C,QAAQ;AACrD;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,mCAAmC,mDAAO;AAC1C;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA,+BAA+B;AAC/B,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA,0CAA0C,QAAQ;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,YAAY,2CAA2C;AACvD;AACA;AACA,iBAAiB,mEAAkB;AACnC,EAAE,kDAAM;AACR,EAAE,kDAAM;;AAER;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iEAAe,MAAM,EAAC","sources":["webpack://@vaadin/bundles/./node_modules/@vaadin/map/node_modules/ol/interaction/Select.js"],"sourcesContent":["/**\n * @module ol/interaction/Select\n */\nimport Collection from '../Collection.js';\nimport CollectionEventType from '../CollectionEventType.js';\nimport Feature from '../Feature.js';\nimport {extend} from '../array.js';\nimport Event from '../events/Event.js';\nimport {never, shiftKeyOnly, singleClick} from '../events/condition.js';\nimport {TRUE} from '../functions.js';\nimport VectorLayer from '../layer/Vector.js';\nimport {createEditingStyle} from '../style/Style.js';\nimport {getUid} from '../util.js';\nimport Interaction from './Interaction.js';\n\n/**\n * @enum {string}\n */\nconst SelectEventType = {\n /**\n * Triggered when feature(s) has been (de)selected.\n * @event SelectEvent#select\n * @api\n */\n SELECT: 'select',\n};\n\n/**\n * A function that takes a {@link module:ol/Feature~Feature} and returns `true` if the feature may be\n * selected or `false` otherwise.\n * @typedef {function(import(\"../Feature.js\").default, import(\"../layer/Layer.js\").default<import(\"../source/Source.js\").default> | undefined):boolean} FilterFunction\n */\n\n/**\n * @typedef {Object} Options\n * @property {import(\"../events/condition.js\").Condition} [addCondition] A function\n * that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a\n * boolean to indicate whether that event should be handled.\n * By default, this is {@link module:ol/events/condition.never}. Use this if you\n * want to use different events for add and remove instead of `toggle`.\n * @property {import(\"../events/condition.js\").Condition} [condition] A function that\n * takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a\n * boolean to indicate whether that event should be handled. This is the event\n * for the selected features as a whole. By default, this is\n * {@link module:ol/events/condition.singleClick}. Clicking on a feature selects that\n * feature and removes any that were in the selection. Clicking outside any\n * feature removes all from the selection.\n * See `toggle`, `add`, `remove` options for adding/removing extra features to/\n * from the selection.\n * @property {Array<import(\"../layer/Layer.js\").default>|function(import(\"../layer/Layer.js\").default<import(\"../source/Source.js\").default>): boolean} [layers]\n * A list of layers from which features should be selected. Alternatively, a\n * filter function can be provided. The function will be called for each layer\n * in the map and should return `true` for layers that you want to be\n * selectable. If the option is absent, all visible layers will be considered\n * selectable.\n * @property {import(\"../style/Style.js\").StyleLike|null} [style]\n * Style for the selected features. By default the default edit style is used\n * (see {@link module:ol/style/Style~Style}). Set to `null` if this interaction should not apply\n * any style changes for selected features.\n * If set to a falsey value, the selected feature's style will not change.\n * @property {import(\"../events/condition.js\").Condition} [removeCondition] A function\n * that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a\n * boolean to indicate whether that event should be handled.\n * By default, this is {@link module:ol/events/condition.never}. Use this if you\n * want to use different events for add and remove instead of `toggle`.\n * @property {import(\"../events/condition.js\").Condition} [toggleCondition] A function\n * that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a\n * boolean to indicate whether that event should be handled. This is in addition\n * to the `condition` event. By default,\n * {@link module:ol/events/condition.shiftKeyOnly}, i.e. pressing `shift` as\n * well as the `condition` event, adds that feature to the current selection if\n * it is not currently selected, and removes it if it is. See `add` and `remove`\n * if you want to use different events instead of a toggle.\n * @property {boolean} [multi=false] A boolean that determines if the default\n * behaviour should select only single features or all (overlapping) features at\n * the clicked map position. The default of `false` means single select.\n * @property {Collection<Feature>} [features]\n * Collection where the interaction will place selected features. Optional. If\n * not set the interaction will create a collection. In any case the collection\n * used by the interaction is returned by\n * {@link module:ol/interaction/Select~Select#getFeatures}.\n * @property {FilterFunction} [filter] A function\n * that takes a {@link module:ol/Feature~Feature} and a\n * {@link module:ol/layer/Layer~Layer} and returns `true` if the feature may be\n * selected or `false` otherwise.\n * @property {number} [hitTolerance=0] Hit-detection tolerance. Pixels inside\n * the radius around the given position will be checked for features.\n */\n\n/**\n * @classdesc\n * Events emitted by {@link module:ol/interaction/Select~Select} instances are instances of\n * this type.\n */\nexport class SelectEvent extends Event {\n /**\n * @param {SelectEventType} type The event type.\n * @param {Array<import(\"../Feature.js\").default>} selected Selected features.\n * @param {Array<import(\"../Feature.js\").default>} deselected Deselected features.\n * @param {import(\"../MapBrowserEvent.js\").default} mapBrowserEvent Associated\n * {@link module:ol/MapBrowserEvent~MapBrowserEvent}.\n */\n constructor(type, selected, deselected, mapBrowserEvent) {\n super(type);\n\n /**\n * Selected features array.\n * @type {Array<import(\"../Feature.js\").default>}\n * @api\n */\n this.selected = selected;\n\n /**\n * Deselected features array.\n * @type {Array<import(\"../Feature.js\").default>}\n * @api\n */\n this.deselected = deselected;\n\n /**\n * Associated {@link module:ol/MapBrowserEvent~MapBrowserEvent}.\n * @type {import(\"../MapBrowserEvent.js\").default}\n * @api\n */\n this.mapBrowserEvent = mapBrowserEvent;\n }\n}\n\n/**\n * Original feature styles to reset to when features are no longer selected.\n * @type {Object<number, import(\"../style/Style.js\").default|Array<import(\"../style/Style.js\").default>|import(\"../style/Style.js\").StyleFunction>}\n */\nconst originalFeatureStyles = {};\n\n/***\n * @template Return\n * @typedef {import(\"../Observable.js\").OnSignature<import(\"../Observable.js\").EventTypes, import(\"../events/Event.js\").default, Return> &\n * import(\"../Observable.js\").OnSignature<import(\"../ObjectEventType.js\").Types|\n * 'change:active', import(\"../Object.js\").ObjectEvent, Return> &\n * import(\"../Observable.js\").OnSignature<'select', SelectEvent, Return> &\n * import(\"../Observable.js\").CombinedOnSignature<import(\"../Observable.js\").EventTypes|import(\"../ObjectEventType.js\").Types|\n * 'change:active'|'select', Return>} SelectOnSignature\n */\n\n/**\n * @classdesc\n * Interaction for selecting vector features. By default, selected features are\n * styled differently, so this interaction can be used for visual highlighting,\n * as well as selecting features for other actions, such as modification or\n * output. There are three ways of controlling which features are selected:\n * using the browser event as defined by the `condition` and optionally the\n * `toggle`, `add`/`remove`, and `multi` options; a `layers` filter; and a\n * further feature filter using the `filter` option.\n *\n * @fires SelectEvent\n * @api\n */\nclass Select extends Interaction {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n super();\n\n /***\n * @type {SelectOnSignature<import(\"../events.js\").EventsKey>}\n */\n this.on;\n\n /***\n * @type {SelectOnSignature<import(\"../events.js\").EventsKey>}\n */\n this.once;\n\n /***\n * @type {SelectOnSignature<void>}\n */\n this.un;\n\n options = options ? options : {};\n\n /**\n * @private\n */\n this.boundAddFeature_ = this.addFeature_.bind(this);\n\n /**\n * @private\n */\n this.boundRemoveFeature_ = this.removeFeature_.bind(this);\n\n /**\n * @private\n * @type {import(\"../events/condition.js\").Condition}\n */\n this.condition_ = options.condition ? options.condition : singleClick;\n\n /**\n * @private\n * @type {import(\"../events/condition.js\").Condition}\n */\n this.addCondition_ = options.addCondition ? options.addCondition : never;\n\n /**\n * @private\n * @type {import(\"../events/condition.js\").Condition}\n */\n this.removeCondition_ = options.removeCondition\n ? options.removeCondition\n : never;\n\n /**\n * @private\n * @type {import(\"../events/condition.js\").Condition}\n */\n this.toggleCondition_ = options.toggleCondition\n ? options.toggleCondition\n : shiftKeyOnly;\n\n /**\n * @private\n * @type {boolean}\n */\n this.multi_ = options.multi ? options.multi : false;\n\n /**\n * @private\n * @type {FilterFunction}\n */\n this.filter_ = options.filter ? options.filter : TRUE;\n\n /**\n * @private\n * @type {number}\n */\n this.hitTolerance_ = options.hitTolerance ? options.hitTolerance : 0;\n\n /**\n * @private\n * @type {import(\"../style/Style.js\").default|Array<import(\"../style/Style.js\").default>|import(\"../style/Style.js\").StyleFunction|null}\n */\n this.style_ =\n options.style !== undefined ? options.style : getDefaultStyleFunction();\n\n /**\n * @private\n * @type {Collection<Feature>}\n */\n this.features_ = options.features || new Collection();\n\n /** @type {function(import(\"../layer/Layer.js\").default<import(\"../source/Source.js\").default>): boolean} */\n let layerFilter;\n if (options.layers) {\n if (typeof options.layers === 'function') {\n layerFilter = options.layers;\n } else {\n const layers = options.layers;\n layerFilter = function (layer) {\n return layers.includes(layer);\n };\n }\n } else {\n layerFilter = TRUE;\n }\n\n /**\n * @private\n * @type {function(import(\"../layer/Layer.js\").default<import(\"../source/Source.js\").default>): boolean}\n */\n this.layerFilter_ = layerFilter;\n\n /**\n * An association between selected feature (key)\n * and layer (value)\n * @private\n * @type {Object<string, import(\"../layer/Layer.js\").default>}\n */\n this.featureLayerAssociation_ = {};\n }\n\n /**\n * @param {import(\"../Feature.js\").default} feature Feature.\n * @param {import(\"../layer/Layer.js\").default} layer Layer.\n * @private\n */\n addFeatureLayerAssociation_(feature, layer) {\n this.featureLayerAssociation_[getUid(feature)] = layer;\n }\n\n /**\n * Get the selected features.\n * @return {Collection<Feature>} Features collection.\n * @api\n */\n getFeatures() {\n return this.features_;\n }\n\n /**\n * Returns the Hit-detection tolerance.\n * @return {number} Hit tolerance in pixels.\n * @api\n */\n getHitTolerance() {\n return this.hitTolerance_;\n }\n\n /**\n * Returns the associated {@link module:ol/layer/Vector~VectorLayer vector layer} of\n * a selected feature.\n * @param {import(\"../Feature.js\").default} feature Feature\n * @return {import('../layer/Vector.js').default} Layer.\n * @api\n */\n getLayer(feature) {\n return /** @type {import('../layer/Vector.js').default} */ (\n this.featureLayerAssociation_[getUid(feature)]\n );\n }\n\n /**\n * Hit-detection tolerance. Pixels inside the radius around the given position\n * will be checked for features.\n * @param {number} hitTolerance Hit tolerance in pixels.\n * @api\n */\n setHitTolerance(hitTolerance) {\n this.hitTolerance_ = hitTolerance;\n }\n\n /**\n * Remove the interaction from its current map, if any, and attach it to a new\n * map, if any. Pass `null` to just remove the interaction from the current map.\n * @param {import(\"../Map.js\").default|null} map Map.\n * @api\n * @override\n */\n setMap(map) {\n const currentMap = this.getMap();\n if (currentMap && this.style_) {\n this.features_.forEach(this.restorePreviousStyle_.bind(this));\n }\n super.setMap(map);\n if (map) {\n this.features_.addEventListener(\n CollectionEventType.ADD,\n this.boundAddFeature_,\n );\n this.features_.addEventListener(\n CollectionEventType.REMOVE,\n this.boundRemoveFeature_,\n );\n\n if (this.style_) {\n this.features_.forEach(this.applySelectedStyle_.bind(this));\n }\n } else {\n this.features_.removeEventListener(\n CollectionEventType.ADD,\n this.boundAddFeature_,\n );\n this.features_.removeEventListener(\n CollectionEventType.REMOVE,\n this.boundRemoveFeature_,\n );\n }\n }\n\n /**\n * @param {import(\"../Collection.js\").CollectionEvent<Feature>} evt Event.\n * @private\n */\n addFeature_(evt) {\n const feature = evt.element;\n if (this.style_) {\n this.applySelectedStyle_(feature);\n }\n if (!this.getLayer(feature)) {\n const layer = this.findLayerOfFeature_(feature);\n if (layer) {\n this.addFeatureLayerAssociation_(feature, layer);\n }\n }\n }\n\n /**\n * @param {import(\"../Collection.js\").CollectionEvent<Feature>} evt Event.\n * @private\n */\n removeFeature_(evt) {\n if (this.style_) {\n this.restorePreviousStyle_(evt.element);\n }\n this.removeFeatureLayerAssociation_(evt.element);\n }\n\n /**\n * @param {Feature} feature Feature of which to get the layer\n * @return {VectorLayer} layer, if one was found.\n * @private\n */\n findLayerOfFeature_(feature) {\n const layer = /** @type {VectorLayer} */ (\n this.getMap()\n .getAllLayers()\n .find(function (layer) {\n if (\n layer instanceof VectorLayer &&\n layer.getSource() &&\n layer.getSource().hasFeature(feature)\n ) {\n return layer;\n }\n })\n );\n return layer;\n }\n\n /**\n * @return {import(\"../style/Style.js\").StyleLike|null} Select style.\n */\n getStyle() {\n return this.style_;\n }\n\n /**\n * @param {Feature} feature Feature\n * @private\n */\n applySelectedStyle_(feature) {\n const key = getUid(feature);\n if (!(key in originalFeatureStyles)) {\n originalFeatureStyles[key] = feature.getStyle();\n }\n feature.setStyle(this.style_);\n }\n\n /**\n * @param {Feature} feature Feature\n * @private\n */\n restorePreviousStyle_(feature) {\n const interactions = this.getMap().getInteractions().getArray();\n for (let i = interactions.length - 1; i >= 0; --i) {\n const interaction = interactions[i];\n if (\n interaction !== this &&\n interaction instanceof Select &&\n interaction.getStyle() &&\n interaction.getFeatures().getArray().lastIndexOf(feature) !== -1\n ) {\n feature.setStyle(interaction.getStyle());\n return;\n }\n }\n\n const key = getUid(feature);\n feature.setStyle(originalFeatureStyles[key]);\n delete originalFeatureStyles[key];\n }\n\n /**\n * @param {Feature} feature Feature.\n * @private\n */\n removeFeatureLayerAssociation_(feature) {\n delete this.featureLayerAssociation_[getUid(feature)];\n }\n\n /**\n * Try to select a feature as if it was clicked and `addCondition` evaluated to True.\n * Unlike modifying `select.getFeatures()` directly, this respects the `filter` and `layers` options (except `multi`, which is ignored).\n * The {@link module:ol/interaction/Select~SelectEvent} fired by this won't have a mapBrowserEvent property\n * @param {Feature} feature The feature to select\n * @return {boolean} True if the feature was selected\n * @api\n */\n selectFeature(feature) {\n const layer = this.findLayerOfFeature_(feature);\n if (!this.layerFilter_(layer) || !this.filter_(feature, layer)) {\n return false;\n }\n const features = this.getFeatures();\n if (features.getArray().includes(feature)) {\n return false;\n }\n this.addFeatureLayerAssociation_(feature, layer);\n features.push(feature);\n this.dispatchEvent(\n new SelectEvent(SelectEventType.SELECT, [feature], [], undefined),\n );\n return true;\n }\n\n /**\n * Try to deselect a feature as if it was clicked.\n * Compared to `select.getFeatures().remove(feature)` this causes a SelectEvent.\n * The {@link module:ol/interaction/Select~SelectEvent} fired by this won't have a mapBrowserEvent property\n * @param {Feature} feature The feature to deselect\n * @return {boolean} True if the feature was deselected\n * @api\n */\n deselectFeature(feature) {\n const features = this.getFeatures();\n const index = features.getArray().indexOf(feature);\n if (index === -1) {\n return false;\n }\n features.removeAt(index);\n this.dispatchEvent(\n new SelectEvent(SelectEventType.SELECT, [], [feature], undefined),\n );\n return true;\n }\n\n /**\n * Try to toggle a feature as if it was clicked and `toggleCondition` was True.\n * Unlike modifying `select.getFeatures()` directly, this respects the `filter` and `layers` options (except `multi`, which is ignored).\n * The {@link module:ol/interaction/Select~SelectEvent} fired by this won't have a mapBrowserEvent property\n * @param {Feature} feature The feature to deselect\n * @api\n */\n toggleFeature(feature) {\n if (!this.deselectFeature(feature)) {\n this.selectFeature(feature);\n }\n }\n\n /**\n * Deselect all features as if a user deselected them.\n * Compared to `select.getFeatures().clear()` this causes a SelectEvent.\n * The {@link module:ol/interaction/Select~SelectEvent} fired by this won't have a mapBrowserEvent property\n * @api\n */\n clearSelection() {\n const features = this.getFeatures();\n if (features.getLength() !== 0) {\n const deselected = features.getArray().slice(); // shallow copy\n features.clear();\n this.dispatchEvent(\n new SelectEvent(SelectEventType.SELECT, [], deselected, undefined),\n );\n }\n }\n\n /**\n * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may change the\n * selected state of features.\n * @param {import(\"../MapBrowserEvent.js\").default} mapBrowserEvent Map browser event.\n * @return {boolean} `false` to stop event propagation.\n * @override\n */\n handleEvent(mapBrowserEvent) {\n if (!this.condition_(mapBrowserEvent)) {\n return true;\n }\n const add = this.addCondition_(mapBrowserEvent);\n const remove = this.removeCondition_(mapBrowserEvent);\n const toggle = this.toggleCondition_(mapBrowserEvent);\n const set = !add && !remove && !toggle;\n const map = mapBrowserEvent.map;\n const features = this.getFeatures();\n\n /**\n * @type {Array<Feature>}\n */\n const deselected = [];\n\n /**\n * @type {Array<Feature>}\n */\n const selected = [];\n\n if (set) {\n // Replace the currently selected feature(s) with the feature(s) at the\n // pixel, or clear the selected feature(s) if there is no feature at\n // the pixel.\n map.forEachFeatureAtPixel(\n mapBrowserEvent.pixel,\n (feature, layer) => {\n if (!(feature instanceof Feature) || !this.filter_(feature, layer)) {\n return;\n }\n this.addFeatureLayerAssociation_(feature, layer);\n selected.push(feature);\n return !this.multi_;\n },\n {\n layerFilter: this.layerFilter_,\n hitTolerance: this.hitTolerance_,\n },\n );\n\n for (let i = features.getLength() - 1; i >= 0; --i) {\n const feature = features.item(i);\n const index = selected.indexOf(feature);\n if (index === -1) {\n features.removeAt(i);\n deselected.push(feature);\n } else {\n // feature is already selected\n selected.splice(index, 1);\n }\n }\n if (selected.length !== 0) {\n features.extend(selected);\n }\n } else {\n // Modify the currently selected feature(s).\n map.forEachFeatureAtPixel(\n mapBrowserEvent.pixel,\n (feature, layer) => {\n if (!(feature instanceof Feature) || !this.filter_(feature, layer)) {\n return;\n }\n const hasFeature = features.getArray().includes(feature);\n if (hasFeature && (remove || toggle)) {\n deselected.push(feature);\n } else if (!hasFeature && (add || toggle)) {\n this.addFeatureLayerAssociation_(feature, layer);\n selected.push(feature);\n }\n return !this.multi_; // stop if not multi\n },\n {\n layerFilter: this.layerFilter_,\n hitTolerance: this.hitTolerance_,\n },\n );\n for (let j = deselected.length - 1; j >= 0; --j) {\n features.remove(deselected[j]);\n }\n features.extend(selected);\n }\n if (selected.length > 0 || deselected.length > 0) {\n this.dispatchEvent(\n new SelectEvent(\n SelectEventType.SELECT,\n selected,\n deselected,\n mapBrowserEvent,\n ),\n );\n }\n return true;\n }\n}\n\n/**\n * @return {import(\"../style/Style.js\").StyleFunction} Styles.\n */\nfunction getDefaultStyleFunction() {\n const styles = createEditingStyle();\n extend(styles['Polygon'], styles['LineString']);\n extend(styles['GeometryCollection'], styles['LineString']);\n\n return function (feature) {\n if (!feature.getGeometry()) {\n return null;\n }\n return styles[feature.getGeometry().getType()];\n };\n}\n\nexport default Select;\n"],"names":[],"sourceRoot":""}