Skip to content

Commit

Permalink
Add index.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
qiuxiang committed Jul 30, 2021
1 parent a9c49e0 commit e6d9530
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 5 deletions.
22 changes: 22 additions & 0 deletions lib/js/index.d.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from "react";
import { View } from "react-native";
import { MapView } from ".";

const latlng = { latitude: 0, longitude: 0 };

export default () => (
<View>
<MapView center={latlng}>
<MapView.Marker coordinate={latlng} view={() => <View />} />
<MapView.Polygon points={[latlng]} strokeColor="red" strokeWidth={2} />
<MapView.Polyline points={[latlng]} />
<MapView.HeatMap points={[{ ...latlng, intensity: 1 }]} />
<MapView.Cluster
markers={[{ coordinate: latlng }]}
renderMarker={({ coordinate }) => (
<MapView.Marker coordinate={coordinate} />
)}
/>
</MapView>
</View>
);
73 changes: 70 additions & 3 deletions lib/js/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, ComponentType } from "react";
import { ViewProps, ColorPropType } from "react-native";
import { Component, ReactElement } from "react";
import { ViewProps, ViewStyle } from "react-native";

export type Point = {
x: number;
Expand Down Expand Up @@ -44,7 +44,7 @@ export interface MarkerProps extends ViewProps {
coordinate: LatLng;
color?: string;
image?: string;
view?: JSX.Element;
view?: () => ReactElement<any>;
title?: string;
selected?: boolean;
draggable?: boolean;
Expand All @@ -62,6 +62,69 @@ export class Marker extends Component<MarkerProps> {
update(): void;
}

export interface PolylineProps extends ViewProps {
points: LatLng[];
color?: string;
colors?: string;
width?: number;
}

export class Polyline extends Component<PolylineProps> {}

export interface PolygonProps extends ViewProps {
points: LatLng[];
strokeWidth?: number;
strokeColor?: string;
fillColor?: string;
}

export class Polygon extends Component<PolygonProps> {}

export interface CircleProps extends ViewProps {
center: LatLng;
radius: number;
strokeWidth?: number;
strokeColor?: string;
fillColor?: string;
}

export class Circle extends Component<CircleProps> {}

export type HeatMapPoint = { intensity: number } & LatLng;

export interface HeatMapProps extends ViewProps {
points: HeatMapPoint[];
radius?: number;
opacity?: number;
}

export class HeatMap extends Component<HeatMapProps> {}

export type ClusterParams = {
id: number;
count: number;
coordinate: LatLng;
};

export type ClusterMarkerItem = {
coordinate: LatLng;
extra?: any;
};

export interface ClusterProps extends ViewProps {
markers: ClusterMarkerItem[];
renderMarker: (ClusterMarkerItem) => ReactElement<any>;
radius?: number;
clusterStyle?: ViewStyle;
clusterTextStyle?: ViewStyle;
renderCluster?: (ClusterParams) => ReactElement<any>;
onPress?: (ClusterParams) => void;
}

export class Cluster extends Component<ClusterProps> {
update({ zoomLevel: number, region: Region }): void;
}

export interface MapViewProps extends ViewProps {
satellite?: boolean;
trafficEnabled?: boolean;
Expand Down Expand Up @@ -95,5 +158,9 @@ export interface MapViewProps extends ViewProps {

export class MapView extends Component<MapViewProps> {
static Marker: typeof Marker;
static Polyline: typeof Polyline;
static Polygon: typeof Polygon;
static HeatMap: typeof HeatMap;
static Cluster: typeof Cluster;
setStatus(status: MapViewStatus, duration?: number): void;
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"location",
"baidumap"
],
"version": "0.5.10",
"version": "0.6.0",
"author": "7c00 <i@7c00.cc>",
"repository": {
"type": "git",
Expand All @@ -32,6 +32,8 @@
"run-ios": "node node_modules/react-native/local-cli/cli.js run-ios"
},
"dependencies": {
"@types/react": "^16.4.14",
"@types/react-native": "^0.56.18",
"supercluster": "^3.0.2"
},
"peerDependencies": {
Expand All @@ -48,7 +50,8 @@
"flow-bin": "^0.69.0",
"react": "^16.2.0",
"react-native": "^0.52.3",
"react-navigation": "1.5.11"
"react-navigation": "1.5.11",
"typescript": "^3.0.3"
},
"presets": [
"react-native"
Expand Down
27 changes: 27 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,25 @@
lodash "^4.2.0"
to-fast-properties "^2.0.0"

"@types/prop-types@*":
version "15.5.5"
resolved "http://registry.npm.taobao.org/@types/prop-types/download/@types/prop-types-15.5.5.tgz#17038dd322c2325f5da650a94d5f9974943625e3"
dependencies:
"@types/react" "*"

"@types/react-native@^0.56.18":
version "0.56.18"
resolved "http://registry.npm.taobao.org/@types/react-native/download/@types/react-native-0.56.18.tgz#9e656d87da53a1fdd42be4cc4eab23f81bff71e9"
dependencies:
"@types/react" "*"

"@types/react@*", "@types/react@^16.4.14":
version "16.4.14"
resolved "http://registry.npm.taobao.org/@types/react/download/@types/react-16.4.14.tgz#47c604c8e46ed674bbdf4aabf82b34b9041c6a04"
dependencies:
"@types/prop-types" "*"
csstype "^2.2.0"

abbrev@1:
version "1.1.1"
resolved "http://registry.npm.taobao.org/abbrev/download/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
Expand Down Expand Up @@ -1397,6 +1416,10 @@ csrf@~3.0.0:
tsscmp "1.0.5"
uid-safe "2.1.4"

csstype@^2.2.0:
version "2.5.7"
resolved "http://registry.npm.taobao.org/csstype/download/csstype-2.5.7.tgz#bf9235d5872141eccfb2d16d82993c6b149179ff"

csurf@~1.8.3:
version "1.8.3"
resolved "http://registry.npm.taobao.org/csurf/download/csurf-1.8.3.tgz#23f2a13bf1d8fce1d0c996588394442cba86a56a"
Expand Down Expand Up @@ -4650,6 +4673,10 @@ typedarray@^0.0.6:
version "0.0.6"
resolved "http://registry.npm.taobao.org/typedarray/download/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"

typescript@^3.0.3:
version "3.0.3"
resolved "http://registry.npm.taobao.org/typescript/download/typescript-3.0.3.tgz#4853b3e275ecdaa27f78fda46dc273a7eb7fc1c8"

ua-parser-js@^0.7.9:
version "0.7.17"
resolved "http://registry.npm.taobao.org/ua-parser-js/download/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac"
Expand Down

0 comments on commit e6d9530

Please sign in to comment.