@trackunit/react-map-adapter-shared 0.0.201 → 0.0.202
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/index.cjs.js +44 -0
- package/index.esm.js +43 -1
- package/package.json +3 -3
- package/src/LayerPort.d.ts +7 -0
- package/src/index.d.ts +1 -0
- package/src/inertHitTarget.d.ts +14 -0
package/index.cjs.js
CHANGED
|
@@ -1053,6 +1053,48 @@ const googleMapCspDirectives = () => ({
|
|
|
1053
1053
|
"worker-src": ["blob:"],
|
|
1054
1054
|
});
|
|
1055
1055
|
|
|
1056
|
+
/**
|
|
1057
|
+
* Hit-target suspension for map elements that must stay visible but let pointer events
|
|
1058
|
+
* through to the map while a drawing mode is active (ADR 0030).
|
|
1059
|
+
*
|
|
1060
|
+
* Terra Draw accepts a click, and ends a drag, only when the event target is the map
|
|
1061
|
+
* element itself. Markers, cluster bubbles and the symbol canvas sit above the map and
|
|
1062
|
+
* take the pointer first. An inline `pointer-events` is not enough to stop that: mapbox-gl
|
|
1063
|
+
* rewrites a marker's inline value every frame, Google sets `auto` on the advanced marker
|
|
1064
|
+
* host, and React-rendered content sets `auto` on its own surfaces. A class backed by an
|
|
1065
|
+
* `!important` rule that covers the element and everything inside it holds in every case.
|
|
1066
|
+
*/
|
|
1067
|
+
const INERT_HIT_TARGET_CLASS = "tu-map-hit-target-inert";
|
|
1068
|
+
const INERT_HIT_TARGET_RULE = `.${INERT_HIT_TARGET_CLASS}, .${INERT_HIT_TARGET_CLASS} * { pointer-events: none !important; }`;
|
|
1069
|
+
const documentsWithRule = new WeakSet();
|
|
1070
|
+
/**
|
|
1071
|
+
* Installs the rule once per document: as a constructed stylesheet where the browser has
|
|
1072
|
+
* them, as a `<style>` element otherwise (older engines, jsdom).
|
|
1073
|
+
*/
|
|
1074
|
+
const ensureInertHitTargetRule = (doc) => {
|
|
1075
|
+
if (documentsWithRule.has(doc))
|
|
1076
|
+
return;
|
|
1077
|
+
documentsWithRule.add(doc);
|
|
1078
|
+
try {
|
|
1079
|
+
const sheet = new CSSStyleSheet();
|
|
1080
|
+
sheet.replaceSync(INERT_HIT_TARGET_RULE);
|
|
1081
|
+
doc.adoptedStyleSheets = [...doc.adoptedStyleSheets, sheet];
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
catch {
|
|
1085
|
+
// No constructed stylesheets here; fall through to a <style> element.
|
|
1086
|
+
}
|
|
1087
|
+
const style = doc.createElement("style");
|
|
1088
|
+
style.textContent = INERT_HIT_TARGET_RULE;
|
|
1089
|
+
doc.head.append(style);
|
|
1090
|
+
};
|
|
1091
|
+
/** Suspends or restores hit testing on an element and everything rendered inside it. */
|
|
1092
|
+
const setHitTargetInert = (element, inert) => {
|
|
1093
|
+
if (inert)
|
|
1094
|
+
ensureInertHitTargetRule(element.ownerDocument);
|
|
1095
|
+
element.classList.toggle(INERT_HIT_TARGET_CLASS, inert);
|
|
1096
|
+
};
|
|
1097
|
+
|
|
1056
1098
|
const isViewportLike = (value) => {
|
|
1057
1099
|
return typeof value === "object" && value !== null && "type" in value;
|
|
1058
1100
|
};
|
|
@@ -2690,6 +2732,7 @@ exports.DEFAULT_ZOOM = DEFAULT_ZOOM;
|
|
|
2690
2732
|
exports.EMPTY_DRAW_VALUE = EMPTY_DRAW_VALUE;
|
|
2691
2733
|
exports.GEODESIC_MAX_SEGMENT_KM = GEODESIC_MAX_SEGMENT_KM;
|
|
2692
2734
|
exports.HIT_SURFACE_SELECTOR = HIT_SURFACE_SELECTOR;
|
|
2735
|
+
exports.INERT_HIT_TARGET_CLASS = INERT_HIT_TARGET_CLASS;
|
|
2693
2736
|
exports.INITIAL_CAMERA_STATE = INITIAL_CAMERA_STATE;
|
|
2694
2737
|
exports.INITIAL_INTERACTION_STATE = INITIAL_INTERACTION_STATE;
|
|
2695
2738
|
exports.INITIAL_MAP_STATE = INITIAL_MAP_STATE;
|
|
@@ -2765,6 +2808,7 @@ exports.resolveSelectedStyle = resolveSelectedStyle;
|
|
|
2765
2808
|
exports.resolveStrokeColors = resolveStrokeColors;
|
|
2766
2809
|
exports.resolveSymbolDescriptor = resolveSymbolDescriptor;
|
|
2767
2810
|
exports.safePolygon = safePolygon;
|
|
2811
|
+
exports.setHitTargetInert = setHitTargetInert;
|
|
2768
2812
|
exports.toDeg = toDeg;
|
|
2769
2813
|
exports.toRad = toRad;
|
|
2770
2814
|
exports.unwrapLongitudeNear = unwrapLongitudeNear;
|
package/index.esm.js
CHANGED
|
@@ -1051,6 +1051,48 @@ const googleMapCspDirectives = () => ({
|
|
|
1051
1051
|
"worker-src": ["blob:"],
|
|
1052
1052
|
});
|
|
1053
1053
|
|
|
1054
|
+
/**
|
|
1055
|
+
* Hit-target suspension for map elements that must stay visible but let pointer events
|
|
1056
|
+
* through to the map while a drawing mode is active (ADR 0030).
|
|
1057
|
+
*
|
|
1058
|
+
* Terra Draw accepts a click, and ends a drag, only when the event target is the map
|
|
1059
|
+
* element itself. Markers, cluster bubbles and the symbol canvas sit above the map and
|
|
1060
|
+
* take the pointer first. An inline `pointer-events` is not enough to stop that: mapbox-gl
|
|
1061
|
+
* rewrites a marker's inline value every frame, Google sets `auto` on the advanced marker
|
|
1062
|
+
* host, and React-rendered content sets `auto` on its own surfaces. A class backed by an
|
|
1063
|
+
* `!important` rule that covers the element and everything inside it holds in every case.
|
|
1064
|
+
*/
|
|
1065
|
+
const INERT_HIT_TARGET_CLASS = "tu-map-hit-target-inert";
|
|
1066
|
+
const INERT_HIT_TARGET_RULE = `.${INERT_HIT_TARGET_CLASS}, .${INERT_HIT_TARGET_CLASS} * { pointer-events: none !important; }`;
|
|
1067
|
+
const documentsWithRule = new WeakSet();
|
|
1068
|
+
/**
|
|
1069
|
+
* Installs the rule once per document: as a constructed stylesheet where the browser has
|
|
1070
|
+
* them, as a `<style>` element otherwise (older engines, jsdom).
|
|
1071
|
+
*/
|
|
1072
|
+
const ensureInertHitTargetRule = (doc) => {
|
|
1073
|
+
if (documentsWithRule.has(doc))
|
|
1074
|
+
return;
|
|
1075
|
+
documentsWithRule.add(doc);
|
|
1076
|
+
try {
|
|
1077
|
+
const sheet = new CSSStyleSheet();
|
|
1078
|
+
sheet.replaceSync(INERT_HIT_TARGET_RULE);
|
|
1079
|
+
doc.adoptedStyleSheets = [...doc.adoptedStyleSheets, sheet];
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
catch {
|
|
1083
|
+
// No constructed stylesheets here; fall through to a <style> element.
|
|
1084
|
+
}
|
|
1085
|
+
const style = doc.createElement("style");
|
|
1086
|
+
style.textContent = INERT_HIT_TARGET_RULE;
|
|
1087
|
+
doc.head.append(style);
|
|
1088
|
+
};
|
|
1089
|
+
/** Suspends or restores hit testing on an element and everything rendered inside it. */
|
|
1090
|
+
const setHitTargetInert = (element, inert) => {
|
|
1091
|
+
if (inert)
|
|
1092
|
+
ensureInertHitTargetRule(element.ownerDocument);
|
|
1093
|
+
element.classList.toggle(INERT_HIT_TARGET_CLASS, inert);
|
|
1094
|
+
};
|
|
1095
|
+
|
|
1054
1096
|
const isViewportLike = (value) => {
|
|
1055
1097
|
return typeof value === "object" && value !== null && "type" in value;
|
|
1056
1098
|
};
|
|
@@ -2679,4 +2721,4 @@ const resolveStrokeColors = (style, shapeType, theme) => {
|
|
|
2679
2721
|
};
|
|
2680
2722
|
};
|
|
2681
2723
|
|
|
2682
|
-
export { ANCHOR_SELECTOR, CIRCLE_SYMBOL_DEFAULT_DIAMETER_PX, CIRCLE_SYMBOL_DEFAULT_OPACITY, DEFAULT_CENTER, DEFAULT_MAP_APPEARANCE, DEFAULT_ZOOM, EMPTY_DRAW_VALUE, GEODESIC_MAX_SEGMENT_KM, HIT_SURFACE_SELECTOR, INITIAL_CAMERA_STATE, INITIAL_INTERACTION_STATE, INITIAL_MAP_STATE, INITIAL_MAP_STATUS, KEYBOARD_PAN_AMOUNT, KEYBOARD_ZOOM_AMOUNT, LAYER_FADE_DURATION_MS, MAP_CURSORS, MAX_ZOOM, MIN_ZOOM, NO_DRAW_ERRORS, SAFE_AREA_DEFAULT_BUFFER_PX, TRAFFIC_MIN_ZOOM, WORLD_BBOX, allocSafeAreaDebugId, anchorFromBottomCenter, angularDistance, attachSafeAreaHoverListeners, bboxEquals, bufferRectCorners, buildAdaptiveDomEntries, buildAdaptiveDomRenderFn, buildAdaptiveSymbolStyleFn, cameraStateEquals, canPatchAdaptiveMarker, canPatchAdaptiveViewport, canPatchMarkerInPlace, clearSafeArea, collectFeatureIdSet, computeInitialState, computeMarkerDomPortalZIndex, convexHull, createClusterPinElement, createDefaultClusterElement, createSymbolDotElement, defineAdapter, densifyGeodesicFeatures, disableSafeAreaDebug, discriminateRenderResult, enableSafeAreaDebug, estimateZoomFromBounds, extractLineCoordinates, extractPointCoordinates, extractPolygonPaths, extractSourceData, fadeInElement, filterRectsByCursorDirection, geometryTypeToShapeType, getAdaptiveDomFeatureIds, getAnchorRect, getEffectiveRestrictBounds, getHitSurfaceRect, googleMapCspDirectives, hasSameFeatureIds, intermediatePoint, isCanvasMarkerMode, isEventOfType, isSafeAreaDebugEnabled, mapAppearanceSchema, mapStateEquals, mapThemeSchema, mapTypeSchema, mapboxMapCspDirectives, mercatorCenterFromBounds, mergeAntimeridianFeatures, patchPortalDescriptors, pointInPolygon, removeGoneIndexedMarkers, renderSafeArea, resolveCircleSymbolDefaults, resolveHoveredStyle, resolveSelectedStyle, resolveStrokeColors, resolveSymbolDescriptor, safePolygon, toDeg, toRad, unwrapLongitudeNear, validateInitialViewport, watchSafeAreaLeave };
|
|
2724
|
+
export { ANCHOR_SELECTOR, CIRCLE_SYMBOL_DEFAULT_DIAMETER_PX, CIRCLE_SYMBOL_DEFAULT_OPACITY, DEFAULT_CENTER, DEFAULT_MAP_APPEARANCE, DEFAULT_ZOOM, EMPTY_DRAW_VALUE, GEODESIC_MAX_SEGMENT_KM, HIT_SURFACE_SELECTOR, INERT_HIT_TARGET_CLASS, INITIAL_CAMERA_STATE, INITIAL_INTERACTION_STATE, INITIAL_MAP_STATE, INITIAL_MAP_STATUS, KEYBOARD_PAN_AMOUNT, KEYBOARD_ZOOM_AMOUNT, LAYER_FADE_DURATION_MS, MAP_CURSORS, MAX_ZOOM, MIN_ZOOM, NO_DRAW_ERRORS, SAFE_AREA_DEFAULT_BUFFER_PX, TRAFFIC_MIN_ZOOM, WORLD_BBOX, allocSafeAreaDebugId, anchorFromBottomCenter, angularDistance, attachSafeAreaHoverListeners, bboxEquals, bufferRectCorners, buildAdaptiveDomEntries, buildAdaptiveDomRenderFn, buildAdaptiveSymbolStyleFn, cameraStateEquals, canPatchAdaptiveMarker, canPatchAdaptiveViewport, canPatchMarkerInPlace, clearSafeArea, collectFeatureIdSet, computeInitialState, computeMarkerDomPortalZIndex, convexHull, createClusterPinElement, createDefaultClusterElement, createSymbolDotElement, defineAdapter, densifyGeodesicFeatures, disableSafeAreaDebug, discriminateRenderResult, enableSafeAreaDebug, estimateZoomFromBounds, extractLineCoordinates, extractPointCoordinates, extractPolygonPaths, extractSourceData, fadeInElement, filterRectsByCursorDirection, geometryTypeToShapeType, getAdaptiveDomFeatureIds, getAnchorRect, getEffectiveRestrictBounds, getHitSurfaceRect, googleMapCspDirectives, hasSameFeatureIds, intermediatePoint, isCanvasMarkerMode, isEventOfType, isSafeAreaDebugEnabled, mapAppearanceSchema, mapStateEquals, mapThemeSchema, mapTypeSchema, mapboxMapCspDirectives, mercatorCenterFromBounds, mergeAntimeridianFeatures, patchPortalDescriptors, pointInPolygon, removeGoneIndexedMarkers, renderSafeArea, resolveCircleSymbolDefaults, resolveHoveredStyle, resolveSelectedStyle, resolveStrokeColors, resolveSymbolDescriptor, safePolygon, setHitTargetInert, toDeg, toRad, unwrapLongitudeNear, validateInitialViewport, watchSafeAreaLeave };
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-map-adapter-shared",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.202",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=24.x"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@trackunit/react-map-color-utils": "0.0.
|
|
11
|
-
"@trackunit/geo-json-utils": "1.21.
|
|
10
|
+
"@trackunit/react-map-color-utils": "0.0.176",
|
|
11
|
+
"@trackunit/geo-json-utils": "1.21.35",
|
|
12
12
|
"@trackunit/ui-design-tokens": "1.21.34",
|
|
13
13
|
"es-toolkit": "^1.52.0",
|
|
14
14
|
"zod": "^3.25.76"
|
package/src/LayerPort.d.ts
CHANGED
|
@@ -14,6 +14,13 @@ export type InteractiveMarkerConfig = Readonly<{
|
|
|
14
14
|
clusterConfig: ClusterConfig<unknown> | null;
|
|
15
15
|
clusterRender: ClusterRenderConfig<unknown, unknown> | null;
|
|
16
16
|
clusterFeatures: GeoJsonFeatureCollection | null;
|
|
17
|
+
/**
|
|
18
|
+
* Whether markers and clusters are hit targets. `<Layers>` passes `false` while a
|
|
19
|
+
* drawing mode is active (ADR 0030): the markers stay visible, but pointer events
|
|
20
|
+
* fall through to the map so the drawing engine receives every click. Hover and
|
|
21
|
+
* click entity events stop while `false`.
|
|
22
|
+
*/
|
|
23
|
+
interactive: boolean;
|
|
17
24
|
/**
|
|
18
25
|
* Populated by `<Layers>` when `markerRender.mode === "adaptive"` so adapters
|
|
19
26
|
* can split symbol vs DOM per feature (plan §8).
|
package/src/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./constants";
|
|
|
4
4
|
export * from "./DrawPort";
|
|
5
5
|
export * from "./geodesicDensify";
|
|
6
6
|
export * from "./google-map-csp-directives";
|
|
7
|
+
export * from "./inertHitTarget";
|
|
7
8
|
export * from "./initialViewportValidation";
|
|
8
9
|
export * from "./interactionTypes";
|
|
9
10
|
export * from "./layerApiTypes";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hit-target suspension for map elements that must stay visible but let pointer events
|
|
3
|
+
* through to the map while a drawing mode is active (ADR 0030).
|
|
4
|
+
*
|
|
5
|
+
* Terra Draw accepts a click, and ends a drag, only when the event target is the map
|
|
6
|
+
* element itself. Markers, cluster bubbles and the symbol canvas sit above the map and
|
|
7
|
+
* take the pointer first. An inline `pointer-events` is not enough to stop that: mapbox-gl
|
|
8
|
+
* rewrites a marker's inline value every frame, Google sets `auto` on the advanced marker
|
|
9
|
+
* host, and React-rendered content sets `auto` on its own surfaces. A class backed by an
|
|
10
|
+
* `!important` rule that covers the element and everything inside it holds in every case.
|
|
11
|
+
*/
|
|
12
|
+
export declare const INERT_HIT_TARGET_CLASS = "tu-map-hit-target-inert";
|
|
13
|
+
/** Suspends or restores hit testing on an element and everything rendered inside it. */
|
|
14
|
+
export declare const setHitTargetInert: (element: HTMLElement, inert: boolean) => void;
|