maplair 4.1.0 → 4.2.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 (211) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/esm/Maplair.js +5 -4
  3. package/dist/esm/Maplair.js.map +1 -1
  4. package/dist/esm/_virtual/_rolldown/runtime.js +1 -2
  5. package/dist/esm/control/AttributionControl.js +1 -2
  6. package/dist/esm/control/ButtonControl.js +1 -2
  7. package/dist/esm/control/ContextMenu.js +1 -2
  8. package/dist/esm/control/Control.js +1 -2
  9. package/dist/esm/control/FullscreenControl.js +1 -2
  10. package/dist/esm/control/LayersControl.js +27 -31
  11. package/dist/esm/control/LayersControl.js.map +1 -1
  12. package/dist/esm/control/LegendControl.js +1 -2
  13. package/dist/esm/control/MiniMapControl.js +1 -2
  14. package/dist/esm/control/RotateControl.js +1 -2
  15. package/dist/esm/control/ScaleControl.js +1 -2
  16. package/dist/esm/control/SearchControl.js +1 -2
  17. package/dist/esm/control/SideBySideControl.js +1 -2
  18. package/dist/esm/control/TextControl.js +1 -2
  19. package/dist/esm/control/TimeControl.js +1 -2
  20. package/dist/esm/control/ZoomControl.js +18 -29
  21. package/dist/esm/control/ZoomControl.js.map +1 -1
  22. package/dist/esm/core/Class.js +2 -9
  23. package/dist/esm/core/Class.js.map +1 -1
  24. package/dist/esm/core/Events.js +1 -2
  25. package/dist/esm/core/Handler.js +10 -3
  26. package/dist/esm/core/Handler.js.map +1 -1
  27. package/dist/esm/core/I18n.js +1 -2
  28. package/dist/esm/core/Util.js +2 -3
  29. package/dist/esm/core/Util.js.map +1 -1
  30. package/dist/esm/dom/DomEvent.DoubleTap.js +1 -2
  31. package/dist/esm/dom/DomEvent.PointerEvents.js +1 -2
  32. package/dist/esm/dom/DomEvent.js +10 -18
  33. package/dist/esm/dom/DomEvent.js.map +1 -1
  34. package/dist/esm/dom/DomUtil.js +1 -2
  35. package/dist/esm/dom/Draggable.js +4 -3
  36. package/dist/esm/dom/Draggable.js.map +1 -1
  37. package/dist/esm/dom/PosAnimation.js +1 -2
  38. package/dist/esm/geo/LatLng.js +1 -2
  39. package/dist/esm/geo/LatLngBounds.js +9 -15
  40. package/dist/esm/geo/LatLngBounds.js.map +1 -1
  41. package/dist/esm/geo/crs/CRS.js +1 -2
  42. package/dist/esm/geo/crs/EPSG3395.js +4 -5
  43. package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
  44. package/dist/esm/geo/crs/EPSG3857.js +4 -5
  45. package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
  46. package/dist/esm/geo/crs/EPSG4326.js +3 -4
  47. package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
  48. package/dist/esm/geo/crs/EarthCRS.js +1 -2
  49. package/dist/esm/geo/crs/SimpleCRS.js +3 -4
  50. package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
  51. package/dist/esm/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +4 -5
  52. package/dist/esm/geo/projection/LonLatProjection.js.map +1 -0
  53. package/dist/esm/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +3 -4
  54. package/dist/esm/geo/projection/MercatorProjection.js.map +1 -0
  55. package/dist/esm/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +4 -5
  56. package/dist/esm/geo/projection/SphericalMercatorProjection.js.map +1 -0
  57. package/dist/esm/geometry/Bounds.js +10 -14
  58. package/dist/esm/geometry/Bounds.js.map +1 -1
  59. package/dist/esm/geometry/LineUtil.js +2 -3
  60. package/dist/esm/geometry/LineUtil.js.map +1 -1
  61. package/dist/esm/geometry/Point.js +1 -2
  62. package/dist/esm/geometry/PolyUtil.js +17 -25
  63. package/dist/esm/geometry/PolyUtil.js.map +1 -1
  64. package/dist/esm/geometry/Transformation.js +1 -2
  65. package/dist/esm/layer/BlanketOverlay.js +1 -2
  66. package/dist/esm/layer/Classification.js +1 -2
  67. package/dist/esm/layer/DivOverlay.js +2 -3
  68. package/dist/esm/layer/DivOverlay.js.map +1 -1
  69. package/dist/esm/layer/FeatureGroup.js +5 -4
  70. package/dist/esm/layer/FeatureGroup.js.map +1 -1
  71. package/dist/esm/layer/GeoJSON.Load.js +1 -2
  72. package/dist/esm/layer/GeoJSON.js +8 -10
  73. package/dist/esm/layer/GeoJSON.js.map +1 -1
  74. package/dist/esm/layer/GeoJSONUtil.js +1 -2
  75. package/dist/esm/layer/HeatLayer.js +2 -3
  76. package/dist/esm/layer/HeatLayer.js.map +1 -1
  77. package/dist/esm/layer/ImageOverlay.js +2 -3
  78. package/dist/esm/layer/ImageOverlay.js.map +1 -1
  79. package/dist/esm/layer/Layer.js +1 -2
  80. package/dist/esm/layer/LayerGroup.js +2 -3
  81. package/dist/esm/layer/LayerGroup.js.map +1 -1
  82. package/dist/esm/layer/Popup.js +9 -16
  83. package/dist/esm/layer/Popup.js.map +1 -1
  84. package/dist/esm/layer/SVGOverlay.js +1 -2
  85. package/dist/esm/layer/Tooltip.js +16 -17
  86. package/dist/esm/layer/Tooltip.js.map +1 -1
  87. package/dist/esm/layer/VideoOverlay.js +1 -2
  88. package/dist/esm/layer/marker/DefaultIcon.js +29 -7
  89. package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
  90. package/dist/esm/layer/marker/DivIcon.js +1 -2
  91. package/dist/esm/layer/marker/Icon.js +2 -2
  92. package/dist/esm/layer/marker/Icon.js.map +1 -1
  93. package/dist/esm/layer/marker/Marker.Drag.js +43 -4
  94. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
  95. package/dist/esm/layer/marker/Marker.Move.js +4 -6
  96. package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
  97. package/dist/esm/layer/marker/Marker.js +54 -14
  98. package/dist/esm/layer/marker/Marker.js.map +1 -1
  99. package/dist/esm/layer/marker/MarkerClusterGroup.js +1 -2
  100. package/dist/esm/layer/marker/SvgIcon.js +1 -2
  101. package/dist/esm/layer/tile/GridLayer.js +4 -4
  102. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  103. package/dist/esm/layer/tile/TileLayer.js +8 -8
  104. package/dist/esm/layer/tile/TileLayer.js.map +1 -1
  105. package/dist/esm/layer/tile/WMSTileLayer.js +5 -4
  106. package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
  107. package/dist/esm/layer/vector/Canvas.js +7 -14
  108. package/dist/esm/layer/vector/Canvas.js.map +1 -1
  109. package/dist/esm/layer/vector/Circle.js +4 -3
  110. package/dist/esm/layer/vector/Circle.js.map +1 -1
  111. package/dist/esm/layer/vector/CircleMarker.js +2 -3
  112. package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
  113. package/dist/esm/layer/vector/Path.DashAnimation.js +1 -2
  114. package/dist/esm/layer/vector/Path.ZoomStyles.js +1 -2
  115. package/dist/esm/layer/vector/Path.js +1 -2
  116. package/dist/esm/layer/vector/Polygon.js +2 -3
  117. package/dist/esm/layer/vector/Polygon.js.map +1 -1
  118. package/dist/esm/layer/vector/Polyline.Decorations.js +1 -2
  119. package/dist/esm/layer/vector/Polyline.js +2 -3
  120. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  121. package/dist/esm/layer/vector/Rectangle.js +1 -2
  122. package/dist/esm/layer/vector/Renderer.getRenderer.js +4 -5
  123. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
  124. package/dist/esm/layer/vector/Renderer.js +1 -2
  125. package/dist/esm/layer/vector/SVG.js +7 -4
  126. package/dist/esm/layer/vector/SVG.js.map +1 -1
  127. package/dist/esm/map/Hash.js +1 -2
  128. package/dist/esm/map/Map.Rotation.js +31 -16
  129. package/dist/esm/map/Map.Rotation.js.map +1 -1
  130. package/dist/esm/map/Map.js +10 -17
  131. package/dist/esm/map/Map.js.map +1 -1
  132. package/dist/esm/map/MapSync.js +1 -2
  133. package/dist/esm/map/handler/BoxZoomHandler.js +20 -40
  134. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
  135. package/dist/esm/map/handler/DisplaceHandler.js +1 -2
  136. package/dist/esm/map/handler/DoubleClickZoomHandler.js +1 -2
  137. package/dist/esm/map/handler/DragHandler.js +1 -2
  138. package/dist/esm/map/handler/KeyboardHandler.js +23 -43
  139. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  140. package/dist/esm/map/handler/PinchZoomHandler.js +1 -2
  141. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +1 -2
  142. package/dist/esm/map/handler/TapDragZoomHandler.js +1 -2
  143. package/dist/esm/map/handler/TapHoldHandler.js +1 -2
  144. package/dist/esm/package.js +2 -3
  145. package/dist/maplair-global-src.js +487 -613
  146. package/dist/maplair-global-src.js.map +1 -1
  147. package/dist/maplair-global.js +2 -2
  148. package/dist/maplair-global.js.map +1 -1
  149. package/dist/maplair-src.js +483 -609
  150. package/dist/maplair-src.js.map +1 -1
  151. package/dist/maplair.css +1 -1263
  152. package/dist/maplair.js +2 -2
  153. package/dist/maplair.js.map +1 -1
  154. package/package.json +3 -8
  155. package/src/Maplair.all.js +0 -1
  156. package/src/control/LayersControl.js +39 -52
  157. package/src/control/ZoomControl.js +17 -31
  158. package/src/core/Class.js +5 -14
  159. package/src/core/Handler.js +11 -1
  160. package/src/core/Util.js +1 -1
  161. package/src/dom/DomEvent.js +9 -19
  162. package/src/dom/Draggable.js +5 -1
  163. package/src/geo/LatLngBounds.js +8 -15
  164. package/src/geo/crs/EPSG3395.js +3 -3
  165. package/src/geo/crs/EPSG3857.js +3 -3
  166. package/src/geo/crs/EPSG4326.js +2 -2
  167. package/src/geo/crs/SimpleCRS.js +2 -2
  168. package/src/geo/index.js +1 -2
  169. package/src/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +1 -1
  170. package/src/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +1 -1
  171. package/src/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +1 -1
  172. package/src/geo/projection/index.js +5 -5
  173. package/src/geometry/Bounds.js +12 -17
  174. package/src/geometry/LineUtil.js +1 -1
  175. package/src/geometry/PolyUtil.js +23 -31
  176. package/src/layer/DivOverlay.js +1 -1
  177. package/src/layer/FeatureGroup.js +8 -2
  178. package/src/layer/GeoJSON.js +10 -13
  179. package/src/layer/HeatLayer.js +1 -1
  180. package/src/layer/ImageOverlay.js +2 -2
  181. package/src/layer/LayerGroup.js +1 -1
  182. package/src/layer/Popup.js +9 -19
  183. package/src/layer/Tooltip.js +19 -17
  184. package/src/layer/marker/DefaultIcon.js +33 -5
  185. package/src/layer/marker/Icon.js +2 -0
  186. package/src/layer/marker/Marker.Drag.js +53 -5
  187. package/src/layer/marker/Marker.Move.js +3 -4
  188. package/src/layer/marker/Marker.js +64 -13
  189. package/src/layer/tile/GridLayer.js +5 -2
  190. package/src/layer/tile/TileLayer.js +9 -6
  191. package/src/layer/tile/WMSTileLayer.js +5 -2
  192. package/src/layer/vector/Canvas.js +10 -14
  193. package/src/layer/vector/Circle.js +4 -1
  194. package/src/layer/vector/CircleMarker.js +2 -1
  195. package/src/layer/vector/Polygon.js +1 -1
  196. package/src/layer/vector/Polyline.js +1 -1
  197. package/src/layer/vector/Renderer.getRenderer.js +4 -3
  198. package/src/layer/vector/SVG.js +12 -2
  199. package/src/map/Map.Rotation.js +28 -4
  200. package/src/map/Map.js +17 -21
  201. package/src/map/handler/BoxZoomHandler.js +21 -42
  202. package/src/map/handler/KeyboardHandler.js +34 -53
  203. package/src/maplair.css +5 -0
  204. package/dist/esm/geo/projection/Projection.LonLat.js.map +0 -1
  205. package/dist/esm/geo/projection/Projection.Mercator.js.map +0 -1
  206. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +0 -1
  207. package/dist/esm/geo/projection/index.js +0 -14
  208. package/dist/esm/geo/projection/index.js.map +0 -1
  209. package/dist/esm/layer/marker/Marker.Rotation.js +0 -70
  210. package/dist/esm/layer/marker/Marker.Rotation.js.map +0 -1
  211. package/src/layer/marker/Marker.Rotation.js +0 -103
@@ -3,7 +3,7 @@ import { create } from "../dom/DomUtil.js";
3
3
  import { Control } from "./Control.js";
4
4
  import { I18n } from "../core/I18n.js";
5
5
  import { ButtonControl } from "./ButtonControl.js";
6
- //#region src/control/TimeControl.js
6
+ // src/control/TimeControl.js
7
7
  /** @import {ControlOptions} from './Control.js' */
8
8
  /** @import {MaplairMap} from '../map/Map.js' */
9
9
  /** @import {Layer} from '../layer/Layer.js' */
@@ -402,7 +402,6 @@ var TimeControl = class TimeControl extends Control {
402
402
  return this;
403
403
  }
404
404
  };
405
- //#endregion
406
405
  export { TimeControl };
407
406
 
408
407
  //# sourceMappingURL=TimeControl.js.map
@@ -2,7 +2,7 @@ import { disableClickPropagation, on, stop } from "../dom/DomEvent.js";
2
2
  import { create } from "../dom/DomUtil.js";
3
3
  import { Control } from "./Control.js";
4
4
  import { I18n } from "../core/I18n.js";
5
- //#region src/control/ZoomControl.js
5
+ // src/control/ZoomControl.js
6
6
  /** @import {ControlOptions} from './Control.js' */
7
7
  /** @import {MaplairMap} from '../map/Map.js' */
8
8
  /**
@@ -56,8 +56,8 @@ var ZoomControl = class ZoomControl extends Control {
56
56
  */
57
57
  onAdd(map) {
58
58
  const zoomName = "maplair-control-zoom", container = create("div", `${zoomName} maplair-bar`), options = this.options;
59
- this._zoomInButton = this._createButton(options.zoomInText, I18n.translate("Zoom in"), `${zoomName}-in`, container, this._zoomIn);
60
- this._zoomOutButton = this._createButton(options.zoomOutText, I18n.translate("Zoom out"), `${zoomName}-out`, container, this._zoomOut);
59
+ this._zoomInButton = this._createButton(options.zoomInText, I18n.translate("Zoom in"), `${zoomName}-in`, container, (e) => this._zoom(e, 1));
60
+ this._zoomOutButton = this._createButton(options.zoomOutText, I18n.translate("Zoom out"), `${zoomName}-out`, container, (e) => this._zoom(e, -1));
61
61
  this._updateDisabled();
62
62
  map.on("zoomend zoomlevelschange", this._updateDisabled, this);
63
63
  return container;
@@ -87,16 +87,11 @@ var ZoomControl = class ZoomControl extends Control {
87
87
  this._updateDisabled();
88
88
  return this;
89
89
  }
90
- _zoomIn(e) {
91
- if (!this._disabled && this._map._zoom < this._map.getMaxZoom()) {
92
- this._map._setUserEvent(e);
93
- this._map.zoomIn(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1));
94
- }
95
- }
96
- _zoomOut(e) {
97
- if (!this._disabled && this._map._zoom > this._map.getMinZoom()) {
98
- this._map._setUserEvent(e);
99
- this._map.zoomOut(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1));
90
+ _zoom(e, dir) {
91
+ const map = this._map;
92
+ if (!this._disabled && (dir > 0 ? map._zoom < map.getMaxZoom() : map._zoom > map.getMinZoom())) {
93
+ map._setUserEvent(e);
94
+ map.zoomIn(dir * map.options.zoomDelta * (e.shiftKey ? 3 : 1));
100
95
  }
101
96
  }
102
97
  _createButton(html, title, className, container, fn) {
@@ -106,24 +101,19 @@ var ZoomControl = class ZoomControl extends Control {
106
101
  link.title = title;
107
102
  link.setAttribute("aria-label", title);
108
103
  disableClickPropagation(link);
109
- on(link, "click", stop);
110
- on(link, "click", fn, this);
111
- on(link, "click", this._refocusOnMap, this);
104
+ on(link, "click", (e) => {
105
+ stop(e);
106
+ fn.call(this, e);
107
+ this._refocusOnMap(e);
108
+ });
112
109
  return link;
113
110
  }
114
111
  _updateDisabled() {
115
- const map = this._map, className = "maplair-disabled";
116
- this._zoomInButton.classList.remove(className);
117
- this._zoomOutButton.classList.remove(className);
118
- this._zoomInButton.setAttribute("aria-disabled", "false");
119
- this._zoomOutButton.setAttribute("aria-disabled", "false");
120
- if (this._disabled || map._zoom === map.getMinZoom()) {
121
- this._zoomOutButton.classList.add(className);
122
- this._zoomOutButton.setAttribute("aria-disabled", "true");
123
- }
124
- if (this._disabled || map._zoom === map.getMaxZoom()) {
125
- this._zoomInButton.classList.add(className);
126
- this._zoomInButton.setAttribute("aria-disabled", "true");
112
+ const map = this._map;
113
+ for (const [button, limit] of [[this._zoomInButton, map.getMaxZoom()], [this._zoomOutButton, map.getMinZoom()]]) {
114
+ const disabled = this._disabled || map._zoom === limit;
115
+ button.classList.toggle("maplair-disabled", disabled);
116
+ button.setAttribute("aria-disabled", `${disabled}`);
127
117
  }
128
118
  }
129
119
  /**
@@ -141,7 +131,6 @@ var ZoomControl = class ZoomControl extends Control {
141
131
  });
142
132
  }
143
133
  };
144
- //#endregion
145
134
  export { ZoomControl };
146
135
 
147
136
  //# sourceMappingURL=ZoomControl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ZoomControl.js","names":["DomUtil.create","DomEvent.stop"],"sources":["../../../src/control/ZoomControl.js"],"sourcesContent":["\nimport {Control} from './Control.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport {I18n} from '../core/I18n.js';\n/** @import {ControlOptions} from './Control.js' */\n/** @import {MaplairMap} from '../map/Map.js' */\n\n/**\n * Options of `ZoomControl`.\n * @typedef {object} ZoomControlOptions\n * @property {string} [position='topleft'] The position of the control (one of the map\n * corners). Possible values are `'topleft'`, `'topright'`, `'bottomleft'` or\n * `'bottomright'`.\n * @property {string} [zoomInText='<span aria-hidden=\"true\">+</span>'] The text set on\n * the 'zoom in' button.\n * @property {string} [zoomOutText='<span aria-hidden=\"true\">&#x2212;</span>'] The text\n * set on the 'zoom out' button.\n * @extends ControlOptions\n */\n\n/**\n * Map options of `ZoomControl`.\n * @typedef {object} ZoomControlMapOptions\n * @lends MaplairMapOptions\n * @property {boolean} [zoomControl=true] Whether a [zoom control](#control-zoom) is\n * added to the map by default.\n */\n\n/**\n * Properties of `MaplairMap` set by `ZoomControl`.\n * @typedef {object} ZoomControlMapProperties\n * @lends MaplairMap\n * @property {ZoomControl} zoomControl The default zoom control (only available if the\n * [`zoomControl` option](#map-zoomcontrol) was `true` when creating the map).\n */\n\n/**\n * A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by\n * default unless you set its [`zoomControl` option](#map-zoomcontrol) to `false`.\n */\nexport class ZoomControl extends Control {\n\n\tstatic defaultOptions = {\n\t\tposition: 'topleft',\n\t\tzoomInText: '<span aria-hidden=\"true\">+</span>',\n\t\tzoomOutText: '<span aria-hidden=\"true\">&#x2212;</span>',\n\t};\n\n\t/**\n\t * Creates a zoom control.\n\t * @param {...ZoomControlOptions} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(ZoomControl);\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t * @returns {HTMLElement}\n\t */\n\tonAdd(map) {\n\t\tconst zoomName = 'maplair-control-zoom',\n\t\tcontainer = DomUtil.create('div', `${zoomName} maplair-bar`),\n\t\toptions = this.options;\n\n\t\tthis._zoomInButton = this._createButton(options.zoomInText, I18n.translate('Zoom in'),\n\t\t\t`${zoomName}-in`, container, this._zoomIn);\n\t\tthis._zoomOutButton = this._createButton(options.zoomOutText, I18n.translate('Zoom out'),\n\t\t\t`${zoomName}-out`, container, this._zoomOut);\n\n\t\tthis._updateDisabled();\n\t\tmap.on('zoomend zoomlevelschange', this._updateDisabled, this);\n\n\t\treturn container;\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tmap.off('zoomend zoomlevelschange', this._updateDisabled, this);\n\t}\n\n\t/**\n\t * Disables the zoom buttons.\n\t * @returns {this}\n\t */\n\tdisable() {\n\t\tthis._disabled = true;\n\t\tthis._updateDisabled();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Enables the zoom buttons (if the zoom level allows).\n\t * @returns {this}\n\t */\n\tenable() {\n\t\tthis._disabled = false;\n\t\tthis._updateDisabled();\n\t\treturn this;\n\t}\n\n\t_zoomIn(e) {\n\t\tif (!this._disabled && this._map._zoom < this._map.getMaxZoom()) {\n\t\t\tthis._map._setUserEvent(e);\n\t\t\tthis._map.zoomIn(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1));\n\t\t}\n\t}\n\n\t_zoomOut(e) {\n\t\tif (!this._disabled && this._map._zoom > this._map.getMinZoom()) {\n\t\t\tthis._map._setUserEvent(e);\n\t\t\tthis._map.zoomOut(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1));\n\t\t}\n\t}\n\n\t_createButton(html, title, className, container, fn) {\n\t\tconst link = DomUtil.create('button', className, container);\n\t\tlink.type = 'button';\n\t\tlink.innerHTML = html;\n\t\tlink.title = title;\n\t\tlink.setAttribute('aria-label', title);\n\n\t\tDomEvent.disableClickPropagation(link);\n\t\tDomEvent.on(link, 'click', DomEvent.stop);\n\t\tDomEvent.on(link, 'click', fn, this);\n\t\tDomEvent.on(link, 'click', this._refocusOnMap, this);\n\n\t\treturn link;\n\t}\n\n\t_updateDisabled() {\n\t\tconst map = this._map,\n\t\tclassName = 'maplair-disabled';\n\n\t\tthis._zoomInButton.classList.remove(className);\n\t\tthis._zoomOutButton.classList.remove(className);\n\t\tthis._zoomInButton.setAttribute('aria-disabled', 'false');\n\t\tthis._zoomOutButton.setAttribute('aria-disabled', 'false');\n\n\t\tif (this._disabled || map._zoom === map.getMinZoom()) {\n\t\t\tthis._zoomOutButton.classList.add(className);\n\t\t\tthis._zoomOutButton.setAttribute('aria-disabled', 'true');\n\t\t}\n\t\tif (this._disabled || map._zoom === map.getMaxZoom()) {\n\t\t\tthis._zoomInButton.classList.add(className);\n\t\t\tthis._zoomInButton.setAttribute('aria-disabled', 'true');\n\t\t}\n\t}\n\n\t/**\n\t * Registers this default feature on the map class, called by `MaplairMap` itself.\n\t * @internal\n\t * @param {typeof MaplairMap} MaplairMap\n\t */\n\tstatic register(MaplairMap) {\n\t\tMaplairMap.mergeOptions({\n\t\t\tzoomControl: true\n\t\t});\n\n\t\tMaplairMap.addInitHook(function () {\n\t\t\tif (this.options.zoomControl) {\n\t\t\t\tthis.zoomControl = new ZoomControl();\n\t\t\t\tthis.addControl(this.zoomControl);\n\t\t\t}\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,cAAb,MAAa,oBAAoB,QAAQ;CAExC,OAAO,iBAAiB;EACvB,UAAU;EAC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1D,KAAK,OAAO;EACZ,KAAK,YAAY;EACjB,KAAK,QAAQ;EACb,KAAK,aAAa,cAAc,KAAK;EAErC,wBAAiC,IAAI;EACrC,GAAY,MAAM,SAASC,IAAa;EACxC,GAAY,MAAM,SAAS,IAAI,IAAI;EACnC,GAAY,MAAM,SAAS,KAAK,eAAe,IAAI;EAEnD,OAAO;CACR;CAEA,kBAAkB;EACjB,MAAM,MAAM,KAAK,MACjB,YAAY;EAEZ,KAAK,cAAc,UAAU,OAAO,SAAS;EAC7C,KAAK,eAAe,UAAU,OAAO,SAAS;EAC9C,KAAK,cAAc,aAAa,iBAAiB,OAAO;EACxD,KAAK,eAAe,aAAa,iBAAiB,OAAO;EAEzD,IAAI,KAAK,aAAa,IAAI,UAAU,IAAI,WAAW,GAAG;GACrD,KAAK,eAAe,UAAU,IAAI,SAAS;GAC3C,KAAK,eAAe,aAAa,iBAAiB,MAAM;EACzD;EACA,IAAI,KAAK,aAAa,IAAI,UAAU,IAAI,WAAW,GAAG;GACrD,KAAK,cAAc,UAAU,IAAI,SAAS;GAC1C,KAAK,cAAc,aAAa,iBAAiB,MAAM;EACxD;CACD;;;;;;CAOA,OAAO,SAAS,YAAY;EAC3B,WAAW,aAAa,EACvB,aAAa,KACd,CAAC;EAED,WAAW,YAAY,WAAY;GAClC,IAAI,KAAK,QAAQ,aAAa;IAC7B,KAAK,cAAc,IAAI,YAAY;IACnC,KAAK,WAAW,KAAK,WAAW;GACjC;EACD,CAAC;CACF;AACD"}
1
+ {"version":3,"file":"ZoomControl.js","names":["DomUtil.create"],"sources":["../../../src/control/ZoomControl.js"],"sourcesContent":["\nimport {Control} from './Control.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport {I18n} from '../core/I18n.js';\n/** @import {ControlOptions} from './Control.js' */\n/** @import {MaplairMap} from '../map/Map.js' */\n\n/**\n * Options of `ZoomControl`.\n * @typedef {object} ZoomControlOptions\n * @property {string} [position='topleft'] The position of the control (one of the map\n * corners). Possible values are `'topleft'`, `'topright'`, `'bottomleft'` or\n * `'bottomright'`.\n * @property {string} [zoomInText='<span aria-hidden=\"true\">+</span>'] The text set on\n * the 'zoom in' button.\n * @property {string} [zoomOutText='<span aria-hidden=\"true\">&#x2212;</span>'] The text\n * set on the 'zoom out' button.\n * @extends ControlOptions\n */\n\n/**\n * Map options of `ZoomControl`.\n * @typedef {object} ZoomControlMapOptions\n * @lends MaplairMapOptions\n * @property {boolean} [zoomControl=true] Whether a [zoom control](#control-zoom) is\n * added to the map by default.\n */\n\n/**\n * Properties of `MaplairMap` set by `ZoomControl`.\n * @typedef {object} ZoomControlMapProperties\n * @lends MaplairMap\n * @property {ZoomControl} zoomControl The default zoom control (only available if the\n * [`zoomControl` option](#map-zoomcontrol) was `true` when creating the map).\n */\n\n/**\n * A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by\n * default unless you set its [`zoomControl` option](#map-zoomcontrol) to `false`.\n */\nexport class ZoomControl extends Control {\n\n\tstatic defaultOptions = {\n\t\tposition: 'topleft',\n\t\tzoomInText: '<span aria-hidden=\"true\">+</span>',\n\t\tzoomOutText: '<span aria-hidden=\"true\">&#x2212;</span>',\n\t};\n\n\t/**\n\t * Creates a zoom control.\n\t * @param {...ZoomControlOptions} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(ZoomControl);\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t * @returns {HTMLElement}\n\t */\n\tonAdd(map) {\n\t\tconst zoomName = 'maplair-control-zoom',\n\t\tcontainer = DomUtil.create('div', `${zoomName} maplair-bar`),\n\t\toptions = this.options;\n\n\t\tthis._zoomInButton = this._createButton(options.zoomInText, I18n.translate('Zoom in'),\n\t\t\t`${zoomName}-in`, container, e => this._zoom(e, 1));\n\t\tthis._zoomOutButton = this._createButton(options.zoomOutText, I18n.translate('Zoom out'),\n\t\t\t`${zoomName}-out`, container, e => this._zoom(e, -1));\n\n\t\tthis._updateDisabled();\n\t\tmap.on('zoomend zoomlevelschange', this._updateDisabled, this);\n\n\t\treturn container;\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tmap.off('zoomend zoomlevelschange', this._updateDisabled, this);\n\t}\n\n\t/**\n\t * Disables the zoom buttons.\n\t * @returns {this}\n\t */\n\tdisable() {\n\t\tthis._disabled = true;\n\t\tthis._updateDisabled();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Enables the zoom buttons (if the zoom level allows).\n\t * @returns {this}\n\t */\n\tenable() {\n\t\tthis._disabled = false;\n\t\tthis._updateDisabled();\n\t\treturn this;\n\t}\n\n\t_zoom(e, dir) {\n\t\tconst map = this._map;\n\t\tif (!this._disabled && (dir > 0 ? map._zoom < map.getMaxZoom() : map._zoom > map.getMinZoom())) {\n\t\t\tmap._setUserEvent(e);\n\t\t\tmap.zoomIn(dir * map.options.zoomDelta * (e.shiftKey ? 3 : 1));\n\t\t}\n\t}\n\n\t_createButton(html, title, className, container, fn) {\n\t\tconst link = DomUtil.create('button', className, container);\n\t\tlink.type = 'button';\n\t\tlink.innerHTML = html;\n\t\tlink.title = title;\n\t\tlink.setAttribute('aria-label', title);\n\n\t\tDomEvent.disableClickPropagation(link);\n\t\tDomEvent.on(link, 'click', (e) => {\n\t\t\tDomEvent.stop(e);\n\t\t\tfn.call(this, e);\n\t\t\tthis._refocusOnMap(e);\n\t\t});\n\n\t\treturn link;\n\t}\n\n\t_updateDisabled() {\n\t\tconst map = this._map;\n\t\tfor (const [button, limit] of [[this._zoomInButton, map.getMaxZoom()], [this._zoomOutButton, map.getMinZoom()]]) {\n\t\t\tconst disabled = this._disabled || map._zoom === limit;\n\t\t\tbutton.classList.toggle('maplair-disabled', disabled);\n\t\t\tbutton.setAttribute('aria-disabled', `${disabled}`);\n\t\t}\n\t}\n\n\t/**\n\t * Registers this default feature on the map class, called by `MaplairMap` itself.\n\t * @internal\n\t * @param {typeof MaplairMap} MaplairMap\n\t */\n\tstatic register(MaplairMap) {\n\t\tMaplairMap.mergeOptions({\n\t\t\tzoomControl: true\n\t\t});\n\n\t\tMaplairMap.addInitHook(function () {\n\t\t\tif (this.options.zoomControl) {\n\t\t\t\tthis.zoomControl = new ZoomControl();\n\t\t\t\tthis.addControl(this.zoomControl);\n\t\t\t}\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,cAAb,MAAa,oBAAoB,QAAQ;CAExC,OAAO,iBAAiB;EACvB,UAAU;EACV,YAAY;EACZ,aAAa;CACd;;;;;CAMA,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,WAAW;CAC/B;;;;;;CAOA,MAAM,KAAK;EACV,MAAM,WAAW,wBACjB,YAAYA,OAAe,OAAO,GAAG,SAAS,aAAa,GAC3D,UAAU,KAAK;EAEf,KAAK,gBAAiB,KAAK,cAAc,QAAQ,YAAY,KAAK,UAAU,SAAS,GACpF,GAAG,SAAS,MAAO,YAAW,MAAK,KAAK,MAAM,GAAG,CAAC,CAAC;EACpD,KAAK,iBAAiB,KAAK,cAAc,QAAQ,aAAa,KAAK,UAAU,UAAU,GACtF,GAAG,SAAS,OAAO,YAAW,MAAK,KAAK,MAAM,GAAG,EAAE,CAAC;EAErD,KAAK,gBAAgB;EACrB,IAAI,GAAG,4BAA4B,KAAK,iBAAiB,IAAI;EAE7D,OAAO;CACR;;;;;CAMA,SAAS,KAAK;EACb,IAAI,IAAI,4BAA4B,KAAK,iBAAiB,IAAI;CAC/D;;;;;CAMA,UAAU;EACT,KAAK,YAAY;EACjB,KAAK,gBAAgB;EACrB,OAAO;CACR;;;;;CAMA,SAAS;EACR,KAAK,YAAY;EACjB,KAAK,gBAAgB;EACrB,OAAO;CACR;CAEA,MAAM,GAAG,KAAK;EACb,MAAM,MAAM,KAAK;EACjB,IAAI,CAAC,KAAK,cAAc,MAAM,IAAI,IAAI,QAAQ,IAAI,WAAW,IAAI,IAAI,QAAQ,IAAI,WAAW,IAAI;GAC/F,IAAI,cAAc,CAAC;GACnB,IAAI,OAAO,MAAM,IAAI,QAAQ,aAAa,EAAE,WAAW,IAAI,EAAE;EAC9D;CACD;CAEA,cAAc,MAAM,OAAO,WAAW,WAAW,IAAI;EACpD,MAAM,OAAOA,OAAe,UAAU,WAAW,SAAS;EAC1D,KAAK,OAAO;EACZ,KAAK,YAAY;EACjB,KAAK,QAAQ;EACb,KAAK,aAAa,cAAc,KAAK;EAErC,wBAAiC,IAAI;EACrC,GAAY,MAAM,UAAU,MAAM;GACjC,KAAc,CAAC;GACf,GAAG,KAAK,MAAM,CAAC;GACf,KAAK,cAAc,CAAC;EACrB,CAAC;EAED,OAAO;CACR;CAEA,kBAAkB;EACjB,MAAM,MAAM,KAAK;EACjB,KAAK,MAAM,CAAC,QAAQ,UAAU,CAAC,CAAC,KAAK,eAAe,IAAI,WAAW,CAAC,GAAG,CAAC,KAAK,gBAAgB,IAAI,WAAW,CAAC,CAAC,GAAG;GAChH,MAAM,WAAW,KAAK,aAAa,IAAI,UAAU;GACjD,OAAO,UAAU,OAAO,oBAAoB,QAAQ;GACpD,OAAO,aAAa,iBAAiB,GAAG,UAAU;EACnD;CACD;;;;;;CAOA,OAAO,SAAS,YAAY;EAC3B,WAAW,aAAa,EACvB,aAAa,KACd,CAAC;EAED,WAAW,YAAY,WAAY;GAClC,IAAI,KAAK,QAAQ,aAAa;IAC7B,KAAK,cAAc,IAAI,YAAY;IACnC,KAAK,WAAW,KAAK,WAAW;GACjC;EACD,CAAC;CACF;AACD"}
@@ -1,5 +1,5 @@
1
1
  import { setOptions } from "./Util.js";
2
- //#region src/core/Class.js
2
+ // src/core/Class.js
3
3
  /**
4
4
  * Class powers the OOP facilities of Maplair and is used to create almost all of the
5
5
  * Maplair classes documented here.
@@ -157,15 +157,9 @@ var Class = class {
157
157
  * @returns {T}
158
158
  */
159
159
  static include(props) {
160
- for (const k of getAllMethodNames(props)) if (k !== "constructor" && k !== "options") this.prototype[k] = props[k];
160
+ for (let obj = props; obj && obj !== Object.prototype; obj = Object.getPrototypeOf(obj)) for (const k of Object.getOwnPropertyNames(obj)) if (k !== "constructor" && k !== "options") this.prototype[k] = props[k];
161
161
  if (props.options) this.mergeOptions(props.options);
162
162
  return this;
163
- function* getAllMethodNames(obj) {
164
- do {
165
- if (obj === Object || obj === Object.prototype) break;
166
- for (const k of Object.getOwnPropertyNames(obj)) yield k;
167
- } while ((obj = Object.getPrototypeOf(obj)) !== null);
168
- }
169
163
  }
170
164
  /**
171
165
  * [Merges `options`](#class-options) into the `defaultOptions` of the class.
@@ -230,7 +224,6 @@ var Class = class {
230
224
  return this;
231
225
  }
232
226
  };
233
- //#endregion
234
227
  export { Class };
235
228
 
236
229
  //# sourceMappingURL=Class.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Class.js","names":[],"sources":["../../../src/core/Class.js"],"sourcesContent":["import * as Util from './Util.js';\n\n// Thanks to John Resig and Dean Edwards for inspiration!\n\n/**\n * Class powers the OOP facilities of Maplair and is used to create almost all of the\n * Maplair classes documented here.\n *\n * It implements a simple classical inheritance model using JavaScript's standard\n * `extends` keyword, and introduces several special properties for convenient code\n * organization — options and init hooks.\n *\n * <h3 id=\"class-options\">Options</h3>\n *\n * `options` is a special property whose defaults, the static `defaultOptions` of the\n * class, are merged with those of the parent class instead of overriding them\n * completely, which makes managing configuration of objects and default values\n * convenient:\n *\n * ```js\n * class MyClass extends Class {\n * static defaultOptions = {\n * myOption1: 'foo',\n * myOption2: 'bar'\n * };\n * }\n *\n * class MyChildClass extends MyClass {\n * static defaultOptions = {\n * myOption1: 'baz',\n * myOption3: 5\n * };\n * }\n *\n * const a = new MyChildClass();\n * a.options.myOption1; // 'baz'\n * a.options.myOption2; // 'bar'\n * a.options.myOption3; // 5\n * ```\n *\n * There's also [`Util.setOptions`](#util-setoptions), a method for\n * conveniently merging options passed to constructor with the defaults\n * defined in the class:\n *\n * ```js\n * class MyClass extends Class {\n * static defaultOptions = {\n * foo: 'bar',\n * bla: 5\n * };\n *\n * constructor(options) {\n * super();\n * Util.setOptions(this, options);\n * ...\n * }\n * }\n *\n * const a = new MyClass({bla: 10});\n * a.options; // {foo: 'bar', bla: 10}\n * ```\n *\n * Note that the options object allows any keys, not just\n * the options defined by the class and its base classes.\n * This means you can use the options object to store\n * application specific information, as long as you avoid\n * keys that are already used by the class in question.\n *\n * <h3 id=\"class-includes\">Mixins</h3>\n *\n * You can add methods and properties from other objects using the `include` method\n * (such objects are called mixins):\n *\n * ```js\n * const MyMixin = {\n * foo() { ... },\n * bar: 5\n * };\n *\n * class MyClass extends Class {}\n *\n * MyClass.include(MyMixin);\n *\n * const a = new MyClass();\n * a.foo();\n * ```\n *\n * <h3 id=\"class-constructor-hooks\">Constructor hooks</h3>\n *\n * If you're a plugin developer, you often need to add additional initialization code\n * to existing classes (e.g. editing hooks for `Polyline`). Maplair comes with a way to\n * do it easily using the `addInitHook` method:\n *\n * ```js\n * Polyline.addInitHook(function () {\n * // ... do something in constructor additionally\n * // e.g. add event listeners, set custom properties etc.\n * this.editing = new PolylineEditor(this);\n * });\n * ```\n *\n * You can also use the following shortcut when you just need to make one additional\n * method call:\n *\n * ```js\n * MyClass.addInitHook('methodName', arg1, arg2, …);\n * ```\n *\n * The hooks of a class run at the end of its constructor, which calls\n * [`callInitHooks`](#class-callinithooks) — so they can rely on everything the\n * constructor sets up. All Maplair classes do so. Hooks of parent classes run\n * first, and parent classes without a constructor of their own (such as `Layer`\n * or `Path`) have their hooks run along with their subclasses. Each hook runs\n * once per object.\n *\n * Note that the hooks of a parent class run before the constructor of a subclass\n * continues. To support hooks on your own classes, call `this.callInitHooks()`\n * at the end of their constructor:\n *\n * ```js\n * class MyMarker extends Marker {\n * constructor(latlng, options) {\n * super(latlng, options); // runs the hooks of Marker (and of Layer etc.)\n * this.extra = 'ready';\n * this.callInitHooks(); // runs the hooks of MyMarker\n * }\n * }\n * ```\n *\n * @example\n * ```js\n * class MyClass extends Class {\n * constructor(greeter) {\n * super();\n * this.greeter = greeter;\n * this.callInitHooks(MyClass); // optional, see constructor hooks above\n * }\n *\n * greet(name) {\n * alert(this.greeter + ', ' + name)\n * }\n * }\n *\n * // create instance of MyClass, passing \"Hello\" to the constructor\n * const a = new MyClass(\"Hello\");\n *\n * // call greet method, alerting \"Hello, World\"\n * a.greet(\"World\");\n * ```\n */\nexport class Class {\n\t/**\n\t * [Includes a mixin](#class-includes) into the current class: copies the properties\n\t * of `props` (and of its prototypes) to the prototype of the class, and merges\n\t * `props.options` into its default options.\n\t * @template {typeof Class} T\n\t * @this {T}\n\t * @param {object} props\n\t * @returns {T}\n\t */\n\tstatic include(props) {\n\t\tfor (const k of getAllMethodNames(props)) {\n\t\t\tif (k !== 'constructor' && k !== 'options') {\n\t\t\t\tthis.prototype[k] = props[k];\n\t\t\t}\n\t\t}\n\t\tif (props.options) {\n\t\t\tthis.mergeOptions(props.options);\n\t\t}\n\t\treturn this;\n\n\t\tfunction *getAllMethodNames(obj) {\n\t\t\tdo {\n\t\t\t\tif (obj === Object || obj === Object.prototype) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tfor (const k of Object.getOwnPropertyNames(obj)) {\n\t\t\t\t\tyield k;\n\t\t\t\t}\n\t\t\t} while ((obj = Object.getPrototypeOf(obj)) !== null);\n\t\t}\n\t}\n\n\t/**\n\t * [Merges `options`](#class-options) into the `defaultOptions` of the class.\n\t * @template {typeof Class} T\n\t * @this {T}\n\t * @param {object} options\n\t * @returns {T}\n\t */\n\tstatic mergeOptions(options) {\n\t\tif (!Object.hasOwn(this, 'defaultOptions')) {\n\t\t\tthis.defaultOptions = Object.create(this.defaultOptions ?? Object.prototype);\n\t\t}\n\t\tObject.assign(this.defaultOptions, options);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Deprecated alias of `mergeOptions()`, kept for code written for Maplair 4.0.\n\t * @deprecated Use `static defaultOptions = {…}` or `mergeOptions()`.\n\t * @template {typeof Class} T\n\t * @this {T}\n\t * @param {object} options\n\t * @returns {T}\n\t */\n\tstatic setDefaultOptions(options) {\n\t\treturn this.mergeOptions(options);\n\t}\n\n\t/**\n\t * Adds a [constructor hook](#class-constructor-hooks) to the class: a function\n\t * (called with the object as `this`), or the name of a method to call with the\n\t * given arguments.\n\t * @template {typeof Class} T\n\t * @this {T}\n\t * @param {((this: any) => void)|string} fn\n\t * @param {...any} args Arguments of the method `fn`.\n\t * @returns {T}\n\t */\n\tstatic addInitHook(fn, ...args) { // (Function) || (String, args...)\n\t\tconst init = typeof fn === 'function' ? fn : function () {\n\t\t\tthis[fn](...args);\n\t\t};\n\n\t\tif (!Object.hasOwn(this, '_initHooks')) { // do not use ??= here, which would find the parent class' hooks\n\t\t\tthis._initHooks = [];\n\t\t}\n\t\tthis._initHooks.push(init);\n\t\treturn this;\n\t}\n\n\tconstructor() {\n\t\tif (this.initialize) {\n\t\t\tthrow new Error(`${this.constructor.name}: initialize() is not called in Maplair. ` +\n\t\t\t\t'Rename it to constructor() and call super() at its start.');\n\t\t}\n\n\t\tUtil.setOptions(this);\n\t}\n\n\t/**\n\t * Runs the [constructor hooks](#class-constructor-hooks) of the given class and\n\t * of its parent classes, which haven't run yet for this object. Classes call it\n\t * at the end of their constructor, e.g. `this.callInitHooks(MyClass)`.\n\t * Without `cls`, runs the hooks of all classes of this object.\n\t * @param {Function} [cls]\n\t * @returns {this}\n\t */\n\tcallInitHooks(cls = this.constructor) {\n\t\tconst done = this._initHooksCalledFor;\n\t\tif (done && (done === cls || done.prototype instanceof cls)) {\n\t\t\treturn this; // the hooks of `cls` already ran\n\t\t}\n\n\t\t// parent classes first; stop at the class whose hooks (and whose parent\n\t\t// classes' hooks) already ran, e.g. in the constructor of a parent class\n\t\tconst classes = [];\n\t\tfor (let c = cls; c && c !== Function.prototype && c !== done; c = Object.getPrototypeOf(c)) {\n\t\t\tclasses.unshift(c);\n\t\t}\n\t\tthis._initHooksCalledFor =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aAAa,CAAC;EAEpB,KAAK,WAAW,KAAK,IAAI;EACzB,OAAO;CACR;CAEA,cAAc;EACb,IAAI,KAAK,YACR,MAAM,IAAI,MAAM,GAAG,KAAK,YAAY,KAAK,mGACmB;EAG7D,WAAgB,IAAI;CACrB;;;;;;;;;CAUA,cAAc,MAAM,KAAK,aAAa;EACrC,MAAM,OAAO,KAAK;EAClB,IAAI,SAAS,SAAS,OAAO,KAAK,qBAAqB,MACtD,OAAO;EAKR,MAAM,UAAU,CAAC;EACjB,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,SAAS,aAAa,MAAM,MAAM,IAAI,OAAO,eAAe,CAAC,GACzF,QAAQ,QAAQ,CAAC;EAElB,KAAK,sBAAsB;EAE3B,KAAK,MAAM,KAAK,SACf,IAAI,OAAO,OAAO,GAAG,YAAY,GAChC,KAAK,MAAM,QAAQ,EAAE,YACpB,KAAK,KAAK,IAAI;EAIjB,OAAO;CACR;AACD"}
1
+ {"version":3,"file":"Class.js","names":[],"sources":["../../../src/core/Class.js"],"sourcesContent":["import * as Util from './Util.js';\n\n// Thanks to John Resig and Dean Edwards for inspiration!\n\n/**\n * Class powers the OOP facilities of Maplair and is used to create almost all of the\n * Maplair classes documented here.\n *\n * It implements a simple classical inheritance model using JavaScript's standard\n * `extends` keyword, and introduces several special properties for convenient code\n * organization — options and init hooks.\n *\n * <h3 id=\"class-options\">Options</h3>\n *\n * `options` is a special property whose defaults, the static `defaultOptions` of the\n * class, are merged with those of the parent class instead of overriding them\n * completely, which makes managing configuration of objects and default values\n * convenient:\n *\n * ```js\n * class MyClass extends Class {\n * static defaultOptions = {\n * myOption1: 'foo',\n * myOption2: 'bar'\n * };\n * }\n *\n * class MyChildClass extends MyClass {\n * static defaultOptions = {\n * myOption1: 'baz',\n * myOption3: 5\n * };\n * }\n *\n * const a = new MyChildClass();\n * a.options.myOption1; // 'baz'\n * a.options.myOption2; // 'bar'\n * a.options.myOption3; // 5\n * ```\n *\n * There's also [`Util.setOptions`](#util-setoptions), a method for\n * conveniently merging options passed to constructor with the defaults\n * defined in the class:\n *\n * ```js\n * class MyClass extends Class {\n * static defaultOptions = {\n * foo: 'bar',\n * bla: 5\n * };\n *\n * constructor(options) {\n * super();\n * Util.setOptions(this, options);\n * ...\n * }\n * }\n *\n * const a = new MyClass({bla: 10});\n * a.options; // {foo: 'bar', bla: 10}\n * ```\n *\n * Note that the options object allows any keys, not just\n * the options defined by the class and its base classes.\n * This means you can use the options object to store\n * application specific information, as long as you avoid\n * keys that are already used by the class in question.\n *\n * <h3 id=\"class-includes\">Mixins</h3>\n *\n * You can add methods and properties from other objects using the `include` method\n * (such objects are called mixins):\n *\n * ```js\n * const MyMixin = {\n * foo() { ... },\n * bar: 5\n * };\n *\n * class MyClass extends Class {}\n *\n * MyClass.include(MyMixin);\n *\n * const a = new MyClass();\n * a.foo();\n * ```\n *\n * <h3 id=\"class-constructor-hooks\">Constructor hooks</h3>\n *\n * If you're a plugin developer, you often need to add additional initialization code\n * to existing classes (e.g. editing hooks for `Polyline`). Maplair comes with a way to\n * do it easily using the `addInitHook` method:\n *\n * ```js\n * Polyline.addInitHook(function () {\n * // ... do something in constructor additionally\n * // e.g. add event listeners, set custom properties etc.\n * this.editing = new PolylineEditor(this);\n * });\n * ```\n *\n * You can also use the following shortcut when you just need to make one additional\n * method call:\n *\n * ```js\n * MyClass.addInitHook('methodName', arg1, arg2, …);\n * ```\n *\n * The hooks of a class run at the end of its constructor, which calls\n * [`callInitHooks`](#class-callinithooks) — so they can rely on everything the\n * constructor sets up. All Maplair classes do so. Hooks of parent classes run\n * first, and parent classes without a constructor of their own (such as `Layer`\n * or `Path`) have their hooks run along with their subclasses. Each hook runs\n * once per object.\n *\n * Note that the hooks of a parent class run before the constructor of a subclass\n * continues. To support hooks on your own classes, call `this.callInitHooks()`\n * at the end of their constructor:\n *\n * ```js\n * class MyMarker extends Marker {\n * constructor(latlng, options) {\n * super(latlng, options); // runs the hooks of Marker (and of Layer etc.)\n * this.extra = 'ready';\n * this.callInitHooks(); // runs the hooks of MyMarker\n * }\n * }\n * ```\n *\n * @example\n * ```js\n * class MyClass extends Class {\n * constructor(greeter) {\n * super();\n * this.greeter = greeter;\n * this.callInitHooks(MyClass); // optional, see constructor hooks above\n * }\n *\n * greet(name) {\n * alert(this.greeter + ', ' + name)\n * }\n * }\n *\n * // create instance of MyClass, passing \"Hello\" to the constructor\n * const a = new MyClass(\"Hello\");\n *\n * // call greet method, alerting \"Hello, World\"\n * a.greet(\"World\");\n * ```\n */\nexport class Class {\n\t/**\n\t * [Includes a mixin](#class-includes) into the current class: copies the properties\n\t * of `props` (and of its prototypes) to the prototype of the class, and merges\n\t * `props.options` into its default options.\n\t * @template {typeof Class} T\n\t * @this {T}\n\t * @param {object} props\n\t * @returns {T}\n\t */\n\tstatic include(props) {\n\t\tfor (let obj = props; obj && obj !== Object.prototype; obj = Object.getPrototypeOf(obj)) {\n\t\t\tfor (const k of Object.getOwnPropertyNames(obj)) {\n\t\t\t\tif (k !== 'constructor' && k !== 'options') {\n\t\t\t\t\tthis.prototype[k] = props[k];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (props.options) {\n\t\t\tthis.mergeOptions(props.options);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * [Merges `options`](#class-options) into the `defaultOptions` of the class.\n\t * @template {typeof Class} T\n\t * @this {T}\n\t * @param {object} options\n\t * @returns {T}\n\t */\n\tstatic mergeOptions(options) {\n\t\tif (!Object.hasOwn(this, 'defaultOptions')) {\n\t\t\tthis.defaultOptions = Object.create(this.defaultOptions ?? Object.prototype);\n\t\t}\n\t\tObject.assign(this.defaultOptions, options);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Deprecated alias of `mergeOptions()`, kept for code written for Maplair 4.0.\n\t * @deprecated Use `static defaultOptions = {…}` or `mergeOptions()`.\n\t * @template {typeof Class} T\n\t * @this {T}\n\t * @param {object} options\n\t * @returns {T}\n\t */\n\tstatic setDefaultOptions(options) {\n\t\treturn this.mergeOptions(options);\n\t}\n\n\t/**\n\t * Adds a [constructor hook](#class-constructor-hooks) to the class: a function\n\t * (called with the object as `this`), or the name of a method to call with the\n\t * given arguments.\n\t * @template {typeof Class} T\n\t * @this {T}\n\t * @param {((this: any) => void)|string} fn\n\t * @param {...any} args Arguments of the method `fn`.\n\t * @returns {T}\n\t */\n\tstatic addInitHook(fn, ...args) { // (Function) || (String, args...)\n\t\tconst init = typeof fn === 'function' ? fn : function () {\n\t\t\tthis[fn](...args);\n\t\t};\n\n\t\tif (!Object.hasOwn(this, '_initHooks')) { // do not use ??= here, which would find the parent class' hooks\n\t\t\tthis._initHooks = [];\n\t\t}\n\t\tthis._initHooks.push(init);\n\t\treturn this;\n\t}\n\n\tconstructor() {\n\t\tif (this.initialize) {\n\t\t\tthrow new Error(`${this.constructor.name}: initialize() is not called in Maplair. ` +\n\t\t\t\t'Rename it to constructor() and call super() at its start.');\n\t\t}\n\n\t\tUtil.setOptions(this);\n\t}\n\n\t/**\n\t * Runs the [constructor hooks](#class-constructor-hooks) of the given class and\n\t * of its parent classes, which haven't run yet for this object. Classes call it\n\t * at the end of their constructor, e.g. `this.callInitHooks(MyClass)`.\n\t * Without `cls`, runs the hooks of all classes of this object.\n\t * @param {Function} [cls]\n\t * @returns {this}\n\t */\n\tcallInitHooks(cls = this.constructor) {\n\t\tconst done = this._initHooksCalledFor;\n\t\tif (done && (done === cls || done.prototype instanceof cls)) {\n\t\t\treturn this; // the hooks of `cls` already ran\n\t\t}\n\n\t\t// parent classes first; stop at the class whose hooks (and whose parent\n\t\t// classes' hooks) already ran, e.g. in the constructor of a parent class\n\t\tconst classes = [];\n\t\tfor (let c = cls; c && c !== Function.prototype && c !== done; c = Object.getPrototypeOf(c)) {\n\t\t\tclasses.unshift(c);\n\t\t}\n\t\tthis._initHooksCalledFor = cls;\n\n\t\tfor (const c of classes) {\n\t\t\tif (Object.hasOwn(c, '_initHooks')) {\n\t\t\t\tfor (const hook of c._initHooks) {\n\t\t\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AAK,aAAa;EACrC,MAAM,OAAO,KAAK;EAClB,IAAI,SAAS,SAAS,OAAO,KAAK,qBAAqB,MACtD,OAAO;EAKR,MAAM,UAAU,CAAC;EACjB,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,SAAS,aAAa,MAAM,MAAM,IAAI,OAAO,eAAe,CAAC,GACzF,QAAQ,QAAQ,CAAC;EAElB,KAAK,sBAAsB;EAE3B,KAAK,MAAM,KAAK,SACf,IAAI,OAAO,OAAO,GAAG,YAAY,GAChC,KAAK,MAAM,QAAQ,EAAE,YACpB,KAAK,KAAK,IAAI;EAIjB,OAAO;CACR;AACD"}
@@ -1,6 +1,6 @@
1
1
  import { falseFn, splitWords, stamp } from "./Util.js";
2
2
  import { Class } from "./Class.js";
3
- //#region src/core/Events.js
3
+ // src/core/Events.js
4
4
  const warnedEvents = /* @__PURE__ */ new Set();
5
5
  /** @import {LatLng} from '../geo/LatLng.js' */
6
6
  /** @import {LatLngBounds} from '../geo/LatLngBounds.js' */
@@ -387,7 +387,6 @@ var Evented = class Evented extends Class {
387
387
  }, true);
388
388
  }
389
389
  };
390
- //#endregion
391
390
  export { Evented };
392
391
 
393
392
  //# sourceMappingURL=Events.js.map
@@ -1,12 +1,12 @@
1
1
  import { Class } from "./Class.js";
2
- //#region src/core/Handler.js
2
+ // src/core/Handler.js
3
3
  /** @import {MaplairMap} from '../map/Map.js' */
4
4
  /**
5
5
  * Abstract class for map interaction handlers, the base class of the handlers that
6
6
  * are used internally to inject interaction features like dragging to classes like
7
7
  * `MaplairMap` and `Marker`.
8
8
  *
9
- * Classes inheriting from `Handler` must implement the two following extension methods:
9
+ * Classes inheriting from `Handler` implement the two following extension methods:
10
10
  *
11
11
  * * `addHooks()` is called when the handler is enabled, should add event hooks.
12
12
  * * `removeHooks()` is called when the handler is disabled, should remove the event
@@ -49,6 +49,14 @@ var Handler = class Handler extends Class {
49
49
  return !!this._enabled;
50
50
  }
51
51
  /**
52
+ * Called when the handler is enabled, should add event hooks.
53
+ */
54
+ addHooks() {}
55
+ /**
56
+ * Called when the handler is disabled, should remove the event hooks added previously.
57
+ */
58
+ removeHooks() {}
59
+ /**
52
60
  * Adds a new handler of this class to the given map with the given name, which is
53
61
  * then available as the property of the map with this name.
54
62
  * @template {typeof Handler} T
@@ -62,7 +70,6 @@ var Handler = class Handler extends Class {
62
70
  return this;
63
71
  }
64
72
  };
65
- //#endregion
66
73
  export { Handler };
67
74
 
68
75
  //# sourceMappingURL=Handler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Handler.js","names":[],"sources":["../../../src/core/Handler.js"],"sourcesContent":["import {Class} from './Class.js';\n/** @import {MaplairMap} from '../map/Map.js' */\n\n/**\n * Abstract class for map interaction handlers, the base class of the handlers that\n * are used internally to inject interaction features like dragging to classes like\n * `MaplairMap` and `Marker`.\n *\n * Classes inheriting from `Handler` must implement the two following extension methods:\n *\n * * `addHooks()` is called when the handler is enabled, should add event hooks.\n * * `removeHooks()` is called when the handler is disabled, should remove the event\n * hooks added previously.\n */\nexport class Handler extends Class {\n\t/**\n\t * @param {MaplairMap} map The map the handler belongs to.\n\t */\n\tconstructor(map) {\n\t\tsuper();\n\t\tthis._map = map;\n\n\t\tthis.callInitHooks(Handler);\n\t}\n\n\t/**\n\t * Enables the handler.\n\t * @returns {this}\n\t */\n\tenable() {\n\t\tif (this._enabled) { return this; }\n\n\t\tthis._enabled = true;\n\t\tthis.addHooks();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Disables the handler.\n\t * @returns {this}\n\t */\n\tdisable() {\n\t\tif (!this._enabled) { return this; }\n\n\t\tthis._enabled = false;\n\t\tthis.removeHooks();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns `true` if the handler is enabled.\n\t * @returns {boolean}\n\t */\n\tenabled() {\n\t\treturn !!this._enabled;\n\t}\n\n\t/**\n\t * Adds a new handler of this class to the given map with the given name, which is\n\t * then available as the property of the map with this name.\n\t * @template {typeof Handler} T\n\t * @this {T}\n\t * @param {MaplairMap} map\n\t * @param {string} name\n\t * @returns {T}\n\t */\n\tstatic addTo(map, name) {\n\t\tmap.addHandler(name, this);\n\t\treturn this;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,IAAa,UAAb,MAAa,gBAAgB,MAAM;;;;CAIlC,YAAY,KAAK;EAChB,MAAM;EACN,KAAK,OAAO;EAEZ,KAAK,cAAc,OAAO;CAC3B;;;;;CAMA,SAAS;EACR,IAAI,KAAK,UAAY,OAAO;EAE5B,KAAK,WAAW;EAChB,KAAK,SAAS;EACd,OAAO;CACR;;;;;CAMA,UAAU;EACT,IAAI,CAAC,KAAK,UAAY,OAAO;EAE7B,KAAK,WAAW;EAChB,KAAK,YAAY;EACjB,OAAO;CACR;;;;;CAMA,UAAU;EACT,OAAO,CAAC,CAAC,KAAK;CACf;;;;;;;;;;CAWA,OAAO,MAAM,KAAK,MAAM;EACvB,IAAI,WAAW,MAAM,IAAI;EACzB,OAAO;CACR;AACD"}
1
+ {"version":3,"file":"Handler.js","names":[],"sources":["../../../src/core/Handler.js"],"sourcesContent":["import {Class} from './Class.js';\n/** @import {MaplairMap} from '../map/Map.js' */\n\n/**\n * Abstract class for map interaction handlers, the base class of the handlers that\n * are used internally to inject interaction features like dragging to classes like\n * `MaplairMap` and `Marker`.\n *\n * Classes inheriting from `Handler` implement the two following extension methods:\n *\n * * `addHooks()` is called when the handler is enabled, should add event hooks.\n * * `removeHooks()` is called when the handler is disabled, should remove the event\n * hooks added previously.\n */\nexport class Handler extends Class {\n\t/**\n\t * @param {MaplairMap} map The map the handler belongs to.\n\t */\n\tconstructor(map) {\n\t\tsuper();\n\t\tthis._map = map;\n\n\t\tthis.callInitHooks(Handler);\n\t}\n\n\t/**\n\t * Enables the handler.\n\t * @returns {this}\n\t */\n\tenable() {\n\t\tif (this._enabled) { return this; }\n\n\t\tthis._enabled = true;\n\t\tthis.addHooks();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Disables the handler.\n\t * @returns {this}\n\t */\n\tdisable() {\n\t\tif (!this._enabled) { return this; }\n\n\t\tthis._enabled = false;\n\t\tthis.removeHooks();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns `true` if the handler is enabled.\n\t * @returns {boolean}\n\t */\n\tenabled() {\n\t\treturn !!this._enabled;\n\t}\n\n\t/**\n\t * Called when the handler is enabled, should add event hooks.\n\t */\n\taddHooks() {}\n\n\t/**\n\t * Called when the handler is disabled, should remove the event hooks added previously.\n\t */\n\tremoveHooks() {}\n\n\t/**\n\t * Adds a new handler of this class to the given map with the given name, which is\n\t * then available as the property of the map with this name.\n\t * @template {typeof Handler} T\n\t * @this {T}\n\t * @param {MaplairMap} map\n\t * @param {string} name\n\t * @returns {T}\n\t */\n\tstatic addTo(map, name) {\n\t\tmap.addHandler(name, this);\n\t\treturn this;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,IAAa,UAAb,MAAa,gBAAgB,MAAM;;;;CAIlC,YAAY,KAAK;EAChB,MAAM;EACN,KAAK,OAAO;EAEZ,KAAK,cAAc,OAAO;CAC3B;;;;;CAMA,SAAS;EACR,IAAI,KAAK,UAAY,OAAO;EAE5B,KAAK,WAAW;EAChB,KAAK,SAAS;EACd,OAAO;CACR;;;;;CAMA,UAAU;EACT,IAAI,CAAC,KAAK,UAAY,OAAO;EAE7B,KAAK,WAAW;EAChB,KAAK,YAAY;EACjB,OAAO;CACR;;;;;CAMA,UAAU;EACT,OAAO,CAAC,CAAC,KAAK;CACf;;;;CAKA,WAAW,CAAC;;;;CAKZ,cAAc,CAAC;;;;;;;;;;CAWf,OAAO,MAAM,KAAK,MAAM;EACvB,IAAI,WAAW,MAAM,IAAI;EACzB,OAAO;CACR;AACD"}
@@ -1,5 +1,5 @@
1
1
  import { template } from "./Util.js";
2
- //#region src/core/I18n.js
2
+ // src/core/I18n.js
3
3
  /**
4
4
  * Utility functions to deal with translations.
5
5
  *
@@ -68,7 +68,6 @@ var I18n = class {
68
68
  }
69
69
  }
70
70
  };
71
- //#endregion
72
71
  export { I18n };
73
72
 
74
73
  //# sourceMappingURL=I18n.js.map
@@ -1,5 +1,5 @@
1
1
  import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
- //#region src/core/Util.js
2
+ // src/core/Util.js
3
3
  var Util_exports = /* @__PURE__ */ __exportAll({
4
4
  falseFn: () => falseFn,
5
5
  formatNum: () => formatNum,
@@ -57,7 +57,7 @@ function throttle(fn, time, context) {
57
57
  }
58
58
  /**
59
59
  * Returns the number `x` modulo `range` in such a way so it lies within
60
- * `range[0]` and `range[1]`. The returned value will be always smaller than
60
+ * `range[0]` and `range[1]`. The returned value will always be smaller than
61
61
  * `range[1]` unless `includeMax` is set to `true`.
62
62
  * @param {number} x
63
63
  * @param {[number, number]} range
@@ -139,7 +139,6 @@ function template(str, data) {
139
139
  return value;
140
140
  });
141
141
  }
142
- //#endregion
143
142
  export { Util_exports, falseFn, formatNum, lastId, setOptions, splitWords, stamp, template, throttle, wrapNum };
144
143
 
145
144
  //# sourceMappingURL=Util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Util.js","names":[],"sources":["../../../src/core/Util.js"],"sourcesContent":["// Util: various utility functions, used by Maplair internally.\n\n/**\n * Last unique ID used by [`stamp()`](#util-stamp).\n * @type {number}\n */\nexport let lastId = 0;\n\n/**\n * Returns the unique ID of an object, assigning it one if it doesn't have it.\n * @param {object} obj\n * @returns {number}\n */\nexport function stamp(obj) {\n\tif (!('_maplair_id' in obj)) {\n\t\tobj['_maplair_id'] = ++lastId;\n\t}\n\treturn obj._maplair_id;\n}\n\n/**\n * Returns a function which executes function `fn` with the given scope `context`\n * (so that the `this` keyword refers to `context` inside `fn`'s code). The function\n * `fn` will be called no more than one time per given amount of `time`. The arguments\n * received by the bound function will be any arguments passed when binding the\n * function, followed by any arguments passed when invoking the bound function.\n * @param {(...args: any[]) => void} fn\n * @param {number} time In milliseconds.\n * @param {object} [context]\n * @returns {(...args: any[]) => void}\n */\nexport function throttle(fn, time, context) {\n\tlet lock, queuedArgs;\n\n\tfunction later() {\n\t\t// reset lock and call if queued\n\t\tlock = false;\n\t\tif (queuedArgs) {\n\t\t\twrapperFn.apply(context, queuedArgs);\n\t\t\tqueuedArgs = false;\n\t\t}\n\t}\n\n\tfunction wrapperFn(...args) {\n\t\tif (lock) {\n\t\t\t// called too soon, queue to call later\n\t\t\tqueuedArgs = args;\n\n\t\t} else {\n\t\t\t// call and lock until later\n\t\t\tfn.apply(context, args);\n\t\t\tsetTimeout(later, time);\n\t\t\tlock = true;\n\t\t}\n\t}\n\n\treturn wrapperFn;\n}\n\n/**\n * Returns the number `x` modulo `range` in such a way so it lies within\n * `range[0]` and `range[1]`. The returned value will be always smaller than\n * `range[1]` unless `includeMax` is set to `true`.\n * @param {number} x\n * @param {[number, number]} range\n * @param {boolean} [includeMax]\n * @returns {number}\n */\nexport function wrapNum(x, range, includeMax) {\n\tconst max = range[1],\n\tmin = range[0],\n\td = max - min;\n\treturn x === max && includeMax ? x : ((x - min) % d + d) % d + min;\n}\n\n/**\n * A function which always returns `false`.\n * @returns {false}\n */\nexport function falseFn() { return false; }\n\n/**\n * Returns the number `num` rounded with specified `precision`.\n * The default `precision` value is 6 decimal places.\n * `false` can be passed to skip any processing (can be useful to avoid round-off errors).\n * @param {number} num\n * @param {number|false} [precision]\n * @returns {number}\n */\nexport function formatNum(num, precision) {\n\tif (precision === false) { return num; }\n\tconst pow = 10 ** (precision === undefined ? 6 : precision);\n\treturn Math.round(num * pow) / pow;\n}\n\nconst WHITESPACE_RE = /\\s+/;\n\n/**\n * Trims and splits the string on whitespace and returns the array of parts.\n * @param {string} str\n * @returns {string[]}\n */\nexport function splitWords(str) {\n\treturn str.trim().split(WHITESPACE_RE);\n}\n\n/**\n * Merges the given properties to the `options` of the `obj` object, returning the\n * resulting options. See `Class options`.\n * @param {object} obj\n * @param {object} [options]\n * @returns {object}\n */\nexport function setOptions(obj, options) {\n\tif (!Object.hasOwn(obj, 'options')) {\n\t\tconst defaults = getDefaultOptions(obj.constructor) ?? obj.options;\n\t\tobj.options = defaults ? Object.create(defaults) : {};\n\t}\n\tfor (const i in options) {\n\t\tif (Object.hasOwn(options, i)) {\n\t\t\tobj.options[i] = options[i];\n\t\t}\n\t}\n\treturn obj.options;\n}\n\nconst chainedDefaults = new WeakMap(); // class -> the defaultOptions object it was chained with\n\n// Links the `defaultOptions` of each class in the chain to its parent's, so defaults are inherited and stay live.\n// Done on first use because a static field can't do it in its initializer and stay tree-shakeable.\nfunction getDefaultOptions(cls) {\n\tconst defaults = cls?.defaultOptions;\n\tif (defaults && chainedDefaults.get(cls) !== defaults) {\n\t\tfor (let c = cls; c.defaultOptions; c = Object.getPrototypeOf(c)) {\n\t\t\tif (Object.hasOwn(c, 'defaultOptions')) {\n\t\t\t\tObject.setPrototypeOf(c.defaultOptions, Object.getPrototypeOf(c).defaultOptions ?? Object.prototype);\n\t\t\t}\n\t\t}\n\t\tchainedDefaults.set(cls, defaults);\n\t}\n\treturn defaults;\n}\n\nconst templateRe = /\\{ *([\\w_ -]+) *\\}/g;\n\n/**\n * Simple templating facility, accepts a template string of the form `'Hello {a}, {b}'`\n * and a data object like `{a: 'foo', b: 'bar'}`, returns evaluated string\n * `('Hello foo, bar')`. You can also specify functions instead of strings for\n * data values — they will be evaluated passing `data` as an argument.\n * @param {string} str\n * @param {Record<string, any>} data\n * @returns {string}\n */\nexport function template(str, data) {\n\treturn str.replace(templateRe, (str, key) => {\n\t\tlet value = data[key];\n\n\t\tif (value === undefined) {\n\t\t\tthrow new Error(`No value provided for variable ${str}`);\n\n\t\t} else if (typeof value === 'function') {\n\t\t\tvalue = value(data);\n\t\t}\n\t\treturn value;\n\t});\n}\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;AAMA,IAAW,SAAS;;;;;;AAOpB,SAAgB,MAAM,KAAK;CAC1B,IAAI,EAAE,iBAAiB,MACtB,IAAI,iBAAiB,EAAE;CAExB,OAAO,IAAI;AACZ;;;;;;;;;;;;AAaA,SAAgB,SAAS,IAAI,MAA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AU;EACtD,KAAK,IAAI,IAAI,KAAK,EAAE,gBAAgB,IAAI,OAAO,eAAe,CAAC,GAC9D,IAAI,OAAO,OAAO,GAAG,gBAAgB,GACpC,OAAO,eAAe,EAAE,gBAAgB,OAAO,eAAe,CAAC,CAAC,CAAC,kBAAkB,OAAO,SAAS;EAGrG,gBAAgB,IAAI,KAAK,QAAQ;CAClC;CACA,OAAO;AACR;AAEA,MAAM,aAAa;;;;;;;;;;AAWnB,SAAgB,SAAS,KAAK,MAAM;CACnC,OAAO,IAAI,QAAQ,aAAa,KAAK,QAAQ;EAC5C,IAAI,QAAQ,KAAK;EAEjB,IAAI,UAAU,KAAA,GACb,MAAM,IAAI,MAAM,kCAAkC,KAAK;OAEjD,IAAI,OAAO,UAAU,YAC3B,QAAQ,MAAM,IAAI;EAEnB,OAAO;CACR,CAAC;AACF"}
1
+ {"version":3,"file":"Util.js","names":[],"sources":["../../../src/core/Util.js"],"sourcesContent":["// Util: various utility functions, used by Maplair internally.\n\n/**\n * Last unique ID used by [`stamp()`](#util-stamp).\n * @type {number}\n */\nexport let lastId = 0;\n\n/**\n * Returns the unique ID of an object, assigning it one if it doesn't have it.\n * @param {object} obj\n * @returns {number}\n */\nexport function stamp(obj) {\n\tif (!('_maplair_id' in obj)) {\n\t\tobj['_maplair_id'] = ++lastId;\n\t}\n\treturn obj._maplair_id;\n}\n\n/**\n * Returns a function which executes function `fn` with the given scope `context`\n * (so that the `this` keyword refers to `context` inside `fn`'s code). The function\n * `fn` will be called no more than one time per given amount of `time`. The arguments\n * received by the bound function will be any arguments passed when binding the\n * function, followed by any arguments passed when invoking the bound function.\n * @param {(...args: any[]) => void} fn\n * @param {number} time In milliseconds.\n * @param {object} [context]\n * @returns {(...args: any[]) => void}\n */\nexport function throttle(fn, time, context) {\n\tlet lock, queuedArgs;\n\n\tfunction later() {\n\t\t// reset lock and call if queued\n\t\tlock = false;\n\t\tif (queuedArgs) {\n\t\t\twrapperFn.apply(context, queuedArgs);\n\t\t\tqueuedArgs = false;\n\t\t}\n\t}\n\n\tfunction wrapperFn(...args) {\n\t\tif (lock) {\n\t\t\t// called too soon, queue to call later\n\t\t\tqueuedArgs = args;\n\n\t\t} else {\n\t\t\t// call and lock until later\n\t\t\tfn.apply(context, args);\n\t\t\tsetTimeout(later, time);\n\t\t\tlock = true;\n\t\t}\n\t}\n\n\treturn wrapperFn;\n}\n\n/**\n * Returns the number `x` modulo `range` in such a way so it lies within\n * `range[0]` and `range[1]`. The returned value will always be smaller than\n * `range[1]` unless `includeMax` is set to `true`.\n * @param {number} x\n * @param {[number, number]} range\n * @param {boolean} [includeMax]\n * @returns {number}\n */\nexport function wrapNum(x, range, includeMax) {\n\tconst max = range[1],\n\tmin = range[0],\n\td = max - min;\n\treturn x === max && includeMax ? x : ((x - min) % d + d) % d + min;\n}\n\n/**\n * A function which always returns `false`.\n * @returns {false}\n */\nexport function falseFn() { return false; }\n\n/**\n * Returns the number `num` rounded with specified `precision`.\n * The default `precision` value is 6 decimal places.\n * `false` can be passed to skip any processing (can be useful to avoid round-off errors).\n * @param {number} num\n * @param {number|false} [precision]\n * @returns {number}\n */\nexport function formatNum(num, precision) {\n\tif (precision === false) { return num; }\n\tconst pow = 10 ** (precision === undefined ? 6 : precision);\n\treturn Math.round(num * pow) / pow;\n}\n\nconst WHITESPACE_RE = /\\s+/;\n\n/**\n * Trims and splits the string on whitespace and returns the array of parts.\n * @param {string} str\n * @returns {string[]}\n */\nexport function splitWords(str) {\n\treturn str.trim().split(WHITESPACE_RE);\n}\n\n/**\n * Merges the given properties to the `options` of the `obj` object, returning the\n * resulting options. See `Class options`.\n * @param {object} obj\n * @param {object} [options]\n * @returns {object}\n */\nexport function setOptions(obj, options) {\n\tif (!Object.hasOwn(obj, 'options')) {\n\t\tconst defaults = getDefaultOptions(obj.constructor) ?? obj.options;\n\t\tobj.options = defaults ? Object.create(defaults) : {};\n\t}\n\tfor (const i in options) {\n\t\tif (Object.hasOwn(options, i)) {\n\t\t\tobj.options[i] = options[i];\n\t\t}\n\t}\n\treturn obj.options;\n}\n\nconst chainedDefaults = new WeakMap(); // class -> the defaultOptions object it was chained with\n\n// Links the `defaultOptions` of each class in the chain to its parent's, so defaults are inherited and stay live.\n// Done on first use because a static field can't do it in its initializer and stay tree-shakeable.\nfunction getDefaultOptions(cls) {\n\tconst defaults = cls?.defaultOptions;\n\tif (defaults && chainedDefaults.get(cls) !== defaults) {\n\t\tfor (let c = cls; c.defaultOptions; c = Object.getPrototypeOf(c)) {\n\t\t\tif (Object.hasOwn(c, 'defaultOptions')) {\n\t\t\t\tObject.setPrototypeOf(c.defaultOptions, Object.getPrototypeOf(c).defaultOptions ?? Object.prototype);\n\t\t\t}\n\t\t}\n\t\tchainedDefaults.set(cls, defaults);\n\t}\n\treturn defaults;\n}\n\nconst templateRe = /\\{ *([\\w_ -]+) *\\}/g;\n\n/**\n * Simple templating facility, accepts a template string of the form `'Hello {a}, {b}'`\n * and a data object like `{a: 'foo', b: 'bar'}`, returns evaluated string\n * `('Hello foo, bar')`. You can also specify functions instead of strings for\n * data values — they will be evaluated passing `data` as an argument.\n * @param {string} str\n * @param {Record<string, any>} data\n * @returns {string}\n */\nexport function template(str, data) {\n\treturn str.replace(templateRe, (str, key) => {\n\t\tlet value = data[key];\n\n\t\tif (value === undefined) {\n\t\t\tthrow new Error(`No value provided for variable ${str}`);\n\n\t\t} else if (typeof value === 'function') {\n\t\t\tvalue = value(data);\n\t\t}\n\t\treturn value;\n\t});\n}\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;AAMA,IAAW,SAAS;;;;;;AAOpB,SAAgB,MAAM,KAAK;CAC1B,IAAI,EAAE,iBAAiB,MACtB,IAAI,iBAAiB,EAAE;CAExB,OAAO,IAAI;AACZ;;;;;;;;;;;;AAaA,SAAgB,SAAS,IAAI,MAAM,SAAS;CAC3C,IAAI,MAAM;CAEV,SAAS,QAAQ;EAEhB,OAAO;EACP,IAAI,YAAY;GACf,UAAU,MAAM,SAAS,UAAU;GACnC,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GACpC,OAAO,eAAe,EAAE,gBAAgB,OAAO,eAAe,CAAC,CAAC,CAAC,kBAAkB,OAAO,SAAS;EAGrG,gBAAgB,IAAI,KAAK,QAAQ;CAClC;CACA,OAAO;AACR;AAEA,MAAM,aAAa;;;;;;;;;;AAWnB,SAAgB,SAAS,KAAK,MAAM;CACnC,OAAO,IAAI,QAAQ,aAAa,KAAK,QAAQ;EAC5C,IAAI,QAAQ,KAAK;EAEjB,IAAI,UAAU,KAAA,GACb,MAAM,IAAI,MAAM,kCAAkC,KAAK;OAEjD,IAAI,OAAO,UAAU,YAC3B,QAAQ,MAAM,IAAI;EAEnB,OAAO;CACR,CAAC;AACF"}
@@ -1,4 +1,4 @@
1
- //#region src/dom/DomEvent.DoubleTap.js
1
+ // src/dom/DomEvent.DoubleTap.js
2
2
  function makeDblclick(ev) {
3
3
  const init = {
4
4
  bubbles: ev.bubbles,
@@ -85,7 +85,6 @@ function removeDoubleTapListener(obj, handlers) {
85
85
  obj.removeEventListener("pointerdown", handlers.onPointerDown, true);
86
86
  obj.removeEventListener("click", handlers.simDblclick);
87
87
  }
88
- //#endregion
89
88
  export { addDoubleTapListener, removeDoubleTapListener };
90
89
 
91
90
  //# sourceMappingURL=DomEvent.DoubleTap.js.map
@@ -1,5 +1,5 @@
1
1
  import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
- //#region src/dom/DomEvent.PointerEvents.js
2
+ // src/dom/DomEvent.PointerEvents.js
3
3
  var DomEvent_PointerEvents_exports = /* @__PURE__ */ __exportAll({
4
4
  disablePointerDetection: () => disablePointerDetection,
5
5
  enablePointerDetection: () => enablePointerDetection,
@@ -50,7 +50,6 @@ function _onDelete(e) {
50
50
  function getPointers() {
51
51
  return [...activePointers.values()];
52
52
  }
53
- //#endregion
54
53
  export { DomEvent_PointerEvents_exports, disablePointerDetection, enablePointerDetection, getPointers };
55
54
 
56
55
  //# sourceMappingURL=DomEvent.PointerEvents.js.map
@@ -4,7 +4,7 @@ import { Point } from "../geometry/Point.js";
4
4
  import { addDoubleTapListener, removeDoubleTapListener } from "./DomEvent.DoubleTap.js";
5
5
  import { DomEvent_PointerEvents_exports } from "./DomEvent.PointerEvents.js";
6
6
  import { getScale } from "./DomUtil.js";
7
- //#region src/dom/DomEvent.js
7
+ // src/dom/DomEvent.js
8
8
  var DomEvent_exports = /* @__PURE__ */ __exportAll({
9
9
  PointerEvents: () => DomEvent_PointerEvents_exports,
10
10
  disableClickPropagation: () => disableClickPropagation,
@@ -30,12 +30,11 @@ var DomEvent_exports = /* @__PURE__ */ __exportAll({
30
30
  * @param {string|Record<string, (ev: any) => void>} types
31
31
  * @param {((ev: any) => void)|object} [fn]
32
32
  * @param {object} [context]
33
- * @returns {typeof import('./DomEvent.js')}
33
+ * @returns {void}
34
34
  */
35
35
  function on(obj, types, fn, context) {
36
36
  if (types && typeof types === "object") for (const [type, listener] of Object.entries(types)) addOne(obj, type, listener, fn);
37
37
  else for (const type of splitWords(types)) addOne(obj, type, fn, context);
38
- return this;
39
38
  }
40
39
  const eventsKey = "_maplair_events";
41
40
  /**
@@ -49,7 +48,7 @@ const eventsKey = "_maplair_events";
49
48
  * @param {string|Record<string, (ev: any) => void>} [types]
50
49
  * @param {((ev: any) => void)|object} [fn]
51
50
  * @param {object} [context]
52
- * @returns {typeof import('./DomEvent.js')}
51
+ * @returns {void}
53
52
  */
54
53
  function off(obj, types, fn, context) {
55
54
  if (arguments.length === 1) {
@@ -61,7 +60,6 @@ function off(obj, types, fn, context) {
61
60
  if (arguments.length === 2) batchRemove(obj, (type) => types.includes(type));
62
61
  else for (const type of types) removeOne(obj, type, fn, context);
63
62
  }
64
- return this;
65
63
  }
66
64
  const DIGIT_RE = /\d/;
67
65
  function batchRemove(obj, filterFn) {
@@ -72,7 +70,7 @@ function batchRemove(obj, filterFn) {
72
70
  }
73
71
  function addOne(obj, type, fn, context) {
74
72
  const id = type + stamp(fn) + (context ? `_${stamp(context)}` : "");
75
- if (obj[eventsKey] && obj[eventsKey][id]) return this;
73
+ if (obj[eventsKey] && obj[eventsKey][id]) return;
76
74
  let handler = function(e) {
77
75
  return fn.call(context || obj, e);
78
76
  };
@@ -84,7 +82,7 @@ function addOne(obj, type, fn, context) {
84
82
  function removeOne(obj, type, fn, context, id) {
85
83
  id ??= type + stamp(fn) + (context ? `_${stamp(context)}` : "");
86
84
  const handler = obj[eventsKey] && obj[eventsKey][id];
87
- if (!handler) return this;
85
+ if (!handler) return;
88
86
  if (type === "dblclick") removeDoubleTapListener(obj, handler);
89
87
  else obj.removeEventListener(type, handler, false);
90
88
  obj[eventsKey][id] = null;
@@ -97,22 +95,20 @@ function removeOne(obj, type, fn, context, id) {
97
95
  * ```
98
96
  * Also accepts a Maplair event with an `originalEvent`.
99
97
  * @param {Event|{originalEvent: Event}} e
100
- * @returns {typeof import('./DomEvent.js')}
98
+ * @returns {void}
101
99
  */
102
100
  function stopPropagation(e) {
103
101
  if (e.stopPropagation) e.stopPropagation();
104
102
  else if (e.originalEvent) e.originalEvent._stopped = true;
105
103
  else console.debug("Unsupported event", e);
106
- return this;
107
104
  }
108
105
  /**
109
106
  * Adds `stopPropagation` to the element's `'wheel'` events (plus browser variants).
110
107
  * @param {HTMLElement} el
111
- * @returns {typeof import('./DomEvent.js')}
108
+ * @returns {void}
112
109
  */
113
110
  function disableScrollPropagation(el) {
114
111
  addOne(el, "wheel", stopPropagation);
115
- return this;
116
112
  }
117
113
  /**
118
114
  * Adds `stopPropagation` to the element's `'dblclick'`, `'contextmenu'`
@@ -120,12 +116,11 @@ function disableScrollPropagation(el) {
120
116
  * For `'click'` events, prevents the map from handling the click
121
117
  * while still allowing the native DOM click event to propagate normally.
122
118
  * @param {HTMLElement} el
123
- * @returns {typeof import('./DomEvent.js')}
119
+ * @returns {void}
124
120
  */
125
121
  function disableClickPropagation(el) {
126
122
  on(el, "pointerdown dblclick contextmenu", stopPropagation);
127
123
  el["_maplair_disable_click"] = true;
128
- return this;
129
124
  }
130
125
  /**
131
126
  * Prevents the default action of the DOM Event `e` from happening (such as
@@ -133,21 +128,19 @@ function disableClickPropagation(el) {
133
128
  * with page reload when a `<form>` is submitted).
134
129
  * Use it inside listener functions.
135
130
  * @param {Event} e
136
- * @returns {typeof import('./DomEvent.js')}
131
+ * @returns {void}
137
132
  */
138
133
  function preventDefault(e) {
139
134
  e.preventDefault?.();
140
- return this;
141
135
  }
142
136
  /**
143
137
  * Does `stopPropagation` and `preventDefault` at the same time.
144
138
  * @param {Event} e
145
- * @returns {typeof import('./DomEvent.js')}
139
+ * @returns {void}
146
140
  */
147
141
  function stop(e) {
148
142
  preventDefault(e);
149
143
  stopPropagation(e);
150
- return this;
151
144
  }
152
145
  /**
153
146
  * Gets normalized pointer position from a DOM event relative to the
@@ -190,7 +183,6 @@ function getWheelDelta(e) {
190
183
  function isExternalTarget(el, e) {
191
184
  return !el.contains(e.relatedTarget);
192
185
  }
193
- //#endregion
194
186
  export { DomEvent_exports, DomEvent_PointerEvents_exports as PointerEvents, disableClickPropagation, disableScrollPropagation, getPointerPosition, getWheelDelta, getWheelPxFactor, isExternalTarget, off, on, preventDefault, stop, stopPropagation };
195
187
 
196
188
  //# sourceMappingURL=DomEvent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DomEvent.js","names":["Util.splitWords","Util.stamp"],"sources":["../../../src/dom/DomEvent.js"],"sourcesContent":["import {Point} from '../geometry/Point.js';\nimport * as Util from '../core/Util.js';\nimport {addDoubleTapListener, removeDoubleTapListener} from './DomEvent.DoubleTap.js';\nimport {getScale} from './DomUtil.js';\n\nimport * as PointerEvents from './DomEvent.PointerEvents.js';\nexport {PointerEvents};\n\n// DomEvent: utility functions to work with the\n// [DOM events](https://developer.mozilla.org/docs/Web/API/Event), used by Maplair\n// internally. The functions return the `DomEvent` namespace for chaining.\n\n// Inspired by John Resig, Dean Edwards and YUI addEvent implementations.\n\n/**\n * Adds a listener function (`fn`) to a particular DOM event type of the\n * element `obj`. You can optionally specify the context of the listener\n * (object the `this` keyword will point to). You can also pass several\n * space-separated types (e.g. `'click dblclick'`). Alternatively, adds a set of\n * type/listener pairs, e.g. `{click: onClick, pointermove: onPointerMove}`, with the\n * context as third argument.\n * @param {EventTarget} obj\n * @param {string|Record<string, (ev: any) => void>} types\n * @param {((ev: any) => void)|object} [fn]\n * @param {object} [context]\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function on(obj, types, fn, context) {\n\n\tif (types && typeof types === 'object') {\n\t\tfor (const [type, listener] of Object.entries(types)) {\n\t\t\taddOne(obj, type, listener, fn);\n\t\t}\n\t} else {\n\t\tfor (const type of Util.splitWords(types)) {\n\t\t\taddOne(obj, type, fn, context);\n\t\t}\n\t}\n\n\treturn this;\n}\n\nconst eventsKey = '_maplair_events';\n\n/**\n * Removes a previously added listener function.\n * Note that if you passed a custom context to on, you must pass the same\n * context to `off` in order to remove the listener. Alternatively, removes a set of\n * type/listener pairs, e.g. `{click: onClick, pointermove: onPointerMove}`; with\n * `types` only, removes all previously added listeners of given types; with the\n * element only, removes all previously added listeners from the given element.\n * @param {EventTarget} obj\n * @param {string|Record<string, (ev: any) => void>} [types]\n * @param {((ev: any) => void)|object} [fn]\n * @param {object} [context]\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function off(obj, types, fn, context) {\n\n\tif (arguments.length === 1) {\n\t\tbatchRemove(obj);\n\t\tdelete obj[eventsKey];\n\n\t} else if (types && typeof types === 'object') {\n\t\tfor (const [type, listener] of Object.entries(types)) {\n\t\t\tremoveOne(obj, type, listener, fn);\n\t\t}\n\n\t} else {\n\t\ttypes = Util.splitWords(types);\n\n\t\tif (arguments.length === 2) {\n\t\t\tbatchRemove(obj, type => types.includes(type));\n\t\t} else {\n\t\t\tfor (const type of types) {\n\t\t\t\tremoveOne(obj, type, fn, context);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn this;\n}\n\nconst DIGIT_RE = /\\d/;\n\nfunction batchRemove(obj, filterFn) {\n\tfor (const id of Object.keys(obj[eventsKey] ?? {})) {\n\t\tconst type = id.split(DIGIT_RE)[0];\n\t\tif (!filterFn || filterFn(type)) {\n\t\t\tremoveOne(obj, type, null, null, id);\n\t\t}\n\t}\n}\n\nfunction addOne(obj, type, fn, context) {\n\tconst id = type + Util.stamp(fn) + (context ? `_${Util.stamp(context)}` : '');\n\n\tif (obj[eventsKey] && obj[eventsKey][id]) { return this; }\n\n\tlet handler = function (e) {\n\t\treturn fn.call(context || obj, e);\n\t};\n\n\tif (type === 'dblclick') {\n\t\thandler = addDoubleTapListener(obj, handler);\n\t} else {\n\t\tobj.addEventListener(type, handler, type === 'wheel' ? {passive: false} : false);\n\t}\n\n\tobj[eventsKey] ??= {};\n\tobj[eventsKey][id] = handler;\n}\n\nfunction removeOne(obj, type, fn, context, id) {\n\tid ??= type + Util.stamp(fn) + (context ? `_${Util.stamp(context)}` : '');\n\tconst handler = obj[eventsKey] && obj[eventsKey][id];\n\n\tif (!handler) { return this; }\n\n\tif (type === 'dblclick') {\n\t\tremoveDoubleTapListener(obj, handler);\n\t} else {\n\t\tobj.removeEventListener(type, handler, false);\n\t}\n\n\tobj[eventsKey][id] = null;\n}\n\n/**\n * Stop the given event from propagation to parent elements. Used inside the listener\n * functions:\n * ```js\n * DomEvent.on(div, 'click', DomEvent.stopPropagation);\n * ```\n * Also accepts a Maplair event with an `originalEvent`.\n * @param {Event|{originalEvent: Event}} e\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function stopPropagation(e) {\n\n\t// feature detection rather than `instanceof Event`, which fails for events from other windows (e.g. iframes)\n\tif (e.stopPropagation) {\n\t\te.stopPropagation();\n\t} else if (e.originalEvent) { // In case of Maplair event.\n\t\te.originalEvent._stopped = true;\n\t} else {\n\t\t// custom Maplair event\n\t\tconsole.debug('Unsupported event', e);\n\t}\n\n\treturn this;\n}\n\n/**\n * Adds `stopPropagation` to the element's `'wheel'` events (plus browser variants).\n * @param {HTMLElement} el\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function disableScrollPropagation(el) {\n\taddOne(el, 'wheel', stopPropagation);\n\treturn this;\n}\n\n/**\n * Adds `stopPropagation` to the element's `'dblclick'`, `'contextmenu'`\n * and `'pointerdown'` events (plus browser variants).\n * For `'click'` events, prevents the map from handling the click\n * while still allowing the native DOM click event to propagate normally.\n * @param {HTMLElement} el\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function disableClickPropagation(el) {\n\ton(el, 'pointerdown dblclick contextmenu', stopPropagation);\n\tel['_maplair_disable_click'] = true;\n\treturn this;\n}\n\n/**\n * Prevents the default action of the DOM Event `e` from happening (such as\n * following a link in the href of the a element, or doing a POST request\n * with page reload when a `<form>` is submitted).\n * Use it inside listener functions.\n * @param {Event} e\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function preventDefault(e) {\n\te.preventDefault?.();\n\treturn this;\n}\n\n/**\n * Does `stopPropagation` and `preventDefault` at the same time.\n * @param {Event} e\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function stop(e) {\n\tpreventDefault(e);\n\tstopPropagation(e);\n\treturn this;\n}\n\n/**\n * Gets normalized pointer position from a DOM event relative to the\n * `container` (border excluded) or to the whole page if not specified.\n * @param {MouseEvent|Touch} e\n * @param {HTMLElement} [container]\n * @returns {Point}\n */\nexport function getPointerPosition(e, container) {\n\tif (!container) {\n\t\treturn new Point(e.clientX, e.clientY);\n\t}\n\n\tconst scale = getScale(container),\n\toffset = scale.boundingClientRect; // left and top values are in page scale (like the event clientX/Y)\n\n\treturn new Point(\n\t\t// offset.left/top values are in page scale (like clientX/Y),\n\t\t// whereas clientLeft/Top (border width) values are the original values (before CSS scale applies).\n\t\t(e.clientX - offset.left) / scale.x - container.clientLeft,\n\t\t(e.clientY - offset.top) / scale.y - container.clientTop\n\t);\n}\n\n/**\n * Gets the wheel pixel factor based on the devicePixelRatio.\n * @returns {number}\n */\nexport function getWheelPxFactor() {\n\t// We need double the scroll pixels (see #7403 and #4538)\n\treturn window.devicePixelRatio * 2;\n}\n\n/**\n * Gets normalized wheel delta from a wheel DOM event, in vertical\n * pixels scrolled (negative if scrolling down).\n * Events from pointing devices without precise scrolling are mapped to\n * a best guess of 60 pixels.\n * @param {WheelEvent} e\n * @returns {number}\n */\nexport function getWheelDelta(e) {\n\treturn (e.deltaY && e.deltaMode === 0) ? -e.deltaY / getWheelPxFactor() : // Pixels\n\t\t(e.deltaY && e.deltaMode === 1) ? -e.deltaY * 20 : // Lines\n\t\t(e.deltaY && e.deltaMode === 2) ? -e.deltaY * 60 : // Pages\n\t\t(e.deltaX || e.deltaZ) ? 0 :\t// Skip horizontal/depth wheel events\n\t\t0;\n}\n\n/**\n * Checks if the pointer really left/entered the element `el` (for\n * `pointerover`/`pointerout`).\n * @internal\n * @param {Node} el\n * @param {MouseEvent} e\n * @returns {boolean}\n */\nexport function isExternalTarget(el, e) {\n\treturn !el.contains(e.relatedTarget);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,GAAG,KAAK,OAAO,IAAI,SAAS;CAE3C,IAAI,SAAS,OAAO,UAAU,UAC7B,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,KAAK,GAClD,OAAO,KAAK,MAAM,UAAU,EAAE;MAG/B,KAAK,MAAM,QAAQA,WAAgB,KAAK,GACvC,OAAO,KAAK,MAAM,IAAI,OAAO;CAI/B,OAAO;AACR;AAEA,MAAM,YAAY;;;;;;;;;;;;;;AAelB,SAAgB,IAAI,KAAK,OAAO,IAAI,SAAS;CAE5C,IAAI,UAAU,WAAW,GAAG;EAC3B,YAAY,GAAG;EACf,OAAO,IAAI;CAEZ,OAAO,IAAI,SAAS,OAAO,UAAU,UACpC,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,KAAK,GAClD,UAAU,KAAK,MAAM,UAAU,EAAE;MAG5B;EACN,QAAQA,WAAgB,KAAK;EAE7B,IAAI,UAAU,WAAW,GACxB,YAAY,MAAK,SAAQ,MAAM,SAAS,IAAI,CAAC;OAE7C,KAAK,MAAM,QAAQ,OAClB,UAAU,KAA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R;;;;;;AAOA,SAAgB,yBAAyB,IAAI;CAC5C,OAAO,IAAI,SAAS,eAAe;CACnC,OAAO;AACR;;;;;;;;;AAUA,SAAgB,wBAAwB,IAAI;CAC3C,GAAG,IAAI,oCAAoC,eAAe;CAC1D,GAAG,4BAA4B;CAC/B,OAAO;AACR;;;;;;;;;AAUA,SAAgB,eAAe,GAAG;CACjC,EAAE,iBAAiB;CACnB,OAAO;AACR;;;;;;AAOA,SAAgB,KAAK,GAAG;CACvB,eAAe,CAAC;CAChB,gBAAgB,CAAC;CACjB,OAAO;AACR;;;;;;;;AASA,SAAgB,mBAAmB,GAAG,WAAW;CAChD,IAAI,CAAC,WACJ,OAAO,IAAI,MAAM,EAAE,SAAS,EAAE,OAAO;CAGtC,MAAM,QAAQ,SAAS,SAAS,GAChC,SAAS,MAAM;CAEf,OAAO,IAAI,OAGT,EAAE,UAAU,OAAO,QAAQ,MAAM,IAAI,UAAU,aAC/C,EAAE,UAAU,OAAO,OAAO,MAAM,IAAI,UAAU,SAChD;AACD;;;;;AAMA,SAAgB,mBAAmB;CAElC,OAAO,OAAO,mBAAmB;AAClC;;;;;;;;;AAUA,SAAgB,cAAc,GAAG;CAChC,OAAQ,EAAE,UAAU,EAAE,cAAc,IAAK,CAAC,EAAE,SAAS,iBAAiB,IACpE,EAAE,UAAU,EAAE,cAAc,IAAK,CAAC,EAAE,SAAS,KAC7C,EAAE,UAAU,EAAE,cAAc,IAAK,CAAC,EAAE,SAAS,KAC7C,EAAE,UAAU,EAAE,SAAU,IACzB;AACF;;;;;;;;;AAUA,SAAgB,iBAAiB,IAAI,GAAG;CACvC,OAAO,CAAC,GAAG,SAAS,EAAE,aAAa;AACpC"}
1
+ {"version":3,"file":"DomEvent.js","names":["Util.splitWords","Util.stamp"],"sources":["../../../src/dom/DomEvent.js"],"sourcesContent":["import {Point} from '../geometry/Point.js';\nimport * as Util from '../core/Util.js';\nimport {addDoubleTapListener, removeDoubleTapListener} from './DomEvent.DoubleTap.js';\nimport {getScale} from './DomUtil.js';\n\nimport * as PointerEvents from './DomEvent.PointerEvents.js';\nexport {PointerEvents};\n\n// DomEvent: utility functions to work with the\n// [DOM events](https://developer.mozilla.org/docs/Web/API/Event), used by Maplair\n// internally. The functions return the `DomEvent` namespace for chaining.\n\n// Inspired by John Resig, Dean Edwards and YUI addEvent implementations.\n\n/**\n * Adds a listener function (`fn`) to a particular DOM event type of the\n * element `obj`. You can optionally specify the context of the listener\n * (object the `this` keyword will point to). You can also pass several\n * space-separated types (e.g. `'click dblclick'`). Alternatively, adds a set of\n * type/listener pairs, e.g. `{click: onClick, pointermove: onPointerMove}`, with the\n * context as third argument.\n * @param {EventTarget} obj\n * @param {string|Record<string, (ev: any) => void>} types\n * @param {((ev: any) => void)|object} [fn]\n * @param {object} [context]\n * @returns {void}\n */\nexport function on(obj, types, fn, context) {\n\n\tif (types && typeof types === 'object') {\n\t\tfor (const [type, listener] of Object.entries(types)) {\n\t\t\taddOne(obj, type, listener, fn);\n\t\t}\n\t} else {\n\t\tfor (const type of Util.splitWords(types)) {\n\t\t\taddOne(obj, type, fn, context);\n\t\t}\n\t}\n}\n\nconst eventsKey = '_maplair_events';\n\n/**\n * Removes a previously added listener function.\n * Note that if you passed a custom context to on, you must pass the same\n * context to `off` in order to remove the listener. Alternatively, removes a set of\n * type/listener pairs, e.g. `{click: onClick, pointermove: onPointerMove}`; with\n * `types` only, removes all previously added listeners of given types; with the\n * element only, removes all previously added listeners from the given element.\n * @param {EventTarget} obj\n * @param {string|Record<string, (ev: any) => void>} [types]\n * @param {((ev: any) => void)|object} [fn]\n * @param {object} [context]\n * @returns {void}\n */\nexport function off(obj, types, fn, context) {\n\n\tif (arguments.length === 1) {\n\t\tbatchRemove(obj);\n\t\tdelete obj[eventsKey];\n\n\t} else if (types && typeof types === 'object') {\n\t\tfor (const [type, listener] of Object.entries(types)) {\n\t\t\tremoveOne(obj, type, listener, fn);\n\t\t}\n\n\t} else {\n\t\ttypes = Util.splitWords(types);\n\n\t\tif (arguments.length === 2) {\n\t\t\tbatchRemove(obj, type => types.includes(type));\n\t\t} else {\n\t\t\tfor (const type of types) {\n\t\t\t\tremoveOne(obj, type, fn, context);\n\t\t\t}\n\t\t}\n\t}\n}\n\nconst DIGIT_RE = /\\d/;\n\nfunction batchRemove(obj, filterFn) {\n\tfor (const id of Object.keys(obj[eventsKey] ?? {})) {\n\t\tconst type = id.split(DIGIT_RE)[0];\n\t\tif (!filterFn || filterFn(type)) {\n\t\t\tremoveOne(obj, type, null, null, id);\n\t\t}\n\t}\n}\n\nfunction addOne(obj, type, fn, context) {\n\tconst id = type + Util.stamp(fn) + (context ? `_${Util.stamp(context)}` : '');\n\n\tif (obj[eventsKey] && obj[eventsKey][id]) { return; }\n\n\tlet handler = function (e) {\n\t\treturn fn.call(context || obj, e);\n\t};\n\n\tif (type === 'dblclick') {\n\t\thandler = addDoubleTapListener(obj, handler);\n\t} else {\n\t\tobj.addEventListener(type, handler, type === 'wheel' ? {passive: false} : false);\n\t}\n\n\tobj[eventsKey] ??= {};\n\tobj[eventsKey][id] = handler;\n}\n\nfunction removeOne(obj, type, fn, context, id) {\n\tid ??= type + Util.stamp(fn) + (context ? `_${Util.stamp(context)}` : '');\n\tconst handler = obj[eventsKey] && obj[eventsKey][id];\n\n\tif (!handler) { return; }\n\n\tif (type === 'dblclick') {\n\t\tremoveDoubleTapListener(obj, handler);\n\t} else {\n\t\tobj.removeEventListener(type, handler, false);\n\t}\n\n\tobj[eventsKey][id] = null;\n}\n\n/**\n * Stop the given event from propagation to parent elements. Used inside the listener\n * functions:\n * ```js\n * DomEvent.on(div, 'click', DomEvent.stopPropagation);\n * ```\n * Also accepts a Maplair event with an `originalEvent`.\n * @param {Event|{originalEvent: Event}} e\n * @returns {void}\n */\nexport function stopPropagation(e) {\n\n\t// feature detection rather than `instanceof Event`, which fails for events from other windows (e.g. iframes)\n\tif (e.stopPropagation) {\n\t\te.stopPropagation();\n\t} else if (e.originalEvent) { // In case of Maplair event.\n\t\te.originalEvent._stopped = true;\n\t} else {\n\t\t// custom Maplair event\n\t\tconsole.debug('Unsupported event', e);\n\t}\n}\n\n/**\n * Adds `stopPropagation` to the element's `'wheel'` events (plus browser variants).\n * @param {HTMLElement} el\n * @returns {void}\n */\nexport function disableScrollPropagation(el) {\n\taddOne(el, 'wheel', stopPropagation);\n}\n\n/**\n * Adds `stopPropagation` to the element's `'dblclick'`, `'contextmenu'`\n * and `'pointerdown'` events (plus browser variants).\n * For `'click'` events, prevents the map from handling the click\n * while still allowing the native DOM click event to propagate normally.\n * @param {HTMLElement} el\n * @returns {void}\n */\nexport function disableClickPropagation(el) {\n\ton(el, 'pointerdown dblclick contextmenu', stopPropagation);\n\tel['_maplair_disable_click'] = true;\n}\n\n/**\n * Prevents the default action of the DOM Event `e` from happening (such as\n * following a link in the href of the a element, or doing a POST request\n * with page reload when a `<form>` is submitted).\n * Use it inside listener functions.\n * @param {Event} e\n * @returns {void}\n */\nexport function preventDefault(e) {\n\te.preventDefault?.();\n}\n\n/**\n * Does `stopPropagation` and `preventDefault` at the same time.\n * @param {Event} e\n * @returns {void}\n */\nexport function stop(e) {\n\tpreventDefault(e);\n\tstopPropagation(e);\n}\n\n/**\n * Gets normalized pointer position from a DOM event relative to the\n * `container` (border excluded) or to the whole page if not specified.\n * @param {MouseEvent|Touch} e\n * @param {HTMLElement} [container]\n * @returns {Point}\n */\nexport function getPointerPosition(e, container) {\n\tif (!container) {\n\t\treturn new Point(e.clientX, e.clientY);\n\t}\n\n\tconst scale = getScale(container),\n\toffset = scale.boundingClientRect; // left and top values are in page scale (like the event clientX/Y)\n\n\treturn new Point(\n\t\t// offset.left/top values are in page scale (like clientX/Y),\n\t\t// whereas clientLeft/Top (border width) values are the original values (before CSS scale applies).\n\t\t(e.clientX - offset.left) / scale.x - container.clientLeft,\n\t\t(e.clientY - offset.top) / scale.y - container.clientTop\n\t);\n}\n\n/**\n * Gets the wheel pixel factor based on the devicePixelRatio.\n * @returns {number}\n */\nexport function getWheelPxFactor() {\n\t// We need double the scroll pixels (see #7403 and #4538)\n\treturn window.devicePixelRatio * 2;\n}\n\n/**\n * Gets normalized wheel delta from a wheel DOM event, in vertical\n * pixels scrolled (negative if scrolling down).\n * Events from pointing devices without precise scrolling are mapped to\n * a best guess of 60 pixels.\n * @param {WheelEvent} e\n * @returns {number}\n */\nexport function getWheelDelta(e) {\n\treturn (e.deltaY && e.deltaMode === 0) ? -e.deltaY / getWheelPxFactor() : // Pixels\n\t\t(e.deltaY && e.deltaMode === 1) ? -e.deltaY * 20 : // Lines\n\t\t(e.deltaY && e.deltaMode === 2) ? -e.deltaY * 60 : // Pages\n\t\t(e.deltaX || e.deltaZ) ? 0 :\t// Skip horizontal/depth wheel events\n\t\t0;\n}\n\n/**\n * Checks if the pointer really left/entered the element `el` (for\n * `pointerover`/`pointerout`).\n * @internal\n * @param {Node} el\n * @param {MouseEvent} e\n * @returns {boolean}\n */\nexport function isExternalTarget(el, e) {\n\treturn !el.contains(e.relatedTarget);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,GAAG,KAAK,OAAO,IAAI,SAAS;CAE3C,IAAI,SAAS,OAAO,UAAU,UAC7B,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,KAAK,GAClD,OAAO,KAAK,MAAM,UAAU,EAAE;MAG/B,KAAK,MAAM,QAAQA,WAAgB,KAAK,GACvC,OAAO,KAAK,MAAM,IAAI,OAAO;AAGhC;AAEA,MAAM,YAAY;;;;;;;;;;;;;;AAelB,SAAgB,IAAI,KAAK,OAAO,IAAI,SAAS;CAE5C,IAAI,UAAU,WAAW,GAAG;EAC3B,YAAY,GAAG;EACf,OAAO,IAAI;CAEZ,OAAO,IAAI,SAAS,OAAO,UAAU,UACpC,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,KAAK,GAClD,UAAU,KAAK,MAAM,UAAU,EAAE;MAG5B;EACN,QAAQA,WAAgB,KAAK;EAE7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,IAAI,EAAE,eACZ,EAAE,cAAc,WAAW;MAG3B,QAAQ,MAAM,qBAAqB,CAAC;AAEtC;;;;;;AAOA,SAAgB,yBAAyB,IAAI;CAC5C,OAAO,IAAI,SAAS,eAAe;AACpC;;;;;;;;;AAUA,SAAgB,wBAAwB,IAAI;CAC3C,GAAG,IAAI,oCAAoC,eAAe;CAC1D,GAAG,4BAA4B;AAChC;;;;;;;;;AAUA,SAAgB,eAAe,GAAG;CACjC,EAAE,iBAAiB;AACpB;;;;;;AAOA,SAAgB,KAAK,GAAG;CACvB,eAAe,CAAC;CAChB,gBAAgB,CAAC;AAClB;;;;;;;;AASA,SAAgB,mBAAmB,GAAG,WAAW;CAChD,IAAI,CAAC,WACJ,OAAO,IAAI,MAAM,EAAE,SAAS,EAAE,OAAO;CAGtC,MAAM,QAAQ,SAAS,SAAS,GAChC,SAAS,MAAM;CAEf,OAAO,IAAI,OAGT,EAAE,UAAU,OAAO,QAAQ,MAAM,IAAI,UAAU,aAC/C,EAAE,UAAU,OAAO,OAAO,MAAM,IAAI,UAAU,SAChD;AACD;;;;;AAMA,SAAgB,mBAAmB;CAElC,OAAO,OAAO,mBAAmB;AAClC;;;;;;;;;AAUA,SAAgB,cAAc,GAAG;CAChC,OAAQ,EAAE,UAAU,EAAE,cAAc,IAAK,CAAC,EAAE,SAAS,iBAAiB,IACpE,EAAE,UAAU,EAAE,cAAc,IAAK,CAAC,EAAE,SAAS,KAC7C,EAAE,UAAU,EAAE,cAAc,IAAK,CAAC,EAAE,SAAS,KAC7C,EAAE,UAAU,EAAE,SAAU,IACzB;AACF;;;;;;;;;AAUA,SAAgB,iBAAiB,IAAI,GAAG;CACvC,OAAO,CAAC,GAAG,SAAS,EAAE,aAAa;AACpC"}
@@ -1,7 +1,7 @@
1
1
  import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
2
  import { Point } from "../geometry/Point.js";
3
3
  import { off, on, preventDefault } from "./DomEvent.js";
4
- //#region src/dom/DomUtil.js
4
+ // src/dom/DomUtil.js
5
5
  var DomUtil_exports = /* @__PURE__ */ __exportAll({
6
6
  create: () => create,
7
7
  disableImageDrag: () => disableImageDrag,
@@ -141,7 +141,6 @@ function getScale(element) {
141
141
  boundingClientRect: rect
142
142
  };
143
143
  }
144
- //#endregion
145
144
  export { DomUtil_exports, create, disableImageDrag, enableImageDrag, get, getPosition, getScale, getSizedParentNode, setPosition, setTransform, toBack, toFront };
146
145
 
147
146
  //# sourceMappingURL=DomUtil.js.map