@trackunit/react-map 0.0.11 → 0.1.1-alpha-84ab66282fc.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/index.cjs.js +13 -3
- package/index.esm.js +13 -3
- package/package.json +10 -10
- package/src/layers/Layers.d.ts +20 -1
- package/src/layers/internal/useEntityInteraction.d.ts +10 -1
package/index.cjs.js
CHANGED
|
@@ -6813,7 +6813,7 @@ const noopGuard = (_active) => undefined;
|
|
|
6813
6813
|
* suppresses adapter hover-start/hover-end). Call with `false` when the DOM
|
|
6814
6814
|
* hover ends, allowing adapter events to flow again.
|
|
6815
6815
|
*/
|
|
6816
|
-
const useEntityInteraction = ({ layerPort, hover, select, dblClick, }) => {
|
|
6816
|
+
const useEntityInteraction = ({ layerPort, hover, select, dblClick, onClick, }) => {
|
|
6817
6817
|
const hoverRef = react.useRef(hover);
|
|
6818
6818
|
react.useEffect(() => {
|
|
6819
6819
|
hoverRef.current = hover;
|
|
@@ -6826,6 +6826,10 @@ const useEntityInteraction = ({ layerPort, hover, select, dblClick, }) => {
|
|
|
6826
6826
|
react.useEffect(() => {
|
|
6827
6827
|
dblClickRef.current = dblClick;
|
|
6828
6828
|
}, [dblClick]);
|
|
6829
|
+
const onClickRef = react.useRef(onClick);
|
|
6830
|
+
react.useEffect(() => {
|
|
6831
|
+
onClickRef.current = onClick;
|
|
6832
|
+
}, [onClick]);
|
|
6829
6833
|
const guardRef = react.useRef(noopGuard);
|
|
6830
6834
|
react.useEffect(() => {
|
|
6831
6835
|
if (layerPort === null)
|
|
@@ -6843,6 +6847,7 @@ const useEntityInteraction = ({ layerPort, hover, select, dblClick, }) => {
|
|
|
6843
6847
|
const { type } = event;
|
|
6844
6848
|
switch (type) {
|
|
6845
6849
|
case "click":
|
|
6850
|
+
onClickRef.current?.(event.entity);
|
|
6846
6851
|
selectRef.current(event.entity);
|
|
6847
6852
|
break;
|
|
6848
6853
|
case "dblclick":
|
|
@@ -8916,7 +8921,7 @@ const applyPortalZIndex = (container, zIndex) => {
|
|
|
8916
8921
|
* );
|
|
8917
8922
|
* ```
|
|
8918
8923
|
*/
|
|
8919
|
-
const Layers = ({ layers, api }) => {
|
|
8924
|
+
const Layers = ({ layers, api, onEntityClick, onEntityDblClick }) => {
|
|
8920
8925
|
const layerPort = useLayerPort();
|
|
8921
8926
|
const [decorationLayers, setDecorationLayers] = react.useState([]);
|
|
8922
8927
|
const [viewportStyleOverrides, setViewportStyleOverrides] = react.useState(new Map());
|
|
@@ -8950,12 +8955,17 @@ const Layers = ({ layers, api }) => {
|
|
|
8950
8955
|
layers.select(entity);
|
|
8951
8956
|
}
|
|
8952
8957
|
}, [layers]);
|
|
8953
|
-
const
|
|
8958
|
+
const fitOnDblClick = useDblClickFit(api, layers.handles);
|
|
8959
|
+
const handleDblClick = react.useCallback((entity) => {
|
|
8960
|
+
onEntityDblClick?.(entity);
|
|
8961
|
+
fitOnDblClick?.(entity);
|
|
8962
|
+
}, [onEntityDblClick, fitOnDblClick]);
|
|
8954
8963
|
const setDomHoverActive = useEntityInteraction({
|
|
8955
8964
|
layerPort,
|
|
8956
8965
|
hover: layers.hover,
|
|
8957
8966
|
select: coordinatedSelect,
|
|
8958
8967
|
dblClick: handleDblClick,
|
|
8968
|
+
onClick: onEntityClick,
|
|
8959
8969
|
});
|
|
8960
8970
|
const coordinatedHover = react.useCallback((entity) => {
|
|
8961
8971
|
setDomHoverActive(entity !== null);
|
package/index.esm.js
CHANGED
|
@@ -6812,7 +6812,7 @@ const noopGuard = (_active) => undefined;
|
|
|
6812
6812
|
* suppresses adapter hover-start/hover-end). Call with `false` when the DOM
|
|
6813
6813
|
* hover ends, allowing adapter events to flow again.
|
|
6814
6814
|
*/
|
|
6815
|
-
const useEntityInteraction = ({ layerPort, hover, select, dblClick, }) => {
|
|
6815
|
+
const useEntityInteraction = ({ layerPort, hover, select, dblClick, onClick, }) => {
|
|
6816
6816
|
const hoverRef = useRef(hover);
|
|
6817
6817
|
useEffect(() => {
|
|
6818
6818
|
hoverRef.current = hover;
|
|
@@ -6825,6 +6825,10 @@ const useEntityInteraction = ({ layerPort, hover, select, dblClick, }) => {
|
|
|
6825
6825
|
useEffect(() => {
|
|
6826
6826
|
dblClickRef.current = dblClick;
|
|
6827
6827
|
}, [dblClick]);
|
|
6828
|
+
const onClickRef = useRef(onClick);
|
|
6829
|
+
useEffect(() => {
|
|
6830
|
+
onClickRef.current = onClick;
|
|
6831
|
+
}, [onClick]);
|
|
6828
6832
|
const guardRef = useRef(noopGuard);
|
|
6829
6833
|
useEffect(() => {
|
|
6830
6834
|
if (layerPort === null)
|
|
@@ -6842,6 +6846,7 @@ const useEntityInteraction = ({ layerPort, hover, select, dblClick, }) => {
|
|
|
6842
6846
|
const { type } = event;
|
|
6843
6847
|
switch (type) {
|
|
6844
6848
|
case "click":
|
|
6849
|
+
onClickRef.current?.(event.entity);
|
|
6845
6850
|
selectRef.current(event.entity);
|
|
6846
6851
|
break;
|
|
6847
6852
|
case "dblclick":
|
|
@@ -8915,7 +8920,7 @@ const applyPortalZIndex = (container, zIndex) => {
|
|
|
8915
8920
|
* );
|
|
8916
8921
|
* ```
|
|
8917
8922
|
*/
|
|
8918
|
-
const Layers = ({ layers, api }) => {
|
|
8923
|
+
const Layers = ({ layers, api, onEntityClick, onEntityDblClick }) => {
|
|
8919
8924
|
const layerPort = useLayerPort();
|
|
8920
8925
|
const [decorationLayers, setDecorationLayers] = useState([]);
|
|
8921
8926
|
const [viewportStyleOverrides, setViewportStyleOverrides] = useState(new Map());
|
|
@@ -8949,12 +8954,17 @@ const Layers = ({ layers, api }) => {
|
|
|
8949
8954
|
layers.select(entity);
|
|
8950
8955
|
}
|
|
8951
8956
|
}, [layers]);
|
|
8952
|
-
const
|
|
8957
|
+
const fitOnDblClick = useDblClickFit(api, layers.handles);
|
|
8958
|
+
const handleDblClick = useCallback((entity) => {
|
|
8959
|
+
onEntityDblClick?.(entity);
|
|
8960
|
+
fitOnDblClick?.(entity);
|
|
8961
|
+
}, [onEntityDblClick, fitOnDblClick]);
|
|
8953
8962
|
const setDomHoverActive = useEntityInteraction({
|
|
8954
8963
|
layerPort,
|
|
8955
8964
|
hover: layers.hover,
|
|
8956
8965
|
select: coordinatedSelect,
|
|
8957
8966
|
dblClick: handleDblClick,
|
|
8967
|
+
onClick: onEntityClick,
|
|
8958
8968
|
});
|
|
8959
8969
|
const coordinatedHover = useCallback((entity) => {
|
|
8960
8970
|
setDomHoverActive(entity !== null);
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-map",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.1-alpha-84ab66282fc.0",
|
|
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": "2.1.
|
|
11
|
-
"@trackunit/css-class-variance-utilities": "1.13.
|
|
12
|
-
"@trackunit/react-form-components": "2.1.
|
|
13
|
-
"@trackunit/react-core-hooks": "1.17.
|
|
14
|
-
"@trackunit/geo-json-utils": "1.14.
|
|
15
|
-
"@trackunit/i18n-library-translation": "2.0.
|
|
16
|
-
"@trackunit/react-modal": "2.1.
|
|
10
|
+
"@trackunit/react-components": "2.1.21-alpha-84ab66282fc.0",
|
|
11
|
+
"@trackunit/css-class-variance-utilities": "1.13.29-alpha-84ab66282fc.0",
|
|
12
|
+
"@trackunit/react-form-components": "2.1.22-alpha-84ab66282fc.0",
|
|
13
|
+
"@trackunit/react-core-hooks": "1.17.35-alpha-84ab66282fc.0",
|
|
14
|
+
"@trackunit/geo-json-utils": "1.14.30-alpha-84ab66282fc.0",
|
|
15
|
+
"@trackunit/i18n-library-translation": "2.0.23-alpha-84ab66282fc.0",
|
|
16
|
+
"@trackunit/react-modal": "2.1.23-alpha-84ab66282fc.0",
|
|
17
17
|
"react-minimal-pie-chart": "^8.4.0",
|
|
18
|
-
"@trackunit/react-map-adapter-shared": "0.0.
|
|
19
|
-
"@trackunit/ui-design-tokens": "1.13.
|
|
18
|
+
"@trackunit/react-map-adapter-shared": "0.0.9-alpha-84ab66282fc.0",
|
|
19
|
+
"@trackunit/ui-design-tokens": "1.13.29-alpha-84ab66282fc.0",
|
|
20
20
|
"@floating-ui/react": "^0.26.25",
|
|
21
21
|
"es-toolkit": "^1.39.10",
|
|
22
22
|
"tailwind-merge": "^2.0.0",
|
package/src/layers/Layers.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Entity } from "@trackunit/react-map-adapter-shared";
|
|
1
2
|
import type { MapApi } from "../core/types";
|
|
2
3
|
import type { UseLayersReturn } from "./useLayers";
|
|
3
4
|
type LayersProps = Readonly<{
|
|
@@ -5,6 +6,24 @@ type LayersProps = Readonly<{
|
|
|
5
6
|
layers: UseLayersReturn;
|
|
6
7
|
/** Map API for viewport-aware features (e.g. edge labels). Optional for backward compat. */
|
|
7
8
|
api?: MapApi;
|
|
9
|
+
/**
|
|
10
|
+
* Called when the user directly clicks an entity on the map.
|
|
11
|
+
*
|
|
12
|
+
* Fires before the entity is selected, and **only** for genuine pointer
|
|
13
|
+
* clicks — programmatic `layers.select()` calls (e.g. from a list
|
|
14
|
+
* selection) do not trigger this callback. Use it to distinguish real
|
|
15
|
+
* map clicks from other selection sources, for example for analytics.
|
|
16
|
+
*/
|
|
17
|
+
onEntityClick?: (entity: Entity) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Called when the user directly double-clicks an entity on the map.
|
|
20
|
+
*
|
|
21
|
+
* Fires before the default fit behavior and **only** for genuine pointer
|
|
22
|
+
* double-clicks — programmatic interactions do not trigger this callback.
|
|
23
|
+
* Use it to distinguish real map double-clicks from other interaction
|
|
24
|
+
* sources, for example for analytics.
|
|
25
|
+
*/
|
|
26
|
+
onEntityDblClick?: (entity: Entity) => void;
|
|
8
27
|
}>;
|
|
9
28
|
/**
|
|
10
29
|
* `<Layers>` -- rendering bridge between layer handles and the map adapter.
|
|
@@ -28,5 +47,5 @@ type LayersProps = Readonly<{
|
|
|
28
47
|
* );
|
|
29
48
|
* ```
|
|
30
49
|
*/
|
|
31
|
-
export declare const Layers: ({ layers, api }: LayersProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
50
|
+
export declare const Layers: ({ layers, api, onEntityClick, onEntityDblClick }: LayersProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
32
51
|
export {};
|
|
@@ -4,6 +4,15 @@ type UseEntityInteractionConfig = Readonly<{
|
|
|
4
4
|
hover: (entity: Entity | null) => void;
|
|
5
5
|
select: (entity: Entity | null) => void;
|
|
6
6
|
dblClick?: (entity: Entity) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Called when the user clicks a map entity (marker, cluster, shape) directly
|
|
9
|
+
* on the map — fired before `select` and exclusively for real pointer clicks.
|
|
10
|
+
*
|
|
11
|
+
* Use this to distinguish a genuine user click from a programmatic
|
|
12
|
+
* `layers.select()` call (e.g. from a list selection), which does not flow
|
|
13
|
+
* through this callback.
|
|
14
|
+
*/
|
|
15
|
+
onClick?: (entity: Entity) => void;
|
|
7
16
|
}>;
|
|
8
17
|
/**
|
|
9
18
|
* Subscribes to entity interaction events (click, dblclick, hover-start,
|
|
@@ -17,5 +26,5 @@ type UseEntityInteractionConfig = Readonly<{
|
|
|
17
26
|
* suppresses adapter hover-start/hover-end). Call with `false` when the DOM
|
|
18
27
|
* hover ends, allowing adapter events to flow again.
|
|
19
28
|
*/
|
|
20
|
-
export declare const useEntityInteraction: ({ layerPort, hover, select, dblClick, }: UseEntityInteractionConfig) => ((active: boolean) => void);
|
|
29
|
+
export declare const useEntityInteraction: ({ layerPort, hover, select, dblClick, onClick, }: UseEntityInteractionConfig) => ((active: boolean) => void);
|
|
21
30
|
export {};
|