@wenle_2523097/agri-map 2.0.1 → 2.0.2
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/dist/components/ColorSwatch/__tests__/index.test.d.ts +5 -0
- package/dist/components/FullscreenControl/__tests__/index.test.d.ts +5 -0
- package/dist/components/Marker/useEditHandlers.d.ts +2 -2
- package/dist/components/Measurement/__tests__/toolbar.test.d.ts +2 -2
- package/dist/components/Notification/__tests__/index.test.d.ts +1 -1
- package/dist/components/PerformanceDashboard/__tests__/index.test.d.ts +1 -1
- package/dist/components/PlotLayer/__tests__/index.test.d.ts +2 -3
- package/dist/components/Popup/__tests__/index.test.d.ts +5 -0
- package/dist/components/Road/hooks/useRoadEvents.d.ts +4 -0
- package/dist/components/SelectIcon/__tests__/index.test.d.ts +4 -0
- package/dist/components/StyleSelector/__tests__/index.test.d.ts +5 -0
- package/dist/components/TrackPlayer/__tests__/index.test.d.ts +5 -0
- package/dist/components/irrigation.esm.js +12 -2
- package/dist/components/irrigation.esm.js.map +1 -1
- package/dist/components/marker.esm.js.map +1 -1
- package/dist/components/plotgrouplayer.esm.js +3 -1
- package/dist/components/plotgrouplayer.esm.js.map +1 -1
- package/dist/components/road.esm.js +41 -13
- package/dist/components/road.esm.js.map +1 -1
- package/dist/hooks/__tests__/useRenderOptimization.test.d.ts +0 -1
- package/dist/hooks/index.esm.js +3 -2
- package/dist/hooks/index.esm.js.map +1 -1
- package/dist/hooks/usePolylineDraw.d.ts +75 -0
- package/dist/hooks/usePolylineEdit.d.ts +70 -0
- package/dist/hooks/usePolylineRenderer.d.ts +1 -1
- package/dist/hooks/useSnapManager.d.ts +50 -0
- package/dist/hooks/useVertexMarkers.d.ts +51 -0
- package/dist/index.esm.js +53 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +53 -14
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +53 -14
- package/dist/index.umd.js.map +1 -1
- package/dist/tests/setup/antd-mock.d.ts +34 -0
- package/dist/tests/setup/browser-mock.d.ts +53 -0
- package/dist/tests/setup/index.d.ts +22 -0
- package/dist/tests/setup/leaflet-mock.d.ts +28 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/irrigation.d.ts +4 -123
- package/dist/types/marker.d.ts +12 -113
- package/dist/types/mixins/DataSourceMixin.d.ts +56 -0
- package/dist/types/mixins/EditableMixin.d.ts +124 -0
- package/dist/types/mixins/InteractionMixin.d.ts +43 -0
- package/dist/types/mixins/LifecycleMixin.d.ts +23 -0
- package/dist/types/mixins/LoadingMixin.d.ts +44 -0
- package/dist/types/mixins/SelectableMixin.d.ts +52 -0
- package/dist/types/mixins/StyleMixin.d.ts +49 -0
- package/dist/types/mixins/ViewControlMixin.d.ts +36 -0
- package/dist/types/mixins/index.d.ts +13 -0
- package/dist/types/plot.d.ts +13 -67
- package/dist/types/road.d.ts +11 -157
- package/dist/types/track.d.ts +5 -15
- package/dist/utils/__tests__/RTreeIndex.test.d.ts +0 -1
- package/dist/utils/drawContext.d.ts +65 -0
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview 统一测试设置 - Ant Design Mock
|
|
3
|
+
* @description 提供 Ant Design 组件 mock,解决 message, Notification 等静态方法在测试环境的问题
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 创建 Ant Design message mock
|
|
7
|
+
*/
|
|
8
|
+
export declare function createMessageMock(): object;
|
|
9
|
+
/**
|
|
10
|
+
* 创建 Ant Design Notification mock
|
|
11
|
+
*/
|
|
12
|
+
export declare function createNotificationMock(): object;
|
|
13
|
+
/**
|
|
14
|
+
* 创建 Ant Design Modal mock
|
|
15
|
+
*/
|
|
16
|
+
export declare function createModalMock(): object;
|
|
17
|
+
/**
|
|
18
|
+
* 创建 Ant Design message.mock
|
|
19
|
+
*/
|
|
20
|
+
export declare function getAntdMessageMock(): {
|
|
21
|
+
default: object;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* 创建 Ant Design Notification mock
|
|
25
|
+
*/
|
|
26
|
+
export declare function getAntdNotificationMock(): object;
|
|
27
|
+
/**
|
|
28
|
+
* 创建完整的 Ant Design mock
|
|
29
|
+
*/
|
|
30
|
+
export declare function createAntdMock(): object;
|
|
31
|
+
/**
|
|
32
|
+
* 获取 Ant Design mock(用于 vi.mock)
|
|
33
|
+
*/
|
|
34
|
+
export declare function getAntdMock(): object;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview 统一测试设置 - Browser API Mock
|
|
3
|
+
* @description 提供浏览器 API mock,解决 performance.memory, getComputedStyle 等在测试环境不可用的问题
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 创建 performance API mock
|
|
7
|
+
*/
|
|
8
|
+
export declare function createPerformanceMock(): object;
|
|
9
|
+
/**
|
|
10
|
+
* 创建 ResizeObserver mock
|
|
11
|
+
*/
|
|
12
|
+
export declare function createResizeObserverMock(): () => object;
|
|
13
|
+
/**
|
|
14
|
+
* 创建 MutationObserver mock
|
|
15
|
+
*/
|
|
16
|
+
export declare function createMutationObserverMock(): () => object;
|
|
17
|
+
/**
|
|
18
|
+
* 创建 IntersectionObserver mock
|
|
19
|
+
*/
|
|
20
|
+
export declare function createIntersectionObserverMock(): typeof IntersectionObserver;
|
|
21
|
+
/**
|
|
22
|
+
* 创建 requestAnimationFrame mock
|
|
23
|
+
*/
|
|
24
|
+
export declare function createRequestAnimationFrameMock(): typeof requestAnimationFrame;
|
|
25
|
+
/**
|
|
26
|
+
* 创建 getComputedStyle mock
|
|
27
|
+
*/
|
|
28
|
+
export declare function createGetComputedStyleMock(): import("vitest").Mock<() => {
|
|
29
|
+
getPropertyValue: import("vitest").Mock<() => string>;
|
|
30
|
+
display: string;
|
|
31
|
+
visibility: string;
|
|
32
|
+
opacity: string;
|
|
33
|
+
color: string;
|
|
34
|
+
backgroundColor: string;
|
|
35
|
+
fontSize: string;
|
|
36
|
+
lineHeight: string;
|
|
37
|
+
position: string;
|
|
38
|
+
top: string;
|
|
39
|
+
left: string;
|
|
40
|
+
width: string;
|
|
41
|
+
height: string;
|
|
42
|
+
margin: string;
|
|
43
|
+
padding: string;
|
|
44
|
+
border: string;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* 设置所有浏览器 mock
|
|
48
|
+
*/
|
|
49
|
+
export declare function setupBrowserMocks(): void;
|
|
50
|
+
/**
|
|
51
|
+
* 清理浏览器 mock
|
|
52
|
+
*/
|
|
53
|
+
export declare function cleanupBrowserMocks(): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview 统一测试设置入口
|
|
3
|
+
* @description 导出所有测试 mock 和辅助函数
|
|
4
|
+
*
|
|
5
|
+
* @usage
|
|
6
|
+
* 在测试文件顶部导入:
|
|
7
|
+
* import { setupLeafletMock, setupBrowserMocks } from '@/tests/setup';
|
|
8
|
+
*
|
|
9
|
+
* 或在 vite.config.ts 中全局设置
|
|
10
|
+
*/
|
|
11
|
+
export { createLeafletMock, getLeafletMock, resetLeafletMock } from './leaflet-mock';
|
|
12
|
+
export { setupBrowserMocks, cleanupBrowserMocks, createPerformanceMock, createResizeObserverMock, createMutationObserverMock, createIntersectionObserverMock, createRequestAnimationFrameMock, createGetComputedStyleMock, } from './browser-mock';
|
|
13
|
+
export { createAntdMock, getAntdMock, createMessageMock, createNotificationMock, createModalMock, } from './antd-mock';
|
|
14
|
+
/**
|
|
15
|
+
* 初始化所有测试 mock
|
|
16
|
+
* 建议在 vite.config.ts 的 test.setupFiles 中调用
|
|
17
|
+
*/
|
|
18
|
+
export declare function setupAllMocks(): void;
|
|
19
|
+
declare const _default: {
|
|
20
|
+
setupAllMocks: typeof setupAllMocks;
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview 统一测试设置 - Leaflet Mock
|
|
3
|
+
* @description 提供完整的 Leaflet mock,解决测试中 L.DomUtil.create 等方法 undefined 的问题
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 创建完整的 Leaflet Map mock
|
|
7
|
+
*/
|
|
8
|
+
export declare function createMapMock(): object;
|
|
9
|
+
/**
|
|
10
|
+
* 创建 Leaflet DomUtil mock
|
|
11
|
+
*/
|
|
12
|
+
export declare function createDomUtilMock(): object;
|
|
13
|
+
/**
|
|
14
|
+
* 创建 Leaflet LatLng mock
|
|
15
|
+
*/
|
|
16
|
+
export declare function createLatLngMock(): object;
|
|
17
|
+
/**
|
|
18
|
+
* 创建完整的 Leaflet mock
|
|
19
|
+
*/
|
|
20
|
+
export declare function createLeafletMock(): object;
|
|
21
|
+
/**
|
|
22
|
+
* 获取默认的 Leaflet mock(用于 vi.mock)
|
|
23
|
+
*/
|
|
24
|
+
export declare function getLeafletMock(): object;
|
|
25
|
+
/**
|
|
26
|
+
* 重置 Leaflet mock
|
|
27
|
+
*/
|
|
28
|
+
export declare function resetLeafletMock(): void;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -27,3 +27,4 @@ export type { MapContentProps } from './config';
|
|
|
27
27
|
export type { PlotLabelProps } from './plot';
|
|
28
28
|
export type { PopupProps, PopupTrigger, PopupPlacement, PopupConfig, PopupState, PopupContextValue, } from './popup';
|
|
29
29
|
export type { LeafletEventHandler, GeoJSONFeature, GeoJSONFeatureCollection, PartialPathOptions, MaybePromise, AnyFunction, DeepPartial, DeepRequired, DeepReadonly, NonNullable, UnwrapPromise, UnwrapArray, RefType, EventHandler, AsyncEventHandler, RenderFn, ComponentType, MaybeControlledProps, ControlledProps, UncontrolledProps, } from './utils';
|
|
30
|
+
export type { DataSourceMixin, LoadingMixin, ViewControlMixin, AutoFitConfig, SelectableMixin, StyleMixin, InteractionMixin, LifecycleMixin, EditableMixin, EditModeConfig, ToolbarButton, ToolbarColor, ToolbarSize, } from './mixins';
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* 灌溉渠相关类型定义
|
|
3
3
|
*/
|
|
4
4
|
import type { Coordinate, PathOptions } from './basic';
|
|
5
|
-
import type {
|
|
6
|
-
import type { LifecycleConfig } from './lifecycle';
|
|
5
|
+
import type { DataSourceMixin, SelectableMixin, StyleMixin, LoadingMixin, LifecycleMixin, ViewControlMixin, InteractionMixin, EditableMixin } from './mixins';
|
|
7
6
|
/**
|
|
8
7
|
* 灌溉渠字段名映射
|
|
9
8
|
* @description 自定义 dataSource 中数据的字段名
|
|
@@ -98,17 +97,9 @@ export interface IrrigationEvents {
|
|
|
98
97
|
}
|
|
99
98
|
/**
|
|
100
99
|
* 灌溉渠组件属性
|
|
101
|
-
* @description Irrigation 组件的 Props
|
|
100
|
+
* @description Irrigation 组件的 Props 定义,使用 Mixin 组合重构
|
|
102
101
|
*/
|
|
103
|
-
export interface IrrigationProps {
|
|
104
|
-
/** 灌溉渠数据数组 */
|
|
105
|
-
dataSource?: IrrigationData[] | Record<string, unknown>[];
|
|
106
|
-
/** 自定义数据字段名映射 */
|
|
107
|
-
fieldNames?: IrrigationFieldNames;
|
|
108
|
-
/** 点击灌溉渠时的回调 */
|
|
109
|
-
onClick?: (item: IrrigationData) => void;
|
|
110
|
-
/** 右键点击灌溉渠时的回调 */
|
|
111
|
-
onContextMenu?: (item: IrrigationData, event: L.LeafletMouseEvent) => void;
|
|
102
|
+
export interface IrrigationProps extends DataSourceMixin<IrrigationData | Record<string, unknown>>, SelectableMixin<string | number>, StyleMixin<IrrigationData>, LoadingMixin, LifecycleMixin<'Irrigation'>, ViewControlMixin, InteractionMixin<IrrigationData>, EditableMixin<'create' | 'edit' | 'delete' | 'reverse'> {
|
|
112
103
|
/**
|
|
113
104
|
* 默认灌溉渠样式
|
|
114
105
|
* @description undefined | null | false | {} 时使用默认配置 IRRIGATION_DEFAULT_PATH
|
|
@@ -119,70 +110,15 @@ export interface IrrigationProps {
|
|
|
119
110
|
* @description undefined | null | false | {} 时使用默认配置 IRRIGATION_DEFAULT_SELECTED_PATH
|
|
120
111
|
*/
|
|
121
112
|
selectedPath?: PathOptions | null | false;
|
|
122
|
-
/**
|
|
123
|
-
* 动态样式函数
|
|
124
|
-
* @description 根据灌溉渠数据动态返回样式,优先级:数据级 path > style 函数 > Props 级 path
|
|
125
|
-
*/
|
|
126
|
-
style?: (data: IrrigationData) => PathOptions;
|
|
127
|
-
/** 编辑模式 */
|
|
128
|
-
editMode?: boolean | ('create' | 'edit' | 'delete' | 'reverse')[] | {
|
|
129
|
-
/** 启用的编辑按钮 */
|
|
130
|
-
enabled?: boolean | ('create' | 'edit' | 'delete' | 'reverse')[];
|
|
131
|
-
/** 自定义工具栏内容 */
|
|
132
|
-
toolbar?: ReactNode;
|
|
133
|
-
/** 内置按钮的统一颜色(支持预设色和自定义颜色如 #ff0000、rgba(255,0,0,0.5)) */
|
|
134
|
-
color?: 'default' | 'primary' | 'danger' | 'success' | 'warning' | 'error' | 'magenta' | 'volcano' | 'gold' | 'orange' | 'cyan' | 'geekblue' | 'purple' | string;
|
|
135
|
-
/** 内置按钮的统一尺寸(支持预设尺寸和自定义数字,单位 px) */
|
|
136
|
-
size?: 'large' | 'middle' | 'small' | number;
|
|
137
|
-
};
|
|
138
|
-
/** 新建灌溉渠回调 */
|
|
139
|
-
onCreate?: (result: IrrigationCreateResult) => void;
|
|
140
|
-
/** 编辑灌溉渠属性回调(点击编辑按钮时触发) */
|
|
141
|
-
onEdit?: (result: IrrigationEditPropertyParams) => void;
|
|
142
|
-
/** 重绘灌溉渠形状回调(重绘保存后触发) */
|
|
143
|
-
onRedraw?: (result: IrrigationEditResult) => void;
|
|
144
|
-
/** 删除灌溉渠回调 */
|
|
145
|
-
onDelete?: (result: IrrigationDeleteResult) => void;
|
|
146
|
-
/** 保存回调 */
|
|
147
|
-
onSave?: (result: {
|
|
148
|
-
mode: string;
|
|
149
|
-
} & (IrrigationCreateResult | IrrigationEditResult)) => void;
|
|
150
|
-
/** 选中变化回调 */
|
|
151
|
-
onSelect?: (id: string | number | null) => void;
|
|
152
113
|
/** 反转流向回调 */
|
|
153
114
|
onReverse?: (result: IrrigationReverseResult) => void;
|
|
154
|
-
/** 选中的灌溉渠 ID(受控模式) */
|
|
155
|
-
value?: string | number | null;
|
|
156
|
-
/** 默认选中的灌溉渠 ID(非受控模式) */
|
|
157
|
-
defaultValue?: string | number;
|
|
158
115
|
/** 是否显示灌溉渠长度 */
|
|
159
116
|
showDistance?: boolean;
|
|
160
117
|
/**
|
|
161
118
|
* 蚁行动画配置
|
|
162
119
|
* @description 显示灌溉渠方向箭头动画
|
|
163
|
-
* @example
|
|
164
|
-
* ```tsx
|
|
165
|
-
* <Irrigation antPath /> // 全部显示
|
|
166
|
-
* <Irrigation antPath="selected" /> // 仅选中显示
|
|
167
|
-
* ```
|
|
168
120
|
*/
|
|
169
121
|
antPath?: boolean | 'selected';
|
|
170
|
-
/** 是否显示编辑模式提示 */
|
|
171
|
-
showEditHint?: boolean;
|
|
172
|
-
/**
|
|
173
|
-
* 进出水口默认图标
|
|
174
|
-
* @description 所有渠道的进水口/出水口默认图标配置,可被数据项级 channel.inlet/outlet 覆盖。
|
|
175
|
-
* 不传时,有 channel.inlet/outlet 配置的渠道使用内置默认箭头图标。
|
|
176
|
-
* @example
|
|
177
|
-
* ```tsx
|
|
178
|
-
* <Irrigation
|
|
179
|
-
* icons={{
|
|
180
|
-
* inlet: { icon: 'pulse-green', iconSize: 32 },
|
|
181
|
-
* outlet: { icon: 'pulse-orange', iconSize: 32 },
|
|
182
|
-
* }}
|
|
183
|
-
* />
|
|
184
|
-
* ```
|
|
185
|
-
*/
|
|
186
122
|
/**
|
|
187
123
|
* 进水口显示控制
|
|
188
124
|
* @description true: 显示所有渠道进水口 | 'selected': 仅显示选中渠道进水口 | false: 不显示
|
|
@@ -196,64 +132,9 @@ export interface IrrigationProps {
|
|
|
196
132
|
*/
|
|
197
133
|
outlet?: boolean | 'selected';
|
|
198
134
|
/**
|
|
199
|
-
*
|
|
200
|
-
* @description 返回一个事件回调对象,可按需绑定事件,支持基于数据项的条件化事件处理
|
|
201
|
-
* @param item - 当前灌溉渠数据
|
|
202
|
-
* @param index - 当前灌溉渠在数据源中的索引
|
|
203
|
-
* @returns IrrigationEvents 事件回调对象
|
|
204
|
-
* @example
|
|
205
|
-
* ```tsx
|
|
206
|
-
* <Irrigation
|
|
207
|
-
* dataSource={channels}
|
|
208
|
-
* onRow={(item, index) => ({
|
|
209
|
-
* onClick: () => console.log('点击了', item.name),
|
|
210
|
-
* onContextMenu: (item, e) => { e.originalEvent.preventDefault(); },
|
|
211
|
-
* })}
|
|
212
|
-
* />
|
|
213
|
-
* ```
|
|
135
|
+
* 统一的声明式事件管理(替代 InteractionMixin 的 onClick/onContextMenu)
|
|
214
136
|
*/
|
|
215
137
|
onRow?: (item: IrrigationData, index: number) => IrrigationEvents;
|
|
216
|
-
/**
|
|
217
|
-
* 是否显示加载状态
|
|
218
|
-
* @description 当为 true 时,在地图上显示加载动画覆盖层
|
|
219
|
-
* @default false
|
|
220
|
-
*/
|
|
221
|
-
loading?: boolean;
|
|
222
|
-
/**
|
|
223
|
-
* 加载遮罩配置
|
|
224
|
-
* @description 自定义加载遮罩的样式
|
|
225
|
-
*/
|
|
226
|
-
loadingMask?: {
|
|
227
|
-
/** 是否显示遮罩,默认 true */
|
|
228
|
-
enabled?: boolean;
|
|
229
|
-
/** 遮罩背景色,默认 'rgba(0, 0, 0, 0.5)' */
|
|
230
|
-
background?: string;
|
|
231
|
-
/** 遮罩层级,默认 1000 */
|
|
232
|
-
zIndex?: number;
|
|
233
|
-
};
|
|
234
|
-
/**
|
|
235
|
-
* 生命周期回调配置
|
|
236
|
-
* @description 管理组件的挂载、渲染、状态变化、卸载等生命周期节点
|
|
237
|
-
* @since 1.4.0
|
|
238
|
-
* @example
|
|
239
|
-
* ```tsx
|
|
240
|
-
* lifecycle={{
|
|
241
|
-
* onBeforeMount: (data) => validateIrrigationData(data),
|
|
242
|
-
* onFirstRender: (stats) => reportPerformance(stats),
|
|
243
|
-
* onStateChange: (payload) => trackEditAction(payload),
|
|
244
|
-
* onBeforeUnmount: () => saveDraft(),
|
|
245
|
-
* }}
|
|
246
|
-
* ```
|
|
247
|
-
*/
|
|
248
|
-
lifecycle?: LifecycleConfig<'Irrigation'>;
|
|
249
|
-
/**
|
|
250
|
-
* 是否在首次加载数据后自动 fitBounds 适配地图视图
|
|
251
|
-
* @default false
|
|
252
|
-
*/
|
|
253
|
-
autoFit?: boolean | {
|
|
254
|
-
maxZoom?: number;
|
|
255
|
-
padding?: number | [number, number];
|
|
256
|
-
};
|
|
257
138
|
/**
|
|
258
139
|
* 子组件
|
|
259
140
|
* @description 用于嵌套 Popup 等子组件
|
package/dist/types/marker.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { Coordinate } from './basic';
|
|
5
5
|
import type { ReactNode } from 'react';
|
|
6
6
|
import type { IconConfig, ClusterIconConfig } from './icon';
|
|
7
|
-
import type {
|
|
7
|
+
import type { DataSourceMixin, SelectableMixin, StyleMixin, LoadingMixin, LifecycleMixin, ViewControlMixin, InteractionMixin, EditableMixin } from './mixins';
|
|
8
8
|
export type { IconConfig } from './icon';
|
|
9
9
|
export type { ClusterIconConfig } from './icon';
|
|
10
10
|
/**
|
|
@@ -203,128 +203,27 @@ export interface MarkerDisplayModeConfig {
|
|
|
203
203
|
export type MarkerClusterConfig = MarkerDisplayModeConfig;
|
|
204
204
|
/**
|
|
205
205
|
* 标注组件属性
|
|
206
|
-
* @description Marker 组件的 Props
|
|
206
|
+
* @description Marker 组件的 Props 定义,使用 Mixin 组合重构
|
|
207
207
|
*/
|
|
208
|
-
export interface MarkerProps {
|
|
209
|
-
/** 标注数据数组 */
|
|
210
|
-
dataSource?: MarkerData[];
|
|
211
|
-
/** 字段名称映射,自定义 dataSource 中的字段名 */
|
|
212
|
-
fieldNames?: MarkerFieldNames;
|
|
213
|
-
/** 点击标注时的回调 */
|
|
214
|
-
onClick?: (item: MarkerData) => void;
|
|
215
|
-
/** 右键点击标注时的回调 */
|
|
216
|
-
onContextMenu?: (item: MarkerData, e: L.LeafletMouseEvent) => void;
|
|
208
|
+
export interface MarkerProps extends DataSourceMixin<MarkerData>, SelectableMixin<string | number>, StyleMixin<MarkerData>, LoadingMixin, LifecycleMixin<'Marker'>, ViewControlMixin, InteractionMixin<MarkerData>, EditableMixin<'create' | 'edit' | 'move' | 'delete'> {
|
|
217
209
|
/** 是否永久显示弹窗 */
|
|
218
210
|
permanent?: boolean;
|
|
219
|
-
/**
|
|
220
|
-
* 动态样式函数
|
|
221
|
-
* @description 根据标注数据动态返回图标配置,优先级:数据级 icon > style 函数 > Props 级 icon
|
|
222
|
-
*/
|
|
223
|
-
style?: (data: MarkerData) => IconConfig;
|
|
224
|
-
/**
|
|
225
|
-
* 默认图标配置
|
|
226
|
-
* @description 设置所有标注点的默认图标,优先级低于数据级 icon
|
|
227
|
-
*/
|
|
211
|
+
/** 默认图标配置 */
|
|
228
212
|
icon?: IconConfig;
|
|
229
|
-
/**
|
|
230
|
-
* 选中状态图标配置
|
|
231
|
-
* @description 设置标注点选中时的图标
|
|
232
|
-
*/
|
|
213
|
+
/** 选中状态图标配置 */
|
|
233
214
|
selectedIcon?: IconConfig;
|
|
234
|
-
/**
|
|
235
|
-
editMode?: boolean | ('create' | 'edit' | 'move' | 'delete')[] | MarkerEditModeConfig;
|
|
236
|
-
/** 新建标注回调 */
|
|
237
|
-
onCreate?: (result: MarkerCreateResult) => void;
|
|
238
|
-
/** 编辑标注回调(点击编辑按钮触发) */
|
|
239
|
-
onEdit?: (result: MarkerEditResult) => void;
|
|
240
|
-
/** 移动标注回调 */
|
|
215
|
+
/** 覆盖编辑模式回调:移动标注 */
|
|
241
216
|
onMove?: (result: MarkerMoveResult) => void;
|
|
242
|
-
/**
|
|
243
|
-
onDelete?: (result: MarkerDeleteResult) => void;
|
|
244
|
-
/** 保存回调 */
|
|
217
|
+
/** 覆盖保存回调类型 */
|
|
245
218
|
onSave?: (result: {
|
|
246
219
|
mode: string;
|
|
247
220
|
} & (MarkerCreateResult | MarkerMoveResult)) => void;
|
|
248
|
-
/**
|
|
249
|
-
onSelect?: (id: string | number | null) => void;
|
|
250
|
-
/** 选中的标注 ID(受控模式) */
|
|
251
|
-
value?: string | number | null;
|
|
252
|
-
/** 默认选中的标注 ID(非受控模式) */
|
|
253
|
-
defaultValue?: string | number;
|
|
254
|
-
/** 是否显示编辑模式提示,默认 false */
|
|
255
|
-
showEditHint?: boolean;
|
|
256
|
-
/** Marker 数据加载完成回调 */
|
|
257
|
-
onLoaded?: (data: MarkerData[]) => void;
|
|
258
|
-
/**
|
|
259
|
-
* 显示模式配置
|
|
260
|
-
* - true: 启用默认显示模式(聚合)
|
|
261
|
-
* - 对象: 自定义显示模式配置
|
|
262
|
-
* @description 启用后,在小缩放级别下将相近的标注点聚合为气泡显示
|
|
263
|
-
*/
|
|
221
|
+
/** 显示模式配置 */
|
|
264
222
|
displayMode?: boolean | MarkerDisplayModeConfig;
|
|
265
|
-
/**
|
|
266
|
-
* 聚合气泡点击回调
|
|
267
|
-
* @param count - 聚合内的标注点数量
|
|
268
|
-
* @param markers - 聚合内的标注数据数组
|
|
269
|
-
*/
|
|
223
|
+
/** 聚合气泡点击回调 */
|
|
270
224
|
onClusterClick?: (count: number, markers: MarkerData[]) => void;
|
|
271
|
-
/**
|
|
272
|
-
* 统一的声明式事件管理(类似 Ant Design Table 的 onRow)
|
|
273
|
-
* @description 返回一个事件回调对象,可按需绑定事件,支持基于数据项的条件化事件处理
|
|
274
|
-
* @param item - 当前标注数据
|
|
275
|
-
* @param index - 当前标注在数据源中的索引
|
|
276
|
-
* @returns MarkerEvents 事件回调对象
|
|
277
|
-
* @example
|
|
278
|
-
* ```tsx
|
|
279
|
-
* <Marker
|
|
280
|
-
* dataSource={markers}
|
|
281
|
-
* onRow={(item, index) => ({
|
|
282
|
-
* onClick: () => console.log('点击了', item.title),
|
|
283
|
-
* onContextMenu: (item, e) => { e.originalEvent.preventDefault(); },
|
|
284
|
-
* })}
|
|
285
|
-
* />
|
|
286
|
-
* ```
|
|
287
|
-
*/
|
|
225
|
+
/** 声明式事件管理(替代 InteractionMixin 的 onClick/onContextMenu) */
|
|
288
226
|
onRow?: (item: MarkerData, index: number) => MarkerEvents;
|
|
289
|
-
/**
|
|
290
|
-
|
|
291
|
-
* @description 当为 true 时,在标注点上显示加载动画覆盖层
|
|
292
|
-
* @default false
|
|
293
|
-
*/
|
|
294
|
-
loading?: boolean;
|
|
295
|
-
/**
|
|
296
|
-
* 加载遮罩配置
|
|
297
|
-
* @description 自定义加载遮罩的样式
|
|
298
|
-
*/
|
|
299
|
-
loadingMask?: {
|
|
300
|
-
/** 是否显示遮罩,默认 true */
|
|
301
|
-
enabled?: boolean;
|
|
302
|
-
/** 遮罩背景色,默认 'rgba(0, 0, 0, 0.5)' */
|
|
303
|
-
background?: string;
|
|
304
|
-
/** 遮罩层级,默认 1000 */
|
|
305
|
-
zIndex?: number;
|
|
306
|
-
};
|
|
307
|
-
/**
|
|
308
|
-
* 生命周期回调配置
|
|
309
|
-
* @description 管理组件的挂载、渲染、状态变化、卸载等生命周期节点
|
|
310
|
-
* @since 1.4.0
|
|
311
|
-
* @example
|
|
312
|
-
* ```tsx
|
|
313
|
-
* lifecycle={{
|
|
314
|
-
* onBeforeMount: (data) => validateMarkerData(data),
|
|
315
|
-
* onFirstRender: (stats) => reportPerformance(stats),
|
|
316
|
-
* onStateChange: (payload) => trackEditAction(payload),
|
|
317
|
-
* onBeforeUnmount: () => saveDraft(),
|
|
318
|
-
* }}
|
|
319
|
-
* ```
|
|
320
|
-
*/
|
|
321
|
-
lifecycle?: LifecycleConfig<'Marker'>;
|
|
322
|
-
/**
|
|
323
|
-
* 是否在首次加载数据后自动 fitBounds 适配地图视图
|
|
324
|
-
* @default false
|
|
325
|
-
*/
|
|
326
|
-
autoFit?: boolean | {
|
|
327
|
-
maxZoom?: number;
|
|
328
|
-
padding?: number | [number, number];
|
|
329
|
-
};
|
|
227
|
+
/** Marker 数据加载完成回调 */
|
|
228
|
+
onLoaded?: (data: MarkerData[]) => void;
|
|
330
229
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview 数据源 Mixin
|
|
3
|
+
* @description 所有需要 dataSource 的组件共享此 Mixin
|
|
4
|
+
* @module types/mixins
|
|
5
|
+
*/
|
|
6
|
+
import type { Coordinate } from '../basic';
|
|
7
|
+
/**
|
|
8
|
+
* 数据源 Mixin
|
|
9
|
+
* @description 提供统一的数据源和字段映射配置
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* interface MarkerProps extends DataSourceMixin<MarkerData> {
|
|
13
|
+
* dataSource: MarkerData[];
|
|
14
|
+
* fieldNames?: MarkerFieldNames;
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export interface DataSourceMixin<T = unknown> {
|
|
19
|
+
/**
|
|
20
|
+
* 数据源数组
|
|
21
|
+
* @description 组件渲染所需的数据集合
|
|
22
|
+
*/
|
|
23
|
+
dataSource?: T[];
|
|
24
|
+
/**
|
|
25
|
+
* 字段名映射
|
|
26
|
+
* @description 用于自定义 dataSource 中的字段名
|
|
27
|
+
*/
|
|
28
|
+
fieldNames?: Record<string, string>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 数据项必需字段
|
|
32
|
+
*/
|
|
33
|
+
export interface RequiredDataFields {
|
|
34
|
+
/** 唯一标识 */
|
|
35
|
+
id: string | number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 带坐标的数据项
|
|
39
|
+
*/
|
|
40
|
+
export interface CoordinateDataItem extends RequiredDataFields {
|
|
41
|
+
/** 坐标位置 [纬度, 经度] */
|
|
42
|
+
position?: Coordinate;
|
|
43
|
+
/** 坐标点数组 */
|
|
44
|
+
points?: Coordinate[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 数据验证结果
|
|
48
|
+
*/
|
|
49
|
+
export interface DataValidationResult<T> {
|
|
50
|
+
valid: boolean;
|
|
51
|
+
data?: T[];
|
|
52
|
+
errors?: {
|
|
53
|
+
index: number;
|
|
54
|
+
message: string;
|
|
55
|
+
}[];
|
|
56
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview 编辑模式 Mixin
|
|
3
|
+
* @description CRUD 操作支持
|
|
4
|
+
* @module types/mixins
|
|
5
|
+
*/
|
|
6
|
+
import type { ReactNode } from 'react';
|
|
7
|
+
/**
|
|
8
|
+
* 工具栏颜色
|
|
9
|
+
*/
|
|
10
|
+
export type ToolbarColor = 'default' | 'primary' | 'danger' | 'warning' | 'success' | string;
|
|
11
|
+
/**
|
|
12
|
+
* 工具栏尺寸
|
|
13
|
+
*/
|
|
14
|
+
export type ToolbarSize = 'large' | 'middle' | 'small' | number;
|
|
15
|
+
/**
|
|
16
|
+
* 工具栏按钮
|
|
17
|
+
* @description 通用工具栏按钮配置
|
|
18
|
+
*/
|
|
19
|
+
export interface ToolbarButton<T extends string = string> {
|
|
20
|
+
/** 按钮操作类型 */
|
|
21
|
+
action: T;
|
|
22
|
+
/** 按钮文字 */
|
|
23
|
+
label: string;
|
|
24
|
+
/** 按钮图标 */
|
|
25
|
+
icon?: ReactNode;
|
|
26
|
+
/** 工具提示 */
|
|
27
|
+
tooltip?: string;
|
|
28
|
+
/** 按钮样式变体 */
|
|
29
|
+
variant?: 'default' | 'primary' | 'danger';
|
|
30
|
+
/** 按钮颜色 */
|
|
31
|
+
color?: ToolbarColor;
|
|
32
|
+
/** 是否需要选中项才能使用 */
|
|
33
|
+
needsSelection?: boolean;
|
|
34
|
+
/** 是否在编辑模式下显示 */
|
|
35
|
+
showInEdit?: boolean;
|
|
36
|
+
/** 是否禁用 */
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 基础编辑模式配置
|
|
41
|
+
* @description 各组件编辑模式的公共结构
|
|
42
|
+
*/
|
|
43
|
+
export interface EditModeConfig {
|
|
44
|
+
/** 启用的编辑操作 */
|
|
45
|
+
enabled?: boolean | string[];
|
|
46
|
+
/** 自定义工具栏 */
|
|
47
|
+
toolbar?: ReactNode;
|
|
48
|
+
/** 工具栏颜色 */
|
|
49
|
+
color?: ToolbarColor;
|
|
50
|
+
/** 工具栏尺寸 */
|
|
51
|
+
size?: ToolbarSize;
|
|
52
|
+
/** 是否只显示图标 */
|
|
53
|
+
iconOnly?: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 编辑模式 Mixin
|
|
57
|
+
* @description 提供统一的编辑功能配置
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* // 使用字符串字面量类型
|
|
61
|
+
* interface MarkerProps extends EditableMixin<'create' | 'edit' | 'move' | 'delete'> {
|
|
62
|
+
* editMode?: boolean | ('create' | 'edit' | 'move' | 'delete')[];
|
|
63
|
+
* }
|
|
64
|
+
*
|
|
65
|
+
* // 使用对象配置
|
|
66
|
+
* interface RoadProps extends EditableMixin<string> {
|
|
67
|
+
* editMode?: EditModeConfig;
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export interface EditableMixin<T extends string = string> {
|
|
72
|
+
/**
|
|
73
|
+
* 编辑模式
|
|
74
|
+
* @description
|
|
75
|
+
* - `false`: 禁用编辑
|
|
76
|
+
* - `true`: 启用全部编辑功能
|
|
77
|
+
* - `string[]`: 启用的特定编辑操作
|
|
78
|
+
* - `object`: 自定义编辑配置
|
|
79
|
+
*/
|
|
80
|
+
editMode?: boolean | T[] | EditModeConfig;
|
|
81
|
+
/**
|
|
82
|
+
* 是否显示编辑提示
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
85
|
+
showEditHint?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* 创建完成回调
|
|
88
|
+
* @param result - 创建结果
|
|
89
|
+
*/
|
|
90
|
+
onCreate?: (result: any) => void;
|
|
91
|
+
/**
|
|
92
|
+
* 编辑完成回调
|
|
93
|
+
* @param result - 编辑结果
|
|
94
|
+
*/
|
|
95
|
+
onEdit?: (result: any) => void;
|
|
96
|
+
/**
|
|
97
|
+
* 重绘完成回调(部分组件支持)
|
|
98
|
+
* @param result - 重绘结果
|
|
99
|
+
*/
|
|
100
|
+
onRedraw?: (result: any) => void;
|
|
101
|
+
/**
|
|
102
|
+
* 删除确认回调
|
|
103
|
+
* @param result - 删除结果
|
|
104
|
+
*/
|
|
105
|
+
onDelete?: (result: any) => void;
|
|
106
|
+
/**
|
|
107
|
+
* 保存完成回调
|
|
108
|
+
* @param result - 保存结果
|
|
109
|
+
*/
|
|
110
|
+
onSave?: (result: any) => void;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* 编辑操作类型
|
|
114
|
+
*/
|
|
115
|
+
export type EditAction = 'create' | 'edit' | 'move' | 'delete' | 'redraw' | 'clip' | 'reverse';
|
|
116
|
+
/**
|
|
117
|
+
* 编辑结果基类
|
|
118
|
+
*/
|
|
119
|
+
export interface BaseEditResult {
|
|
120
|
+
/** 编辑操作类型 */
|
|
121
|
+
action: EditAction;
|
|
122
|
+
/** 操作的 ID */
|
|
123
|
+
id?: string | number;
|
|
124
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview 交互 Mixin
|
|
3
|
+
* @description 点击、右键等交互事件
|
|
4
|
+
* @module types/mixins
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* 交互 Mixin
|
|
8
|
+
* @description 提供统一的交互事件处理
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* interface MarkerProps extends InteractionMixin<MarkerData> {
|
|
12
|
+
* onClick?: (item: MarkerData) => void;
|
|
13
|
+
* onContextMenu?: (item: MarkerData, e: any) => void;
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export interface InteractionMixin<T = unknown> {
|
|
18
|
+
/**
|
|
19
|
+
* 点击事件回调
|
|
20
|
+
* @param item - 被点击的数据项
|
|
21
|
+
*/
|
|
22
|
+
onClick?: (item: T) => void;
|
|
23
|
+
/**
|
|
24
|
+
* 右键点击事件回调
|
|
25
|
+
* @param item - 被点击的数据项
|
|
26
|
+
* @param e - 事件对象
|
|
27
|
+
*/
|
|
28
|
+
onContextMenu?: (item: T, e: any) => void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 行事件回调
|
|
32
|
+
* @description 鼠标悬停或移出时触发
|
|
33
|
+
* @param item - 数据项
|
|
34
|
+
* @param index - 数据项索引
|
|
35
|
+
*/
|
|
36
|
+
export type RowEventHandler<T = unknown> = (item: T, index: number) => void;
|
|
37
|
+
/**
|
|
38
|
+
* 悬停事件参数
|
|
39
|
+
*/
|
|
40
|
+
export interface HoverEvent<T = unknown> {
|
|
41
|
+
item: T;
|
|
42
|
+
type: 'mouseover' | 'mouseout';
|
|
43
|
+
}
|