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

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.
@@ -59,31 +59,52 @@ export interface PolygonStyleObject {
59
59
  * @param item 폴리곤 데이터
60
60
  * @param context 선택/호버/활성 상태 정보
61
61
  * @returns 커스터마이징된 폴리곤 스타일 (반환하지 않거나 null/undefined면 그리지 않음)
62
+ */
63
+ export declare type PolygonStyleCustomizer<T> = (item: CanvasData<T>, context: PolygonStyleContext) => PolygonStyle | null | undefined;
64
+ /**
65
+ * 폴리곤 스타일 커스터마이징 객체 타입
62
66
  *
63
67
  * @example
64
68
  * ```typescript
65
- * customStyle={(item, context) => {
66
- * // item의 속성에 따라 동적으로 스타일 결정
67
- * if (item.someProperty > 100) {
68
- * return { fillColor: 'red', strokeColor: 'darkred', lineWidth: 3 };
69
- * }
69
+ * // 예시 1: deps 있음 (외부 상태를 참조하는 경우)
70
+ * <CanvasPolygonLayer
71
+ * customStyle={{
72
+ * callback: (item, context) => {
73
+ * // 상태 정보를 기반으로 스타일 결정
74
+ * if (context.isActive) {
75
+ * return { fillColor: 'yellow', strokeColor: 'orange', lineWidth: 5 };
76
+ * }
77
+ * if (context.isHovered) {
78
+ * return { fillColor: 'blue', strokeColor: 'darkblue', lineWidth: 3 };
79
+ * }
80
+ * if (context.isSelected) {
81
+ * return { fillColor: 'green', strokeColor: 'darkgreen', lineWidth: 4 };
82
+ * }
83
+ * return null;
84
+ * },
85
+ * deps: [selectedPolygon] // 외부 상태 변경 시 자동 재렌더링
86
+ * }}
87
+ * />
70
88
  *
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
- *
82
- * // 아무것도 반환하지 않으면 그리지 않음 (return null 또는 return undefined도 가능)
83
- * }}
89
+ * // 예시 2: deps 없음 (외부 상태를 참조하지 않는 경우)
90
+ * <CanvasPolygonLayer
91
+ * customStyle={{
92
+ * callback: (item, context) => {
93
+ * if (item.area > 1000) {
94
+ * return { fillColor: 'red', strokeColor: 'darkred', lineWidth: 2 };
95
+ * }
96
+ * return null;
97
+ * }
98
+ * }}
99
+ * />
84
100
  * ```
85
101
  */
86
- export declare type PolygonStyleCustomizer<T> = (item: CanvasData<T>, context: PolygonStyleContext) => PolygonStyle | null | undefined;
102
+ export interface PolygonStyleCustomizerWithDeps<T> {
103
+ /** 스타일 커스터마이징 콜백 함수 (필수) */
104
+ callback: PolygonStyleCustomizer<T>;
105
+ /** 외부 상태 의존성 배열 (선택, 변경 시 Canvas 재렌더링) */
106
+ deps?: React.DependencyList;
107
+ }
87
108
  /**
88
109
  * 공통 Props (모든 방식 공통)
89
110
  */
@@ -140,12 +161,12 @@ interface CanvasPolygonLayerPropsWithIndividualStyles<T> extends CanvasPolygonLa
140
161
  /** 다른 방식 props는 사용 불가 */
141
162
  renderStyle?: never;
142
163
  /**
143
- * 폴리곤 스타일 커스터마이징 함수 (선택)
164
+ * 폴리곤 스타일 커스터마이징 객체 (선택)
144
165
  *
145
166
  * customStyle이 제공되면 우선적으로 사용되며, null/undefined를 반환하면 개별 props로 정의된 기본 스타일을 사용합니다.
146
167
  * item 데이터와 상태 정보를 기반으로 자유롭게 스타일을 커스터마이징할 수 있습니다.
147
168
  */
148
- customStyle?: PolygonStyleCustomizer<T>;
169
+ customStyle?: PolygonStyleCustomizerWithDeps<T>;
149
170
  }
150
171
  /**
151
172
  * 객체 Props 방식
@@ -184,12 +205,12 @@ interface CanvasPolygonLayerPropsWithObjectStyle<T> extends CanvasPolygonLayerBa
184
205
  selectedLineWidth?: never;
185
206
  selectedStrokeColor?: never;
186
207
  /**
187
- * 폴리곤 스타일 커스터마이징 함수 (선택)
208
+ * 폴리곤 스타일 커스터마이징 객체 (선택)
188
209
  *
189
210
  * customStyle이 제공되면 우선적으로 사용되며, null/undefined를 반환하면 renderStyle로 정의된 기본 스타일을 사용합니다.
190
211
  * item 데이터와 상태 정보를 기반으로 자유롭게 스타일을 커스터마이징할 수 있습니다.
191
212
  */
192
- customStyle?: PolygonStyleCustomizer<T>;
213
+ customStyle?: PolygonStyleCustomizerWithDeps<T>;
193
214
  }
194
215
  /**
195
216
  * 함수 Props 방식 (커스터마이징 방식)
@@ -223,12 +244,12 @@ interface CanvasPolygonLayerPropsWithObjectStyle<T> extends CanvasPolygonLayerBa
223
244
  */
224
245
  interface CanvasPolygonLayerPropsWithCustomStyle<T> extends CanvasPolygonLayerBaseProps<T> {
225
246
  /**
226
- * 폴리곤 스타일 커스터마이징 함수
247
+ * 폴리곤 스타일 커스터마이징 객체
227
248
  *
228
249
  * item 데이터와 상태 정보를 기반으로 자유롭게 스타일을 커스터마이징할 수 있습니다.
229
250
  * 스타일을 반환하지 않거나 null/undefined를 반환하면 해당 폴리곤을 그리지 않습니다.
230
251
  */
231
- customStyle: PolygonStyleCustomizer<T>;
252
+ customStyle: PolygonStyleCustomizerWithDeps<T>;
232
253
  /** 다른 방식 props는 사용 불가 */
233
254
  activeFillColor?: never;
234
255
  activeLineWidth?: never;
@@ -46,9 +46,12 @@ var CanvasPolygonLayer = function (props) {
46
46
  var isObjectMode = 'renderStyle' in props && props.renderStyle !== undefined;
47
47
  var isIndividualMode = 'baseFillColor' in props && props.baseFillColor !== undefined; // 각 방식별 props 추출
48
48
 
49
- var customStyle = hasCustomStyle ? props.customStyle : undefined;
49
+ var customStyleProp = hasCustomStyle ? props.customStyle : undefined;
50
50
  var individualProps = isIndividualMode ? props : undefined;
51
- var objectProps = isObjectMode ? props : undefined; // --------------------------------------------------------------------------
51
+ var objectProps = isObjectMode ? props : undefined; // customStyle 객체에서 callback과 deps 추출
52
+
53
+ var customStyle = customStyleProp === null || customStyleProp === void 0 ? void 0 : customStyleProp.callback;
54
+ var customStyleDeps = customStyleProp === null || customStyleProp === void 0 ? void 0 : customStyleProp.deps; // --------------------------------------------------------------------------
52
55
  // Hooks & Context
53
56
  // --------------------------------------------------------------------------
54
57
 
@@ -604,7 +607,17 @@ var CanvasPolygonLayer = function (props) {
604
607
  boundingBoxCacheRef.current.clear();
605
608
  selectedItemsMapRef.current = hooks.syncSelectedItems(data, selectedIdsRef.current, selectedItemsMapRef.current);
606
609
  renderAllImmediate();
607
- }, [data]);
610
+ }, [data]); // customStyle deps 변경 시 Canvas 재렌더링
611
+
612
+ React.useEffect(function () {
613
+ var _a, _b, _c, _d;
614
+
615
+ if (!stageRef.current || !customStyleDeps) return; // Shape 재생성을 위해 기존 shape 제거
616
+
617
+ (_b = (_a = baseLayerRef.current) === null || _a === void 0 ? void 0 : _a.findOne('.base-render-shape')) === null || _b === void 0 ? void 0 : _b.destroy();
618
+ (_d = (_c = eventLayerRef.current) === null || _c === void 0 ? void 0 : _c.findOne('.event-render-shape')) === null || _d === void 0 ? void 0 : _d.destroy();
619
+ renderAllImmediate(); // eslint-disable-next-line react-hooks/exhaustive-deps
620
+ }, customStyleDeps || []);
608
621
  return reactDom.createPortal(React__default["default"].createElement("div", {
609
622
  ref: containerRef,
610
623
  style: {
package/dist/index.es.js CHANGED
@@ -6021,9 +6021,12 @@ var CanvasPolygonLayer = function (props) {
6021
6021
  var isObjectMode = 'renderStyle' in props && props.renderStyle !== undefined;
6022
6022
  var isIndividualMode = 'baseFillColor' in props && props.baseFillColor !== undefined; // 각 방식별 props 추출
6023
6023
 
6024
- var customStyle = hasCustomStyle ? props.customStyle : undefined;
6024
+ var customStyleProp = hasCustomStyle ? props.customStyle : undefined;
6025
6025
  var individualProps = isIndividualMode ? props : undefined;
6026
- var objectProps = isObjectMode ? props : undefined; // --------------------------------------------------------------------------
6026
+ var objectProps = isObjectMode ? props : undefined; // customStyle 객체에서 callback과 deps 추출
6027
+
6028
+ var customStyle = customStyleProp === null || customStyleProp === void 0 ? void 0 : customStyleProp.callback;
6029
+ var customStyleDeps = customStyleProp === null || customStyleProp === void 0 ? void 0 : customStyleProp.deps; // --------------------------------------------------------------------------
6027
6030
  // Hooks & Context
6028
6031
  // --------------------------------------------------------------------------
6029
6032
 
@@ -6579,7 +6582,17 @@ var CanvasPolygonLayer = function (props) {
6579
6582
  boundingBoxCacheRef.current.clear();
6580
6583
  selectedItemsMapRef.current = syncSelectedItems(data, selectedIdsRef.current, selectedItemsMapRef.current);
6581
6584
  renderAllImmediate();
6582
- }, [data]);
6585
+ }, [data]); // customStyle deps 변경 시 Canvas 재렌더링
6586
+
6587
+ useEffect(function () {
6588
+ var _a, _b, _c, _d;
6589
+
6590
+ if (!stageRef.current || !customStyleDeps) return; // Shape 재생성을 위해 기존 shape 제거
6591
+
6592
+ (_b = (_a = baseLayerRef.current) === null || _a === void 0 ? void 0 : _a.findOne('.base-render-shape')) === null || _b === void 0 ? void 0 : _b.destroy();
6593
+ (_d = (_c = eventLayerRef.current) === null || _c === void 0 ? void 0 : _c.findOne('.event-render-shape')) === null || _d === void 0 ? void 0 : _d.destroy();
6594
+ renderAllImmediate(); // eslint-disable-next-line react-hooks/exhaustive-deps
6595
+ }, customStyleDeps || []);
6583
6596
  return createPortal(React.createElement("div", {
6584
6597
  ref: containerRef,
6585
6598
  style: {
package/dist/index.umd.js CHANGED
@@ -6025,9 +6025,12 @@
6025
6025
  var isObjectMode = 'renderStyle' in props && props.renderStyle !== undefined;
6026
6026
  var isIndividualMode = 'baseFillColor' in props && props.baseFillColor !== undefined; // 각 방식별 props 추출
6027
6027
 
6028
- var customStyle = hasCustomStyle ? props.customStyle : undefined;
6028
+ var customStyleProp = hasCustomStyle ? props.customStyle : undefined;
6029
6029
  var individualProps = isIndividualMode ? props : undefined;
6030
- var objectProps = isObjectMode ? props : undefined; // --------------------------------------------------------------------------
6030
+ var objectProps = isObjectMode ? props : undefined; // customStyle 객체에서 callback과 deps 추출
6031
+
6032
+ var customStyle = customStyleProp === null || customStyleProp === void 0 ? void 0 : customStyleProp.callback;
6033
+ var customStyleDeps = customStyleProp === null || customStyleProp === void 0 ? void 0 : customStyleProp.deps; // --------------------------------------------------------------------------
6031
6034
  // Hooks & Context
6032
6035
  // --------------------------------------------------------------------------
6033
6036
 
@@ -6583,7 +6586,17 @@
6583
6586
  boundingBoxCacheRef.current.clear();
6584
6587
  selectedItemsMapRef.current = syncSelectedItems(data, selectedIdsRef.current, selectedItemsMapRef.current);
6585
6588
  renderAllImmediate();
6586
- }, [data]);
6589
+ }, [data]); // customStyle deps 변경 시 Canvas 재렌더링
6590
+
6591
+ React.useEffect(function () {
6592
+ var _a, _b, _c, _d;
6593
+
6594
+ if (!stageRef.current || !customStyleDeps) return; // Shape 재생성을 위해 기존 shape 제거
6595
+
6596
+ (_b = (_a = baseLayerRef.current) === null || _a === void 0 ? void 0 : _a.findOne('.base-render-shape')) === null || _b === void 0 ? void 0 : _b.destroy();
6597
+ (_d = (_c = eventLayerRef.current) === null || _c === void 0 ? void 0 : _c.findOne('.event-render-shape')) === null || _d === void 0 ? void 0 : _d.destroy();
6598
+ renderAllImmediate(); // eslint-disable-next-line react-hooks/exhaustive-deps
6599
+ }, customStyleDeps || []);
6587
6600
  return reactDom.createPortal(React__default["default"].createElement("div", {
6588
6601
  ref: containerRef,
6589
6602
  style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mint-ui/map",
3
- "version": "1.2.0-test.63",
3
+ "version": "1.2.0-test.65",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "browser": "./dist/index.umd.js",