leaflet-draw-tooltips 1.0.0 → 1.0.1

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,5 +1,5 @@
1
1
  /*!
2
- * leaflet-draw-tooltips v1.0.0
2
+ * leaflet-draw-tooltips v1.0.1
3
3
  * External tooltip plugin for Leaflet.draw - move drawing hints outside the map
4
4
  * @license MIT
5
5
  * @copyright (c) 2025
@@ -331,6 +331,13 @@ function patchDrawTooltip(config) {
331
331
  dispose: function() {
332
332
  this._externalTooltip.dispose();
333
333
  return this;
334
+ },
335
+
336
+ /**
337
+ * 空实现,避免调用时报错
338
+ */
339
+ _onMouseOut: function() {
340
+ return;
334
341
  }
335
342
  });
336
343
 
@@ -1 +1 @@
1
- function t(t,e,i=!0){t&&(i?t.textContent=e||"":t.innerHTML=e||"")}class e{constructor({containerEl:t,sanitize:e=!0,onUpdate:i=null}){this.containerEl=t,this.sanitize=e,this.onUpdate=i,this._visible=!1,this._isError=!1,this._currentContent={text:"",subtext:""},this._setupDOM()}_setupDOM(){this.containerEl.innerHTML="",this.textEl=document.createElement("div"),this.textEl.className="leaflet-draw-hint-text",this.subtextEl=document.createElement("div"),this.subtextEl.className="leaflet-draw-hint-subtext",this.containerEl.appendChild(this.textEl),this.containerEl.appendChild(this.subtextEl),this.containerEl.style.display="none"}updateContent(e){if(!this.containerEl)return this;const{text:i="",subtext:n=""}=e||{};return this._currentContent={text:i,subtext:n},i||n?(t(this.textEl,i,this.sanitize),t(this.subtextEl,n,this.sanitize),this._show()):this._hide(),this._notifyUpdate(),this}updatePosition(t){return this}showAsError(){return this.containerEl?(this._isError=!0,this.containerEl.classList.add("is-error"),this._notifyUpdate(),this):this}removeError(){return this.containerEl?(this._isError=!1,this.containerEl.classList.remove("is-error"),this._notifyUpdate(),this):this}dispose(){this._hide(),this._currentContent={text:"",subtext:""},this.textEl&&(this.textEl.textContent=""),this.subtextEl&&(this.subtextEl.textContent=""),this._notifyUpdate(),this.containerEl=null,this.textEl=null,this.subtextEl=null,this.onUpdate=null}_show(){this.containerEl&&(this._visible||(this._visible=!0,this.containerEl.style.display="block"))}_hide(){this.containerEl&&this._visible&&(this._visible=!1,this.containerEl.style.display="none",this.removeError())}_notifyUpdate(){"function"==typeof this.onUpdate&&this.onUpdate({...this._currentContent},{visible:this._visible,isError:this._isError})}}function i(t={}){const{map:i,el:n,hideMapTooltip:s=!0,sanitize:o=!0,onUpdate:r=null}=t;if(!i||"function"!=typeof i.on)throw new Error("[leaflet-draw-tooltip] options.map 必须是有效的 Leaflet Map 实例");if(!n)throw new Error("[leaflet-draw-tooltip] options.el 必须提供(HTMLElement 或选择器)");const l=function(t){if(t instanceof HTMLElement)return t;if("string"==typeof t){const e=document.querySelector(t);if(!e)throw new Error(`[leaflet-draw-tooltip] 找不到元素: ${t}`);return e}throw new Error("[leaflet-draw-tooltip] el 必须是 HTMLElement 或选择器字符串")}(n);if(s){const t=i.getContainer();t&&t.classList.add("leaflet-draw-tooltip-hide")}const a={containerEl:l,sanitize:o,onUpdate:r};!function(t){if("undefined"==typeof L||!L.Draw||!L.Draw.Tooltip)throw new Error("[leaflet-draw-tooltip] Leaflet.draw 未加载,请确保在加载 leaflet-draw 之后调用");const i=L.Draw.Tooltip;L.Draw.Tooltip=L.Class.extend({initialize:function(i){this._externalTooltip=new e(t)},updateContent:function(t){return this._externalTooltip.updateContent(t),this},updatePosition:function(t){return this._externalTooltip.updatePosition(t),this},showAsError:function(){return this._externalTooltip.showAsError(),this},removeError:function(){return this._externalTooltip.removeError(),this},dispose:function(){return this._externalTooltip.dispose(),this}}),L.Draw.Tooltip._isPatched=!0,L.Draw.Tooltip._originalClass=i}(a);const h=new e(a);return{cleanup:function(){if(h&&h.dispose(),s){const t=i.getContainer();t&&t.classList.remove("leaflet-draw-tooltip-hide")}},tooltip:h}}export{i as installLeafletDrawExternalTooltip};
1
+ function t(t,e,i=!0){t&&(i?t.textContent=e||"":t.innerHTML=e||"")}class e{constructor({containerEl:t,sanitize:e=!0,onUpdate:i=null}){this.containerEl=t,this.sanitize=e,this.onUpdate=i,this._visible=!1,this._isError=!1,this._currentContent={text:"",subtext:""},this._setupDOM()}_setupDOM(){this.containerEl.innerHTML="",this.textEl=document.createElement("div"),this.textEl.className="leaflet-draw-hint-text",this.subtextEl=document.createElement("div"),this.subtextEl.className="leaflet-draw-hint-subtext",this.containerEl.appendChild(this.textEl),this.containerEl.appendChild(this.subtextEl),this.containerEl.style.display="none"}updateContent(e){if(!this.containerEl)return this;const{text:i="",subtext:n=""}=e||{};return this._currentContent={text:i,subtext:n},i||n?(t(this.textEl,i,this.sanitize),t(this.subtextEl,n,this.sanitize),this._show()):this._hide(),this._notifyUpdate(),this}updatePosition(t){return this}showAsError(){return this.containerEl?(this._isError=!0,this.containerEl.classList.add("is-error"),this._notifyUpdate(),this):this}removeError(){return this.containerEl?(this._isError=!1,this.containerEl.classList.remove("is-error"),this._notifyUpdate(),this):this}dispose(){this._hide(),this._currentContent={text:"",subtext:""},this.textEl&&(this.textEl.textContent=""),this.subtextEl&&(this.subtextEl.textContent=""),this._notifyUpdate(),this.containerEl=null,this.textEl=null,this.subtextEl=null,this.onUpdate=null}_show(){this.containerEl&&(this._visible||(this._visible=!0,this.containerEl.style.display="block"))}_hide(){this.containerEl&&this._visible&&(this._visible=!1,this.containerEl.style.display="none",this.removeError())}_notifyUpdate(){"function"==typeof this.onUpdate&&this.onUpdate({...this._currentContent},{visible:this._visible,isError:this._isError})}}function i(t={}){const{map:i,el:n,hideMapTooltip:s=!0,sanitize:o=!0,onUpdate:r=null}=t;if(!i||"function"!=typeof i.on)throw new Error("[leaflet-draw-tooltip] options.map 必须是有效的 Leaflet Map 实例");if(!n)throw new Error("[leaflet-draw-tooltip] options.el 必须提供(HTMLElement 或选择器)");const l=function(t){if(t instanceof HTMLElement)return t;if("string"==typeof t){const e=document.querySelector(t);if(!e)throw new Error(`[leaflet-draw-tooltip] 找不到元素: ${t}`);return e}throw new Error("[leaflet-draw-tooltip] el 必须是 HTMLElement 或选择器字符串")}(n);if(s){const t=i.getContainer();t&&t.classList.add("leaflet-draw-tooltip-hide")}const a={containerEl:l,sanitize:o,onUpdate:r};!function(t){if("undefined"==typeof L||!L.Draw||!L.Draw.Tooltip)throw new Error("[leaflet-draw-tooltip] Leaflet.draw 未加载,请确保在加载 leaflet-draw 之后调用");const i=L.Draw.Tooltip;L.Draw.Tooltip=L.Class.extend({initialize:function(i){this._externalTooltip=new e(t)},updateContent:function(t){return this._externalTooltip.updateContent(t),this},updatePosition:function(t){return this._externalTooltip.updatePosition(t),this},showAsError:function(){return this._externalTooltip.showAsError(),this},removeError:function(){return this._externalTooltip.removeError(),this},dispose:function(){return this._externalTooltip.dispose(),this},_onMouseOut:function(){}}),L.Draw.Tooltip._isPatched=!0,L.Draw.Tooltip._originalClass=i}(a);const h=new e(a);return{cleanup:function(){if(h&&h.dispose(),s){const t=i.getContainer();t&&t.classList.remove("leaflet-draw-tooltip-hide")}},tooltip:h}}export{i as installLeafletDrawExternalTooltip};
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).LeafletDrawTooltip={})}(this,function(t){"use strict";function e(t,e,i=!0){t&&(i?t.textContent=e||"":t.innerHTML=e||"")}class i{constructor({containerEl:t,sanitize:e=!0,onUpdate:i=null}){this.containerEl=t,this.sanitize=e,this.onUpdate=i,this._visible=!1,this._isError=!1,this._currentContent={text:"",subtext:""},this._setupDOM()}_setupDOM(){this.containerEl.innerHTML="",this.textEl=document.createElement("div"),this.textEl.className="leaflet-draw-hint-text",this.subtextEl=document.createElement("div"),this.subtextEl.className="leaflet-draw-hint-subtext",this.containerEl.appendChild(this.textEl),this.containerEl.appendChild(this.subtextEl),this.containerEl.style.display="none"}updateContent(t){if(!this.containerEl)return this;const{text:i="",subtext:n=""}=t||{};return this._currentContent={text:i,subtext:n},i||n?(e(this.textEl,i,this.sanitize),e(this.subtextEl,n,this.sanitize),this._show()):this._hide(),this._notifyUpdate(),this}updatePosition(t){return this}showAsError(){return this.containerEl?(this._isError=!0,this.containerEl.classList.add("is-error"),this._notifyUpdate(),this):this}removeError(){return this.containerEl?(this._isError=!1,this.containerEl.classList.remove("is-error"),this._notifyUpdate(),this):this}dispose(){this._hide(),this._currentContent={text:"",subtext:""},this.textEl&&(this.textEl.textContent=""),this.subtextEl&&(this.subtextEl.textContent=""),this._notifyUpdate(),this.containerEl=null,this.textEl=null,this.subtextEl=null,this.onUpdate=null}_show(){this.containerEl&&(this._visible||(this._visible=!0,this.containerEl.style.display="block"))}_hide(){this.containerEl&&this._visible&&(this._visible=!1,this.containerEl.style.display="none",this.removeError())}_notifyUpdate(){"function"==typeof this.onUpdate&&this.onUpdate({...this._currentContent},{visible:this._visible,isError:this._isError})}}t.installLeafletDrawExternalTooltip=function(t={}){const{map:e,el:n,hideMapTooltip:o=!0,sanitize:s=!0,onUpdate:r=null}=t;if(!e||"function"!=typeof e.on)throw new Error("[leaflet-draw-tooltip] options.map 必须是有效的 Leaflet Map 实例");if(!n)throw new Error("[leaflet-draw-tooltip] options.el 必须提供(HTMLElement 或选择器)");const l=function(t){if(t instanceof HTMLElement)return t;if("string"==typeof t){const e=document.querySelector(t);if(!e)throw new Error(`[leaflet-draw-tooltip] 找不到元素: ${t}`);return e}throw new Error("[leaflet-draw-tooltip] el 必须是 HTMLElement 或选择器字符串")}(n);if(o){const t=e.getContainer();t&&t.classList.add("leaflet-draw-tooltip-hide")}const a={containerEl:l,sanitize:s,onUpdate:r};!function(t){if("undefined"==typeof L||!L.Draw||!L.Draw.Tooltip)throw new Error("[leaflet-draw-tooltip] Leaflet.draw 未加载,请确保在加载 leaflet-draw 之后调用");const e=L.Draw.Tooltip;L.Draw.Tooltip=L.Class.extend({initialize:function(e){this._externalTooltip=new i(t)},updateContent:function(t){return this._externalTooltip.updateContent(t),this},updatePosition:function(t){return this._externalTooltip.updatePosition(t),this},showAsError:function(){return this._externalTooltip.showAsError(),this},removeError:function(){return this._externalTooltip.removeError(),this},dispose:function(){return this._externalTooltip.dispose(),this}}),L.Draw.Tooltip._isPatched=!0,L.Draw.Tooltip._originalClass=e}(a);const h=new i(a);return{cleanup:function(){if(h&&h.dispose(),o){const t=e.getContainer();t&&t.classList.remove("leaflet-draw-tooltip-hide")}},tooltip:h}}});
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).LeafletDrawTooltip={})}(this,function(t){"use strict";function e(t,e,i=!0){t&&(i?t.textContent=e||"":t.innerHTML=e||"")}class i{constructor({containerEl:t,sanitize:e=!0,onUpdate:i=null}){this.containerEl=t,this.sanitize=e,this.onUpdate=i,this._visible=!1,this._isError=!1,this._currentContent={text:"",subtext:""},this._setupDOM()}_setupDOM(){this.containerEl.innerHTML="",this.textEl=document.createElement("div"),this.textEl.className="leaflet-draw-hint-text",this.subtextEl=document.createElement("div"),this.subtextEl.className="leaflet-draw-hint-subtext",this.containerEl.appendChild(this.textEl),this.containerEl.appendChild(this.subtextEl),this.containerEl.style.display="none"}updateContent(t){if(!this.containerEl)return this;const{text:i="",subtext:n=""}=t||{};return this._currentContent={text:i,subtext:n},i||n?(e(this.textEl,i,this.sanitize),e(this.subtextEl,n,this.sanitize),this._show()):this._hide(),this._notifyUpdate(),this}updatePosition(t){return this}showAsError(){return this.containerEl?(this._isError=!0,this.containerEl.classList.add("is-error"),this._notifyUpdate(),this):this}removeError(){return this.containerEl?(this._isError=!1,this.containerEl.classList.remove("is-error"),this._notifyUpdate(),this):this}dispose(){this._hide(),this._currentContent={text:"",subtext:""},this.textEl&&(this.textEl.textContent=""),this.subtextEl&&(this.subtextEl.textContent=""),this._notifyUpdate(),this.containerEl=null,this.textEl=null,this.subtextEl=null,this.onUpdate=null}_show(){this.containerEl&&(this._visible||(this._visible=!0,this.containerEl.style.display="block"))}_hide(){this.containerEl&&this._visible&&(this._visible=!1,this.containerEl.style.display="none",this.removeError())}_notifyUpdate(){"function"==typeof this.onUpdate&&this.onUpdate({...this._currentContent},{visible:this._visible,isError:this._isError})}}t.installLeafletDrawExternalTooltip=function(t={}){const{map:e,el:n,hideMapTooltip:o=!0,sanitize:s=!0,onUpdate:r=null}=t;if(!e||"function"!=typeof e.on)throw new Error("[leaflet-draw-tooltip] options.map 必须是有效的 Leaflet Map 实例");if(!n)throw new Error("[leaflet-draw-tooltip] options.el 必须提供(HTMLElement 或选择器)");const l=function(t){if(t instanceof HTMLElement)return t;if("string"==typeof t){const e=document.querySelector(t);if(!e)throw new Error(`[leaflet-draw-tooltip] 找不到元素: ${t}`);return e}throw new Error("[leaflet-draw-tooltip] el 必须是 HTMLElement 或选择器字符串")}(n);if(o){const t=e.getContainer();t&&t.classList.add("leaflet-draw-tooltip-hide")}const a={containerEl:l,sanitize:s,onUpdate:r};!function(t){if("undefined"==typeof L||!L.Draw||!L.Draw.Tooltip)throw new Error("[leaflet-draw-tooltip] Leaflet.draw 未加载,请确保在加载 leaflet-draw 之后调用");const e=L.Draw.Tooltip;L.Draw.Tooltip=L.Class.extend({initialize:function(e){this._externalTooltip=new i(t)},updateContent:function(t){return this._externalTooltip.updateContent(t),this},updatePosition:function(t){return this._externalTooltip.updatePosition(t),this},showAsError:function(){return this._externalTooltip.showAsError(),this},removeError:function(){return this._externalTooltip.removeError(),this},dispose:function(){return this._externalTooltip.dispose(),this},_onMouseOut:function(){}}),L.Draw.Tooltip._isPatched=!0,L.Draw.Tooltip._originalClass=e}(a);const h=new i(a);return{cleanup:function(){if(h&&h.dispose(),o){const t=e.getContainer();t&&t.classList.remove("leaflet-draw-tooltip-hide")}},tooltip:h}}});
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * leaflet-draw-tooltips v1.0.0
2
+ * leaflet-draw-tooltips v1.0.1
3
3
  * External tooltip plugin for Leaflet.draw - move drawing hints outside the map
4
4
  * @license MIT
5
5
  * @copyright (c) 2025
@@ -337,6 +337,13 @@
337
337
  dispose: function() {
338
338
  this._externalTooltip.dispose();
339
339
  return this;
340
+ },
341
+
342
+ /**
343
+ * 空实现,避免调用时报错
344
+ */
345
+ _onMouseOut: function() {
346
+ return;
340
347
  }
341
348
  });
342
349
 
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "leaflet-draw-tooltips",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "External tooltip plugin for Leaflet.draw - move drawing hints outside the map",
5
- "main": "dist/leaflet-draw-tooltip.umd.cjs",
6
- "module": "dist/leaflet-draw-tooltip.js",
5
+ "main": "dist/leaflet-draw-tooltips.umd.cjs",
6
+ "module": "dist/leaflet-draw-tooltips.js",
7
7
  "type": "module",
8
8
  "exports": {
9
9
  ".": {
10
- "import": "./dist/leaflet-draw-tooltip.js",
11
- "require": "./dist/leaflet-draw-tooltip.umd.cjs"
10
+ "import": "./dist/leaflet-draw-tooltips.js",
11
+ "require": "./dist/leaflet-draw-tooltips.umd.cjs"
12
12
  }
13
13
  },
14
14
  "files": [
@@ -21,7 +21,7 @@
21
21
  "keywords": [
22
22
  "leaflet",
23
23
  "leaflet-draw",
24
- "tooltip",
24
+ "tooltips",
25
25
  "external",
26
26
  "plugin"
27
27
  ],
@@ -29,12 +29,12 @@
29
29
  "license": "MIT",
30
30
  "repository": {
31
31
  "type": "git",
32
- "url": "https://github.com/Qun88/leaflet-draw-tooltip.git"
32
+ "url": "https://github.com/Qun88/leaflet-draw-tooltips.git"
33
33
  },
34
34
  "bugs": {
35
- "url": "https://github.com/Qun88/leaflet-draw-tooltip/issues"
35
+ "url": "https://github.com/Qun88/leaflet-draw-tooltips/issues"
36
36
  },
37
- "homepage": "https://github.com/Qun88/leaflet-draw-tooltip#readme",
37
+ "homepage": "https://github.com/Qun88/leaflet-draw-tooltips#readme",
38
38
  "devDependencies": {
39
39
  "@rollup/plugin-terser": "^0.4.4",
40
40
  "rollup": "^4.54.0",
@@ -76,6 +76,13 @@ export function patchDrawTooltip(config) {
76
76
  dispose: function() {
77
77
  this._externalTooltip.dispose();
78
78
  return this;
79
+ },
80
+
81
+ /**
82
+ * 空实现,避免调用时报错
83
+ */
84
+ _onMouseOut: function() {
85
+ return;
79
86
  }
80
87
  });
81
88