@flowmap.gl/data 8.0.2 → 8.0.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/.turbo/turbo-build.log +1 -1
- package/dist/FlowmapSelectors.d.ts +1 -0
- package/dist/FlowmapSelectors.d.ts.map +1 -1
- package/dist/FlowmapSelectors.js +9 -4
- package/dist/FlowmapState.d.ts +2 -0
- package/dist/FlowmapState.d.ts.map +1 -1
- package/dist/FlowmapState.js +1 -1
- package/package.json +2 -2
- package/src/FlowmapSelectors.ts +13 -4
- package/src/FlowmapState.ts +3 -0
- package/.turbo/turbo-dev.log +0 -670
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowmap.gl/data",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@types/mapbox__geo-viewport": "^0.5.0",
|
|
42
42
|
"@types/seedrandom": "^3.0.5"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "3b490dcf0cc2e0235f054b7205f8fa3eb23132d7",
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
}
|
package/src/FlowmapSelectors.ts
CHANGED
|
@@ -101,6 +101,10 @@ export default class FlowmapSelectors<
|
|
|
101
101
|
};
|
|
102
102
|
getMaxTopFlowsDisplayNum = (state: FlowmapState, props: FlowmapData<L, F>) =>
|
|
103
103
|
state.settings.maxTopFlowsDisplayNum;
|
|
104
|
+
getFlowEndpointsInViewportMode = (
|
|
105
|
+
state: FlowmapState,
|
|
106
|
+
props: FlowmapData<L, F>,
|
|
107
|
+
) => state.settings.flowEndpointsInViewportMode;
|
|
104
108
|
getSelectedLocations = (state: FlowmapState, props: FlowmapData<L, F>) =>
|
|
105
109
|
state.filter?.selectedLocations;
|
|
106
110
|
getLocationFilterMode = (state: FlowmapState, props: FlowmapData<L, F>) =>
|
|
@@ -847,12 +851,14 @@ export default class FlowmapSelectors<
|
|
|
847
851
|
this.getSelectedLocationsSet,
|
|
848
852
|
this.getLocationFilterMode,
|
|
849
853
|
this.getMaxTopFlowsDisplayNum,
|
|
854
|
+
this.getFlowEndpointsInViewportMode,
|
|
850
855
|
(
|
|
851
856
|
flows,
|
|
852
857
|
locationIdsInViewport,
|
|
853
858
|
selectedLocationsSet,
|
|
854
859
|
locationFilterMode,
|
|
855
860
|
maxTopFlowsDisplayNum,
|
|
861
|
+
flowEndpointsInViewportMode,
|
|
856
862
|
) => {
|
|
857
863
|
if (!flows || !locationIdsInViewport) return undefined;
|
|
858
864
|
const picked: (F | AggregateFlow)[] = [];
|
|
@@ -860,10 +866,13 @@ export default class FlowmapSelectors<
|
|
|
860
866
|
for (const flow of flows) {
|
|
861
867
|
const origin = this.accessors.getFlowOriginId(flow);
|
|
862
868
|
const dest = this.accessors.getFlowDestId(flow);
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
869
|
+
const originInView = locationIdsInViewport.has(origin);
|
|
870
|
+
const destInView = locationIdsInViewport.has(dest);
|
|
871
|
+
const isInViewport =
|
|
872
|
+
flowEndpointsInViewportMode === 'both'
|
|
873
|
+
? originInView && destInView
|
|
874
|
+
: originInView || destInView;
|
|
875
|
+
if (isInViewport) {
|
|
867
876
|
if (
|
|
868
877
|
this.isFlowInSelection(
|
|
869
878
|
flow,
|
package/src/FlowmapState.ts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
import {LocationFilterMode, ViewportProps} from './types';
|
|
8
8
|
|
|
9
|
+
export type FlowEndpointsInViewportMode = 'any' | 'both';
|
|
10
|
+
|
|
9
11
|
export interface FilterState {
|
|
10
12
|
selectedLocations?: (string | number)[];
|
|
11
13
|
locationFilterMode?: LocationFilterMode;
|
|
@@ -28,6 +30,7 @@ export interface SettingsState {
|
|
|
28
30
|
colorScheme: string | string[] | undefined;
|
|
29
31
|
highlightColor: string;
|
|
30
32
|
maxTopFlowsDisplayNum: number;
|
|
33
|
+
flowEndpointsInViewportMode: FlowEndpointsInViewportMode;
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
export interface FlowmapState {
|