maplibre-gl-layer-control 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +51 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +51 -6
- package/dist/index.mjs.map +1 -1
- package/dist/maplibre-gl-layer-control.css +75 -0
- package/dist/types/index.d.ts +5 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2200,10 +2200,10 @@ class LayerControl {
|
|
|
2200
2200
|
removeBtn.title = "Remove layer from map";
|
|
2201
2201
|
removeBtn.addEventListener("click", (e) => {
|
|
2202
2202
|
e.stopPropagation();
|
|
2203
|
-
|
|
2203
|
+
this.showRemoveConfirmation(editor, () => {
|
|
2204
2204
|
this.closeStyleEditor(layerId);
|
|
2205
2205
|
this.removeLayer(layerId);
|
|
2206
|
-
}
|
|
2206
|
+
});
|
|
2207
2207
|
});
|
|
2208
2208
|
const closeActionBtn = document.createElement("button");
|
|
2209
2209
|
closeActionBtn.className = "style-editor-button style-editor-button-close";
|
|
@@ -2292,10 +2292,10 @@ class LayerControl {
|
|
|
2292
2292
|
removeBtn.title = "Remove layer from map";
|
|
2293
2293
|
removeBtn.addEventListener("click", (e) => {
|
|
2294
2294
|
e.stopPropagation();
|
|
2295
|
-
|
|
2295
|
+
this.showRemoveConfirmation(editor, () => {
|
|
2296
2296
|
this.closeStyleEditor(layerId);
|
|
2297
2297
|
this.removeLayer(layerId);
|
|
2298
|
-
}
|
|
2298
|
+
});
|
|
2299
2299
|
});
|
|
2300
2300
|
const closeActionBtn = document.createElement("button");
|
|
2301
2301
|
closeActionBtn.className = "style-editor-button style-editor-button-close";
|
|
@@ -2375,10 +2375,10 @@ class LayerControl {
|
|
|
2375
2375
|
removeBtn.title = "Remove layer from map";
|
|
2376
2376
|
removeBtn.addEventListener("click", (e) => {
|
|
2377
2377
|
e.stopPropagation();
|
|
2378
|
-
|
|
2378
|
+
this.showRemoveConfirmation(editor, () => {
|
|
2379
2379
|
this.closeStyleEditor(layerId);
|
|
2380
2380
|
this.removeLayer(layerId);
|
|
2381
|
-
}
|
|
2381
|
+
});
|
|
2382
2382
|
});
|
|
2383
2383
|
const closeActionBtn = document.createElement("button");
|
|
2384
2384
|
closeActionBtn.className = "style-editor-button style-editor-button-close";
|
|
@@ -3247,6 +3247,51 @@ class LayerControl {
|
|
|
3247
3247
|
this.buildLayerItems();
|
|
3248
3248
|
(_b = this.onLayerReorder) == null ? void 0 : _b.call(this, this.getUserLayerIdsInMapOrder());
|
|
3249
3249
|
}
|
|
3250
|
+
/**
|
|
3251
|
+
* Show inline remove confirmation instead of browser confirm() dialog.
|
|
3252
|
+
* Works in Jupyter notebooks where native dialogs may not appear.
|
|
3253
|
+
*/
|
|
3254
|
+
showRemoveConfirmation(container, onConfirm) {
|
|
3255
|
+
const existing = container.querySelector(".layer-control-remove-confirm");
|
|
3256
|
+
if (existing) {
|
|
3257
|
+
existing.remove();
|
|
3258
|
+
}
|
|
3259
|
+
const confirmEl = document.createElement("div");
|
|
3260
|
+
confirmEl.className = "layer-control-remove-confirm";
|
|
3261
|
+
const message = document.createElement("div");
|
|
3262
|
+
message.className = "layer-control-remove-confirm-message";
|
|
3263
|
+
message.innerHTML = `
|
|
3264
|
+
<svg class="layer-control-remove-confirm-icon" viewBox="0 0 20 20" fill="currentColor">
|
|
3265
|
+
<path fill-rule="evenodd" d="M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd"/>
|
|
3266
|
+
</svg>
|
|
3267
|
+
<span>Remove this layer?</span>
|
|
3268
|
+
`;
|
|
3269
|
+
const buttons = document.createElement("div");
|
|
3270
|
+
buttons.className = "layer-control-remove-confirm-buttons";
|
|
3271
|
+
const cancelBtn = document.createElement("button");
|
|
3272
|
+
cancelBtn.className = "layer-control-remove-confirm-btn layer-control-remove-confirm-btn-cancel";
|
|
3273
|
+
cancelBtn.textContent = "Cancel";
|
|
3274
|
+
cancelBtn.addEventListener("click", (e) => {
|
|
3275
|
+
e.stopPropagation();
|
|
3276
|
+
confirmEl.remove();
|
|
3277
|
+
});
|
|
3278
|
+
const confirmBtn = document.createElement("button");
|
|
3279
|
+
confirmBtn.className = "layer-control-remove-confirm-btn layer-control-remove-confirm-btn-confirm";
|
|
3280
|
+
confirmBtn.textContent = "Remove";
|
|
3281
|
+
confirmBtn.addEventListener("click", (e) => {
|
|
3282
|
+
e.stopPropagation();
|
|
3283
|
+
confirmEl.remove();
|
|
3284
|
+
onConfirm();
|
|
3285
|
+
});
|
|
3286
|
+
buttons.appendChild(cancelBtn);
|
|
3287
|
+
buttons.appendChild(confirmBtn);
|
|
3288
|
+
confirmEl.appendChild(message);
|
|
3289
|
+
confirmEl.appendChild(buttons);
|
|
3290
|
+
container.appendChild(confirmEl);
|
|
3291
|
+
requestAnimationFrame(() => {
|
|
3292
|
+
confirmEl.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
3293
|
+
});
|
|
3294
|
+
}
|
|
3250
3295
|
/**
|
|
3251
3296
|
* Remove a layer from the map
|
|
3252
3297
|
*/
|