@abi-software/flatmapvuer 1.13.5-demo.0 → 1.13.5-demo.2
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/package.json
CHANGED
|
@@ -1738,6 +1738,9 @@ export default {
|
|
|
1738
1738
|
provenanceTaxonomy: taxons,
|
|
1739
1739
|
alert: featuresAlert
|
|
1740
1740
|
}]
|
|
1741
|
+
if (eventType === 'mouseenter') {
|
|
1742
|
+
this.lastHoveredFeature = data;
|
|
1743
|
+
}
|
|
1741
1744
|
if (eventType === 'click') {
|
|
1742
1745
|
// If multiple paths overlap at the click location,
|
|
1743
1746
|
// `data` is an object with numeric keys for each feature (e.g., {0: {...}, 1: {...}, ..., mapUUID: '...'}).
|
|
@@ -3154,6 +3157,62 @@ export default {
|
|
|
3154
3157
|
setConnectionType: function (type) {
|
|
3155
3158
|
this.connectionType = type;
|
|
3156
3159
|
},
|
|
3160
|
+
/**
|
|
3161
|
+
* MutationObserver callback to intercept tooltip popup DOM elements
|
|
3162
|
+
* and customize their content before the browser renders them.
|
|
3163
|
+
*/
|
|
3164
|
+
_handleTooltipMutation: function (mutations) {
|
|
3165
|
+
for (const mutation of mutations) {
|
|
3166
|
+
for (const node of mutation.addedNodes) {
|
|
3167
|
+
if (node.nodeType === 1) {
|
|
3168
|
+
// Check if the added node itself is the tooltip popup
|
|
3169
|
+
if (node.matches && node.matches('.flatmap-tooltip-popup')) {
|
|
3170
|
+
this._applyCustomTooltipContent(node);
|
|
3171
|
+
} else if (node.querySelector) {
|
|
3172
|
+
// Check if it contains a tooltip popup
|
|
3173
|
+
const popup = node.querySelector('.flatmap-tooltip-popup');
|
|
3174
|
+
if (popup) {
|
|
3175
|
+
this._applyCustomTooltipContent(popup);
|
|
3176
|
+
}
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
},
|
|
3182
|
+
/**
|
|
3183
|
+
* Replace the default tooltip content with custom content from
|
|
3184
|
+
* the tooltipContentProvider prop, if available.
|
|
3185
|
+
*/
|
|
3186
|
+
_applyCustomTooltipContent: function (popupEl) {
|
|
3187
|
+
if (!this.tooltipContentProvider || !this.lastHoveredFeature) return;
|
|
3188
|
+
try {
|
|
3189
|
+
const featureData = this.lastHoveredFeature;
|
|
3190
|
+
// Detect multi-feature data format used by click events when multiple
|
|
3191
|
+
// paths overlap: {0: {...}, 1: {...}, ..., mapUUID: '...'}
|
|
3192
|
+
const isMultiFeature = featureData[0] && typeof featureData[0] === 'object';
|
|
3193
|
+
let customHtml;
|
|
3194
|
+
if (isMultiFeature) {
|
|
3195
|
+
const features = [];
|
|
3196
|
+
const mapUUID = featureData.mapUUID;
|
|
3197
|
+
for (const [key, value] of Object.entries(featureData)) {
|
|
3198
|
+
if (key !== 'mapUUID' && value && typeof value === 'object') {
|
|
3199
|
+
features.push({ ...value, mapUUID });
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
customHtml = this.tooltipContentProvider(features.length > 1 ? features : features[0]);
|
|
3203
|
+
} else {
|
|
3204
|
+
customHtml = this.tooltipContentProvider(featureData);
|
|
3205
|
+
}
|
|
3206
|
+
if (customHtml) {
|
|
3207
|
+
const contentEl = popupEl.querySelector('.maplibregl-popup-content');
|
|
3208
|
+
if (contentEl) {
|
|
3209
|
+
contentEl.innerHTML = customHtml;
|
|
3210
|
+
}
|
|
3211
|
+
}
|
|
3212
|
+
} catch (e) {
|
|
3213
|
+
console.warn('[flatmapvuer] Error in tooltipContentProvider:', e);
|
|
3214
|
+
}
|
|
3215
|
+
},
|
|
3157
3216
|
},
|
|
3158
3217
|
props: {
|
|
3159
3218
|
/**
|
|
@@ -3394,6 +3453,17 @@ export default {
|
|
|
3394
3453
|
return []
|
|
3395
3454
|
},
|
|
3396
3455
|
},
|
|
3456
|
+
/**
|
|
3457
|
+
* A function that provides custom tooltip HTML content for path features.
|
|
3458
|
+
* The function receives the feature data from the mouseenter event (including `id`, `label`, etc.)
|
|
3459
|
+
* and should return an HTML string to display in the tooltip, or return null/undefined
|
|
3460
|
+
* to keep the default tooltip.
|
|
3461
|
+
* This is used by mapintegratedvuer to show 'long-label' from connectivity knowledge.
|
|
3462
|
+
*/
|
|
3463
|
+
tooltipContentProvider: {
|
|
3464
|
+
type: Function,
|
|
3465
|
+
default: null,
|
|
3466
|
+
},
|
|
3397
3467
|
},
|
|
3398
3468
|
provide() {
|
|
3399
3469
|
return {
|
|
@@ -3496,6 +3566,8 @@ export default {
|
|
|
3496
3566
|
drawnCreatedEvent: {},
|
|
3497
3567
|
previousEditEvent: {},
|
|
3498
3568
|
previousDeletedEvent: {},
|
|
3569
|
+
lastHoveredFeature: null,
|
|
3570
|
+
tooltipObserver: null,
|
|
3499
3571
|
connectionEntry: {},
|
|
3500
3572
|
existDrawnFeatures: [], // Store all exist drawn features
|
|
3501
3573
|
doubleClickedFeature: false,
|
|
@@ -3694,6 +3766,27 @@ export default {
|
|
|
3694
3766
|
this.createFlatmap()
|
|
3695
3767
|
}
|
|
3696
3768
|
refreshFlatmapKnowledgeCache();
|
|
3769
|
+
|
|
3770
|
+
// Set up MutationObserver to customize tooltip content when
|
|
3771
|
+
// tooltipContentProvider prop is provided.
|
|
3772
|
+
if (this.tooltipContentProvider) {
|
|
3773
|
+
this.$nextTick(() => {
|
|
3774
|
+
const container = this.$refs.flatmapContainer || this.$el;
|
|
3775
|
+
if (container) {
|
|
3776
|
+
this.tooltipObserver = new MutationObserver(this._handleTooltipMutation.bind(this));
|
|
3777
|
+
this.tooltipObserver.observe(container, {
|
|
3778
|
+
childList: true,
|
|
3779
|
+
subtree: true,
|
|
3780
|
+
});
|
|
3781
|
+
}
|
|
3782
|
+
});
|
|
3783
|
+
}
|
|
3784
|
+
},
|
|
3785
|
+
beforeUnmount: function () {
|
|
3786
|
+
if (this.tooltipObserver) {
|
|
3787
|
+
this.tooltipObserver.disconnect();
|
|
3788
|
+
this.tooltipObserver = null;
|
|
3789
|
+
}
|
|
3697
3790
|
},
|
|
3698
3791
|
}
|
|
3699
3792
|
</script>
|
|
@@ -4450,4 +4543,7 @@ export default {
|
|
|
4450
4543
|
}
|
|
4451
4544
|
}
|
|
4452
4545
|
|
|
4546
|
+
.flatmap-feature-label {
|
|
4547
|
+
padding: 6px;
|
|
4548
|
+
}
|
|
4453
4549
|
</style>
|
|
@@ -94,6 +94,7 @@
|
|
|
94
94
|
:showOpenMapButton="showOpenMapButton"
|
|
95
95
|
:showPathwayFilter="showPathwayFilter"
|
|
96
96
|
:externalLegends="externalLegends"
|
|
97
|
+
:tooltipContentProvider="tooltipContentProvider"
|
|
97
98
|
/>
|
|
98
99
|
|
|
99
100
|
<!-- multiflatmap-error -->
|
|
@@ -893,6 +894,14 @@ export default {
|
|
|
893
894
|
return []
|
|
894
895
|
},
|
|
895
896
|
},
|
|
897
|
+
/**
|
|
898
|
+
* A function that provides custom tooltip HTML content for path features.
|
|
899
|
+
* Passed through to each FlatmapVuer instance.
|
|
900
|
+
*/
|
|
901
|
+
tooltipContentProvider: {
|
|
902
|
+
type: Function,
|
|
903
|
+
default: null,
|
|
904
|
+
},
|
|
896
905
|
},
|
|
897
906
|
data: function () {
|
|
898
907
|
return {
|