@trackunit/react-map 0.2.283 → 0.2.284
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 +69 -25
- package/index.esm.js +70 -27
- package/package.json +10 -10
- package/src/annotations/mapAnnotations.d.ts +5 -0
- package/src/controls/annotationButtonClasses.d.ts +1 -1
- package/src/draw/useDraw.d.ts +9 -0
- package/src/index.d.ts +1 -1
- package/src/layers/__testHelpers.d.ts +3 -1
- package/src/layers/types.d.ts +7 -0
- package/src/layers/useMarkers/useMarkers.d.ts +8 -0
package/index.cjs.js
CHANGED
|
@@ -272,17 +272,34 @@ const createPanelStore = () => {
|
|
|
272
272
|
* focus accessibility. Matches the focus ring pattern in InteractiveDecoration.tsx
|
|
273
273
|
* so all interactive map overlay buttons behave consistently for keyboard users.
|
|
274
274
|
*
|
|
275
|
-
* Compose additional appearance classes on top via `
|
|
275
|
+
* Compose additional appearance classes on top via `cx`.
|
|
276
276
|
*
|
|
277
277
|
* @internal
|
|
278
278
|
*/
|
|
279
279
|
const ANNOTATION_BUTTON_RESET_CLASSES = "appearance-none m-0 cursor-pointer border-0 font-inherit focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1";
|
|
280
280
|
|
|
281
|
-
|
|
282
|
-
//
|
|
283
|
-
//
|
|
284
|
-
//
|
|
285
|
-
const
|
|
281
|
+
// A one-line pill keeps its label on one line and the full radius. A wrapping pill lets a
|
|
282
|
+
// sentence-length hint break onto several lines inside the stack's max width, trades
|
|
283
|
+
// rounded-full for a small radius so the curved ends do not cut into the first and last
|
|
284
|
+
// lines, and aligns its icon with the first line instead of the middle of the block.
|
|
285
|
+
const cvaSimplePill = cssClassVarianceUtilities.cva({
|
|
286
|
+
base: ["flex", "select-none", "gap-1", "bg-white/90", "px-2", "py-1", "text-xs", "font-medium", "shadow-sm"],
|
|
287
|
+
variants: {
|
|
288
|
+
wrap: {
|
|
289
|
+
true: ["items-start", "whitespace-normal", "rounded-lg"],
|
|
290
|
+
false: ["items-center", "whitespace-nowrap", "rounded-full"],
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
const cvaSimpleLabel = cssClassVarianceUtilities.cva({
|
|
295
|
+
base: [],
|
|
296
|
+
variants: {
|
|
297
|
+
wrap: {
|
|
298
|
+
true: ["whitespace-normal"],
|
|
299
|
+
false: ["truncate"],
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
});
|
|
286
303
|
/**
|
|
287
304
|
* Renders a single map annotation based on its content type.
|
|
288
305
|
*
|
|
@@ -298,16 +315,17 @@ const AnnotationRenderer = ({ annotation }) => {
|
|
|
298
315
|
switch (annotation.type) {
|
|
299
316
|
case "simple": {
|
|
300
317
|
const style = annotation.color !== undefined ? { color: annotation.color } : undefined;
|
|
301
|
-
const
|
|
318
|
+
const wrap = annotation.wrap === true;
|
|
319
|
+
const content = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [annotation.icon !== undefined ? jsxRuntime.jsx("span", { className: "shrink-0", children: annotation.icon }) : null, jsxRuntime.jsx("span", { className: cvaSimpleLabel({ wrap }), children: annotation.label })] }));
|
|
302
320
|
const { onClick } = annotation;
|
|
303
321
|
if (onClick !== undefined) {
|
|
304
322
|
const handleClick = (event) => {
|
|
305
323
|
event.stopPropagation();
|
|
306
324
|
onClick();
|
|
307
325
|
};
|
|
308
|
-
return (jsxRuntime.jsx("button", { className:
|
|
326
|
+
return (jsxRuntime.jsx("button", { className: cssClassVarianceUtilities.cx(cvaSimplePill({ wrap }), ANNOTATION_BUTTON_RESET_CLASSES, "text-inherit"), "data-peek-root": true, "data-testid": "annotation-pill", onClick: handleClick, style: style, type: "button", children: content }));
|
|
309
327
|
}
|
|
310
|
-
return (jsxRuntime.jsx("div", { className:
|
|
328
|
+
return (jsxRuntime.jsx("div", { className: cvaSimplePill({ wrap }), "data-peek-root": true, "data-testid": "annotation-pill", style: style, children: content }));
|
|
311
329
|
}
|
|
312
330
|
case "custom": {
|
|
313
331
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: annotation.render() });
|
|
@@ -508,7 +526,7 @@ const AnnotationStack = ({ annotations, isExiting }) => {
|
|
|
508
526
|
transition: `transform ${ANIMATION_DURATION_MS$1}ms ease-out, filter ${ANIMATION_DURATION_MS$1}ms ease-out`,
|
|
509
527
|
}, children: jsxRuntime.jsx(AnnotationRenderer, { annotation: peekAnnotation }) }, peekAnnotation.id));
|
|
510
528
|
})
|
|
511
|
-
: null, hiddenCount > 0 ? (jsxRuntime.jsxs("div", { className: "min-w-4 bg-primary-600 absolute -right-1.5 -top-1.5 h-4 items-center justify-center rounded-full px-1 text-[10px] font-semibold leading-none text-white shadow-sm", "data-annotation-badge": isExpanded ? "hidden" : "visible", "data-testid": "annotation-stack-badge", children: ["+", hiddenCount] })) : null] }), showPanel ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", { className: "flex max-h-[20rem] flex-col items-start gap-[3px] overflow-visible", "data-testid": "annotation-stack-expanded", onClick: handleExpandedPanelClick, ref: setFloating, style: floatingStyles, ...getFloatingProps(), children: olderAnnotations.map((annotation, index) => {
|
|
529
|
+
: null, hiddenCount > 0 ? (jsxRuntime.jsxs("div", { className: "min-w-4 bg-primary-600 absolute -right-1.5 -top-1.5 h-4 items-center justify-center rounded-full px-1 text-[10px] font-semibold leading-none text-white shadow-sm", "data-annotation-badge": isExpanded ? "hidden" : "visible", "data-testid": "annotation-stack-badge", children: ["+", hiddenCount] })) : null] }), showPanel ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", { className: "flex max-h-[20rem] w-max max-w-[16rem] flex-col items-start gap-[3px] overflow-visible", "data-testid": "annotation-stack-expanded", onClick: handleExpandedPanelClick, ref: setFloating, style: floatingStyles, ...getFloatingProps(), children: olderAnnotations.map((annotation, index) => {
|
|
512
530
|
const fromEnd = olderAnnotations.length - 1 - index;
|
|
513
531
|
const peekLevel = Math.min(fromEnd + 1, MAX_PEEK_COUNT);
|
|
514
532
|
const expandDelay = index * STAGGER_DELAY_MS;
|
|
@@ -3475,6 +3493,15 @@ const subscribeNoop = () => noopUnsubscribe$1;
|
|
|
3475
3493
|
const getIdle = () => "idle";
|
|
3476
3494
|
const getEmpty = () => reactMapAdapterShared.EMPTY_DRAW_VALUE;
|
|
3477
3495
|
const getNoErrors = () => reactMapAdapterShared.NO_DRAW_ERRORS;
|
|
3496
|
+
/**
|
|
3497
|
+
* Ids of the controls `useDraw` returns, for a consumer that filters or replaces one of them
|
|
3498
|
+
* (a wizard that confirms before clearing, for instance).
|
|
3499
|
+
*/
|
|
3500
|
+
const DRAW_CONTROL_IDS = {
|
|
3501
|
+
polygon: "draw-polygon",
|
|
3502
|
+
select: "draw-select",
|
|
3503
|
+
clear: "draw-clear",
|
|
3504
|
+
};
|
|
3478
3505
|
/**
|
|
3479
3506
|
* Feature-facing hook for the optional drawing capability (ADR 0030).
|
|
3480
3507
|
*
|
|
@@ -3580,12 +3607,16 @@ const useDraw = (api, options) => {
|
|
|
3580
3607
|
if (limitReached && mode === "polygon")
|
|
3581
3608
|
port?.setMode("idle");
|
|
3582
3609
|
}, [limitReached, mode, port]);
|
|
3610
|
+
// A down engine does not disable the toggles: switching one on is the retry. The
|
|
3611
|
+
// controller loads again on the next mode that needs an engine after a failed load,
|
|
3612
|
+
// and a mode operation that succeeds clears a failed update. Consumers say drawing
|
|
3613
|
+
// is unavailable through `error`.
|
|
3583
3614
|
const controls = react.useMemo(() => {
|
|
3584
3615
|
if (!isSupported || !enabled)
|
|
3585
3616
|
return [];
|
|
3586
3617
|
const polygonToggle = {
|
|
3587
3618
|
type: "toggle",
|
|
3588
|
-
id:
|
|
3619
|
+
id: DRAW_CONTROL_IDS.polygon,
|
|
3589
3620
|
icon: { on: "Pencil", off: "Pencil" },
|
|
3590
3621
|
label: t("draw.polygon"),
|
|
3591
3622
|
section: t("controls.category.tools"),
|
|
@@ -3599,7 +3630,7 @@ const useDraw = (api, options) => {
|
|
|
3599
3630
|
};
|
|
3600
3631
|
const selectToggle = {
|
|
3601
3632
|
type: "toggle",
|
|
3602
|
-
id:
|
|
3633
|
+
id: DRAW_CONTROL_IDS.select,
|
|
3603
3634
|
icon: { on: "CursorArrowRays", off: "CursorArrowRays" },
|
|
3604
3635
|
label: t("draw.select"),
|
|
3605
3636
|
section: t("controls.category.tools"),
|
|
@@ -3612,7 +3643,7 @@ const useDraw = (api, options) => {
|
|
|
3612
3643
|
};
|
|
3613
3644
|
const clearButton = {
|
|
3614
3645
|
type: "button",
|
|
3615
|
-
id:
|
|
3646
|
+
id: DRAW_CONTROL_IDS.clear,
|
|
3616
3647
|
icon: "Trash",
|
|
3617
3648
|
label: t("draw.clear"),
|
|
3618
3649
|
section: t("controls.category.tools"),
|
|
@@ -7597,7 +7628,7 @@ const toClusterFeatureCollection = (config) => {
|
|
|
7597
7628
|
* ```
|
|
7598
7629
|
*/
|
|
7599
7630
|
const useMarkers = (options) => {
|
|
7600
|
-
const { id, name, data, getPosition, getId, cluster, markerRender, clusterRender, controls, loading, fitParticipation = "all", resolveGroups, resolutionContext, } = options;
|
|
7631
|
+
const { id, name, data, getPosition, getId, cluster, markerRender, clusterRender, controls, loading, fitParticipation = "all", interactive = true, resolveGroups, resolutionContext, } = options;
|
|
7601
7632
|
// ---- Data readiness tracking ----
|
|
7602
7633
|
const layerReady = useLayerReady(loading);
|
|
7603
7634
|
// ---- Filter to positioned items ----
|
|
@@ -7682,6 +7713,7 @@ const useMarkers = (options) => {
|
|
|
7682
7713
|
clusterRender: clusterRender ?? null,
|
|
7683
7714
|
clusterFeatures,
|
|
7684
7715
|
clusterMemberItems,
|
|
7716
|
+
interactive,
|
|
7685
7717
|
// Convenience counts
|
|
7686
7718
|
positionedCount: positionedItems.length,
|
|
7687
7719
|
totalCount: data.length,
|
|
@@ -7700,6 +7732,7 @@ const useMarkers = (options) => {
|
|
|
7700
7732
|
clusterRender,
|
|
7701
7733
|
clusterFeatures,
|
|
7702
7734
|
clusterMemberItems,
|
|
7735
|
+
interactive,
|
|
7703
7736
|
positionedItems.length,
|
|
7704
7737
|
data.length,
|
|
7705
7738
|
clusterCount,
|
|
@@ -8800,6 +8833,7 @@ function toMapLayer(handle) {
|
|
|
8800
8833
|
clusterConfig: markerHandle.clusterConfig,
|
|
8801
8834
|
clusterRender: markerHandle.clusterRender,
|
|
8802
8835
|
clusterFeatures: markerHandle.clusterFeatures,
|
|
8836
|
+
interactive: markerHandle.interactive ?? true,
|
|
8803
8837
|
...(markerHandle.adaptiveResolution !== undefined
|
|
8804
8838
|
? { adaptiveResolution: markerHandle.adaptiveResolution }
|
|
8805
8839
|
: {}),
|
|
@@ -12598,12 +12632,12 @@ const applyPortalZIndex = (container, zIndex) => {
|
|
|
12598
12632
|
*/
|
|
12599
12633
|
const Layers = ({ layers, api, onEntityClick, onEntityDblClick }) => {
|
|
12600
12634
|
const layerPort = useLayerPort();
|
|
12601
|
-
// Drawing mode suppresses layer interaction (ADR 0030)
|
|
12602
|
-
//
|
|
12603
|
-
//
|
|
12604
|
-
//
|
|
12605
|
-
//
|
|
12606
|
-
//
|
|
12635
|
+
// Drawing mode suppresses layer interaction (ADR 0030). Shapes, markers, clusters and
|
|
12636
|
+
// routes are pushed to the adapter as non-interactive (see `enrichedHandles`), so they
|
|
12637
|
+
// stay visible but stop being pointer targets and Terra Draw gets every click. Every
|
|
12638
|
+
// interaction consumer below gets its handlers from one gated set (`interaction`), so
|
|
12639
|
+
// no panel opens and no hover state lingers under the draw tool. Programmatic
|
|
12640
|
+
// `layers.select` still works.
|
|
12607
12641
|
const drawing = api?.state.drawing === true;
|
|
12608
12642
|
const [decorationLayers, setDecorationLayers] = react.useState([]);
|
|
12609
12643
|
const [viewportStyleOverrides, setViewportStyleOverrides] = react.useState(new Map());
|
|
@@ -12720,7 +12754,8 @@ const Layers = ({ layers, api, onEntityClick, onEntityDblClick }) => {
|
|
|
12720
12754
|
const fillOverrides = fillGeometryOverrides.get(handle.id);
|
|
12721
12755
|
const zIndexOverridesForHandle = zIndexOverrides.get(handle.id);
|
|
12722
12756
|
const queryShapesAt = (position) => queryAt(handle.id, position);
|
|
12723
|
-
//
|
|
12757
|
+
// While drawing, every layer type goes to the adapter as non-interactive through its
|
|
12758
|
+
// own `interactive` field: shapes in the "none" mode, markers and routes switched off.
|
|
12724
12759
|
const interactiveWhileDrawing = drawing ? { interactive: "none" } : {};
|
|
12725
12760
|
if (styleOverrides === undefined && fillOverrides === undefined && zIndexOverridesForHandle === undefined) {
|
|
12726
12761
|
return { ...handle, ...interactiveWhileDrawing, queryShapesAt };
|
|
@@ -12734,12 +12769,20 @@ const Layers = ({ layers, api, onEntityClick, onEntityDblClick }) => {
|
|
|
12734
12769
|
...(zIndexOverridesForHandle !== undefined ? { featureZIndexOverrides: zIndexOverridesForHandle } : {}),
|
|
12735
12770
|
};
|
|
12736
12771
|
}
|
|
12737
|
-
if (handle.layerType
|
|
12772
|
+
if (handle.layerType === "route") {
|
|
12773
|
+
return drawing && handle.interactive ? { ...handle, interactive: false } : handle;
|
|
12774
|
+
}
|
|
12775
|
+
if (handle.layerType !== "markers")
|
|
12738
12776
|
return handle;
|
|
12739
|
-
const
|
|
12740
|
-
|
|
12777
|
+
const interactive = drawing ? false : (handle.interactive ?? true);
|
|
12778
|
+
const adaptiveResolution = handle.markerRender.mode === "adaptive" ? adaptiveByLayer.get(handle.id) : undefined;
|
|
12779
|
+
if (interactive === handle.interactive && adaptiveResolution === undefined)
|
|
12741
12780
|
return handle;
|
|
12742
|
-
return {
|
|
12781
|
+
return {
|
|
12782
|
+
...handle,
|
|
12783
|
+
interactive,
|
|
12784
|
+
...(adaptiveResolution !== undefined ? { adaptiveResolution } : {}),
|
|
12785
|
+
};
|
|
12743
12786
|
});
|
|
12744
12787
|
}, [
|
|
12745
12788
|
layers.handles,
|
|
@@ -13801,6 +13844,7 @@ exports.ClusterStick = ClusterStick;
|
|
|
13801
13844
|
exports.Controls = Controls;
|
|
13802
13845
|
exports.DEFAULT_APPEARANCE_PERSISTENCE_KEY = DEFAULT_APPEARANCE_PERSISTENCE_KEY;
|
|
13803
13846
|
exports.DEFAULT_MARKER_SIZE_BREAKPOINTS = DEFAULT_MARKER_SIZE_BREAKPOINTS;
|
|
13847
|
+
exports.DRAW_CONTROL_IDS = DRAW_CONTROL_IDS;
|
|
13804
13848
|
exports.DefaultControls = DefaultControls;
|
|
13805
13849
|
exports.Layers = Layers;
|
|
13806
13850
|
exports.MARKER_DARK_PILL = MARKER_DARK_PILL;
|
package/index.esm.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useNamespaceTranslation, registerTranslations } from '@trackunit/i18n-l
|
|
|
3
3
|
import { INITIAL_CAMERA_STATE, INITIAL_MAP_STATUS, KEYBOARD_PAN_AMOUNT, KEYBOARD_ZOOM_AMOUNT, mapAppearanceSchema, DEFAULT_MAP_APPEARANCE, EMPTY_DRAW_VALUE, NO_DRAW_ERRORS, WORLD_BBOX, INITIAL_INTERACTION_STATE, mapThemeSchema, mergeAntimeridianFeatures, extractSourceData, computeMarkerDomPortalZIndex, densifyGeodesicFeatures, angularDistance, intermediatePoint, GEODESIC_MAX_SEGMENT_KM, geometryTypeToShapeType, resolveStrokeColors } from '@trackunit/react-map-adapter-shared';
|
|
4
4
|
export { ANCHOR_SELECTOR, DEFAULT_MAP_APPEARANCE, EMPTY_DRAW_VALUE, HIT_SURFACE_SELECTOR, INITIAL_CAMERA_STATE, INITIAL_INTERACTION_STATE, INITIAL_MAP_STATE, INITIAL_MAP_STATUS, computeMarkerDomPortalZIndex, defineAdapter, geometryTypeToShapeType, mapAppearanceSchema, mapThemeSchema, mapTypeSchema } from '@trackunit/react-map-adapter-shared';
|
|
5
5
|
import { useSyncExternalStore, useMemo, useState, useRef, useCallback, useLayoutEffect, useEffect, useReducer, createContext, useContext, memo, Suspense, useId, Fragment as Fragment$1, forwardRef } from 'react';
|
|
6
|
-
import { cva } from '@trackunit/css-class-variance-utilities';
|
|
6
|
+
import { cva, cx } from '@trackunit/css-class-variance-utilities';
|
|
7
7
|
import { Tooltip, useMergeRefs, Icon, Spinner, Text, useMeasure, useContainerBreakpoints, useDebounce, useWatch, useKeyboardShortcut, IconButton, ToggleGroup as ToggleGroup$1, useIsFullscreen, Popover, PopoverTrigger, PopoverContent, MoreMenu, useHover as useHover$1, cvaInteractableItem, useLocalStorageReducer } from '@trackunit/react-components';
|
|
8
8
|
import { twMerge } from 'tailwind-merge';
|
|
9
9
|
import { useFloating, autoUpdate, offset, flip, useHover, safePolygon, useInteractions, shift, hide, useDismiss, useRole } from '@floating-ui/react';
|
|
@@ -271,17 +271,34 @@ const createPanelStore = () => {
|
|
|
271
271
|
* focus accessibility. Matches the focus ring pattern in InteractiveDecoration.tsx
|
|
272
272
|
* so all interactive map overlay buttons behave consistently for keyboard users.
|
|
273
273
|
*
|
|
274
|
-
* Compose additional appearance classes on top via `
|
|
274
|
+
* Compose additional appearance classes on top via `cx`.
|
|
275
275
|
*
|
|
276
276
|
* @internal
|
|
277
277
|
*/
|
|
278
278
|
const ANNOTATION_BUTTON_RESET_CLASSES = "appearance-none m-0 cursor-pointer border-0 font-inherit focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1";
|
|
279
279
|
|
|
280
|
-
|
|
281
|
-
//
|
|
282
|
-
//
|
|
283
|
-
//
|
|
284
|
-
const
|
|
280
|
+
// A one-line pill keeps its label on one line and the full radius. A wrapping pill lets a
|
|
281
|
+
// sentence-length hint break onto several lines inside the stack's max width, trades
|
|
282
|
+
// rounded-full for a small radius so the curved ends do not cut into the first and last
|
|
283
|
+
// lines, and aligns its icon with the first line instead of the middle of the block.
|
|
284
|
+
const cvaSimplePill = cva({
|
|
285
|
+
base: ["flex", "select-none", "gap-1", "bg-white/90", "px-2", "py-1", "text-xs", "font-medium", "shadow-sm"],
|
|
286
|
+
variants: {
|
|
287
|
+
wrap: {
|
|
288
|
+
true: ["items-start", "whitespace-normal", "rounded-lg"],
|
|
289
|
+
false: ["items-center", "whitespace-nowrap", "rounded-full"],
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
const cvaSimpleLabel = cva({
|
|
294
|
+
base: [],
|
|
295
|
+
variants: {
|
|
296
|
+
wrap: {
|
|
297
|
+
true: ["whitespace-normal"],
|
|
298
|
+
false: ["truncate"],
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
});
|
|
285
302
|
/**
|
|
286
303
|
* Renders a single map annotation based on its content type.
|
|
287
304
|
*
|
|
@@ -297,16 +314,17 @@ const AnnotationRenderer = ({ annotation }) => {
|
|
|
297
314
|
switch (annotation.type) {
|
|
298
315
|
case "simple": {
|
|
299
316
|
const style = annotation.color !== undefined ? { color: annotation.color } : undefined;
|
|
300
|
-
const
|
|
317
|
+
const wrap = annotation.wrap === true;
|
|
318
|
+
const content = (jsxs(Fragment, { children: [annotation.icon !== undefined ? jsx("span", { className: "shrink-0", children: annotation.icon }) : null, jsx("span", { className: cvaSimpleLabel({ wrap }), children: annotation.label })] }));
|
|
301
319
|
const { onClick } = annotation;
|
|
302
320
|
if (onClick !== undefined) {
|
|
303
321
|
const handleClick = (event) => {
|
|
304
322
|
event.stopPropagation();
|
|
305
323
|
onClick();
|
|
306
324
|
};
|
|
307
|
-
return (jsx("button", { className:
|
|
325
|
+
return (jsx("button", { className: cx(cvaSimplePill({ wrap }), ANNOTATION_BUTTON_RESET_CLASSES, "text-inherit"), "data-peek-root": true, "data-testid": "annotation-pill", onClick: handleClick, style: style, type: "button", children: content }));
|
|
308
326
|
}
|
|
309
|
-
return (jsx("div", { className:
|
|
327
|
+
return (jsx("div", { className: cvaSimplePill({ wrap }), "data-peek-root": true, "data-testid": "annotation-pill", style: style, children: content }));
|
|
310
328
|
}
|
|
311
329
|
case "custom": {
|
|
312
330
|
return jsx(Fragment, { children: annotation.render() });
|
|
@@ -507,7 +525,7 @@ const AnnotationStack = ({ annotations, isExiting }) => {
|
|
|
507
525
|
transition: `transform ${ANIMATION_DURATION_MS$1}ms ease-out, filter ${ANIMATION_DURATION_MS$1}ms ease-out`,
|
|
508
526
|
}, children: jsx(AnnotationRenderer, { annotation: peekAnnotation }) }, peekAnnotation.id));
|
|
509
527
|
})
|
|
510
|
-
: null, hiddenCount > 0 ? (jsxs("div", { className: "min-w-4 bg-primary-600 absolute -right-1.5 -top-1.5 h-4 items-center justify-center rounded-full px-1 text-[10px] font-semibold leading-none text-white shadow-sm", "data-annotation-badge": isExpanded ? "hidden" : "visible", "data-testid": "annotation-stack-badge", children: ["+", hiddenCount] })) : null] }), showPanel ? (jsx(Fragment, { children: jsx("div", { className: "flex max-h-[20rem] flex-col items-start gap-[3px] overflow-visible", "data-testid": "annotation-stack-expanded", onClick: handleExpandedPanelClick, ref: setFloating, style: floatingStyles, ...getFloatingProps(), children: olderAnnotations.map((annotation, index) => {
|
|
528
|
+
: null, hiddenCount > 0 ? (jsxs("div", { className: "min-w-4 bg-primary-600 absolute -right-1.5 -top-1.5 h-4 items-center justify-center rounded-full px-1 text-[10px] font-semibold leading-none text-white shadow-sm", "data-annotation-badge": isExpanded ? "hidden" : "visible", "data-testid": "annotation-stack-badge", children: ["+", hiddenCount] })) : null] }), showPanel ? (jsx(Fragment, { children: jsx("div", { className: "flex max-h-[20rem] w-max max-w-[16rem] flex-col items-start gap-[3px] overflow-visible", "data-testid": "annotation-stack-expanded", onClick: handleExpandedPanelClick, ref: setFloating, style: floatingStyles, ...getFloatingProps(), children: olderAnnotations.map((annotation, index) => {
|
|
511
529
|
const fromEnd = olderAnnotations.length - 1 - index;
|
|
512
530
|
const peekLevel = Math.min(fromEnd + 1, MAX_PEEK_COUNT);
|
|
513
531
|
const expandDelay = index * STAGGER_DELAY_MS;
|
|
@@ -3474,6 +3492,15 @@ const subscribeNoop = () => noopUnsubscribe$1;
|
|
|
3474
3492
|
const getIdle = () => "idle";
|
|
3475
3493
|
const getEmpty = () => EMPTY_DRAW_VALUE;
|
|
3476
3494
|
const getNoErrors = () => NO_DRAW_ERRORS;
|
|
3495
|
+
/**
|
|
3496
|
+
* Ids of the controls `useDraw` returns, for a consumer that filters or replaces one of them
|
|
3497
|
+
* (a wizard that confirms before clearing, for instance).
|
|
3498
|
+
*/
|
|
3499
|
+
const DRAW_CONTROL_IDS = {
|
|
3500
|
+
polygon: "draw-polygon",
|
|
3501
|
+
select: "draw-select",
|
|
3502
|
+
clear: "draw-clear",
|
|
3503
|
+
};
|
|
3477
3504
|
/**
|
|
3478
3505
|
* Feature-facing hook for the optional drawing capability (ADR 0030).
|
|
3479
3506
|
*
|
|
@@ -3579,12 +3606,16 @@ const useDraw = (api, options) => {
|
|
|
3579
3606
|
if (limitReached && mode === "polygon")
|
|
3580
3607
|
port?.setMode("idle");
|
|
3581
3608
|
}, [limitReached, mode, port]);
|
|
3609
|
+
// A down engine does not disable the toggles: switching one on is the retry. The
|
|
3610
|
+
// controller loads again on the next mode that needs an engine after a failed load,
|
|
3611
|
+
// and a mode operation that succeeds clears a failed update. Consumers say drawing
|
|
3612
|
+
// is unavailable through `error`.
|
|
3582
3613
|
const controls = useMemo(() => {
|
|
3583
3614
|
if (!isSupported || !enabled)
|
|
3584
3615
|
return [];
|
|
3585
3616
|
const polygonToggle = {
|
|
3586
3617
|
type: "toggle",
|
|
3587
|
-
id:
|
|
3618
|
+
id: DRAW_CONTROL_IDS.polygon,
|
|
3588
3619
|
icon: { on: "Pencil", off: "Pencil" },
|
|
3589
3620
|
label: t("draw.polygon"),
|
|
3590
3621
|
section: t("controls.category.tools"),
|
|
@@ -3598,7 +3629,7 @@ const useDraw = (api, options) => {
|
|
|
3598
3629
|
};
|
|
3599
3630
|
const selectToggle = {
|
|
3600
3631
|
type: "toggle",
|
|
3601
|
-
id:
|
|
3632
|
+
id: DRAW_CONTROL_IDS.select,
|
|
3602
3633
|
icon: { on: "CursorArrowRays", off: "CursorArrowRays" },
|
|
3603
3634
|
label: t("draw.select"),
|
|
3604
3635
|
section: t("controls.category.tools"),
|
|
@@ -3611,7 +3642,7 @@ const useDraw = (api, options) => {
|
|
|
3611
3642
|
};
|
|
3612
3643
|
const clearButton = {
|
|
3613
3644
|
type: "button",
|
|
3614
|
-
id:
|
|
3645
|
+
id: DRAW_CONTROL_IDS.clear,
|
|
3615
3646
|
icon: "Trash",
|
|
3616
3647
|
label: t("draw.clear"),
|
|
3617
3648
|
section: t("controls.category.tools"),
|
|
@@ -7596,7 +7627,7 @@ const toClusterFeatureCollection = (config) => {
|
|
|
7596
7627
|
* ```
|
|
7597
7628
|
*/
|
|
7598
7629
|
const useMarkers = (options) => {
|
|
7599
|
-
const { id, name, data, getPosition, getId, cluster, markerRender, clusterRender, controls, loading, fitParticipation = "all", resolveGroups, resolutionContext, } = options;
|
|
7630
|
+
const { id, name, data, getPosition, getId, cluster, markerRender, clusterRender, controls, loading, fitParticipation = "all", interactive = true, resolveGroups, resolutionContext, } = options;
|
|
7600
7631
|
// ---- Data readiness tracking ----
|
|
7601
7632
|
const layerReady = useLayerReady(loading);
|
|
7602
7633
|
// ---- Filter to positioned items ----
|
|
@@ -7681,6 +7712,7 @@ const useMarkers = (options) => {
|
|
|
7681
7712
|
clusterRender: clusterRender ?? null,
|
|
7682
7713
|
clusterFeatures,
|
|
7683
7714
|
clusterMemberItems,
|
|
7715
|
+
interactive,
|
|
7684
7716
|
// Convenience counts
|
|
7685
7717
|
positionedCount: positionedItems.length,
|
|
7686
7718
|
totalCount: data.length,
|
|
@@ -7699,6 +7731,7 @@ const useMarkers = (options) => {
|
|
|
7699
7731
|
clusterRender,
|
|
7700
7732
|
clusterFeatures,
|
|
7701
7733
|
clusterMemberItems,
|
|
7734
|
+
interactive,
|
|
7702
7735
|
positionedItems.length,
|
|
7703
7736
|
data.length,
|
|
7704
7737
|
clusterCount,
|
|
@@ -8799,6 +8832,7 @@ function toMapLayer(handle) {
|
|
|
8799
8832
|
clusterConfig: markerHandle.clusterConfig,
|
|
8800
8833
|
clusterRender: markerHandle.clusterRender,
|
|
8801
8834
|
clusterFeatures: markerHandle.clusterFeatures,
|
|
8835
|
+
interactive: markerHandle.interactive ?? true,
|
|
8802
8836
|
...(markerHandle.adaptiveResolution !== undefined
|
|
8803
8837
|
? { adaptiveResolution: markerHandle.adaptiveResolution }
|
|
8804
8838
|
: {}),
|
|
@@ -12597,12 +12631,12 @@ const applyPortalZIndex = (container, zIndex) => {
|
|
|
12597
12631
|
*/
|
|
12598
12632
|
const Layers = ({ layers, api, onEntityClick, onEntityDblClick }) => {
|
|
12599
12633
|
const layerPort = useLayerPort();
|
|
12600
|
-
// Drawing mode suppresses layer interaction (ADR 0030)
|
|
12601
|
-
//
|
|
12602
|
-
//
|
|
12603
|
-
//
|
|
12604
|
-
//
|
|
12605
|
-
//
|
|
12634
|
+
// Drawing mode suppresses layer interaction (ADR 0030). Shapes, markers, clusters and
|
|
12635
|
+
// routes are pushed to the adapter as non-interactive (see `enrichedHandles`), so they
|
|
12636
|
+
// stay visible but stop being pointer targets and Terra Draw gets every click. Every
|
|
12637
|
+
// interaction consumer below gets its handlers from one gated set (`interaction`), so
|
|
12638
|
+
// no panel opens and no hover state lingers under the draw tool. Programmatic
|
|
12639
|
+
// `layers.select` still works.
|
|
12606
12640
|
const drawing = api?.state.drawing === true;
|
|
12607
12641
|
const [decorationLayers, setDecorationLayers] = useState([]);
|
|
12608
12642
|
const [viewportStyleOverrides, setViewportStyleOverrides] = useState(new Map());
|
|
@@ -12719,7 +12753,8 @@ const Layers = ({ layers, api, onEntityClick, onEntityDblClick }) => {
|
|
|
12719
12753
|
const fillOverrides = fillGeometryOverrides.get(handle.id);
|
|
12720
12754
|
const zIndexOverridesForHandle = zIndexOverrides.get(handle.id);
|
|
12721
12755
|
const queryShapesAt = (position) => queryAt(handle.id, position);
|
|
12722
|
-
//
|
|
12756
|
+
// While drawing, every layer type goes to the adapter as non-interactive through its
|
|
12757
|
+
// own `interactive` field: shapes in the "none" mode, markers and routes switched off.
|
|
12723
12758
|
const interactiveWhileDrawing = drawing ? { interactive: "none" } : {};
|
|
12724
12759
|
if (styleOverrides === undefined && fillOverrides === undefined && zIndexOverridesForHandle === undefined) {
|
|
12725
12760
|
return { ...handle, ...interactiveWhileDrawing, queryShapesAt };
|
|
@@ -12733,12 +12768,20 @@ const Layers = ({ layers, api, onEntityClick, onEntityDblClick }) => {
|
|
|
12733
12768
|
...(zIndexOverridesForHandle !== undefined ? { featureZIndexOverrides: zIndexOverridesForHandle } : {}),
|
|
12734
12769
|
};
|
|
12735
12770
|
}
|
|
12736
|
-
if (handle.layerType
|
|
12771
|
+
if (handle.layerType === "route") {
|
|
12772
|
+
return drawing && handle.interactive ? { ...handle, interactive: false } : handle;
|
|
12773
|
+
}
|
|
12774
|
+
if (handle.layerType !== "markers")
|
|
12737
12775
|
return handle;
|
|
12738
|
-
const
|
|
12739
|
-
|
|
12776
|
+
const interactive = drawing ? false : (handle.interactive ?? true);
|
|
12777
|
+
const adaptiveResolution = handle.markerRender.mode === "adaptive" ? adaptiveByLayer.get(handle.id) : undefined;
|
|
12778
|
+
if (interactive === handle.interactive && adaptiveResolution === undefined)
|
|
12740
12779
|
return handle;
|
|
12741
|
-
return {
|
|
12780
|
+
return {
|
|
12781
|
+
...handle,
|
|
12782
|
+
interactive,
|
|
12783
|
+
...(adaptiveResolution !== undefined ? { adaptiveResolution } : {}),
|
|
12784
|
+
};
|
|
12742
12785
|
});
|
|
12743
12786
|
}, [
|
|
12744
12787
|
layers.handles,
|
|
@@ -13739,4 +13782,4 @@ const mockMapApi = (overrides) => {
|
|
|
13739
13782
|
*/
|
|
13740
13783
|
setupLibraryTranslations();
|
|
13741
13784
|
|
|
13742
|
-
export { ClusterMarker, ClusterStick, Controls, DEFAULT_APPEARANCE_PERSISTENCE_KEY, DEFAULT_MARKER_SIZE_BREAKPOINTS, DefaultControls, Layers, MARKER_DARK_PILL, MARKER_DISC_BORDER_WIDTH_PX, MARKER_LIGHT_PILL, MARKER_PILL_CONTENT_LAYOUT_SIZE, MARKER_SIZE_MAP, MARKER_TUNING, MapLoadingState, MapMarker, MapMarkerIcon, PanelIconButton, ShapeAnnotationLabel, buildExpandedIds, cvaMapMarker, cvaMarkerIndicator, mockMapApi, useAdaptiveMarkerHelpers, useAutoPanResolver, useCameraIdle, useCameraState, useClusterCountFormat, useControlStack, useControls, useDefaultControls, useDirectionIndicator, useDraw, useEntitiesNearCursor, useExpandedIds, useFitFeatureBounds, useFitToContent, useHeatmap, useImageOverlay, useLabelPlacement, useLayers, useMap, useMapAnnotation, useMapAnnotations, useMapAppearanceControls, useMapKeyboardNavigation, useMarkerColors, useMarkerStateResolvers, useMarkers, usePanel, usePanelPreload, usePersistedAppearanceSeed, usePreviewMap, useRoute, useShapeLabelHelpers, useShapes, useViewportContext };
|
|
13785
|
+
export { ClusterMarker, ClusterStick, Controls, DEFAULT_APPEARANCE_PERSISTENCE_KEY, DEFAULT_MARKER_SIZE_BREAKPOINTS, DRAW_CONTROL_IDS, DefaultControls, Layers, MARKER_DARK_PILL, MARKER_DISC_BORDER_WIDTH_PX, MARKER_LIGHT_PILL, MARKER_PILL_CONTENT_LAYOUT_SIZE, MARKER_SIZE_MAP, MARKER_TUNING, MapLoadingState, MapMarker, MapMarkerIcon, PanelIconButton, ShapeAnnotationLabel, buildExpandedIds, cvaMapMarker, cvaMarkerIndicator, mockMapApi, useAdaptiveMarkerHelpers, useAutoPanResolver, useCameraIdle, useCameraState, useClusterCountFormat, useControlStack, useControls, useDefaultControls, useDirectionIndicator, useDraw, useEntitiesNearCursor, useExpandedIds, useFitFeatureBounds, useFitToContent, useHeatmap, useImageOverlay, useLabelPlacement, useLayers, useMap, useMapAnnotation, useMapAnnotations, useMapAppearanceControls, useMapKeyboardNavigation, useMarkerColors, useMarkerStateResolvers, useMarkers, usePanel, usePanelPreload, usePersistedAppearanceSeed, usePreviewMap, useRoute, useShapeLabelHelpers, useShapes, useViewportContext };
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-map",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.284",
|
|
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-components": "6.0.
|
|
11
|
-
"@trackunit/css-class-variance-utilities": "2.6.
|
|
12
|
-
"@trackunit/react-form-components": "2.17.
|
|
13
|
-
"@trackunit/react-core-hooks": "1.31.
|
|
14
|
-
"@trackunit/geo-json-utils": "1.21.
|
|
15
|
-
"@trackunit/i18n-library-translation": "2.14.
|
|
10
|
+
"@trackunit/react-components": "6.0.29",
|
|
11
|
+
"@trackunit/css-class-variance-utilities": "2.6.35",
|
|
12
|
+
"@trackunit/react-form-components": "2.17.31",
|
|
13
|
+
"@trackunit/react-core-hooks": "1.31.27",
|
|
14
|
+
"@trackunit/geo-json-utils": "1.21.35",
|
|
15
|
+
"@trackunit/i18n-library-translation": "2.14.27",
|
|
16
16
|
"react-minimal-pie-chart": "^8.4.0",
|
|
17
|
-
"@trackunit/react-map-adapter-shared": "0.0.
|
|
18
|
-
"@trackunit/react-map-color-utils": "0.0.
|
|
19
|
-
"@trackunit/shared-utils": "1.22.
|
|
17
|
+
"@trackunit/react-map-adapter-shared": "0.0.202",
|
|
18
|
+
"@trackunit/react-map-color-utils": "0.0.176",
|
|
19
|
+
"@trackunit/shared-utils": "1.22.35",
|
|
20
20
|
"@trackunit/ui-design-tokens": "1.21.34",
|
|
21
21
|
"@floating-ui/react": "^0.26.25",
|
|
22
22
|
"es-toolkit": "^1.52.0",
|
|
@@ -14,6 +14,11 @@ export type MapAnnotationDescriptor = Readonly<{
|
|
|
14
14
|
icon?: ReactNode;
|
|
15
15
|
label: string;
|
|
16
16
|
color?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Let the label wrap onto several lines instead of truncating it.
|
|
19
|
+
* Set it for sentence-length hints; leave it off for short status pills.
|
|
20
|
+
*/
|
|
21
|
+
wrap?: boolean;
|
|
17
22
|
/**
|
|
18
23
|
* When set, the pill is rendered as a button and the handler runs on click.
|
|
19
24
|
* Implementations should call `stopPropagation` so multi-annotation stack
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* focus accessibility. Matches the focus ring pattern in InteractiveDecoration.tsx
|
|
7
7
|
* so all interactive map overlay buttons behave consistently for keyboard users.
|
|
8
8
|
*
|
|
9
|
-
* Compose additional appearance classes on top via `
|
|
9
|
+
* Compose additional appearance classes on top via `cx`.
|
|
10
10
|
*
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
package/src/draw/useDraw.d.ts
CHANGED
|
@@ -70,6 +70,15 @@ export type UseDrawReturn = Readonly<{
|
|
|
70
70
|
*/
|
|
71
71
|
controls: ReadonlyArray<ControlConfig>;
|
|
72
72
|
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Ids of the controls `useDraw` returns, for a consumer that filters or replaces one of them
|
|
75
|
+
* (a wizard that confirms before clearing, for instance).
|
|
76
|
+
*/
|
|
77
|
+
export declare const DRAW_CONTROL_IDS: {
|
|
78
|
+
readonly polygon: "draw-polygon";
|
|
79
|
+
readonly select: "draw-select";
|
|
80
|
+
readonly clear: "draw-clear";
|
|
81
|
+
};
|
|
73
82
|
/**
|
|
74
83
|
* Feature-facing hook for the optional drawing capability (ADR 0030).
|
|
75
84
|
*
|
package/src/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export { useControls } from "./controls/useControls";
|
|
|
18
18
|
export { useDefaultControls, type UseDefaultControlsOptions } from "./controls/useDefaultControls";
|
|
19
19
|
export { EMPTY_DRAW_VALUE } from "@trackunit/react-map-adapter-shared";
|
|
20
20
|
export type { DrawEngineError, DrawError, DrawErrorCode, DrawErrors, DrawMode, DrawPort, DrawValue, DrawValueRejection, } from "@trackunit/react-map-adapter-shared";
|
|
21
|
-
export { useDraw, type UseDrawOptions, type UseDrawReturn } from "./draw/useDraw";
|
|
21
|
+
export { DRAW_CONTROL_IDS, useDraw, type UseDrawOptions, type UseDrawReturn } from "./draw/useDraw";
|
|
22
22
|
export { DEFAULT_APPEARANCE_PERSISTENCE_KEY } from "./appearance/appearanceTypes";
|
|
23
23
|
export type { AppearanceAction, AppearanceOption, AppearanceOptions, MapAppearanceApi, PersistedAppearance, UseMapAppearanceControlsParams, } from "./appearance/appearanceTypes";
|
|
24
24
|
export { useMapAppearanceControls } from "./appearance/useMapAppearanceControls";
|
|
@@ -2,7 +2,7 @@ import type { GeoJsonBbox, GeoJsonFeature, GeoJsonFeatureCollection } from "@tra
|
|
|
2
2
|
import type { LayerPort } from "@trackunit/react-map-adapter-shared";
|
|
3
3
|
import { type Mock } from "vitest";
|
|
4
4
|
import type { MapApi, MapState } from "../core/types";
|
|
5
|
-
import type { LayerHandle, ShapeLayerHandle } from "./types";
|
|
5
|
+
import type { LayerHandle, RouteLayerHandle, ShapeLayerHandle } from "./types";
|
|
6
6
|
import type { UseLayersReturn } from "./useLayers";
|
|
7
7
|
export declare const POLYGON_FEATURES: GeoJsonFeatureCollection;
|
|
8
8
|
export declare const VIEWPORT_BOUNDS: GeoJsonBbox;
|
|
@@ -22,4 +22,6 @@ export type MockLayerPortWithReadiness = {
|
|
|
22
22
|
export declare const createMockLayerPort: () => MockLayerPortWithReadiness;
|
|
23
23
|
export declare const createMockMapApi: (bounds?: GeoJsonBbox | null, stateOverrides?: Partial<MapState>) => MapApi;
|
|
24
24
|
export declare const createShapeHandle: (id: string, labelFn?: (feature: GeoJsonFeature) => string | undefined, features?: GeoJsonFeatureCollection) => ShapeLayerHandle;
|
|
25
|
+
/** A minimal route handle, non-interactive until a test says otherwise. */
|
|
26
|
+
export declare const createRouteHandle: (id: string) => RouteLayerHandle;
|
|
25
27
|
export declare const createMockLayersReturn: (handles: ReadonlyArray<LayerHandle>) => UseLayersReturn;
|
package/src/layers/types.d.ts
CHANGED
|
@@ -90,6 +90,13 @@ export interface MarkerLayerHandle extends LayerMeta {
|
|
|
90
90
|
* cluster portals.
|
|
91
91
|
*/
|
|
92
92
|
readonly clusterMemberItems: ReadonlyMap<string, ReadonlyArray<unknown> | null> | null;
|
|
93
|
+
/**
|
|
94
|
+
* Whether markers and clusters are hit targets (click, hover, double-click).
|
|
95
|
+
* Default `true`, so a hand-built handle can leave it out. `<Layers>` overrides
|
|
96
|
+
* it to `false` for every marker layer while a drawing mode is active
|
|
97
|
+
* (ADR 0030), as it switches shapes to `"none"` and routes off.
|
|
98
|
+
*/
|
|
99
|
+
readonly interactive?: boolean;
|
|
93
100
|
/**
|
|
94
101
|
* Filled by `<Layers>` when `markerRender.mode === "adaptive"` — per-feature
|
|
95
102
|
* resolved display modes for the map adapter (plan §8).
|
|
@@ -47,6 +47,14 @@ export type UseMarkersOptions<TItem, TCluster = ClusterInfo> = Readonly<{
|
|
|
47
47
|
loading?: boolean;
|
|
48
48
|
/** Controls whether this layer's bounds are included in fit-to-content operations. Default: `"all"` */
|
|
49
49
|
fitParticipation?: FitParticipation;
|
|
50
|
+
/**
|
|
51
|
+
* Whether markers and clusters are hit targets (click, hover, double-click).
|
|
52
|
+
* Default: `true`. Set `false` for context-only markers that should neither
|
|
53
|
+
* highlight nor open anything; they stay visible and clicks fall through to
|
|
54
|
+
* the map. `<Layers>` turns every marker layer off while a drawing mode is
|
|
55
|
+
* active, whatever this says.
|
|
56
|
+
*/
|
|
57
|
+
interactive?: boolean;
|
|
50
58
|
/**
|
|
51
59
|
* Per-cluster entity-shape decision (ADR-0016).
|
|
52
60
|
*
|