ol-contextmenu 5.1.3 → 5.1.4

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.
@@ -1,8 +1,8 @@
1
1
 
2
2
  /*!
3
- * ol-contextmenu - v5.1.3
3
+ * ol-contextmenu - v5.1.4
4
4
  * https://github.com/jonataswalker/ol-contextmenu
5
- * Built: Mon Dec 26 2022 20:57:30 GMT-0300 (Brasilia Standard Time)
5
+ * Built: Mon Dec 26 2022 21:16:02 GMT-0300 (Brasilia Standard Time)
6
6
  */
7
7
 
8
8
  .ol-ctx-menu-container{position:absolute;padding:8px;background:#fff;color:#222;font-size:13px;border-radius:5px;box-shadow:#0003 3px 3px 5px;box-sizing:border-box}.ol-ctx-menu-container div,.ol-ctx-menu-container span,.ol-ctx-menu-container a,.ol-ctx-menu-container img,.ol-ctx-menu-container ul,.ol-ctx-menu-container li{margin:0;padding:0;border:0;font:inherit;font-size:100%;vertical-align:baseline}.ol-ctx-menu-container a img{border:none}.ol-ctx-menu-container *,.ol-ctx-menu-container *:before,.ol-ctx-menu-container *:after{box-sizing:inherit}.ol-ctx-menu-container.ol-ctx-menu-hidden{opacity:0;visibility:hidden;transition:visibility 0s linear .3s,opacity .3s}.ol-ctx-menu-container ul{list-style:none}.ol-ctx-menu-container li{position:relative;line-height:20px;padding:2px 5px;white-space:nowrap}.ol-ctx-menu-container li:not(.ol-ctx-menu-separator):hover{cursor:pointer;background-color:#333;color:#eee}.ol-ctx-menu-container li.ol-ctx-menu-submenu .ol-ctx-menu-container{border:1px solid #eee;padding:8px;top:0;opacity:0;visibility:hidden;transition:visibility 0s linear .3s,opacity .3s}.ol-ctx-menu-container li.ol-ctx-menu-submenu:after{position:absolute;top:7px;right:10px;content:"";display:inline-block;width:.6em;height:.6em;border-right:.3em solid #222;border-top:.3em solid #222;transform:rotate(45deg)}.ol-ctx-menu-container li.ol-ctx-menu-submenu:hover:after{border-color:#eee}.ol-ctx-menu-container:not(.ol-ctx-menu-hidden) li.ol-ctx-menu-submenu:hover>.ol-ctx-menu-container{opacity:1;visibility:visible;transition-delay:0s}.ol-ctx-menu-container li.ol-ctx-menu-separator{padding:0}.ol-ctx-menu-container li.ol-ctx-menu-separator hr{border:0;height:1px;background-image:linear-gradient(to left,rgba(0,0,0,0),rgba(0,0,0,.75),rgba(0,0,0,0))}.ol-ctx-menu-icon{text-indent:20px;background-size:20px auto;background-repeat:no-repeat;background-position:left center}.ol-ctx-menu-zoom-in{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABaUlEQVQ4T72U7VHCQBCGn90GtAMuNGCswFiBWIFQgWMFxg6wArECsQKhArEBiB1Qwa1zgQn5IAYcxv13k71n3919L8KJQ07M47+BzgG9TRfZ/JBuWhS6BJFHRJICYrZGZIz3z5Ct2+B7gG6I6kt+wewdkQVwjtkAkR5mC8yu26A1oItR/cTsOweQBdgutD8G7jGm2PJ2n8oqUKIpIjd4HxTM8gvaT/F+AlmWnyWaIXKF95eNguFzTYFhNsdWu9kFgFlaFMANUH3D8wDLoLgSTSD2il8NCe2ZXQBxWDGwxmyUzzOMBZ7wy7Qb2K0wQfXjMOBuhlFpZtNty5sFaTQBuTusZdymeqs1SpYKcO9HkE3KbTd9WFijMHJQ5hBNEAYNq5Qd0dhyke0GiE4QzjqfW23mHT8Hl4DG4Lce3FPE7AtbBSdsbNqpoJLgYkRnNeUV+xwJDHTnUEkxHGbhBXUs5TjJjew/KPy94g+NRaIVRYmMXwAAAABJRU5ErkJggg==)}.ol-ctx-menu-container li:hover.ol-ctx-menu-zoom-in{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABc0lEQVQ4T71U21ECQRDsJgGdvQDECMQIxAjECMQILCPwzAAjECIQI0AiEDPQAPaWCBhrcKHuCUcV5f7dY3v6tUscefHIePhfwBBCF8CZqRCReRs1tQxDCH1VfQLQz4EsSY4AvIjIsgm8AhhCGKrqa9zwrqoLAKckB5HtguR1E2gBMITQU9VPAD8GICIGtl3e+xHJBwBT59xtHcsCYJZlUwA3kcGHbfDep51OZywi3/acZZm9vyJ5WR5o38uACmDunNt6ZwAkUxFZDwghDFT1jeSjiJinhVUBVNVJkiTDKO8CQA+AsbNQ7s1Ps0VVn5MkSfcCtmBoDZi1Bdx4eJ7zbBolrwPy3o9J3rWSHPs3A1BbjVKlYBaIyDgvu9LDXDU2RTZmXVW1oKyLxRD+OrkOrJLy5mVM0iaftDhuhVbsvBzMglzKUNW6IV/OOWtCM8MmVvEkmbwt83LaB19fdgOtVquUZJeknaDdobTwbOcvBzPcN/AXH1DFFWP7u9oAAAAASUVORK5CYII=)}.ol-ctx-menu-zoom-out{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABU0lEQVQ4T72U7VECMRRFz3sNaAdkacC1AtcKxApcKnCsQOwAK3CtQKxAqEBsANYOqCDPyTIC+8WCw5jfybn33dxEOPGSE/P4b6BzQG89RT47ZJoWhy5B5BGRZAMxWyEyxvtnyFdt8AagS1F9KQ6YvSMyB84xGyDSw2yO2XUbtAJ0MaqfmH0XAPIA2y7tj4F7jAm2uG1yWQZKNEHkBu+Dg2njWBJNEbnC+8uaIFRuWfuG2QxbbrOrUd0A1Tc8D7AIjkur7DAAsVf8MiWMZ3ZR2m02LPIMscATfjHqBnY7TFD9OAy4zTCCPG/MUKMM5O6wkXFr9dZq7FQqqHk/hDzbFa73cFONTZFDdRyiCcKg5rrSiLaXkiI6RjjrfG6VzDs+B5eAxuDXeYpmNRGzL2wZ/wof+du4GNFpBVqqz5HA4MM5VEYYDrOs+1I6Q9u/4Q8O9wN/AGgWjBVqQjjgAAAAAElFTkSuQmCC)}.ol-ctx-menu-container li:hover.ol-ctx-menu-zoom-out{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABYklEQVQ4T72U4VHCQBCF36tA91KAWIFYgViBWIFYgWMFYgdYgVCBWAFSgdiBFpAsFWSdxcDkQoBkhnF/ZjbfvX377ogjF4/Mw/8CVbUD4MynEJF5k2lqFapqz8yeAPRKkCXJEYAXEVnugm8BVXVgZq/FD+9mtgBwSrJfqF2QvN4FjYCq2jWzTwA/DhARh20qTdMRyQcA0xDCbZ3KCJhl2RTATaHgo+6HLMv8+xXJy+qB3l8FGoB5CKHsXcRV1b6ZvZF8FBH3NKotoJlNkiQZFONdlLtJ3rufbouZPSdJMjwIbKDQEzBrClx7eC4i33Uepmk6JnnXaOQifzMAtdGoRApugYiMI1uqKkrRWAfZo9MxM1+UZzFewl8mN4nYdVM83L7BkwbXLUrF3sfBLQDQBbDy08x8vOohXyEE71lVq9emuEk+3gZa3XYroCvwFyjP8yHJDsnxwaU08GxvS2uFhw78BbzWrxXgMbsHAAAAAElFTkSuQmCC)}
@@ -1,232 +1,191 @@
1
1
 
2
2
  /*!
3
- * ol-contextmenu - v5.1.3
3
+ * ol-contextmenu - v5.1.4
4
4
  * https://github.com/jonataswalker/ol-contextmenu
5
- * Built: Mon Dec 26 2022 20:57:30 GMT-0300 (Brasilia Standard Time)
5
+ * Built: Mon Dec 26 2022 21:16:02 GMT-0300 (Brasilia Standard Time)
6
6
  */
7
7
 
8
- var S = Object.defineProperty;
9
- var D = (i, e, t) => e in i ? S(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
10
- var c = (i, e, t) => (D(i, typeof e != "symbol" ? e + "" : e, t), t);
11
- import P from "ol/control/Control";
12
- class k {
13
- constructor(e) {
14
- this.propagationStopped, this.defaultPrevented, this.type = e, this.target = null;
15
- }
16
- preventDefault() {
17
- this.defaultPrevented = !0;
18
- }
19
- stopPropagation() {
20
- this.propagationStopped = !0;
21
- }
22
- }
23
- const T = k;
24
- class O extends T {
25
- constructor(e, t, n) {
26
- super(e), this.map = t, this.frameState = n !== void 0 ? n : null;
27
- }
28
- }
29
- const I = O;
30
- class z extends I {
31
- constructor(e, t, n, s, o, a) {
32
- super(e, t, o), this.originalEvent = n, this.pixel_ = null, this.coordinate_ = null, this.dragging = s !== void 0 ? s : !1, this.activePointers = a;
33
- }
34
- get pixel() {
35
- return this.pixel_ || (this.pixel_ = this.map.getEventPixel(this.originalEvent)), this.pixel_;
36
- }
37
- set pixel(e) {
38
- this.pixel_ = e;
39
- }
40
- get coordinate() {
41
- return this.coordinate_ || (this.coordinate_ = this.map.getCoordinateFromPixel(this.pixel)), this.coordinate_;
42
- }
43
- set coordinate(e) {
44
- this.coordinate_ = e;
45
- }
46
- preventDefault() {
47
- super.preventDefault(), "preventDefault" in this.originalEvent && this.originalEvent.preventDefault();
48
- }
49
- stopPropagation() {
50
- super.stopPropagation(), "stopPropagation" in this.originalEvent && this.originalEvent.stopPropagation();
51
- }
52
- }
53
- const H = z;
54
- var M = /* @__PURE__ */ ((i) => (i.CONTEXTMENU = "contextmenu", i.CLICK = "click", i.DBLCLICK = "dblclick", i))(M || {}), u = /* @__PURE__ */ ((i) => (i.BEFOREOPEN = "beforeopen", i.OPEN = "open", i.CLOSE = "close", i.ADD_MENU_ENTRY = "add-menu-entry", i))(u || {});
55
- class L extends H {
56
- constructor(e) {
57
- super(e.type, e.map, e.originalEvent);
8
+ var k = Object.defineProperty;
9
+ var T = (s, n, e) => n in s ? k(s, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[n] = e;
10
+ var l = (s, n, e) => (T(s, typeof n != "symbol" ? n + "" : n, e), e);
11
+ import O from "ol/control/Control";
12
+ import D from "ol/MapBrowserEvent";
13
+ var b = /* @__PURE__ */ ((s) => (s.CONTEXTMENU = "contextmenu", s.CLICK = "click", s.DBLCLICK = "dblclick", s))(b || {}), p = /* @__PURE__ */ ((s) => (s.BEFOREOPEN = "beforeopen", s.OPEN = "open", s.CLOSE = "close", s.ADD_MENU_ENTRY = "add-menu-entry", s))(p || {});
14
+ class L extends D {
15
+ constructor(n) {
16
+ super(n.type, n.map, n.originalEvent);
58
17
  }
59
18
  }
60
- const U = {
19
+ const _ = {
61
20
  width: 150,
62
21
  scrollAt: 4,
63
- eventType: M.CONTEXTMENU,
22
+ eventType: b.CONTEXTMENU,
64
23
  defaultItems: !0,
65
24
  items: []
66
- }, p = "ol-ctx-menu", r = {
67
- namespace: p,
68
- container: `${p}-container`,
69
- separator: `${p}-separator`,
70
- submenu: `${p}-submenu`,
71
- hidden: `${p}-hidden`,
72
- icon: `${p}-icon`,
73
- zoomIn: `${p}-zoom-in`,
74
- zoomOut: `${p}-zoom-out`,
25
+ }, u = "ol-ctx-menu", r = {
26
+ namespace: u,
27
+ container: `${u}-container`,
28
+ separator: `${u}-separator`,
29
+ submenu: `${u}-submenu`,
30
+ hidden: `${u}-hidden`,
31
+ icon: `${u}-icon`,
32
+ zoomIn: `${u}-zoom-in`,
33
+ zoomOut: `${u}-zoom-out`,
75
34
  unselectable: "ol-unselectable"
76
35
  }, w = [
77
36
  {
78
37
  text: "Zoom In",
79
38
  classname: `${r.zoomIn} ${r.icon}`,
80
- callback: (i, e) => {
81
- const t = e.getView();
82
- t.animate({
83
- zoom: Number(t.getZoom()) + 1,
39
+ callback: (s, n) => {
40
+ const e = n.getView();
41
+ e.animate({
42
+ zoom: Number(e.getZoom()) + 1,
84
43
  duration: 700,
85
- center: i.coordinate
44
+ center: s.coordinate
86
45
  });
87
46
  }
88
47
  },
89
48
  {
90
49
  text: "Zoom Out",
91
50
  classname: `${r.zoomOut} ${r.icon}`,
92
- callback: (i, e) => {
93
- const t = e.getView();
94
- t.animate({
95
- zoom: Number(t.getZoom()) - 1,
51
+ callback: (s, n) => {
52
+ const e = n.getView();
53
+ e.animate({
54
+ zoom: Number(e.getZoom()) - 1,
96
55
  duration: 700,
97
- center: i.coordinate
56
+ center: s.coordinate
98
57
  });
99
58
  }
100
59
  }
101
60
  ];
102
- var y = {}, F = {
61
+ var v = {}, I = {
103
62
  get exports() {
104
- return y;
63
+ return v;
105
64
  },
106
- set exports(i) {
107
- y = i;
65
+ set exports(s) {
66
+ v = s;
108
67
  }
109
68
  };
110
- function b() {
69
+ function x() {
111
70
  }
112
- b.prototype = {
113
- on: function(i, e, t) {
114
- var n = this.e || (this.e = {});
115
- return (n[i] || (n[i] = [])).push({
116
- fn: e,
117
- ctx: t
71
+ x.prototype = {
72
+ on: function(s, n, e) {
73
+ var t = this.e || (this.e = {});
74
+ return (t[s] || (t[s] = [])).push({
75
+ fn: n,
76
+ ctx: e
118
77
  }), this;
119
78
  },
120
- once: function(i, e, t) {
121
- var n = this;
122
- function s() {
123
- n.off(i, s), e.apply(t, arguments);
79
+ once: function(s, n, e) {
80
+ var t = this;
81
+ function i() {
82
+ t.off(s, i), n.apply(e, arguments);
124
83
  }
125
- return s._ = e, this.on(i, s, t);
84
+ return i._ = n, this.on(s, i, e);
126
85
  },
127
- emit: function(i) {
128
- var e = [].slice.call(arguments, 1), t = ((this.e || (this.e = {}))[i] || []).slice(), n = 0, s = t.length;
129
- for (n; n < s; n++)
130
- t[n].fn.apply(t[n].ctx, e);
86
+ emit: function(s) {
87
+ var n = [].slice.call(arguments, 1), e = ((this.e || (this.e = {}))[s] || []).slice(), t = 0, i = e.length;
88
+ for (t; t < i; t++)
89
+ e[t].fn.apply(e[t].ctx, n);
131
90
  return this;
132
91
  },
133
- off: function(i, e) {
134
- var t = this.e || (this.e = {}), n = t[i], s = [];
135
- if (n && e)
136
- for (var o = 0, a = n.length; o < a; o++)
137
- n[o].fn !== e && n[o].fn._ !== e && s.push(n[o]);
138
- return s.length ? t[i] = s : delete t[i], this;
92
+ off: function(s, n) {
93
+ var e = this.e || (this.e = {}), t = e[s], i = [];
94
+ if (t && n)
95
+ for (var o = 0, c = t.length; o < c; o++)
96
+ t[o].fn !== n && t[o].fn._ !== n && i.push(t[o]);
97
+ return i.length ? e[s] = i : delete e[s], this;
139
98
  }
140
99
  };
141
- F.exports = b;
142
- var B = y.TinyEmitter = b;
143
- const E = new B();
144
- function g(i) {
145
- const e = document.createDocumentFragment(), t = document.createElement("div");
146
- for (t.innerHTML = i; t.firstChild; )
147
- e.append(t.firstChild);
148
- return e;
100
+ I.exports = x;
101
+ var z = v.TinyEmitter = x;
102
+ const E = new z();
103
+ function g(s) {
104
+ const n = document.createDocumentFragment(), e = document.createElement("div");
105
+ for (e.innerHTML = s; e.firstChild; )
106
+ n.append(e.firstChild);
107
+ return n;
149
108
  }
150
- function R(i) {
151
- var d, l;
152
- const e = document.importNode(i), t = i.offsetWidth;
153
- e.style.cssText = `position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${t}px`;
154
- const n = g("<span>Foo</span>"), s = g("<span>Foo</span>"), o = document.createElement("li"), a = document.createElement("li");
155
- o.append(n), a.append(s), e.append(o), e.append(a), (d = i.parentNode) == null || d.append(e);
156
- const m = e.offsetHeight / 2;
157
- return (l = i.parentNode) == null || l.removeChild(e), m;
109
+ function P(s) {
110
+ var d, a;
111
+ const n = document.importNode(s), e = s.offsetWidth;
112
+ n.style.cssText = `position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${e}px`;
113
+ const t = g("<span>Foo</span>"), i = g("<span>Foo</span>"), o = document.createElement("li"), c = document.createElement("li");
114
+ o.append(t), c.append(i), n.append(o), n.append(c), (d = s.parentNode) == null || d.append(n);
115
+ const m = n.offsetHeight / 2;
116
+ return (a = s.parentNode) == null || a.removeChild(n), m;
158
117
  }
159
- function C(i, e, t = !1) {
160
- const n = `_${Math.random().toString(36).slice(2, 11)}`;
161
- if (typeof e != "string" && "text" in e) {
162
- const m = `<span>${e.text}</span>`, d = g(m), l = document.createElement("li");
163
- return e.classname = e.classname || "", e.icon && (e.classname === "" ? e.classname = r.icon : e.classname.includes(r.icon) === !1 && (e.classname += ` ${r.icon}`), l.setAttribute("style", `background-image:url(${e.icon})`)), l.id = n, l.className = e.classname, l.append(d), i.append(l), E.emit(
164
- u.ADD_MENU_ENTRY,
118
+ function C(s, n, e = !1) {
119
+ const t = `_${Math.random().toString(36).slice(2, 11)}`;
120
+ if (typeof n != "string" && "text" in n) {
121
+ const m = `<span>${n.text}</span>`, d = g(m), a = document.createElement("li");
122
+ return n.classname = n.classname || "", n.icon && (n.classname === "" ? n.classname = r.icon : n.classname.includes(r.icon) === !1 && (n.classname += ` ${r.icon}`), a.setAttribute("style", `background-image:url(${n.icon})`)), a.id = t, a.className = n.classname, a.append(d), s.append(a), E.emit(
123
+ p.ADD_MENU_ENTRY,
165
124
  {
166
- id: n,
167
- isSubmenu: t,
125
+ id: t,
126
+ isSubmenu: e,
168
127
  isSeparator: !1,
169
- callback: "callback" in e ? e.callback : null,
170
- data: "data" in e ? e.data : null
128
+ callback: "callback" in n ? n.callback : null,
129
+ data: "data" in n ? n.data : null
171
130
  },
172
- l
173
- ), l;
131
+ a
132
+ ), a;
174
133
  }
175
- const s = `<li id="${n}" class="${r.separator}"><hr></li>`, o = g(s);
176
- i.append(o);
177
- const a = i.lastChild;
134
+ const i = `<li id="${t}" class="${r.separator}"><hr></li>`, o = g(i);
135
+ s.append(o);
136
+ const c = s.lastChild;
178
137
  return E.emit(
179
- u.ADD_MENU_ENTRY,
138
+ p.ADD_MENU_ENTRY,
180
139
  {
181
- id: n,
182
- isSubmenu: t,
140
+ id: t,
141
+ isSubmenu: e,
183
142
  isSeparator: !0,
184
143
  callback: null,
185
144
  data: null
186
145
  },
187
- a
188
- ), a;
146
+ c
147
+ ), c;
189
148
  }
190
- function x(i, e, t) {
191
- e.forEach((n) => {
192
- if (typeof n != "string" && "items" in n && Array.isArray(n.items)) {
193
- const s = C(i, n, !0);
194
- s.classList.add(r.submenu);
149
+ function M(s, n, e) {
150
+ n.forEach((t) => {
151
+ if (typeof t != "string" && "items" in t && Array.isArray(t.items)) {
152
+ const i = C(s, t, !0);
153
+ i.classList.add(r.submenu);
195
154
  const o = document.createElement("ul");
196
- o.classList.add(r.container), o.style.width = `${t}px`, s.append(o), x(o, n.items, t);
155
+ o.classList.add(r.container), o.style.width = `${e}px`, i.append(o), M(o, t.items, e);
197
156
  } else
198
- C(i, n);
157
+ C(s, t);
199
158
  });
200
159
  }
201
- function v(i, e) {
202
- if (!i)
203
- throw new Error(e);
160
+ function y(s, n) {
161
+ if (!s)
162
+ throw new Error(n);
204
163
  }
205
- class j extends P {
206
- constructor(t = {}) {
207
- v(typeof t == "object", "@param `opts` should be object type!");
208
- const n = document.createElement("div");
209
- super({ element: n });
210
- c(this, "map");
211
- c(this, "container");
212
- c(this, "coordinate", []);
213
- c(this, "pixel", []);
214
- c(this, "contextMenuEventListener");
215
- c(this, "entryCallbackEventListener");
216
- c(this, "mapMoveListener");
217
- c(this, "lineHeight", 0);
218
- c(this, "disabled");
219
- c(this, "opened");
220
- c(this, "items", []);
221
- c(this, "menuEntries", /* @__PURE__ */ new Map());
222
- c(this, "options");
223
- this.options = { ...U, ...t };
224
- const s = document.createElement("ul");
225
- n.append(s), n.style.width = `${this.options.width}px`, n.classList.add(
164
+ class B extends O {
165
+ constructor(e = {}) {
166
+ y(typeof e == "object", "@param `opts` should be object type!");
167
+ const t = document.createElement("div");
168
+ super({ element: t });
169
+ l(this, "map");
170
+ l(this, "container");
171
+ l(this, "coordinate", []);
172
+ l(this, "pixel", []);
173
+ l(this, "contextMenuEventListener");
174
+ l(this, "entryCallbackEventListener");
175
+ l(this, "mapMoveListener");
176
+ l(this, "lineHeight", 0);
177
+ l(this, "disabled");
178
+ l(this, "opened");
179
+ l(this, "items", []);
180
+ l(this, "menuEntries", /* @__PURE__ */ new Map());
181
+ l(this, "options");
182
+ this.options = { ..._, ...e };
183
+ const i = document.createElement("ul");
184
+ t.append(i), t.style.width = `${this.options.width}px`, t.classList.add(
226
185
  r.container,
227
186
  r.unselectable,
228
187
  r.hidden
229
- ), this.container = n, this.contextMenuEventListener = (o) => {
188
+ ), this.container = t, this.contextMenuEventListener = (o) => {
230
189
  this.handleContextMenu(o);
231
190
  }, this.entryCallbackEventListener = (o) => {
232
191
  this.handleEntryCallback(o);
@@ -235,8 +194,8 @@ class j extends P {
235
194
  }, this.disabled = !1, this.opened = !1;
236
195
  }
237
196
  clear() {
238
- for (const t of this.menuEntries.keys())
239
- this.removeMenuEntry(t);
197
+ for (const e of this.menuEntries.keys())
198
+ this.removeMenuEntry(e);
240
199
  this.container.replaceChildren(), this.container.append(document.createElement("ul"));
241
200
  }
242
201
  enable() {
@@ -251,136 +210,136 @@ class j extends P {
251
210
  countItems() {
252
211
  return this.menuEntries.size;
253
212
  }
254
- extend(t) {
255
- v(Array.isArray(t), "@param `items` should be an Array."), x(
213
+ extend(e) {
214
+ y(Array.isArray(e), "@param `items` should be an Array."), M(
256
215
  this.container.firstElementChild,
257
- t,
216
+ e,
258
217
  this.options.width
259
218
  );
260
219
  }
261
220
  closeMenu() {
262
- this.opened = !1, this.container.classList.add(r.hidden), this.dispatchEvent(u.CLOSE);
221
+ this.opened = !1, this.container.classList.add(r.hidden), this.dispatchEvent(p.CLOSE);
263
222
  }
264
223
  isOpen() {
265
224
  return this.opened;
266
225
  }
267
- updatePosition(t) {
268
- v(Array.isArray(t), "@param `pixel` should be an Array."), this.isOpen() && (this.pixel = t, this.positionContainer());
226
+ updatePosition(e) {
227
+ y(Array.isArray(e), "@param `pixel` should be an Array."), this.isOpen() && (this.pixel = e, this.positionContainer());
269
228
  }
270
229
  pop() {
271
- const t = Array.from(this.menuEntries.keys()).pop();
272
- t && this.removeMenuEntry(t);
230
+ const e = Array.from(this.menuEntries.keys()).pop();
231
+ e && this.removeMenuEntry(e);
273
232
  }
274
233
  shift() {
275
- const t = Array.from(this.menuEntries.keys()).shift();
276
- t && this.removeMenuEntry(t);
234
+ const e = Array.from(this.menuEntries.keys()).shift();
235
+ e && this.removeMenuEntry(e);
277
236
  }
278
- push(t) {
279
- t && this.extend([t]);
237
+ push(e) {
238
+ e && this.extend([e]);
280
239
  }
281
- setMap(t) {
282
- if (super.setMap(t), t) {
283
- this.map = t, this.map.getViewport().addEventListener(this.options.eventType, this.contextMenuEventListener, !1), this.map.on("movestart", () => {
240
+ setMap(e) {
241
+ if (super.setMap(e), e) {
242
+ this.map = e, this.map.getViewport().addEventListener(this.options.eventType, this.contextMenuEventListener, !1), this.map.on("movestart", () => {
284
243
  this.handleMapMove();
285
244
  }), E.on(
286
- u.ADD_MENU_ENTRY,
287
- (s, o) => {
288
- this.handleAddMenuEntry(s, o);
245
+ p.ADD_MENU_ENTRY,
246
+ (i, o) => {
247
+ this.handleAddMenuEntry(i, o);
289
248
  },
290
249
  this
291
- ), this.items = this.options.defaultItems ? this.options.items.concat(w) : this.options.items, x(
250
+ ), this.items = this.options.defaultItems ? this.options.items.concat(w) : this.options.items, M(
292
251
  this.container.firstElementChild,
293
252
  this.items,
294
253
  this.options.width
295
254
  );
296
- const n = this.getMenuEntriesLength();
297
- this.lineHeight = n > 0 ? this.container.offsetHeight / n : R(this.container);
255
+ const t = this.getMenuEntriesLength();
256
+ this.lineHeight = t > 0 ? this.container.offsetHeight / t : P(this.container);
298
257
  } else
299
258
  this.removeListeners(), this.clear();
300
259
  }
301
260
  removeListeners() {
302
- this.map.getViewport().removeEventListener(this.options.eventType, this.contextMenuEventListener, !1), E.off(u.ADD_MENU_ENTRY);
261
+ this.map.getViewport().removeEventListener(this.options.eventType, this.contextMenuEventListener, !1), E.off(p.ADD_MENU_ENTRY);
303
262
  }
304
- removeMenuEntry(t) {
305
- const n = document.getElementById(t);
306
- n == null || n.remove(), n == null || n.removeEventListener("click", this.entryCallbackEventListener), this.menuEntries.delete(t);
263
+ removeMenuEntry(e) {
264
+ const t = document.getElementById(e);
265
+ t == null || t.remove(), t == null || t.removeEventListener("click", this.entryCallbackEventListener), this.menuEntries.delete(e);
307
266
  }
308
- handleContextMenu(t) {
309
- var n;
310
- this.coordinate = this.map.getEventCoordinate(t), this.pixel = this.map.getEventPixel(t), this.dispatchEvent(
267
+ handleContextMenu(e) {
268
+ var t;
269
+ this.coordinate = this.map.getEventCoordinate(e), this.pixel = this.map.getEventPixel(e), this.dispatchEvent(
311
270
  new L({
312
- type: u.BEFOREOPEN,
271
+ type: p.BEFOREOPEN,
313
272
  map: this.map,
314
- originalEvent: t
273
+ originalEvent: e
315
274
  })
316
- ), !this.disabled && (this.options.eventType === M.CONTEXTMENU && (t.stopPropagation(), t.preventDefault()), setTimeout(() => {
317
- this.openMenu(t);
318
- }), (n = t.target) == null || n.addEventListener(
275
+ ), !this.disabled && (this.options.eventType === b.CONTEXTMENU && (e.stopPropagation(), e.preventDefault()), setTimeout(() => {
276
+ this.openMenu(e);
277
+ }), (t = e.target) == null || t.addEventListener(
319
278
  "pointerdown",
320
- (s) => {
321
- this.opened && (s.stopPropagation(), this.closeMenu());
279
+ (i) => {
280
+ this.opened && (i.stopPropagation(), this.closeMenu());
322
281
  },
323
282
  { once: !0 }
324
283
  ));
325
284
  }
326
- openMenu(t) {
285
+ openMenu(e) {
327
286
  this.menuEntries.size !== 0 && (this.opened = !0, this.positionContainer(), this.container.classList.remove(r.hidden), this.dispatchEvent(
328
287
  new L({
329
- type: u.OPEN,
288
+ type: p.OPEN,
330
289
  map: this.map,
331
- originalEvent: t
290
+ originalEvent: e
332
291
  })
333
292
  ));
334
293
  }
335
294
  getMenuEntriesLength() {
336
295
  return Array.from(this.menuEntries).filter(
337
- ([, t]) => t.isSeparator === !1 || t.isSubmenu === !1
296
+ ([, e]) => e.isSeparator === !1 || e.isSubmenu === !1
338
297
  ).length;
339
298
  }
340
299
  positionContainer() {
341
- const t = this.map.getSize() || [0, 0], n = {
342
- w: t[0] - this.pixel[0],
343
- h: t[1] - this.pixel[1]
344
- }, s = {
300
+ const e = this.map.getSize() || [0, 0], t = {
301
+ w: e[0] - this.pixel[0],
302
+ h: e[1] - this.pixel[1]
303
+ }, i = {
345
304
  w: this.container.offsetWidth,
346
305
  h: Math.round(this.lineHeight * this.getMenuEntriesLength())
347
- }, o = n.w >= s.w ? this.pixel[0] + 5 : this.pixel[0] - s.w;
348
- this.container.style.left = `${o}px`, this.container.style.top = n.h >= s.h ? `${this.pixel[1] - 10}px` : `${this.pixel[1] - s.h}px`, this.container.style.right = "auto", this.container.style.bottom = "auto", n.w -= s.w;
349
- const a = (l) => Array.from(l.children).filter(
306
+ }, o = t.w >= i.w ? this.pixel[0] + 5 : this.pixel[0] - i.w;
307
+ this.container.style.left = `${o}px`, this.container.style.top = t.h >= i.h ? `${this.pixel[1] - 10}px` : `${this.pixel[1] - i.h}px`, this.container.style.right = "auto", this.container.style.bottom = "auto", t.w -= i.w;
308
+ const c = (a) => Array.from(a.children).filter(
350
309
  (f) => f.tagName === "LI" && f.classList.contains(r.submenu)
351
310
  );
352
311
  let m = 0;
353
- const d = (l, f) => {
354
- m += 1, a(l).forEach((A) => {
355
- const N = f >= s.w ? s.w - 8 : (s.w + 8) * -1, h = A.querySelector(
312
+ const d = (a, f) => {
313
+ m += 1, c(a).forEach((A) => {
314
+ const N = f >= i.w ? i.w - 8 : (i.w + 8) * -1, h = A.querySelector(
356
315
  `ul.${r.container}`
357
316
  ), $ = Math.round(
358
- this.lineHeight * Array.from(h.children).filter((_) => _.tagName === "LI").length
317
+ this.lineHeight * Array.from(h.children).filter((S) => S.tagName === "LI").length
359
318
  );
360
- h.style.left = `${N}px`, h.style.right = "auto", h.style.top = n.h >= $ + s.h ? "0" : `-${h.offsetHeight - 25}px`, h.style.bottom = "auto", h.style.zIndex = String(m), a(h).length > 0 && d(h, f - s.w);
319
+ h.style.left = `${N}px`, h.style.right = "auto", h.style.top = t.h >= $ + i.h ? "0" : `-${h.offsetHeight - 25}px`, h.style.bottom = "auto", h.style.zIndex = String(m), c(h).length > 0 && d(h, f - i.w);
361
320
  });
362
321
  };
363
- d(this.container.firstElementChild, n.w);
322
+ d(this.container.firstElementChild, t.w);
364
323
  }
365
324
  handleMapMove() {
366
325
  this.closeMenu();
367
326
  }
368
- handleEntryCallback(t) {
369
- var a;
370
- t.preventDefault(), t.stopPropagation();
371
- const n = t.currentTarget, s = this.menuEntries.get(n.id);
372
- if (!s)
327
+ handleEntryCallback(e) {
328
+ var c;
329
+ e.preventDefault(), e.stopPropagation();
330
+ const t = e.currentTarget, i = this.menuEntries.get(t.id);
331
+ if (!i)
373
332
  return;
374
333
  const o = {
375
334
  coordinate: this.coordinate,
376
- data: s.data
335
+ data: i.data
377
336
  };
378
- this.closeMenu(), (a = s.callback) == null || a.call(s, o, this.map);
337
+ this.closeMenu(), (c = i.callback) == null || c.call(i, o, this.map);
379
338
  }
380
- handleAddMenuEntry(t, n) {
381
- this.menuEntries.set(t.id, t), this.positionContainer(), "callback" in t && typeof t.callback == "function" && n.addEventListener("click", this.entryCallbackEventListener, !1);
339
+ handleAddMenuEntry(e, t) {
340
+ this.menuEntries.set(e.id, e), this.positionContainer(), "callback" in e && typeof e.callback == "function" && t.addEventListener("click", this.entryCallbackEventListener, !1);
382
341
  }
383
342
  }
384
343
  export {
385
- j as default
344
+ B as default
386
345
  };
@@ -1,8 +1,8 @@
1
1
 
2
2
  /*!
3
- * ol-contextmenu - v5.1.3
3
+ * ol-contextmenu - v5.1.4
4
4
  * https://github.com/jonataswalker/ol-contextmenu
5
- * Built: Mon Dec 26 2022 20:57:30 GMT-0300 (Brasilia Standard Time)
5
+ * Built: Mon Dec 26 2022 21:16:02 GMT-0300 (Brasilia Standard Time)
6
6
  */
7
7
 
8
- (function(p,h){typeof exports=="object"&&typeof module<"u"?module.exports=h(require("ol/control/Control")):typeof define=="function"&&define.amd?define(["ol/control/Control"],h):(p=typeof globalThis<"u"?globalThis:p||self,p.ContextMenu=h(p.ol.control.Control))})(this,function(p){"use strict";var R=Object.defineProperty;var Y=(p,h,m)=>h in p?R(p,h,{enumerable:!0,configurable:!0,writable:!0,value:m}):p[h]=m;var c=(p,h,m)=>(Y(p,typeof h!="symbol"?h+"":h,m),m);class h{constructor(n){this.propagationStopped,this.defaultPrevented,this.type=n,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}const m=h;class _ extends m{constructor(n,t,e){super(n),this.map=t,this.frameState=e!==void 0?e:null}}const S=_;class D extends S{constructor(n,t,e,s,o,a){super(n,t,o),this.originalEvent=e,this.pixel_=null,this.coordinate_=null,this.dragging=s!==void 0?s:!1,this.activePointers=a}get pixel(){return this.pixel_||(this.pixel_=this.map.getEventPixel(this.originalEvent)),this.pixel_}set pixel(n){this.pixel_=n}get coordinate(){return this.coordinate_||(this.coordinate_=this.map.getCoordinateFromPixel(this.pixel)),this.coordinate_}set coordinate(n){this.coordinate_=n}preventDefault(){super.preventDefault(),"preventDefault"in this.originalEvent&&this.originalEvent.preventDefault()}stopPropagation(){super.stopPropagation(),"stopPropagation"in this.originalEvent&&this.originalEvent.stopPropagation()}}const T=D;var M=(i=>(i.CONTEXTMENU="contextmenu",i.CLICK="click",i.DBLCLICK="dblclick",i))(M||{}),d=(i=>(i.BEFOREOPEN="beforeopen",i.OPEN="open",i.CLOSE="close",i.ADD_MENU_ENTRY="add-menu-entry",i))(d||{});class A extends T{constructor(n){super(n.type,n.map,n.originalEvent)}}const P={width:150,scrollAt:4,eventType:M.CONTEXTMENU,defaultItems:!0,items:[]},f="ol-ctx-menu",r={namespace:f,container:`${f}-container`,separator:`${f}-separator`,submenu:`${f}-submenu`,hidden:`${f}-hidden`,icon:`${f}-icon`,zoomIn:`${f}-zoom-in`,zoomOut:`${f}-zoom-out`,unselectable:"ol-unselectable"},N=[{text:"Zoom In",classname:`${r.zoomIn} ${r.icon}`,callback:(i,n)=>{const t=n.getView();t.animate({zoom:Number(t.getZoom())+1,duration:700,center:i.coordinate})}},{text:"Zoom Out",classname:`${r.zoomOut} ${r.icon}`,callback:(i,n)=>{const t=n.getView();t.animate({zoom:Number(t.getZoom())-1,duration:700,center:i.coordinate})}}];var b={},k={get exports(){return b},set exports(i){b=i}};function L(){}L.prototype={on:function(i,n,t){var e=this.e||(this.e={});return(e[i]||(e[i]=[])).push({fn:n,ctx:t}),this},once:function(i,n,t){var e=this;function s(){e.off(i,s),n.apply(t,arguments)}return s._=n,this.on(i,s,t)},emit:function(i){var n=[].slice.call(arguments,1),t=((this.e||(this.e={}))[i]||[]).slice(),e=0,s=t.length;for(e;e<s;e++)t[e].fn.apply(t[e].ctx,n);return this},off:function(i,n){var t=this.e||(this.e={}),e=t[i],s=[];if(e&&n)for(var o=0,a=e.length;o<a;o++)e[o].fn!==n&&e[o].fn._!==n&&s.push(e[o]);return s.length?t[i]=s:delete t[i],this}},k.exports=L;var O=b.TinyEmitter=L;const y=new O;function x(i){const n=document.createDocumentFragment(),t=document.createElement("div");for(t.innerHTML=i;t.firstChild;)n.append(t.firstChild);return n}function I(i){var E,l;const n=document.importNode(i),t=i.offsetWidth;n.style.cssText=`position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${t}px`;const e=x("<span>Foo</span>"),s=x("<span>Foo</span>"),o=document.createElement("li"),a=document.createElement("li");o.append(e),a.append(s),n.append(o),n.append(a),(E=i.parentNode)==null||E.append(n);const g=n.offsetHeight/2;return(l=i.parentNode)==null||l.removeChild(n),g}function $(i,n,t=!1){const e=`_${Math.random().toString(36).slice(2,11)}`;if(typeof n!="string"&&"text"in n){const g=`<span>${n.text}</span>`,E=x(g),l=document.createElement("li");return n.classname=n.classname||"",n.icon&&(n.classname===""?n.classname=r.icon:n.classname.includes(r.icon)===!1&&(n.classname+=` ${r.icon}`),l.setAttribute("style",`background-image:url(${n.icon})`)),l.id=e,l.className=n.classname,l.append(E),i.append(l),y.emit(d.ADD_MENU_ENTRY,{id:e,isSubmenu:t,isSeparator:!1,callback:"callback"in n?n.callback:null,data:"data"in n?n.data:null},l),l}const s=`<li id="${e}" class="${r.separator}"><hr></li>`,o=x(s);i.append(o);const a=i.lastChild;return y.emit(d.ADD_MENU_ENTRY,{id:e,isSubmenu:t,isSeparator:!0,callback:null,data:null},a),a}function C(i,n,t){n.forEach(e=>{if(typeof e!="string"&&"items"in e&&Array.isArray(e.items)){const s=$(i,e,!0);s.classList.add(r.submenu);const o=document.createElement("ul");o.classList.add(r.container),o.style.width=`${t}px`,s.append(o),C(o,e.items,t)}else $(i,e)})}const j="";function w(i,n){if(!i)throw new Error(n)}class z extends p{constructor(t={}){w(typeof t=="object","@param `opts` should be object type!");const e=document.createElement("div");super({element:e});c(this,"map");c(this,"container");c(this,"coordinate",[]);c(this,"pixel",[]);c(this,"contextMenuEventListener");c(this,"entryCallbackEventListener");c(this,"mapMoveListener");c(this,"lineHeight",0);c(this,"disabled");c(this,"opened");c(this,"items",[]);c(this,"menuEntries",new Map);c(this,"options");this.options={...P,...t};const s=document.createElement("ul");e.append(s),e.style.width=`${this.options.width}px`,e.classList.add(r.container,r.unselectable,r.hidden),this.container=e,this.contextMenuEventListener=o=>{this.handleContextMenu(o)},this.entryCallbackEventListener=o=>{this.handleEntryCallback(o)},this.mapMoveListener=()=>{this.handleMapMove()},this.disabled=!1,this.opened=!1}clear(){for(const t of this.menuEntries.keys())this.removeMenuEntry(t);this.container.replaceChildren(),this.container.append(document.createElement("ul"))}enable(){this.disabled=!1}disable(){this.disabled=!0}getDefaultItems(){return N}countItems(){return this.menuEntries.size}extend(t){w(Array.isArray(t),"@param `items` should be an Array."),C(this.container.firstElementChild,t,this.options.width)}closeMenu(){this.opened=!1,this.container.classList.add(r.hidden),this.dispatchEvent(d.CLOSE)}isOpen(){return this.opened}updatePosition(t){w(Array.isArray(t),"@param `pixel` should be an Array."),this.isOpen()&&(this.pixel=t,this.positionContainer())}pop(){const t=Array.from(this.menuEntries.keys()).pop();t&&this.removeMenuEntry(t)}shift(){const t=Array.from(this.menuEntries.keys()).shift();t&&this.removeMenuEntry(t)}push(t){t&&this.extend([t])}setMap(t){if(super.setMap(t),t){this.map=t,this.map.getViewport().addEventListener(this.options.eventType,this.contextMenuEventListener,!1),this.map.on("movestart",()=>{this.handleMapMove()}),y.on(d.ADD_MENU_ENTRY,(s,o)=>{this.handleAddMenuEntry(s,o)},this),this.items=this.options.defaultItems?this.options.items.concat(N):this.options.items,C(this.container.firstElementChild,this.items,this.options.width);const e=this.getMenuEntriesLength();this.lineHeight=e>0?this.container.offsetHeight/e:I(this.container)}else this.removeListeners(),this.clear()}removeListeners(){this.map.getViewport().removeEventListener(this.options.eventType,this.contextMenuEventListener,!1),y.off(d.ADD_MENU_ENTRY)}removeMenuEntry(t){const e=document.getElementById(t);e==null||e.remove(),e==null||e.removeEventListener("click",this.entryCallbackEventListener),this.menuEntries.delete(t)}handleContextMenu(t){var e;this.coordinate=this.map.getEventCoordinate(t),this.pixel=this.map.getEventPixel(t),this.dispatchEvent(new A({type:d.BEFOREOPEN,map:this.map,originalEvent:t})),!this.disabled&&(this.options.eventType===M.CONTEXTMENU&&(t.stopPropagation(),t.preventDefault()),setTimeout(()=>{this.openMenu(t)}),(e=t.target)==null||e.addEventListener("pointerdown",s=>{this.opened&&(s.stopPropagation(),this.closeMenu())},{once:!0}))}openMenu(t){this.menuEntries.size!==0&&(this.opened=!0,this.positionContainer(),this.container.classList.remove(r.hidden),this.dispatchEvent(new A({type:d.OPEN,map:this.map,originalEvent:t})))}getMenuEntriesLength(){return Array.from(this.menuEntries).filter(([,t])=>t.isSeparator===!1||t.isSubmenu===!1).length}positionContainer(){const t=this.map.getSize()||[0,0],e={w:t[0]-this.pixel[0],h:t[1]-this.pixel[1]},s={w:this.container.offsetWidth,h:Math.round(this.lineHeight*this.getMenuEntriesLength())},o=e.w>=s.w?this.pixel[0]+5:this.pixel[0]-s.w;this.container.style.left=`${o}px`,this.container.style.top=e.h>=s.h?`${this.pixel[1]-10}px`:`${this.pixel[1]-s.h}px`,this.container.style.right="auto",this.container.style.bottom="auto",e.w-=s.w;const a=l=>Array.from(l.children).filter(v=>v.tagName==="LI"&&v.classList.contains(r.submenu));let g=0;const E=(l,v)=>{g+=1,a(l).forEach(H=>{const U=v>=s.w?s.w-8:(s.w+8)*-1,u=H.querySelector(`ul.${r.container}`),F=Math.round(this.lineHeight*Array.from(u.children).filter(B=>B.tagName==="LI").length);u.style.left=`${U}px`,u.style.right="auto",u.style.top=e.h>=F+s.h?"0":`-${u.offsetHeight-25}px`,u.style.bottom="auto",u.style.zIndex=String(g),a(u).length>0&&E(u,v-s.w)})};E(this.container.firstElementChild,e.w)}handleMapMove(){this.closeMenu()}handleEntryCallback(t){var a;t.preventDefault(),t.stopPropagation();const e=t.currentTarget,s=this.menuEntries.get(e.id);if(!s)return;const o={coordinate:this.coordinate,data:s.data};this.closeMenu(),(a=s.callback)==null||a.call(s,o,this.map)}handleAddMenuEntry(t,e){this.menuEntries.set(t.id,t),this.positionContainer(),"callback"in t&&typeof t.callback=="function"&&e.addEventListener("click",this.entryCallbackEventListener,!1)}}return z});
8
+ (function(c,h){typeof exports=="object"&&typeof module<"u"?module.exports=h(require("ol/control/Control"),require("ol/MapBrowserEvent")):typeof define=="function"&&define.amd?define(["ol/control/Control","ol/MapBrowserEvent"],h):(c=typeof globalThis<"u"?globalThis:c||self,c.ContextMenu=h(c.ol.control.Control,c.ol.MapBrowserEvent))})(this,function(c,h){"use strict";var P=Object.defineProperty;var H=(c,h,d)=>h in c?P(c,h,{enumerable:!0,configurable:!0,writable:!0,value:d}):c[h]=d;var l=(c,h,d)=>(H(c,typeof h!="symbol"?h+"":h,d),d);var d=(s=>(s.CONTEXTMENU="contextmenu",s.CLICK="click",s.DBLCLICK="dblclick",s))(d||{}),m=(s=>(s.BEFOREOPEN="beforeopen",s.OPEN="open",s.CLOSE="close",s.ADD_MENU_ENTRY="add-menu-entry",s))(m||{});class C extends h{constructor(n){super(n.type,n.map,n.originalEvent)}}const $={width:150,scrollAt:4,eventType:d.CONTEXTMENU,defaultItems:!0,items:[]},f="ol-ctx-menu",r={namespace:f,container:`${f}-container`,separator:`${f}-separator`,submenu:`${f}-submenu`,hidden:`${f}-hidden`,icon:`${f}-icon`,zoomIn:`${f}-zoom-in`,zoomOut:`${f}-zoom-out`,unselectable:"ol-unselectable"},A=[{text:"Zoom In",classname:`${r.zoomIn} ${r.icon}`,callback:(s,n)=>{const e=n.getView();e.animate({zoom:Number(e.getZoom())+1,duration:700,center:s.coordinate})}},{text:"Zoom Out",classname:`${r.zoomOut} ${r.icon}`,callback:(s,n)=>{const e=n.getView();e.animate({zoom:Number(e.getZoom())-1,duration:700,center:s.coordinate})}}];var x={},S={get exports(){return x},set exports(s){x=s}};function b(){}b.prototype={on:function(s,n,e){var t=this.e||(this.e={});return(t[s]||(t[s]=[])).push({fn:n,ctx:e}),this},once:function(s,n,e){var t=this;function i(){t.off(s,i),n.apply(e,arguments)}return i._=n,this.on(s,i,e)},emit:function(s){var n=[].slice.call(arguments,1),e=((this.e||(this.e={}))[s]||[]).slice(),t=0,i=e.length;for(t;t<i;t++)e[t].fn.apply(e[t].ctx,n);return this},off:function(s,n){var e=this.e||(this.e={}),t=e[s],i=[];if(t&&n)for(var o=0,u=t.length;o<u;o++)t[o].fn!==n&&t[o].fn._!==n&&i.push(t[o]);return i.length?e[s]=i:delete e[s],this}},S.exports=b;var T=x.TinyEmitter=b;const v=new T;function M(s){const n=document.createDocumentFragment(),e=document.createElement("div");for(e.innerHTML=s;e.firstChild;)n.append(e.firstChild);return n}function k(s){var E,a;const n=document.importNode(s),e=s.offsetWidth;n.style.cssText=`position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${e}px`;const t=M("<span>Foo</span>"),i=M("<span>Foo</span>"),o=document.createElement("li"),u=document.createElement("li");o.append(t),u.append(i),n.append(o),n.append(u),(E=s.parentNode)==null||E.append(n);const g=n.offsetHeight/2;return(a=s.parentNode)==null||a.removeChild(n),g}function N(s,n,e=!1){const t=`_${Math.random().toString(36).slice(2,11)}`;if(typeof n!="string"&&"text"in n){const g=`<span>${n.text}</span>`,E=M(g),a=document.createElement("li");return n.classname=n.classname||"",n.icon&&(n.classname===""?n.classname=r.icon:n.classname.includes(r.icon)===!1&&(n.classname+=` ${r.icon}`),a.setAttribute("style",`background-image:url(${n.icon})`)),a.id=t,a.className=n.classname,a.append(E),s.append(a),v.emit(m.ADD_MENU_ENTRY,{id:t,isSubmenu:e,isSeparator:!1,callback:"callback"in n?n.callback:null,data:"data"in n?n.data:null},a),a}const i=`<li id="${t}" class="${r.separator}"><hr></li>`,o=M(i);s.append(o);const u=s.lastChild;return v.emit(m.ADD_MENU_ENTRY,{id:t,isSubmenu:e,isSeparator:!0,callback:null,data:null},u),u}function L(s,n,e){n.forEach(t=>{if(typeof t!="string"&&"items"in t&&Array.isArray(t.items)){const i=N(s,t,!0);i.classList.add(r.submenu);const o=document.createElement("ul");o.classList.add(r.container),o.style.width=`${e}px`,i.append(o),L(o,t.items,e)}else N(s,t)})}const U="";function w(s,n){if(!s)throw new Error(n)}class O extends c{constructor(e={}){w(typeof e=="object","@param `opts` should be object type!");const t=document.createElement("div");super({element:t});l(this,"map");l(this,"container");l(this,"coordinate",[]);l(this,"pixel",[]);l(this,"contextMenuEventListener");l(this,"entryCallbackEventListener");l(this,"mapMoveListener");l(this,"lineHeight",0);l(this,"disabled");l(this,"opened");l(this,"items",[]);l(this,"menuEntries",new Map);l(this,"options");this.options={...$,...e};const i=document.createElement("ul");t.append(i),t.style.width=`${this.options.width}px`,t.classList.add(r.container,r.unselectable,r.hidden),this.container=t,this.contextMenuEventListener=o=>{this.handleContextMenu(o)},this.entryCallbackEventListener=o=>{this.handleEntryCallback(o)},this.mapMoveListener=()=>{this.handleMapMove()},this.disabled=!1,this.opened=!1}clear(){for(const e of this.menuEntries.keys())this.removeMenuEntry(e);this.container.replaceChildren(),this.container.append(document.createElement("ul"))}enable(){this.disabled=!1}disable(){this.disabled=!0}getDefaultItems(){return A}countItems(){return this.menuEntries.size}extend(e){w(Array.isArray(e),"@param `items` should be an Array."),L(this.container.firstElementChild,e,this.options.width)}closeMenu(){this.opened=!1,this.container.classList.add(r.hidden),this.dispatchEvent(m.CLOSE)}isOpen(){return this.opened}updatePosition(e){w(Array.isArray(e),"@param `pixel` should be an Array."),this.isOpen()&&(this.pixel=e,this.positionContainer())}pop(){const e=Array.from(this.menuEntries.keys()).pop();e&&this.removeMenuEntry(e)}shift(){const e=Array.from(this.menuEntries.keys()).shift();e&&this.removeMenuEntry(e)}push(e){e&&this.extend([e])}setMap(e){if(super.setMap(e),e){this.map=e,this.map.getViewport().addEventListener(this.options.eventType,this.contextMenuEventListener,!1),this.map.on("movestart",()=>{this.handleMapMove()}),v.on(m.ADD_MENU_ENTRY,(i,o)=>{this.handleAddMenuEntry(i,o)},this),this.items=this.options.defaultItems?this.options.items.concat(A):this.options.items,L(this.container.firstElementChild,this.items,this.options.width);const t=this.getMenuEntriesLength();this.lineHeight=t>0?this.container.offsetHeight/t:k(this.container)}else this.removeListeners(),this.clear()}removeListeners(){this.map.getViewport().removeEventListener(this.options.eventType,this.contextMenuEventListener,!1),v.off(m.ADD_MENU_ENTRY)}removeMenuEntry(e){const t=document.getElementById(e);t==null||t.remove(),t==null||t.removeEventListener("click",this.entryCallbackEventListener),this.menuEntries.delete(e)}handleContextMenu(e){var t;this.coordinate=this.map.getEventCoordinate(e),this.pixel=this.map.getEventPixel(e),this.dispatchEvent(new C({type:m.BEFOREOPEN,map:this.map,originalEvent:e})),!this.disabled&&(this.options.eventType===d.CONTEXTMENU&&(e.stopPropagation(),e.preventDefault()),setTimeout(()=>{this.openMenu(e)}),(t=e.target)==null||t.addEventListener("pointerdown",i=>{this.opened&&(i.stopPropagation(),this.closeMenu())},{once:!0}))}openMenu(e){this.menuEntries.size!==0&&(this.opened=!0,this.positionContainer(),this.container.classList.remove(r.hidden),this.dispatchEvent(new C({type:m.OPEN,map:this.map,originalEvent:e})))}getMenuEntriesLength(){return Array.from(this.menuEntries).filter(([,e])=>e.isSeparator===!1||e.isSubmenu===!1).length}positionContainer(){const e=this.map.getSize()||[0,0],t={w:e[0]-this.pixel[0],h:e[1]-this.pixel[1]},i={w:this.container.offsetWidth,h:Math.round(this.lineHeight*this.getMenuEntriesLength())},o=t.w>=i.w?this.pixel[0]+5:this.pixel[0]-i.w;this.container.style.left=`${o}px`,this.container.style.top=t.h>=i.h?`${this.pixel[1]-10}px`:`${this.pixel[1]-i.h}px`,this.container.style.right="auto",this.container.style.bottom="auto",t.w-=i.w;const u=a=>Array.from(a.children).filter(y=>y.tagName==="LI"&&y.classList.contains(r.submenu));let g=0;const E=(a,y)=>{g+=1,u(a).forEach(D=>{const _=y>=i.w?i.w-8:(i.w+8)*-1,p=D.querySelector(`ul.${r.container}`),I=Math.round(this.lineHeight*Array.from(p.children).filter(z=>z.tagName==="LI").length);p.style.left=`${_}px`,p.style.right="auto",p.style.top=t.h>=I+i.h?"0":`-${p.offsetHeight-25}px`,p.style.bottom="auto",p.style.zIndex=String(g),u(p).length>0&&E(p,y-i.w)})};E(this.container.firstElementChild,t.w)}handleMapMove(){this.closeMenu()}handleEntryCallback(e){var u;e.preventDefault(),e.stopPropagation();const t=e.currentTarget,i=this.menuEntries.get(t.id);if(!i)return;const o={coordinate:this.coordinate,data:i.data};this.closeMenu(),(u=i.callback)==null||u.call(i,o,this.map)}handleAddMenuEntry(e,t){this.menuEntries.set(e.id,e),this.positionContainer(),"callback"in e&&typeof e.callback=="function"&&t.addEventListener("click",this.entryCallbackEventListener,!1)}}return O});
package/dist/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ import OlMap from 'ol/Map';
1
2
  import type { Coordinate } from 'ol/coordinate';
2
- import { Map as OlMap, MapBrowserEvent } from 'ol';
3
+ import MapBrowserEvent from 'ol/MapBrowserEvent';
3
4
  export declare enum EventTypes {
4
5
  CONTEXTMENU = "contextmenu",
5
6
  CLICK = "click",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ol-contextmenu",
3
- "version": "5.1.3",
3
+ "version": "5.1.4",
4
4
  "description": "Custom Context Menu for Openlayers",
5
5
  "type": "module",
6
6
  "browser": "./dist/ol-contextmenu.umd.cjs",