@mint-ui/map 1.2.0-test.65 → 1.2.0-test.66

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.
@@ -0,0 +1,280 @@
1
+ import type React from 'react';
2
+ import type { MarkerOptions } from '../../../types';
3
+ import type { CanvasData } from '../shared';
4
+ /**
5
+ * 폴리곤 스타일 정의
6
+ */
7
+ export interface PolygonStyle {
8
+ /** 채우기 색상 */
9
+ fillColor: string;
10
+ /** 테두리 색상 */
11
+ strokeColor: string;
12
+ /** 테두리 두께 */
13
+ lineWidth: number;
14
+ }
15
+ /**
16
+ * 폴리곤 스타일 컨텍스트 (선택/호버/활성 상태 정보)
17
+ */
18
+ export interface PolygonStyleContext {
19
+ /** 선택 여부 */
20
+ isSelected: boolean;
21
+ /** 호버 여부 */
22
+ isHovered: boolean;
23
+ /** 활성 여부 (마지막 선택된 항목) */
24
+ isActive: boolean;
25
+ }
26
+ /**
27
+ * 폴리곤 스타일 객체
28
+ *
29
+ * 상태별 스타일을 정의합니다. 개별 props 방식과 동일한 알고리즘으로 적용됩니다.
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * renderStyle={{
34
+ * base: { fillColor: 'gray', strokeColor: 'black', lineWidth: 2 },
35
+ * selected: { fillColor: 'green', strokeColor: 'darkgreen', lineWidth: 4 },
36
+ * active: { fillColor: 'yellow', strokeColor: 'orange', lineWidth: 5 },
37
+ * hovered: { fillColor: 'blue', strokeColor: 'darkblue', lineWidth: 3 }
38
+ * }}
39
+ * ```
40
+ */
41
+ export interface PolygonStyleObject {
42
+ /** 기본 폴리곤 스타일 (필수) */
43
+ base: PolygonStyle;
44
+ /** 선택된 폴리곤 스타일 */
45
+ selected?: PolygonStyle;
46
+ /** 활성 폴리곤 스타일 (마지막 선택된 항목) */
47
+ active?: PolygonStyle;
48
+ /** 호버된 폴리곤 스타일 */
49
+ hovered?: PolygonStyle;
50
+ }
51
+ /**
52
+ * 폴리곤 스타일 커스터마이징 함수 타입
53
+ *
54
+ * item 데이터와 상태 정보를 기반으로 자유롭게 스타일을 커스터마이징할 수 있습니다.
55
+ * 스타일을 반환하지 않거나 null/undefined를 반환하면 해당 폴리곤을 그리지 않습니다.
56
+ *
57
+ * @param item 폴리곤 데이터
58
+ * @param context 선택/호버/활성 상태 정보
59
+ * @returns 커스터마이징된 폴리곤 스타일 (반환하지 않거나 null/undefined면 그리지 않음)
60
+ */
61
+ export declare type PolygonStyleCustomizer<T> = (item: CanvasData<T>, context: PolygonStyleContext) => PolygonStyle | null | undefined;
62
+ /**
63
+ * 폴리곤 스타일 커스터마이징 객체 타입
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * // 예시 1: deps 있음 (외부 상태를 참조하는 경우)
68
+ * <CanvasPolygonLayer
69
+ * customStyle={{
70
+ * callback: (item, context) => {
71
+ * // 상태 정보를 기반으로 스타일 결정
72
+ * if (context.isActive) {
73
+ * return { fillColor: 'yellow', strokeColor: 'orange', lineWidth: 5 };
74
+ * }
75
+ * if (context.isHovered) {
76
+ * return { fillColor: 'blue', strokeColor: 'darkblue', lineWidth: 3 };
77
+ * }
78
+ * if (context.isSelected) {
79
+ * return { fillColor: 'green', strokeColor: 'darkgreen', lineWidth: 4 };
80
+ * }
81
+ * return null;
82
+ * },
83
+ * deps: [selectedPolygon] // 외부 상태 변경 시 자동 재렌더링
84
+ * }}
85
+ * />
86
+ *
87
+ * // 예시 2: deps 없음 (외부 상태를 참조하지 않는 경우)
88
+ * <CanvasPolygonLayer
89
+ * customStyle={{
90
+ * callback: (item, context) => {
91
+ * if (item.area > 1000) {
92
+ * return { fillColor: 'red', strokeColor: 'darkred', lineWidth: 2 };
93
+ * }
94
+ * return null;
95
+ * }
96
+ * }}
97
+ * />
98
+ * ```
99
+ */
100
+ export interface PolygonStyleCustomizerWithDeps<T> {
101
+ /** 스타일 커스터마이징 콜백 함수 (필수) */
102
+ callback: PolygonStyleCustomizer<T>;
103
+ /** 외부 상태 의존성 배열 (선택, 변경 시 Canvas 재렌더링) */
104
+ deps?: React.DependencyList;
105
+ }
106
+ /**
107
+ * 공통 Props (모든 방식 공통)
108
+ */
109
+ export interface CanvasPolygonLayerBaseProps<T> extends Pick<MarkerOptions, 'zIndex' | 'anchor' | 'visible'> {
110
+ /** 렌더링할 폴리곤 데이터 배열 */
111
+ data: CanvasData<T>[];
112
+ /** 폴리곤 클릭 시 호출되는 콜백 함수 */
113
+ onClick?: (payload: CanvasData<T>, selectedIds: Set<string>) => void;
114
+ /** 다중 선택 활성화 여부 (기본값: false) */
115
+ enableMultiSelect?: boolean;
116
+ /** 뷰포트 컬링 활성화 여부 (기본값: false) */
117
+ enableViewportCulling?: boolean;
118
+ /** 뷰포트 컬링 여유 공간 (픽셀 단위, 기본값: 100) */
119
+ cullingMargin?: number;
120
+ /** LRU 캐시 최대 크기 (기본값: 10000) */
121
+ maxCacheSize?: number;
122
+ /** 외부에서 제어하는 선택된 항목 배열 */
123
+ selectedItems?: CanvasData<T>[];
124
+ /** 외부에서 전달된 단일 선택 아이템 */
125
+ selectedItem?: CanvasData<T> | null;
126
+ /** 상호작용 비활성화 여부 (기본값: false) */
127
+ disableInteraction?: boolean;
128
+ }
129
+ /**
130
+ * 개별 Props 방식 (기존 방식)
131
+ *
132
+ * baseFillColor, baseStrokeColor, baseLineWidth가 있으면 자동으로 개별 props 방식으로 인식됩니다.
133
+ */
134
+ export interface CanvasPolygonLayerPropsWithIndividualStyles<T> extends CanvasPolygonLayerBaseProps<T> {
135
+ /** 기본 폴리곤 채우기 색상 (필수) */
136
+ baseFillColor: string;
137
+ /** 기본 폴리곤 테두리 색상 (필수) */
138
+ baseStrokeColor: string;
139
+ /** 기본 폴리곤 테두리 두께 (필수) */
140
+ baseLineWidth: number;
141
+ /** 선택된 폴리곤 채우기 색상 */
142
+ selectedFillColor?: string;
143
+ /** 선택된 폴리곤 테두리 색상 */
144
+ selectedStrokeColor?: string;
145
+ /** 선택된 폴리곤 테두리 두께 */
146
+ selectedLineWidth?: number;
147
+ /** 마지막 선택된 폴리곤(Active) 채우기 색상 */
148
+ activeFillColor?: string;
149
+ /** 마지막 선택된 폴리곤(Active) 테두리 색상 */
150
+ activeStrokeColor?: string;
151
+ /** 마지막 선택된 폴리곤(Active) 테두리 두께 */
152
+ activeLineWidth?: number;
153
+ /** Hover 시 폴리곤 채우기 색상 */
154
+ hoveredFillColor?: string;
155
+ /** Hover 시 폴리곤 테두리 색상 */
156
+ hoveredStrokeColor?: string;
157
+ /** Hover 시 폴리곤 테두리 두께 */
158
+ hoveredLineWidth?: number;
159
+ /** 다른 방식 props는 사용 불가 */
160
+ renderStyle?: never;
161
+ /**
162
+ * 폴리곤 스타일 커스터마이징 객체 (선택)
163
+ *
164
+ * customStyle이 제공되면 우선적으로 사용되며, null/undefined를 반환하면 개별 props로 정의된 기본 스타일을 사용합니다.
165
+ * item 데이터와 상태 정보를 기반으로 자유롭게 스타일을 커스터마이징할 수 있습니다.
166
+ */
167
+ customStyle?: PolygonStyleCustomizerWithDeps<T>;
168
+ }
169
+ /**
170
+ * 객체 Props 방식
171
+ *
172
+ * renderStyle 객체가 있으면 자동으로 객체 방식으로 인식됩니다.
173
+ * 상태별 스타일을 정의하면 개별 props 방식과 동일한 알고리즘으로 적용됩니다.
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * renderStyle={{
178
+ * base: { fillColor: 'gray', strokeColor: 'black', lineWidth: 2 },
179
+ * selected: { fillColor: 'green', strokeColor: 'darkgreen', lineWidth: 4 },
180
+ * active: { fillColor: 'yellow', strokeColor: 'orange', lineWidth: 5 },
181
+ * hovered: { fillColor: 'blue', strokeColor: 'darkblue', lineWidth: 3 }
182
+ * }}
183
+ * ```
184
+ */
185
+ export interface CanvasPolygonLayerPropsWithObjectStyle<T> extends CanvasPolygonLayerBaseProps<T> {
186
+ /**
187
+ * 폴리곤 스타일 객체
188
+ *
189
+ * 상태별 스타일을 정의합니다. 개별 props 방식과 동일한 알고리즘으로 적용됩니다.
190
+ */
191
+ renderStyle: PolygonStyleObject;
192
+ /** 다른 방식 props는 사용 불가 */
193
+ activeFillColor?: never;
194
+ activeLineWidth?: never;
195
+ activeStrokeColor?: never;
196
+ baseFillColor?: never;
197
+ baseLineWidth?: never;
198
+ baseStrokeColor?: never;
199
+ hoveredFillColor?: never;
200
+ hoveredLineWidth?: never;
201
+ hoveredStrokeColor?: never;
202
+ selectedFillColor?: never;
203
+ selectedLineWidth?: never;
204
+ selectedStrokeColor?: never;
205
+ /**
206
+ * 폴리곤 스타일 커스터마이징 객체 (선택)
207
+ *
208
+ * customStyle이 제공되면 우선적으로 사용되며, null/undefined를 반환하면 renderStyle로 정의된 기본 스타일을 사용합니다.
209
+ * item 데이터와 상태 정보를 기반으로 자유롭게 스타일을 커스터마이징할 수 있습니다.
210
+ */
211
+ customStyle?: PolygonStyleCustomizerWithDeps<T>;
212
+ }
213
+ /**
214
+ * 함수 Props 방식 (커스터마이징 방식)
215
+ *
216
+ * customStyle 함수가 있으면 자동으로 함수 방식으로 인식됩니다.
217
+ * item 데이터와 상태 정보를 기반으로 자유롭게 스타일을 커스터마이징할 수 있습니다.
218
+ * 스타일을 반환하지 않거나 null/undefined를 반환하면 해당 폴리곤을 그리지 않습니다.
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * customStyle={(item, context) => {
223
+ * // item의 속성에 따라 동적으로 스타일 결정
224
+ * if (item.someProperty > 100) {
225
+ * return { fillColor: 'red', strokeColor: 'darkred', lineWidth: 3 };
226
+ * }
227
+ *
228
+ * // 상태 정보를 기반으로 스타일 결정
229
+ * if (context.isActive) {
230
+ * return { fillColor: 'yellow', strokeColor: 'orange', lineWidth: 5 };
231
+ * }
232
+ * if (context.isHovered) {
233
+ * return { fillColor: 'blue', strokeColor: 'darkblue', lineWidth: 3 };
234
+ * }
235
+ * if (context.isSelected) {
236
+ * return { fillColor: 'green', strokeColor: 'darkgreen', lineWidth: 4 };
237
+ * }
238
+ *
239
+ * // 아무것도 반환하지 않으면 그리지 않음 (return null 또는 return undefined도 가능)
240
+ * }}
241
+ * ```
242
+ */
243
+ export interface CanvasPolygonLayerPropsWithCustomStyle<T> extends CanvasPolygonLayerBaseProps<T> {
244
+ /**
245
+ * 폴리곤 스타일 커스터마이징 객체
246
+ *
247
+ * item 데이터와 상태 정보를 기반으로 자유롭게 스타일을 커스터마이징할 수 있습니다.
248
+ * 스타일을 반환하지 않거나 null/undefined를 반환하면 해당 폴리곤을 그리지 않습니다.
249
+ */
250
+ customStyle: PolygonStyleCustomizerWithDeps<T>;
251
+ /** 다른 방식 props는 사용 불가 */
252
+ activeFillColor?: never;
253
+ activeLineWidth?: never;
254
+ activeStrokeColor?: never;
255
+ baseFillColor?: never;
256
+ baseLineWidth?: never;
257
+ baseStrokeColor?: never;
258
+ hoveredFillColor?: never;
259
+ hoveredLineWidth?: never;
260
+ hoveredStrokeColor?: never;
261
+ renderStyle?: never;
262
+ selectedFillColor?: never;
263
+ selectedLineWidth?: never;
264
+ selectedStrokeColor?: never;
265
+ }
266
+ /**
267
+ * CanvasPolygonLayer Props (Discriminated Union)
268
+ *
269
+ * 세 가지 스타일 지정 방식을 지원:
270
+ * 1. 개별 props 방식: baseFillColor, baseStrokeColor, baseLineWidth가 있으면 자동으로 개별 props 방식
271
+ * 2. 객체 방식: renderStyle 객체가 있으면 자동으로 객체 방식
272
+ * 3. 함수 방식: customStyle 함수가 있으면 자동으로 함수 방식
273
+ *
274
+ * customStyle은 개별 props 방식 또는 renderStyle 객체 방식과 함께 사용할 수 있습니다.
275
+ * customStyle이 제공되면 우선적으로 사용되며, null/undefined를 반환하면 기본 스타일을 사용합니다.
276
+ * styleMode prop은 필요 없으며, 각 prop의 존재 여부로 자동 판단됩니다.
277
+ *
278
+ * @template T 폴리곤 데이터의 추가 속성 타입
279
+ */
280
+ export declare type CanvasPolygonLayerProps<T> = CanvasPolygonLayerPropsWithIndividualStyles<T> | CanvasPolygonLayerPropsWithObjectStyle<T> | CanvasPolygonLayerPropsWithCustomStyle<T>;