gistda-sphere-react 1.0.0 → 1.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gistda-sphere-react",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "React wrapper library for GISTDA Sphere Map API with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -40,19 +40,19 @@
40
40
  "author": "dulapahv",
41
41
  "license": "MIT",
42
42
  "peerDependencies": {
43
- "react": ">=18.0.0",
44
- "react-dom": ">=18.0.0"
43
+ "react": ">=19.0.0",
44
+ "react-dom": ">=19.0.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@biomejs/biome": "^2.3.13",
48
48
  "@testing-library/jest-dom": "^6.9.1",
49
49
  "@testing-library/react": "^16.0.0",
50
- "@types/react": "^18.2.0",
51
- "@types/react-dom": "^18.2.0",
50
+ "@types/react": "^19.0.0",
51
+ "@types/react-dom": "^19.0.0",
52
52
  "@vitest/coverage-v8": "^2.0.0",
53
53
  "jsdom": "^25.0.0",
54
- "react": "^18.2.0",
55
- "react-dom": "^18.2.0",
54
+ "react": "^19.0.0",
55
+ "react-dom": "^19.0.0",
56
56
  "tsup": "^8.0.0",
57
57
  "typescript": "^5.3.0",
58
58
  "ultracite": "^7.1.3",
@@ -1,4 +1,4 @@
1
- import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
1
+ import { type Ref, useEffect, useImperativeHandle, useRef } from "react";
2
2
  import { useMapContext } from "../context/MapContext";
3
3
  import { useSphereContext } from "../context/SphereContext";
4
4
  import type {
@@ -11,9 +11,20 @@ import type {
11
11
  SphereCircle,
12
12
  } from "../types";
13
13
 
14
+ export interface CircleRef {
15
+ getCircle(): SphereCircle | null;
16
+ togglePopup(show?: boolean, location?: Location): void;
17
+ getCenter(): Location | null;
18
+ getBound(): Bound | null;
19
+ getArea(language?: string): number | string | null;
20
+ getRadius(language?: string): number | string | null;
21
+ updateStyle(options: Partial<GeometryOptions>): void;
22
+ }
23
+
14
24
  export interface CircleProps {
15
25
  center: Location;
16
26
  radius: number;
27
+ ref?: Ref<CircleRef>;
17
28
  title?: string;
18
29
  detail?: string;
19
30
  popup?: PopupOptions;
@@ -30,37 +41,25 @@ export interface CircleProps {
30
41
  onDrop?: (circle: SphereCircle) => void;
31
42
  }
32
43
 
33
- export interface CircleRef {
34
- getCircle(): SphereCircle | null;
35
- togglePopup(show?: boolean, location?: Location): void;
36
- getCenter(): Location | null;
37
- getBound(): Bound | null;
38
- getArea(language?: string): number | string | null;
39
- getRadius(language?: string): number | string | null;
40
- updateStyle(options: Partial<GeometryOptions>): void;
41
- }
42
-
43
- export const Circle = forwardRef<CircleRef, CircleProps>(function Circle(
44
- {
45
- center,
46
- radius,
47
- title,
48
- detail,
49
- popup,
50
- visibleRange,
51
- lineWidth,
52
- lineColor,
53
- fillColor,
54
- lineStyle,
55
- clickable,
56
- draggable,
57
- zIndex,
58
- onClick,
59
- onDrag,
60
- onDrop,
61
- },
62
- ref
63
- ) {
44
+ export function Circle({
45
+ center,
46
+ radius,
47
+ ref,
48
+ title,
49
+ detail,
50
+ popup,
51
+ visibleRange,
52
+ lineWidth,
53
+ lineColor,
54
+ fillColor,
55
+ lineStyle,
56
+ clickable,
57
+ draggable,
58
+ zIndex,
59
+ onClick,
60
+ onDrag,
61
+ onDrop,
62
+ }: CircleProps) {
64
63
  const { map, isReady } = useMapContext();
65
64
  const { sphere } = useSphereContext();
66
65
  const circleRef = useRef<SphereCircle | null>(null);
@@ -184,6 +183,4 @@ export const Circle = forwardRef<CircleRef, CircleProps>(function Circle(
184
183
  );
185
184
 
186
185
  return null;
187
- });
188
-
189
- export default Circle;
186
+ }
@@ -1,10 +1,17 @@
1
- import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
1
+ import { type Ref, useEffect, useImperativeHandle, useRef } from "react";
2
2
  import { useMapContext } from "../context/MapContext";
3
3
  import { useSphereContext } from "../context/SphereContext";
4
4
  import type { GeometryOptions, Location, Range, SphereDot } from "../types";
5
5
 
6
+ export interface DotRef {
7
+ getDot(): SphereDot | null;
8
+ setPosition(location: Location): void;
9
+ getPosition(): Location | null;
10
+ }
11
+
6
12
  export interface DotProps {
7
13
  position: Location;
14
+ ref?: Ref<DotRef>;
8
15
  title?: string;
9
16
  detail?: string;
10
17
  visibleRange?: Range;
@@ -18,29 +25,21 @@ export interface DotProps {
18
25
  onDrop?: (dot: SphereDot, location: Location) => void;
19
26
  }
20
27
 
21
- export interface DotRef {
22
- getDot(): SphereDot | null;
23
- setPosition(location: Location): void;
24
- getPosition(): Location | null;
25
- }
26
-
27
- export const Dot = forwardRef<DotRef, DotProps>(function Dot(
28
- {
29
- position,
30
- title,
31
- detail,
32
- visibleRange,
33
- lineWidth,
34
- lineColor,
35
- clickable,
36
- draggable,
37
- zIndex,
38
- onClick,
39
- onDrag,
40
- onDrop,
41
- },
42
- ref
43
- ) {
28
+ export function Dot({
29
+ position,
30
+ ref,
31
+ title,
32
+ detail,
33
+ visibleRange,
34
+ lineWidth,
35
+ lineColor,
36
+ clickable,
37
+ draggable,
38
+ zIndex,
39
+ onClick,
40
+ onDrag,
41
+ onDrop,
42
+ }: DotProps) {
44
43
  const { map, isReady } = useMapContext();
45
44
  const { sphere } = useSphereContext();
46
45
  const dotRef = useRef<SphereDot | null>(null);
@@ -145,6 +144,4 @@ export const Dot = forwardRef<DotRef, DotProps>(function Dot(
145
144
  );
146
145
 
147
146
  return null;
148
- });
149
-
150
- export default Dot;
147
+ }
@@ -1,4 +1,4 @@
1
- import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
1
+ import { type Ref, useEffect, useImperativeHandle, useRef } from "react";
2
2
  import { useMapContext } from "../context/MapContext";
3
3
  import { useSphereContext } from "../context/SphereContext";
4
4
  import type {
@@ -10,8 +10,16 @@ import type {
10
10
  SphereMarker,
11
11
  } from "../types";
12
12
 
13
+ export interface MarkerRef {
14
+ getMarker(): SphereMarker | null;
15
+ togglePopup(show?: boolean): void;
16
+ setPosition(location: Location, animate?: boolean): void;
17
+ setRotation(angle: number): void;
18
+ }
19
+
13
20
  export interface MarkerProps {
14
21
  position: Location;
22
+ ref?: Ref<MarkerRef>;
15
23
  icon?: Icon;
16
24
  title?: string;
17
25
  detail?: string;
@@ -28,33 +36,24 @@ export interface MarkerProps {
28
36
  onLeave?: (marker: SphereMarker) => void;
29
37
  }
30
38
 
31
- export interface MarkerRef {
32
- getMarker(): SphereMarker | null;
33
- togglePopup(show?: boolean): void;
34
- setPosition(location: Location, animate?: boolean): void;
35
- setRotation(angle: number): void;
36
- }
37
-
38
- export const Marker = forwardRef<MarkerRef, MarkerProps>(function Marker(
39
- {
40
- position,
41
- icon,
42
- title,
43
- detail,
44
- popup,
45
- visibleRange,
46
- clickable,
47
- draggable,
48
- zIndex,
49
- rotate,
50
- onClick,
51
- onDrag,
52
- onDrop,
53
- onHover,
54
- onLeave,
55
- },
56
- ref
57
- ) {
39
+ export function Marker({
40
+ position,
41
+ ref,
42
+ icon,
43
+ title,
44
+ detail,
45
+ popup,
46
+ visibleRange,
47
+ clickable,
48
+ draggable,
49
+ zIndex,
50
+ rotate,
51
+ onClick,
52
+ onDrag,
53
+ onDrop,
54
+ onHover,
55
+ onLeave,
56
+ }: MarkerProps) {
58
57
  const { map, isReady } = useMapContext();
59
58
  const { sphere } = useSphereContext();
60
59
  const markerRef = useRef<SphereMarker | null>(null);
@@ -199,6 +198,4 @@ export const Marker = forwardRef<MarkerRef, MarkerProps>(function Marker(
199
198
  );
200
199
 
201
200
  return null;
202
- });
203
-
204
- export default Marker;
201
+ }
@@ -1,4 +1,4 @@
1
- import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
1
+ import { type Ref, useEffect, useImperativeHandle, useRef } from "react";
2
2
  import { useMapContext } from "../context/MapContext";
3
3
  import { useSphereContext } from "../context/SphereContext";
4
4
  import type {
@@ -12,8 +12,21 @@ import type {
12
12
  SpherePolygon,
13
13
  } from "../types";
14
14
 
15
+ export interface PolygonRef {
16
+ getPolygon(): SpherePolygon | null;
17
+ togglePopup(show?: boolean, location?: Location): void;
18
+ getPivot(): Location | null;
19
+ getCentroid(): Location | null;
20
+ getBound(): Bound | null;
21
+ getArea(language?: string): number | string | null;
22
+ rotate(angle: number): void;
23
+ updateStyle(options: Partial<GeometryOptions>): void;
24
+ toGeoJSON(): object | null;
25
+ }
26
+
15
27
  export interface PolygonProps {
16
28
  positions: Location[];
29
+ ref?: Ref<PolygonRef>;
17
30
  title?: string;
18
31
  detail?: string;
19
32
  label?: string;
@@ -35,43 +48,29 @@ export interface PolygonProps {
35
48
  onDrop?: (polygon: SpherePolygon) => void;
36
49
  }
37
50
 
38
- export interface PolygonRef {
39
- getPolygon(): SpherePolygon | null;
40
- togglePopup(show?: boolean, location?: Location): void;
41
- getPivot(): Location | null;
42
- getCentroid(): Location | null;
43
- getBound(): Bound | null;
44
- getArea(language?: string): number | string | null;
45
- rotate(angle: number): void;
46
- updateStyle(options: Partial<GeometryOptions>): void;
47
- toGeoJSON(): object | null;
48
- }
49
-
50
- export const Polygon = forwardRef<PolygonRef, PolygonProps>(function Polygon(
51
- {
52
- positions,
53
- title,
54
- detail,
55
- label,
56
- labelOptions,
57
- popup,
58
- visibleRange,
59
- lineWidth,
60
- lineColor,
61
- fillColor,
62
- lineStyle,
63
- pivot,
64
- clickable,
65
- draggable,
66
- pointer,
67
- zIndex,
68
- editable,
69
- onClick,
70
- onDrag,
71
- onDrop,
72
- },
51
+ export function Polygon({
52
+ positions,
73
53
  ref,
74
- ) {
54
+ title,
55
+ detail,
56
+ label,
57
+ labelOptions,
58
+ popup,
59
+ visibleRange,
60
+ lineWidth,
61
+ lineColor,
62
+ fillColor,
63
+ lineStyle,
64
+ pivot,
65
+ clickable,
66
+ draggable,
67
+ pointer,
68
+ zIndex,
69
+ editable,
70
+ onClick,
71
+ onDrag,
72
+ onDrop,
73
+ }: PolygonProps) {
75
74
  const { map, isReady } = useMapContext();
76
75
  const { sphere } = useSphereContext();
77
76
  const polygonRef = useRef<SpherePolygon | null>(null);
@@ -214,10 +213,8 @@ export const Polygon = forwardRef<PolygonRef, PolygonProps>(function Polygon(
214
213
  },
215
214
  toGeoJSON: () => polygonRef.current?.toJSON() ?? null,
216
215
  }),
217
- [],
216
+ []
218
217
  );
219
218
 
220
219
  return null;
221
- });
222
-
223
- export default Polygon;
220
+ }