ol-contextmenu 5.1.3 → 5.1.5

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.
package/README.md CHANGED
@@ -21,9 +21,7 @@ A `contextmenu` extension for [OpenLayers](http://openlayers.org/). **Requires**
21
21
 
22
22
  ## Demo
23
23
 
24
- [CodeSandbox](https://codesandbox.io/s/openlayers-custom-context-menu-5s99kb?file=/src/index.js)
25
-
26
- [JSFiddle](https://jsfiddle.net/jonataswalker/ooxs1w5d/)
24
+ [JSFiddle](https://jsfiddle.net/jonataswalker/ooxs1w5d/).
27
25
 
28
26
  ## How to use it?
29
27
 
@@ -1,5 +1,5 @@
1
1
  import { Item } from '../types';
2
2
  export declare function createFragment(html: string): DocumentFragment;
3
3
  export declare function getLineHeight(container: HTMLDivElement): number;
4
- export declare function addMenuEntry(parentNode: HTMLUListElement, item: Item, isSubmenu?: boolean): HTMLLIElement;
5
- export declare function addMenuEntries(container: HTMLUListElement, items: Item[], menuWidth: number): void;
4
+ export declare function addMenuEntry(parentNode: HTMLUListElement, item: Item, isSubmenu?: boolean, isInsideSubmenu?: boolean): HTMLLIElement;
5
+ export declare function addMenuEntries(container: HTMLUListElement, items: Item[], menuWidth: number, isInsideSubmenu?: boolean): void;
@@ -1,8 +1,8 @@
1
1
 
2
2
  /*!
3
- * ol-contextmenu - v5.1.3
3
+ * ol-contextmenu - v5.1.5
4
4
  * https://github.com/jonataswalker/ol-contextmenu
5
- * Built: Mon Dec 26 2022 20:57:30 GMT-0300 (Brasilia Standard Time)
5
+ * Built: Sat Mar 11 2023 15:05:27 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)}
@@ -0,0 +1,8 @@
1
+
2
+ /*!
3
+ * ol-contextmenu - v5.1.5
4
+ * https://github.com/jonataswalker/ol-contextmenu
5
+ * Built: Sat Mar 11 2023 15:05:27 GMT-0300 (Brasilia Standard Time)
6
+ */
7
+
8
+ var ContextMenu=function(f,h){"use strict";var U=Object.defineProperty;var F=(f,h,u)=>h in f?U(f,h,{enumerable:!0,configurable:!0,writable:!0,value:u}):f[h]=u;var a=(f,h,u)=>(F(f,typeof h!="symbol"?h+"":h,u),u);var u=(n=>(n.CONTEXTMENU="contextmenu",n.CLICK="click",n.DBLCLICK="dblclick",n))(u||{}),p=(n=>(n.BEFOREOPEN="beforeopen",n.OPEN="open",n.CLOSE="close",n.ADD_MENU_ENTRY="add-menu-entry",n))(p||{});class A extends h.MapBrowserEvent{constructor(t){super(t.type,t.map,t.originalEvent)}}const k={width:150,scrollAt:4,eventType:u.CONTEXTMENU,defaultItems:!0,items:[]},m="ol-ctx-menu",r={namespace:m,container:`${m}-container`,separator:`${m}-separator`,submenu:`${m}-submenu`,hidden:`${m}-hidden`,icon:`${m}-icon`,zoomIn:`${m}-zoom-in`,zoomOut:`${m}-zoom-out`,unselectable:"ol-unselectable"},N=[{text:"Zoom In",classname:`${r.zoomIn} ${r.icon}`,callback:(n,t)=>{const e=t.getView();e.animate({zoom:Number(e.getZoom())+1,duration:700,center:n.coordinate})}},{text:"Zoom Out",classname:`${r.zoomOut} ${r.icon}`,callback:(n,t)=>{const e=t.getView();e.animate({zoom:Number(e.getZoom())-1,duration:700,center:n.coordinate})}}];var x={},T={get exports(){return x},set exports(n){x=n}};function L(){}L.prototype={on:function(n,t,e){var s=this.e||(this.e={});return(s[n]||(s[n]=[])).push({fn:t,ctx:e}),this},once:function(n,t,e){var s=this;function i(){s.off(n,i),t.apply(e,arguments)}return i._=t,this.on(n,i,e)},emit:function(n){var t=[].slice.call(arguments,1),e=((this.e||(this.e={}))[n]||[]).slice(),s=0,i=e.length;for(s;s<i;s++)e[s].fn.apply(e[s].ctx,t);return this},off:function(n,t){var e=this.e||(this.e={}),s=e[n],i=[];if(s&&t)for(var o=0,l=s.length;o<l;o++)s[o].fn!==t&&s[o].fn._!==t&&i.push(s[o]);return i.length?e[n]=i:delete e[n],this}},T.exports=L;var O=x.TinyEmitter=L;const y=new O;function v(n){const t=document.createDocumentFragment(),e=document.createElement("div");for(e.innerHTML=n;e.firstChild;)t.append(e.firstChild);return t}function D(n){const t=document.importNode(n),e=n.offsetWidth;t.style.cssText=`position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${e}px`;const s=v("<span>Foo</span>"),i=v("<span>Foo</span>"),o=document.createElement("li"),l=document.createElement("li");o.append(s),l.append(i),t.append(o),t.append(l),n.parentNode?.append(t);const E=t.offsetHeight/2;return n.parentNode?.removeChild(t),E}function S(n,t,e=!1,s=!1){const i=`_${Math.random().toString(36).slice(2,11)}`;if(typeof t!="string"&&"text"in t){const b=`<span>${t.text}</span>`,g=v(b),c=document.createElement("li");t.classname=t.classname||"",t.icon&&(t.classname===""?t.classname=r.icon:t.classname.includes(r.icon)===!1&&(t.classname+=` ${r.icon}`),c.setAttribute("style",`background-image:url(${t.icon})`)),c.id=i,c.className=t.classname,c.append(g),n.append(c);const $={id:i,isSubmenu:e,isInsideSubmenu:s,isSeparator:!1,callback:"callback"in t?t.callback:null,data:"data"in t?t.data:null};return y.emit(p.ADD_MENU_ENTRY,$,c),c}const o=`<li id="${i}" class="${r.separator}"><hr></li>`,l=v(o);n.append(l);const E=n.lastChild,M={id:i,isSubmenu:!1,isInsideSubmenu:!1,isSeparator:!0,callback:null,data:null};return y.emit(p.ADD_MENU_ENTRY,M,E),E}function w(n,t,e,s){t.forEach(i=>{if(typeof i!="string"&&"items"in i&&Array.isArray(i.items)){const o=S(n,i,!0);o.classList.add(r.submenu);const l=document.createElement("ul");l.classList.add(r.container),l.style.width=`${e}px`,o.append(l),w(l,i.items,e,!0)}else S(n,i,!1,s)})}const R="";function C(n,t){if(!n)throw new Error(t)}class I extends f{constructor(e={}){C(typeof e=="object","@param `opts` should be object type!");const s=document.createElement("div");super({element:s});a(this,"map");a(this,"container");a(this,"coordinate",[]);a(this,"pixel",[]);a(this,"contextMenuEventListener");a(this,"entryCallbackEventListener");a(this,"mapMoveListener");a(this,"lineHeight",0);a(this,"disabled");a(this,"opened");a(this,"items",[]);a(this,"menuEntries",new Map);a(this,"options");this.options={...k,...e};const i=document.createElement("ul");s.append(i),s.style.width=`${this.options.width}px`,s.classList.add(r.container,r.unselectable,r.hidden),this.container=s,this.contextMenuEventListener=o=>{this.handleContextMenu(o)},this.entryCallbackEventListener=o=>{this.handleEntryCallback(o)},this.mapMoveListener=()=>{this.handleMapMove()},this.disabled=!1,this.opened=!1,window.addEventListener("beforeunload",()=>{this.removeListeners()},{once:!0})}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 N}countItems(){return this.menuEntries.size}extend(e){C(Array.isArray(e),"@param `items` should be an Array."),w(this.container.firstElementChild,e,this.options.width)}closeMenu(){this.opened=!1,this.container.classList.add(r.hidden),this.dispatchEvent(p.CLOSE)}isOpen(){return this.opened}updatePosition(e){C(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()}),y.on(p.ADD_MENU_ENTRY,(i,o)=>{this.handleAddMenuEntry(i,o)},this),this.items=this.options.defaultItems?this.options.items.concat(N):this.options.items,w(this.container.firstElementChild,this.items,this.options.width);const s=this.getMenuEntriesLength();this.lineHeight=s>0?this.container.offsetHeight/s:D(this.container)}else this.removeListeners(),this.clear()}removeListeners(){this.map.getViewport().removeEventListener(this.options.eventType,this.contextMenuEventListener,!1),y.off(p.ADD_MENU_ENTRY)}removeMenuEntry(e){const s=document.getElementById(e);s?.remove(),s?.removeEventListener("click",this.entryCallbackEventListener),this.menuEntries.delete(e)}handleContextMenu(e){this.coordinate=this.map.getEventCoordinate(e),this.pixel=this.map.getEventPixel(e),this.dispatchEvent(new A({type:p.BEFOREOPEN,map:this.map,originalEvent:e})),!this.disabled&&(this.options.eventType===u.CONTEXTMENU&&(e.stopPropagation(),e.preventDefault()),setTimeout(()=>{this.openMenu(e)}),e.target?.addEventListener("pointerdown",s=>{this.opened&&(s.stopPropagation(),this.closeMenu())},{once:!0}))}openMenu(e){this.opened=!0,this.positionContainer(),this.container.classList.remove(r.hidden),this.dispatchEvent(new A({type:p.OPEN,map:this.map,originalEvent:e}))}getMenuEntriesLength(){return Array.from(this.menuEntries).filter(([,e])=>e.isSeparator===!1&&e.isSubmenu===!1&&e.isInsideSubmenu===!1).length}positionContainer(){const e=this.map.getSize()||[0,0],s={w:e[0]-this.pixel[0],h:e[1]-this.pixel[1]},i=this.getMenuEntriesLength(),o={w:this.container.offsetWidth,h:Math.round(this.lineHeight*i)},l=s.w>=o.w?this.pixel[0]+5:this.pixel[0]-o.w;this.container.style.left=`${l}px`,this.container.style.top=s.h>=o.h?`${this.pixel[1]-10}px`:`${this.pixel[1]-o.h}px`,this.container.style.right="auto",this.container.style.bottom="auto",s.w-=o.w;const E=g=>Array.from(g.children).filter(c=>c.tagName==="LI"&&c.classList.contains(r.submenu));let M=0;const b=(g,c)=>{M+=1,E(g).forEach(_=>{const z=c>=o.w?o.w-8:(o.w+8)*-1,d=_.querySelector(`ul.${r.container}`),P=Math.round(this.lineHeight*Array.from(d.children).filter(H=>H.tagName==="LI").length);d.style.left=`${z}px`,d.style.right="auto",d.style.top=s.h>=P+o.h?"0":`-${d.offsetHeight-25}px`,d.style.bottom="auto",d.style.zIndex=String(M),E(d).length>0&&b(d,c-o.w)})};b(this.container.firstElementChild,s.w)}handleMapMove(){this.closeMenu()}handleEntryCallback(e){e.preventDefault(),e.stopPropagation();const s=e.currentTarget,i=this.menuEntries.get(s.id);if(!i)return;const o={coordinate:this.coordinate,data:i.data};this.closeMenu(),i.callback?.(o,this.map)}handleAddMenuEntry(e,s){this.menuEntries.set(e.id,e),this.positionContainer(),"callback"in e&&typeof e.callback=="function"&&s.addEventListener("click",this.entryCallbackEventListener,!1)}}return I}(ol.control.Control,ol);
@@ -1,242 +1,202 @@
1
1
 
2
2
  /*!
3
- * ol-contextmenu - v5.1.3
3
+ * ol-contextmenu - v5.1.5
4
4
  * https://github.com/jonataswalker/ol-contextmenu
5
- * Built: Mon Dec 26 2022 20:57:30 GMT-0300 (Brasilia Standard Time)
5
+ * Built: Sat Mar 11 2023 15:05:27 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 O = Object.defineProperty;
9
+ var D = (n, t, e) => t in n ? O(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
10
+ var a = (n, t, e) => (D(n, typeof t != "symbol" ? t + "" : t, e), e);
11
+ import I from "ol/control/Control";
12
+ import { MapBrowserEvent as _ } from "ol";
13
+ var x = /* @__PURE__ */ ((n) => (n.CONTEXTMENU = "contextmenu", n.CLICK = "click", n.DBLCLICK = "dblclick", n))(x || {}), d = /* @__PURE__ */ ((n) => (n.BEFOREOPEN = "beforeopen", n.OPEN = "open", n.CLOSE = "close", n.ADD_MENU_ENTRY = "add-menu-entry", n))(d || {});
14
+ class C extends _ {
15
+ constructor(t) {
16
+ super(t.type, t.map, t.originalEvent);
58
17
  }
59
18
  }
60
- const U = {
19
+ const z = {
61
20
  width: 150,
62
21
  scrollAt: 4,
63
- eventType: M.CONTEXTMENU,
22
+ eventType: x.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
- }, w = [
35
+ }, A = [
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: (n, t) => {
40
+ const e = t.getView();
41
+ e.animate({
42
+ zoom: Number(e.getZoom()) + 1,
84
43
  duration: 700,
85
- center: i.coordinate
44
+ center: n.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: (n, t) => {
52
+ const e = t.getView();
53
+ e.animate({
54
+ zoom: Number(e.getZoom()) - 1,
96
55
  duration: 700,
97
- center: i.coordinate
56
+ center: n.coordinate
98
57
  });
99
58
  }
100
59
  }
101
60
  ];
102
- var y = {}, F = {
61
+ var M = {}, P = {
103
62
  get exports() {
104
- return y;
63
+ return M;
105
64
  },
106
- set exports(i) {
107
- y = i;
65
+ set exports(n) {
66
+ M = n;
108
67
  }
109
68
  };
110
- function b() {
69
+ function L() {
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
+ L.prototype = {
72
+ on: function(n, t, e) {
73
+ var s = this.e || (this.e = {});
74
+ return (s[n] || (s[n] = [])).push({
75
+ fn: t,
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(n, t, e) {
80
+ var s = this;
81
+ function i() {
82
+ s.off(n, i), t.apply(e, arguments);
124
83
  }
125
- return s._ = e, this.on(i, s, t);
84
+ return i._ = t, this.on(n, 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(n) {
87
+ var t = [].slice.call(arguments, 1), e = ((this.e || (this.e = {}))[n] || []).slice(), s = 0, i = e.length;
88
+ for (s; s < i; s++)
89
+ e[s].fn.apply(e[s].ctx, t);
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(n, t) {
93
+ var e = this.e || (this.e = {}), s = e[n], i = [];
94
+ if (s && t)
95
+ for (var o = 0, l = s.length; o < l; o++)
96
+ s[o].fn !== t && s[o].fn._ !== t && i.push(s[o]);
97
+ return i.length ? e[n] = i : delete e[n], 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
+ P.exports = L;
101
+ var H = M.TinyEmitter = L;
102
+ const g = new H();
103
+ function y(n) {
104
+ const t = document.createDocumentFragment(), e = document.createElement("div");
105
+ for (e.innerHTML = n; e.firstChild; )
106
+ t.append(e.firstChild);
107
+ return t;
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 U(n) {
110
+ const t = document.importNode(n), e = n.offsetWidth;
111
+ t.style.cssText = `position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${e}px`;
112
+ const s = y("<span>Foo</span>"), i = y("<span>Foo</span>"), o = document.createElement("li"), l = document.createElement("li");
113
+ o.append(s), l.append(i), t.append(o), t.append(l), n.parentNode?.append(t);
114
+ const p = t.offsetHeight / 2;
115
+ return n.parentNode?.removeChild(t), p;
158
116
  }
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,
165
- {
166
- id: n,
167
- isSubmenu: t,
168
- isSeparator: !1,
169
- callback: "callback" in e ? e.callback : null,
170
- data: "data" in e ? e.data : null
171
- },
172
- l
173
- ), l;
174
- }
175
- const s = `<li id="${n}" class="${r.separator}"><hr></li>`, o = g(s);
176
- i.append(o);
177
- const a = i.lastChild;
178
- return E.emit(
179
- u.ADD_MENU_ENTRY,
180
- {
181
- id: n,
182
- isSubmenu: t,
183
- isSeparator: !0,
184
- callback: null,
185
- data: null
186
- },
187
- a
188
- ), a;
117
+ function N(n, t, e = !1, s = !1) {
118
+ const i = `_${Math.random().toString(36).slice(2, 11)}`;
119
+ if (typeof t != "string" && "text" in t) {
120
+ const E = `<span>${t.text}</span>`, m = y(E), c = document.createElement("li");
121
+ t.classname = t.classname || "", t.icon && (t.classname === "" ? t.classname = r.icon : t.classname.includes(r.icon) === !1 && (t.classname += ` ${r.icon}`), c.setAttribute("style", `background-image:url(${t.icon})`)), c.id = i, c.className = t.classname, c.append(m), n.append(c);
122
+ const w = {
123
+ id: i,
124
+ isSubmenu: e,
125
+ isInsideSubmenu: s,
126
+ isSeparator: !1,
127
+ callback: "callback" in t ? t.callback : null,
128
+ data: "data" in t ? t.data : null
129
+ };
130
+ return g.emit(d.ADD_MENU_ENTRY, w, c), c;
131
+ }
132
+ const o = `<li id="${i}" class="${r.separator}"><hr></li>`, l = y(o);
133
+ n.append(l);
134
+ const p = n.lastChild, f = {
135
+ id: i,
136
+ isSubmenu: !1,
137
+ isInsideSubmenu: !1,
138
+ isSeparator: !0,
139
+ callback: null,
140
+ data: null
141
+ };
142
+ return g.emit(d.ADD_MENU_ENTRY, f, p), p;
189
143
  }
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);
195
- const o = document.createElement("ul");
196
- o.classList.add(r.container), o.style.width = `${t}px`, s.append(o), x(o, n.items, t);
144
+ function b(n, t, e, s) {
145
+ t.forEach((i) => {
146
+ if (typeof i != "string" && "items" in i && Array.isArray(i.items)) {
147
+ const o = N(n, i, !0);
148
+ o.classList.add(r.submenu);
149
+ const l = document.createElement("ul");
150
+ l.classList.add(r.container), l.style.width = `${e}px`, o.append(l), b(l, i.items, e, !0);
197
151
  } else
198
- C(i, n);
152
+ N(n, i, !1, s);
199
153
  });
200
154
  }
201
- function v(i, e) {
202
- if (!i)
203
- throw new Error(e);
155
+ function v(n, t) {
156
+ if (!n)
157
+ throw new Error(t);
204
158
  }
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(
159
+ class Y extends I {
160
+ constructor(e = {}) {
161
+ v(typeof e == "object", "@param `opts` should be object type!");
162
+ const s = document.createElement("div");
163
+ super({ element: s });
164
+ a(this, "map");
165
+ a(this, "container");
166
+ a(this, "coordinate", []);
167
+ a(this, "pixel", []);
168
+ a(this, "contextMenuEventListener");
169
+ a(this, "entryCallbackEventListener");
170
+ a(this, "mapMoveListener");
171
+ a(this, "lineHeight", 0);
172
+ a(this, "disabled");
173
+ a(this, "opened");
174
+ a(this, "items", []);
175
+ a(this, "menuEntries", /* @__PURE__ */ new Map());
176
+ a(this, "options");
177
+ this.options = { ...z, ...e };
178
+ const i = document.createElement("ul");
179
+ s.append(i), s.style.width = `${this.options.width}px`, s.classList.add(
226
180
  r.container,
227
181
  r.unselectable,
228
182
  r.hidden
229
- ), this.container = n, this.contextMenuEventListener = (o) => {
183
+ ), this.container = s, this.contextMenuEventListener = (o) => {
230
184
  this.handleContextMenu(o);
231
185
  }, this.entryCallbackEventListener = (o) => {
232
186
  this.handleEntryCallback(o);
233
187
  }, this.mapMoveListener = () => {
234
188
  this.handleMapMove();
235
- }, this.disabled = !1, this.opened = !1;
189
+ }, this.disabled = !1, this.opened = !1, window.addEventListener(
190
+ "beforeunload",
191
+ () => {
192
+ this.removeListeners();
193
+ },
194
+ { once: !0 }
195
+ );
236
196
  }
237
197
  clear() {
238
- for (const t of this.menuEntries.keys())
239
- this.removeMenuEntry(t);
198
+ for (const e of this.menuEntries.keys())
199
+ this.removeMenuEntry(e);
240
200
  this.container.replaceChildren(), this.container.append(document.createElement("ul"));
241
201
  }
242
202
  enable() {
@@ -246,76 +206,75 @@ class j extends P {
246
206
  this.disabled = !0;
247
207
  }
248
208
  getDefaultItems() {
249
- return w;
209
+ return A;
250
210
  }
251
211
  countItems() {
252
212
  return this.menuEntries.size;
253
213
  }
254
- extend(t) {
255
- v(Array.isArray(t), "@param `items` should be an Array."), x(
214
+ extend(e) {
215
+ v(Array.isArray(e), "@param `items` should be an Array."), b(
256
216
  this.container.firstElementChild,
257
- t,
217
+ e,
258
218
  this.options.width
259
219
  );
260
220
  }
261
221
  closeMenu() {
262
- this.opened = !1, this.container.classList.add(r.hidden), this.dispatchEvent(u.CLOSE);
222
+ this.opened = !1, this.container.classList.add(r.hidden), this.dispatchEvent(d.CLOSE);
263
223
  }
264
224
  isOpen() {
265
225
  return this.opened;
266
226
  }
267
- updatePosition(t) {
268
- v(Array.isArray(t), "@param `pixel` should be an Array."), this.isOpen() && (this.pixel = t, this.positionContainer());
227
+ updatePosition(e) {
228
+ v(Array.isArray(e), "@param `pixel` should be an Array."), this.isOpen() && (this.pixel = e, this.positionContainer());
269
229
  }
270
230
  pop() {
271
- const t = Array.from(this.menuEntries.keys()).pop();
272
- t && this.removeMenuEntry(t);
231
+ const e = Array.from(this.menuEntries.keys()).pop();
232
+ e && this.removeMenuEntry(e);
273
233
  }
274
234
  shift() {
275
- const t = Array.from(this.menuEntries.keys()).shift();
276
- t && this.removeMenuEntry(t);
235
+ const e = Array.from(this.menuEntries.keys()).shift();
236
+ e && this.removeMenuEntry(e);
277
237
  }
278
- push(t) {
279
- t && this.extend([t]);
238
+ push(e) {
239
+ e && this.extend([e]);
280
240
  }
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", () => {
241
+ setMap(e) {
242
+ if (super.setMap(e), e) {
243
+ this.map = e, this.map.getViewport().addEventListener(this.options.eventType, this.contextMenuEventListener, !1), this.map.on("movestart", () => {
284
244
  this.handleMapMove();
285
- }), E.on(
286
- u.ADD_MENU_ENTRY,
287
- (s, o) => {
288
- this.handleAddMenuEntry(s, o);
245
+ }), g.on(
246
+ d.ADD_MENU_ENTRY,
247
+ (i, o) => {
248
+ this.handleAddMenuEntry(i, o);
289
249
  },
290
250
  this
291
- ), this.items = this.options.defaultItems ? this.options.items.concat(w) : this.options.items, x(
251
+ ), this.items = this.options.defaultItems ? this.options.items.concat(A) : this.options.items, b(
292
252
  this.container.firstElementChild,
293
253
  this.items,
294
254
  this.options.width
295
255
  );
296
- const n = this.getMenuEntriesLength();
297
- this.lineHeight = n > 0 ? this.container.offsetHeight / n : R(this.container);
256
+ const s = this.getMenuEntriesLength();
257
+ this.lineHeight = s > 0 ? this.container.offsetHeight / s : U(this.container);
298
258
  } else
299
259
  this.removeListeners(), this.clear();
300
260
  }
301
261
  removeListeners() {
302
- this.map.getViewport().removeEventListener(this.options.eventType, this.contextMenuEventListener, !1), E.off(u.ADD_MENU_ENTRY);
262
+ this.map.getViewport().removeEventListener(this.options.eventType, this.contextMenuEventListener, !1), g.off(d.ADD_MENU_ENTRY);
303
263
  }
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);
264
+ removeMenuEntry(e) {
265
+ const s = document.getElementById(e);
266
+ s?.remove(), s?.removeEventListener("click", this.entryCallbackEventListener), this.menuEntries.delete(e);
307
267
  }
308
- handleContextMenu(t) {
309
- var n;
310
- this.coordinate = this.map.getEventCoordinate(t), this.pixel = this.map.getEventPixel(t), this.dispatchEvent(
311
- new L({
312
- type: u.BEFOREOPEN,
268
+ handleContextMenu(e) {
269
+ this.coordinate = this.map.getEventCoordinate(e), this.pixel = this.map.getEventPixel(e), this.dispatchEvent(
270
+ new C({
271
+ type: d.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 === x.CONTEXTMENU && (e.stopPropagation(), e.preventDefault()), setTimeout(() => {
276
+ this.openMenu(e);
277
+ }), e.target?.addEventListener(
319
278
  "pointerdown",
320
279
  (s) => {
321
280
  this.opened && (s.stopPropagation(), this.closeMenu());
@@ -323,64 +282,65 @@ class j extends P {
323
282
  { once: !0 }
324
283
  ));
325
284
  }
326
- openMenu(t) {
327
- this.menuEntries.size !== 0 && (this.opened = !0, this.positionContainer(), this.container.classList.remove(r.hidden), this.dispatchEvent(
328
- new L({
329
- type: u.OPEN,
285
+ openMenu(e) {
286
+ this.opened = !0, this.positionContainer(), this.container.classList.remove(r.hidden), this.dispatchEvent(
287
+ new C({
288
+ type: d.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 && e.isInsideSubmenu === !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], s = {
301
+ w: e[0] - this.pixel[0],
302
+ h: e[1] - this.pixel[1]
303
+ }, i = this.getMenuEntriesLength(), o = {
345
304
  w: this.container.offsetWidth,
346
- 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(
350
- (f) => f.tagName === "LI" && f.classList.contains(r.submenu)
305
+ // a cheap way to recalculate container height
306
+ // since offsetHeight is like cached
307
+ h: Math.round(this.lineHeight * i)
308
+ }, l = s.w >= o.w ? this.pixel[0] + 5 : this.pixel[0] - o.w;
309
+ this.container.style.left = `${l}px`, this.container.style.top = s.h >= o.h ? `${this.pixel[1] - 10}px` : `${this.pixel[1] - o.h}px`, this.container.style.right = "auto", this.container.style.bottom = "auto", s.w -= o.w;
310
+ const p = (m) => Array.from(m.children).filter(
311
+ (c) => c.tagName === "LI" && c.classList.contains(r.submenu)
351
312
  );
352
- 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(
313
+ let f = 0;
314
+ const E = (m, c) => {
315
+ f += 1, p(m).forEach((S) => {
316
+ const $ = c >= o.w ? o.w - 8 : (o.w + 8) * -1, h = S.querySelector(
356
317
  `ul.${r.container}`
357
- ), $ = Math.round(
358
- this.lineHeight * Array.from(h.children).filter((_) => _.tagName === "LI").length
318
+ ), k = Math.round(
319
+ this.lineHeight * Array.from(h.children).filter((T) => T.tagName === "LI").length
359
320
  );
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);
321
+ h.style.left = `${$}px`, h.style.right = "auto", h.style.top = s.h >= k + o.h ? "0" : `-${h.offsetHeight - 25}px`, h.style.bottom = "auto", h.style.zIndex = String(f), p(h).length > 0 && E(h, c - o.w);
361
322
  });
362
323
  };
363
- d(this.container.firstElementChild, n.w);
324
+ E(this.container.firstElementChild, s.w);
364
325
  }
365
326
  handleMapMove() {
366
327
  this.closeMenu();
367
328
  }
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)
329
+ handleEntryCallback(e) {
330
+ e.preventDefault(), e.stopPropagation();
331
+ const s = e.currentTarget, i = this.menuEntries.get(s.id);
332
+ if (!i)
373
333
  return;
374
334
  const o = {
375
335
  coordinate: this.coordinate,
376
- data: s.data
336
+ data: i.data
377
337
  };
378
- this.closeMenu(), (a = s.callback) == null || a.call(s, o, this.map);
338
+ this.closeMenu(), i.callback?.(o, this.map);
379
339
  }
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);
340
+ handleAddMenuEntry(e, s) {
341
+ this.menuEntries.set(e.id, e), this.positionContainer(), "callback" in e && typeof e.callback == "function" && s.addEventListener("click", this.entryCallbackEventListener, !1);
382
342
  }
383
343
  }
384
344
  export {
385
- j as default
345
+ Y as default
386
346
  };
@@ -1,8 +1,8 @@
1
1
 
2
2
  /*!
3
- * ol-contextmenu - v5.1.3
3
+ * ol-contextmenu - v5.1.5
4
4
  * https://github.com/jonataswalker/ol-contextmenu
5
- * Built: Mon Dec 26 2022 20:57:30 GMT-0300 (Brasilia Standard Time)
5
+ * Built: Sat Mar 11 2023 15:05:27 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(l,c){typeof exports=="object"&&typeof module<"u"?module.exports=c(require("ol/control/Control"),require("ol")):typeof define=="function"&&define.amd?define(["ol/control/Control","ol"],c):(l=typeof globalThis<"u"?globalThis:l||self,l.ContextMenu=c(l.ol.control.Control,l.ol))})(this,function(l,c){"use strict";var U=Object.defineProperty;var F=(l,c,d)=>c in l?U(l,c,{enumerable:!0,configurable:!0,writable:!0,value:d}):l[c]=d;var a=(l,c,d)=>(F(l,typeof c!="symbol"?c+"":c,d),d);var d=(n=>(n.CONTEXTMENU="contextmenu",n.CLICK="click",n.DBLCLICK="dblclick",n))(d||{}),m=(n=>(n.BEFOREOPEN="beforeopen",n.OPEN="open",n.CLOSE="close",n.ADD_MENU_ENTRY="add-menu-entry",n))(m||{});class A extends c.MapBrowserEvent{constructor(t){super(t.type,t.map,t.originalEvent)}}const T={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"},N=[{text:"Zoom In",classname:`${r.zoomIn} ${r.icon}`,callback:(n,t)=>{const e=t.getView();e.animate({zoom:Number(e.getZoom())+1,duration:700,center:n.coordinate})}},{text:"Zoom Out",classname:`${r.zoomOut} ${r.icon}`,callback:(n,t)=>{const e=t.getView();e.animate({zoom:Number(e.getZoom())-1,duration:700,center:n.coordinate})}}];var x={},k={get exports(){return x},set exports(n){x=n}};function L(){}L.prototype={on:function(n,t,e){var s=this.e||(this.e={});return(s[n]||(s[n]=[])).push({fn:t,ctx:e}),this},once:function(n,t,e){var s=this;function i(){s.off(n,i),t.apply(e,arguments)}return i._=t,this.on(n,i,e)},emit:function(n){var t=[].slice.call(arguments,1),e=((this.e||(this.e={}))[n]||[]).slice(),s=0,i=e.length;for(s;s<i;s++)e[s].fn.apply(e[s].ctx,t);return this},off:function(n,t){var e=this.e||(this.e={}),s=e[n],i=[];if(s&&t)for(var o=0,h=s.length;o<h;o++)s[o].fn!==t&&s[o].fn._!==t&&i.push(s[o]);return i.length?e[n]=i:delete e[n],this}},k.exports=L;var O=x.TinyEmitter=L;const y=new O;function v(n){const t=document.createDocumentFragment(),e=document.createElement("div");for(e.innerHTML=n;e.firstChild;)t.append(e.firstChild);return t}function D(n){const t=document.importNode(n),e=n.offsetWidth;t.style.cssText=`position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${e}px`;const s=v("<span>Foo</span>"),i=v("<span>Foo</span>"),o=document.createElement("li"),h=document.createElement("li");o.append(s),h.append(i),t.append(o),t.append(h),n.parentNode?.append(t);const E=t.offsetHeight/2;return n.parentNode?.removeChild(t),E}function S(n,t,e=!1,s=!1){const i=`_${Math.random().toString(36).slice(2,11)}`;if(typeof t!="string"&&"text"in t){const b=`<span>${t.text}</span>`,g=v(b),u=document.createElement("li");t.classname=t.classname||"",t.icon&&(t.classname===""?t.classname=r.icon:t.classname.includes(r.icon)===!1&&(t.classname+=` ${r.icon}`),u.setAttribute("style",`background-image:url(${t.icon})`)),u.id=i,u.className=t.classname,u.append(g),n.append(u);const $={id:i,isSubmenu:e,isInsideSubmenu:s,isSeparator:!1,callback:"callback"in t?t.callback:null,data:"data"in t?t.data:null};return y.emit(m.ADD_MENU_ENTRY,$,u),u}const o=`<li id="${i}" class="${r.separator}"><hr></li>`,h=v(o);n.append(h);const E=n.lastChild,M={id:i,isSubmenu:!1,isInsideSubmenu:!1,isSeparator:!0,callback:null,data:null};return y.emit(m.ADD_MENU_ENTRY,M,E),E}function w(n,t,e,s){t.forEach(i=>{if(typeof i!="string"&&"items"in i&&Array.isArray(i.items)){const o=S(n,i,!0);o.classList.add(r.submenu);const h=document.createElement("ul");h.classList.add(r.container),h.style.width=`${e}px`,o.append(h),w(h,i.items,e,!0)}else S(n,i,!1,s)})}const R="";function C(n,t){if(!n)throw new Error(t)}class I extends l{constructor(e={}){C(typeof e=="object","@param `opts` should be object type!");const s=document.createElement("div");super({element:s});a(this,"map");a(this,"container");a(this,"coordinate",[]);a(this,"pixel",[]);a(this,"contextMenuEventListener");a(this,"entryCallbackEventListener");a(this,"mapMoveListener");a(this,"lineHeight",0);a(this,"disabled");a(this,"opened");a(this,"items",[]);a(this,"menuEntries",new Map);a(this,"options");this.options={...T,...e};const i=document.createElement("ul");s.append(i),s.style.width=`${this.options.width}px`,s.classList.add(r.container,r.unselectable,r.hidden),this.container=s,this.contextMenuEventListener=o=>{this.handleContextMenu(o)},this.entryCallbackEventListener=o=>{this.handleEntryCallback(o)},this.mapMoveListener=()=>{this.handleMapMove()},this.disabled=!1,this.opened=!1,window.addEventListener("beforeunload",()=>{this.removeListeners()},{once:!0})}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 N}countItems(){return this.menuEntries.size}extend(e){C(Array.isArray(e),"@param `items` should be an Array."),w(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){C(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()}),y.on(m.ADD_MENU_ENTRY,(i,o)=>{this.handleAddMenuEntry(i,o)},this),this.items=this.options.defaultItems?this.options.items.concat(N):this.options.items,w(this.container.firstElementChild,this.items,this.options.width);const s=this.getMenuEntriesLength();this.lineHeight=s>0?this.container.offsetHeight/s:D(this.container)}else this.removeListeners(),this.clear()}removeListeners(){this.map.getViewport().removeEventListener(this.options.eventType,this.contextMenuEventListener,!1),y.off(m.ADD_MENU_ENTRY)}removeMenuEntry(e){const s=document.getElementById(e);s?.remove(),s?.removeEventListener("click",this.entryCallbackEventListener),this.menuEntries.delete(e)}handleContextMenu(e){this.coordinate=this.map.getEventCoordinate(e),this.pixel=this.map.getEventPixel(e),this.dispatchEvent(new A({type:m.BEFOREOPEN,map:this.map,originalEvent:e})),!this.disabled&&(this.options.eventType===d.CONTEXTMENU&&(e.stopPropagation(),e.preventDefault()),setTimeout(()=>{this.openMenu(e)}),e.target?.addEventListener("pointerdown",s=>{this.opened&&(s.stopPropagation(),this.closeMenu())},{once:!0}))}openMenu(e){this.opened=!0,this.positionContainer(),this.container.classList.remove(r.hidden),this.dispatchEvent(new A({type:m.OPEN,map:this.map,originalEvent:e}))}getMenuEntriesLength(){return Array.from(this.menuEntries).filter(([,e])=>e.isSeparator===!1&&e.isSubmenu===!1&&e.isInsideSubmenu===!1).length}positionContainer(){const e=this.map.getSize()||[0,0],s={w:e[0]-this.pixel[0],h:e[1]-this.pixel[1]},i=this.getMenuEntriesLength(),o={w:this.container.offsetWidth,h:Math.round(this.lineHeight*i)},h=s.w>=o.w?this.pixel[0]+5:this.pixel[0]-o.w;this.container.style.left=`${h}px`,this.container.style.top=s.h>=o.h?`${this.pixel[1]-10}px`:`${this.pixel[1]-o.h}px`,this.container.style.right="auto",this.container.style.bottom="auto",s.w-=o.w;const E=g=>Array.from(g.children).filter(u=>u.tagName==="LI"&&u.classList.contains(r.submenu));let M=0;const b=(g,u)=>{M+=1,E(g).forEach(_=>{const z=u>=o.w?o.w-8:(o.w+8)*-1,p=_.querySelector(`ul.${r.container}`),P=Math.round(this.lineHeight*Array.from(p.children).filter(H=>H.tagName==="LI").length);p.style.left=`${z}px`,p.style.right="auto",p.style.top=s.h>=P+o.h?"0":`-${p.offsetHeight-25}px`,p.style.bottom="auto",p.style.zIndex=String(M),E(p).length>0&&b(p,u-o.w)})};b(this.container.firstElementChild,s.w)}handleMapMove(){this.closeMenu()}handleEntryCallback(e){e.preventDefault(),e.stopPropagation();const s=e.currentTarget,i=this.menuEntries.get(s.id);if(!i)return;const o={coordinate:this.coordinate,data:i.data};this.closeMenu(),i.callback?.(o,this.map)}handleAddMenuEntry(e,s){this.menuEntries.set(e.id,e),this.positionContainer(),"callback"in e&&typeof e.callback=="function"&&s.addEventListener("click",this.entryCallbackEventListener,!1)}}return I});
package/dist/types.d.ts CHANGED
@@ -18,33 +18,34 @@ export declare class ContextMenuEvent extends MapBrowserEvent<MouseEvent> {
18
18
  originalEvent: MouseEvent;
19
19
  });
20
20
  }
21
- export declare type CallbackObject = {
21
+ export type CallbackObject = {
22
22
  coordinate: Coordinate;
23
23
  data: unknown;
24
24
  };
25
- export declare type ItemSeparator = '-';
26
- export declare type SingleItem = {
25
+ export type ItemSeparator = '-';
26
+ export type SingleItem = {
27
27
  text: string;
28
28
  classname?: string;
29
29
  icon?: string;
30
30
  callback: (object: CallbackObject, map: OlMap) => void;
31
31
  data?: unknown;
32
32
  };
33
- export declare type MenuEntry = {
33
+ export type MenuEntry = {
34
34
  id: string;
35
35
  isSubmenu: boolean;
36
+ isInsideSubmenu: boolean;
36
37
  isSeparator: boolean;
37
38
  callback: SingleItem['callback'] | null;
38
39
  data: unknown;
39
40
  };
40
- export declare type ItemWithNested = {
41
+ export type ItemWithNested = {
41
42
  text: string;
42
43
  classname?: string;
43
44
  icon?: string;
44
45
  items: Item[];
45
46
  };
46
- export declare type Item = SingleItem | ItemSeparator | ItemWithNested;
47
- export declare type Options = {
47
+ export type Item = SingleItem | ItemSeparator | ItemWithNested;
48
+ export type Options = {
48
49
  width: number;
49
50
  scrollAt: number;
50
51
  eventType: `${EventTypes}`;
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "ol-contextmenu",
3
- "version": "5.1.3",
3
+ "version": "5.1.5",
4
4
  "description": "Custom Context Menu for Openlayers",
5
5
  "type": "module",
6
- "browser": "./dist/ol-contextmenu.umd.cjs",
6
+ "main": "./dist/ol-contextmenu.umd.cjs",
7
+ "browser": "./dist/ol-contextmenu.iife.js",
7
8
  "module": "./dist/ol-contextmenu.js",
8
9
  "exports": {
9
10
  ".": {
@@ -13,7 +14,8 @@
13
14
  },
14
15
  "./ol-contextmenu.css": {
15
16
  "import": "./dist/ol-contextmenu.css",
16
- "require": "./dist/ol-contextmenu.css"
17
+ "require": "./dist/ol-contextmenu.css",
18
+ "style": "./dist/ol-contextmenu.css"
17
19
  }
18
20
  },
19
21
  "files": [
@@ -38,32 +40,33 @@
38
40
  "dev": "vite",
39
41
  "build": "rimraf ./dist && vite build",
40
42
  "preview": "vite preview",
41
- "lint": "eslint --cache --ext .js .",
43
+ "lint": "eslint .",
42
44
  "lint:fix": "npm run lint -- --fix",
43
45
  "test": "jest",
44
46
  "prepublishOnly": "npm run lint && npm test && npm run build",
45
47
  "prepare": "husky install"
46
48
  },
47
49
  "devDependencies": {
48
- "@swc/core": "^1.3.24",
50
+ "@swc/core": "^1.3.39",
49
51
  "@swc/jest": "^0.2.24",
50
- "@types/jest": "^29.2.4",
51
- "eslint": "^8.30.0",
52
- "eslint-config-jwalker": "^7.10.0",
53
- "eslint-config-prettier": "^8.5.0",
54
- "eslint-plugin-jest": "^27.1.7",
52
+ "@types/jest": "^29.4.0",
53
+ "eslint": "^8.36.0",
54
+ "eslint-config-jwalker": "^8.0.0",
55
+ "eslint-config-prettier": "^8.7.0",
56
+ "eslint-plugin-jest": "^27.2.1",
55
57
  "eslint-plugin-prettier": "^4.2.1",
56
- "husky": "^8.0.2",
58
+ "husky": "^8.0.3",
57
59
  "identity-obj-proxy": "^3.0.0",
58
- "jest": "^29.3.1",
59
- "jest-environment-jsdom": "^29.3.1",
60
- "ol": "^7.2.2",
61
- "prettier": "^2.8.1",
62
- "rimraf": "^3.0.2",
63
- "typescript": "^4.9.4",
64
- "vite": "^4.0.3",
60
+ "jest": "^29.5.0",
61
+ "jest-environment-jsdom": "^29.5.0",
62
+ "ol": "^7.3.0",
63
+ "prettier": "^2.8.4",
64
+ "rimraf": "^4.4.0",
65
+ "sass": "^1.59.2",
66
+ "typescript": "^4.9.5",
67
+ "vite": "^4.1.4",
65
68
  "vite-plugin-banner": "^0.7.0",
66
- "vite-plugin-dts": "^1.7.1"
69
+ "vite-plugin-dts": "^2.1.0"
67
70
  },
68
71
  "peerDependencies": {
69
72
  "ol": "^7.1.0"
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />