@emuanalytics/flow-rdf-core 4.1.1 → 4.1.3
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/lib/expressions/functions/from-palette.mjs +1 -1
- package/dist/lib/map/plugins/hover/hover.plugin.mjs +17 -9
- package/dist/lib/map/plugins/hover/source-hover.mjs +1 -1
- package/dist/lib/map/plugins/index.d.mts +12 -4
- package/dist/lib/map/plugins/index.d.ts +12 -4
- package/dist/package.json.mjs +1 -1
- package/package.json +2 -2
|
@@ -17,7 +17,7 @@ function fromPalette(expr, parentExpression) {
|
|
|
17
17
|
let colorStops = expr.slice(3);
|
|
18
18
|
let palette;
|
|
19
19
|
if (isString(paletteIdOrArray)) {
|
|
20
|
-
palette = palettes[paletteIdOrArray.toLowerCase()]?.colors || palettes["
|
|
20
|
+
palette = palettes[paletteIdOrArray.toLowerCase()]?.colors || palettes["greys"].colors;
|
|
21
21
|
} else if (isArray(paletteIdOrArray) && paletteIdOrArray[0] === "literal") {
|
|
22
22
|
palette = paletteIdOrArray[1];
|
|
23
23
|
} else {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Debug from 'debug';
|
|
2
|
+
import { isFeatureWithId } from '../../types.mjs';
|
|
2
3
|
import { MapPluginBase } from '../map-plugin-base.mjs';
|
|
3
4
|
import { PopupPlugin } from '../popup.plugin.mjs';
|
|
4
5
|
import { SourceHover } from './source-hover.mjs';
|
|
@@ -22,6 +23,13 @@ class HoverPlugin extends MapPluginBase {
|
|
|
22
23
|
super(pluginManager);
|
|
23
24
|
__publicField(this, "_sourceHovers", /* @__PURE__ */ new Map());
|
|
24
25
|
__publicField(this, "_enablePopups", true);
|
|
26
|
+
/**
|
|
27
|
+
* Compatibility mode replicates the behavior of the deprecated HoverEffectPlugin by implicitly enabling
|
|
28
|
+
* hover support for all interactive map layers.
|
|
29
|
+
*
|
|
30
|
+
* This behaviour may be removed at a future date so it is recommended to explicitly enable hover for each
|
|
31
|
+
* data source where hover effects are required by calling the {@link enableHover} method.
|
|
32
|
+
*/
|
|
25
33
|
__publicField(this, "_compatibilityMode", true);
|
|
26
34
|
__publicField(this, "name", "HoverPlugin");
|
|
27
35
|
try {
|
|
@@ -39,7 +47,6 @@ class HoverPlugin extends MapPluginBase {
|
|
|
39
47
|
* @param options Selection options
|
|
40
48
|
*/
|
|
41
49
|
enableHover(source, options = {}) {
|
|
42
|
-
this._compatibilityMode = false;
|
|
43
50
|
if (options.popup) {
|
|
44
51
|
try {
|
|
45
52
|
this.map.getPlugin(PopupPlugin);
|
|
@@ -56,11 +63,10 @@ class HoverPlugin extends MapPluginBase {
|
|
|
56
63
|
* @param source Map data source ID
|
|
57
64
|
*/
|
|
58
65
|
disableHover(source) {
|
|
59
|
-
this._compatibilityMode = false;
|
|
60
66
|
if (this._sourceHovers.has(source)) {
|
|
61
67
|
this._sourceHovers.get(source).destroy();
|
|
62
|
-
this._sourceHovers.delete(source);
|
|
63
68
|
}
|
|
69
|
+
this._sourceHovers.set(source, null);
|
|
64
70
|
}
|
|
65
71
|
/**
|
|
66
72
|
* Enable display of popups when a feature is hovered and an associated popup has been registered with the map data source.
|
|
@@ -82,16 +88,18 @@ class HoverPlugin extends MapPluginBase {
|
|
|
82
88
|
}
|
|
83
89
|
/** @internal MapPluginBase handler */
|
|
84
90
|
handleMouseMove(event) {
|
|
85
|
-
|
|
91
|
+
const hoveredFeature = event.features[0];
|
|
92
|
+
if (isFeatureWithId(hoveredFeature) && this._compatibilityMode) {
|
|
86
93
|
const sourceId = event.features[0]?.source;
|
|
87
94
|
if (sourceId && !this._sourceHovers.has(sourceId)) {
|
|
88
95
|
debug(`Enabling implicit hover support for source '${sourceId}' in compatibility mode`);
|
|
89
96
|
this._sourceHovers.set(sourceId, new SourceHover(this, sourceId, {}));
|
|
90
97
|
}
|
|
91
98
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
99
|
+
this._sourceHovers.forEach(
|
|
100
|
+
(hover) => hover && hover.handleMouseMove(event.lngLat, hoveredFeature, this._enablePopups)
|
|
101
|
+
);
|
|
102
|
+
const isFeatureHovered = Array.from(this._sourceHovers.values()).filter((hover) => !!hover).some((hover) => hover && !!hover.hoveredFeature);
|
|
95
103
|
if (isFeatureHovered) {
|
|
96
104
|
this.map.maplibreMap._container.classList.add("feature-hovered");
|
|
97
105
|
} else {
|
|
@@ -101,7 +109,7 @@ class HoverPlugin extends MapPluginBase {
|
|
|
101
109
|
/** @internal MapPluginBase handler */
|
|
102
110
|
handleClick(event) {
|
|
103
111
|
const hoveredFeature = event.features[0];
|
|
104
|
-
this._sourceHovers.forEach((hover) => hover.handleClick(event, hoveredFeature));
|
|
112
|
+
this._sourceHovers.forEach((hover) => hover && hover.handleClick(event, hoveredFeature));
|
|
105
113
|
}
|
|
106
114
|
/** @internal MapPluginBase handler */
|
|
107
115
|
handleMouseOut(_event) {
|
|
@@ -114,7 +122,7 @@ class HoverPlugin extends MapPluginBase {
|
|
|
114
122
|
}
|
|
115
123
|
}
|
|
116
124
|
clearHover() {
|
|
117
|
-
this._sourceHovers.forEach((hover) => hover.clearHover());
|
|
125
|
+
this._sourceHovers.forEach((hover) => hover && hover.clearHover());
|
|
118
126
|
this.map.maplibreMap._container.classList.remove("feature-hovered");
|
|
119
127
|
}
|
|
120
128
|
}
|
|
@@ -68,7 +68,7 @@ class SourceHover {
|
|
|
68
68
|
this.clearHover();
|
|
69
69
|
}
|
|
70
70
|
showHover(feature, lngLat, enablePopups) {
|
|
71
|
-
assert(isFeatureWithId(feature));
|
|
71
|
+
assert(isFeatureWithId(feature), "Feature must have an ID to support hover");
|
|
72
72
|
this._map.setFeatureState(feature, { hover: true }, false);
|
|
73
73
|
let selected = false;
|
|
74
74
|
try {
|
|
@@ -963,10 +963,11 @@ interface HoverOptions {
|
|
|
963
963
|
*
|
|
964
964
|
* :::warning
|
|
965
965
|
* This plugin supersedes the deprecated {@link HoverEffectPlugin}. To preserve the
|
|
966
|
-
* behavior of the {@link HoverEffectPlugin}, the {@link HoverPlugin}
|
|
967
|
-
*
|
|
968
|
-
*
|
|
969
|
-
*
|
|
966
|
+
* behavior of the {@link HoverEffectPlugin}, the {@link HoverPlugin} will implicitly
|
|
967
|
+
* enable hover for **all** map data sources with interactive layers. This behaviour
|
|
968
|
+
* may be removed at a future date so it is recommended to explicitly enable hover for
|
|
969
|
+
* each data source where hover effects are required by calling the {@link enableHover}
|
|
970
|
+
* method.
|
|
970
971
|
* :::
|
|
971
972
|
*
|
|
972
973
|
* ## Hover Popups
|
|
@@ -1022,6 +1023,13 @@ interface HoverOptions {
|
|
|
1022
1023
|
declare class HoverPlugin extends MapPluginBase {
|
|
1023
1024
|
private _sourceHovers;
|
|
1024
1025
|
private _enablePopups;
|
|
1026
|
+
/**
|
|
1027
|
+
* Compatibility mode replicates the behavior of the deprecated HoverEffectPlugin by implicitly enabling
|
|
1028
|
+
* hover support for all interactive map layers.
|
|
1029
|
+
*
|
|
1030
|
+
* This behaviour may be removed at a future date so it is recommended to explicitly enable hover for each
|
|
1031
|
+
* data source where hover effects are required by calling the {@link enableHover} method.
|
|
1032
|
+
*/
|
|
1025
1033
|
private _compatibilityMode;
|
|
1026
1034
|
readonly name = "HoverPlugin";
|
|
1027
1035
|
/**
|
|
@@ -963,10 +963,11 @@ interface HoverOptions {
|
|
|
963
963
|
*
|
|
964
964
|
* :::warning
|
|
965
965
|
* This plugin supersedes the deprecated {@link HoverEffectPlugin}. To preserve the
|
|
966
|
-
* behavior of the {@link HoverEffectPlugin}, the {@link HoverPlugin}
|
|
967
|
-
*
|
|
968
|
-
*
|
|
969
|
-
*
|
|
966
|
+
* behavior of the {@link HoverEffectPlugin}, the {@link HoverPlugin} will implicitly
|
|
967
|
+
* enable hover for **all** map data sources with interactive layers. This behaviour
|
|
968
|
+
* may be removed at a future date so it is recommended to explicitly enable hover for
|
|
969
|
+
* each data source where hover effects are required by calling the {@link enableHover}
|
|
970
|
+
* method.
|
|
970
971
|
* :::
|
|
971
972
|
*
|
|
972
973
|
* ## Hover Popups
|
|
@@ -1022,6 +1023,13 @@ interface HoverOptions {
|
|
|
1022
1023
|
declare class HoverPlugin extends MapPluginBase {
|
|
1023
1024
|
private _sourceHovers;
|
|
1024
1025
|
private _enablePopups;
|
|
1026
|
+
/**
|
|
1027
|
+
* Compatibility mode replicates the behavior of the deprecated HoverEffectPlugin by implicitly enabling
|
|
1028
|
+
* hover support for all interactive map layers.
|
|
1029
|
+
*
|
|
1030
|
+
* This behaviour may be removed at a future date so it is recommended to explicitly enable hover for each
|
|
1031
|
+
* data source where hover effects are required by calling the {@link enableHover} method.
|
|
1032
|
+
*/
|
|
1025
1033
|
private _compatibilityMode;
|
|
1026
1034
|
readonly name = "HoverPlugin";
|
|
1027
1035
|
/**
|
package/dist/package.json.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emuanalytics/flow-rdf-core",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"packageManager": "pnpm@7.33.0",
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@emuanalytics/flow-engine-client": "^2.
|
|
74
|
+
"@emuanalytics/flow-engine-client": "^2.2.5",
|
|
75
75
|
"@emuanalytics/mapbox-gl-draw": "^1.3.2",
|
|
76
76
|
"@emuanalytics/maplibre-gl": "^5.8.0",
|
|
77
77
|
"@emuanalytics/maplibre-gl-style-spec": "^24.2.0",
|