@antv/gpt-vis 0.3.1 → 0.3.3

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.
Files changed (44) hide show
  1. package/dist/cjs/ConfigProvider/hooks/useConfig.d.ts +1 -1
  2. package/dist/cjs/ConfigProvider/hooks/useConfig.js +2 -2
  3. package/dist/cjs/FlowDiagram/helper.d.ts +7 -0
  4. package/dist/cjs/FlowDiagram/helper.js +83 -0
  5. package/dist/cjs/FlowDiagram/index.js +10 -2
  6. package/dist/cjs/Map/Component/MapView.d.ts +3 -0
  7. package/dist/cjs/Map/Component/MapView.js +40 -0
  8. package/dist/cjs/Map/Component/Marker.d.ts +3 -0
  9. package/dist/cjs/Map/Component/Marker.js +53 -0
  10. package/dist/cjs/Map/Component/Polyline.d.ts +3 -0
  11. package/dist/cjs/Map/Component/Polyline.js +50 -0
  12. package/dist/cjs/Map/Component/index.d.ts +4 -0
  13. package/dist/cjs/Map/Component/index.js +45 -0
  14. package/dist/cjs/Map/index.js +8 -15
  15. package/dist/cjs/Text/utils/useAntdDarkAlgorithm.js +3 -3
  16. package/dist/cjs/utils/map/context.js +3 -0
  17. package/dist/cjs/utils/map/view.d.ts +2 -0
  18. package/dist/cjs/utils/map/view.js +10 -4
  19. package/dist/cjs/version.d.ts +1 -1
  20. package/dist/cjs/version.js +1 -1
  21. package/dist/esm/ConfigProvider/hooks/useConfig.d.ts +1 -1
  22. package/dist/esm/ConfigProvider/hooks/useConfig.js +5 -2
  23. package/dist/esm/FlowDiagram/helper.d.ts +7 -0
  24. package/dist/esm/FlowDiagram/helper.js +76 -0
  25. package/dist/esm/FlowDiagram/index.js +5 -2
  26. package/dist/esm/Map/Component/MapView.d.ts +3 -0
  27. package/dist/esm/Map/Component/MapView.js +18 -0
  28. package/dist/esm/Map/Component/Marker.d.ts +3 -0
  29. package/dist/esm/Map/Component/Marker.js +35 -0
  30. package/dist/esm/Map/Component/Polyline.d.ts +3 -0
  31. package/dist/esm/Map/Component/Polyline.js +30 -0
  32. package/dist/esm/Map/Component/index.d.ts +4 -0
  33. package/dist/esm/Map/Component/index.js +4 -0
  34. package/dist/esm/Map/index.js +12 -29
  35. package/dist/esm/Text/utils/useAntdDarkAlgorithm.js +2 -1
  36. package/dist/esm/utils/map/context.js +9 -3
  37. package/dist/esm/utils/map/view.d.ts +2 -0
  38. package/dist/esm/utils/map/view.js +6 -5
  39. package/dist/esm/version.d.ts +1 -1
  40. package/dist/esm/version.js +1 -1
  41. package/dist/umd/640.async.js +1 -0
  42. package/dist/umd/index.min.js +1 -1
  43. package/package.json +1 -1
  44. package/dist/umd/708.async.js +0 -1
@@ -8,6 +8,6 @@ export declare function useMapConfig<T extends MapProps>(name: Charts, props: T)
8
8
  mapType: string | undefined;
9
9
  token: string | undefined;
10
10
  } & T;
11
- export declare function useGraphConfig<T extends GraphOptions>(name: Charts, defaultConfig: T, props: T): {
11
+ export declare function useGraphConfig<T extends GraphOptions>(name: Charts, ...configs: Partial<T>[]): {
12
12
  [x: string]: any;
13
13
  };
@@ -95,9 +95,9 @@ function useGraphGlobalConfig(name) {
95
95
  const componentConfig = useComponentGlobalConfig(name);
96
96
  return (0, import_config.mergeGraphOptions)(graphConfig, componentConfig || {});
97
97
  }
98
- function useGraphConfig(name, defaultConfig, props) {
98
+ function useGraphConfig(name, ...configs) {
99
99
  const globalConfig = useGraphGlobalConfig(name);
100
- return (0, import_config.mergeGraphOptions)(defaultConfig, globalConfig, props);
100
+ return (0, import_config.mergeGraphOptions)(globalConfig, ...configs);
101
101
  }
102
102
  // Annotate the CommonJS export names for ESM import in node:
103
103
  0 && (module.exports = {
@@ -0,0 +1,7 @@
1
+ import type { FlowGraphOptions, G6 } from '@ant-design/graphs';
2
+ /**
3
+ * Adjust graph configuration based on data characteristics.
4
+ * @param data - graph data
5
+ * @returns graph options
6
+ */
7
+ export declare function getGraphOptionsByData(data: G6.GraphData): FlowGraphOptions;
@@ -0,0 +1,83 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/FlowDiagram/helper.ts
20
+ var helper_exports = {};
21
+ __export(helper_exports, {
22
+ getGraphOptionsByData: () => getGraphOptionsByData
23
+ });
24
+ module.exports = __toCommonJS(helper_exports);
25
+ function getGraphOptionsByData(data) {
26
+ if (isLinearStructure(data))
27
+ return {
28
+ node: {
29
+ style: {
30
+ ports: [
31
+ { placement: "right" },
32
+ { placement: "left" },
33
+ { placement: "top" },
34
+ { placement: "bottom" }
35
+ ]
36
+ }
37
+ },
38
+ layout: {
39
+ type: "snake",
40
+ cols: 3,
41
+ rowGap: 40
42
+ }
43
+ };
44
+ return {};
45
+ }
46
+ function isLinearStructure(data) {
47
+ const { nodes = [], edges = [] } = data;
48
+ const inDegree = {};
49
+ const outDegree = {};
50
+ const adjList = {};
51
+ nodes.forEach((node) => {
52
+ inDegree[node.id] = 0;
53
+ outDegree[node.id] = 0;
54
+ adjList[node.id] = [];
55
+ });
56
+ edges.forEach((edge) => {
57
+ inDegree[edge.target]++;
58
+ outDegree[edge.source]++;
59
+ adjList[edge.source].push(edge.target);
60
+ });
61
+ const visited = /* @__PURE__ */ new Set();
62
+ const dfs = (nodeId) => {
63
+ if (visited.has(nodeId))
64
+ return;
65
+ visited.add(nodeId);
66
+ adjList[nodeId].forEach(dfs);
67
+ };
68
+ dfs(nodes[0].id);
69
+ if (visited.size !== nodes.length)
70
+ return false;
71
+ const sourceNodes = nodes.filter((node) => inDegree[node.id] === 0);
72
+ const sinkNodes = nodes.filter((node) => outDegree[node.id] === 0);
73
+ if (sourceNodes.length !== 1 || sinkNodes.length !== 1)
74
+ return false;
75
+ const middleNodes = nodes.filter((node) => inDegree[node.id] === 1 && outDegree[node.id] === 1);
76
+ if (middleNodes.length !== nodes.length - 2)
77
+ return false;
78
+ return true;
79
+ }
80
+ // Annotate the CommonJS export names for ESM import in node:
81
+ 0 && (module.exports = {
82
+ getGraphOptionsByData
83
+ });
@@ -36,9 +36,11 @@ var import_graphs = require("@ant-design/graphs");
36
36
  var import_react = __toESM(require("react"));
37
37
  var import_hooks = require("../ConfigProvider/hooks");
38
38
  var import_graph = require("../utils/graph");
39
+ var import_helper = require("./helper");
39
40
  var { TextNode } = import_graphs.RCNode;
40
41
  var defaultConfig = {
41
42
  autoResize: true,
43
+ autoFit: "center",
42
44
  node: {
43
45
  style: {
44
46
  component: (d) => {
@@ -53,7 +55,8 @@ var defaultConfig = {
53
55
  style: {
54
56
  fontSize: 12,
55
57
  background: "linear-gradient(-89deg, #64b7f2 0%, #4c95f3 100%)"
56
- }
58
+ },
59
+ borderWidth: 2
57
60
  }
58
61
  );
59
62
  },
@@ -94,7 +97,12 @@ var defaultConfig = {
94
97
  var FlowDiagram = (props) => {
95
98
  const { data: propsData, ...restProps } = props;
96
99
  const data = (0, import_react.useMemo)(() => (0, import_graph.visGraphData2GraphData)(propsData), [propsData]);
97
- const config = (0, import_hooks.useGraphConfig)("FlowDiagram", defaultConfig, restProps);
100
+ const config = (0, import_hooks.useGraphConfig)(
101
+ "FlowDiagram",
102
+ defaultConfig,
103
+ (0, import_helper.getGraphOptionsByData)(data),
104
+ restProps
105
+ );
98
106
  return /* @__PURE__ */ import_react.default.createElement(import_graphs.FlowGraph, { data, ...config });
99
107
  };
100
108
  var FlowDiagram_default = FlowDiagram;
@@ -0,0 +1,3 @@
1
+ import type { Map } from '../../types/map';
2
+ declare const _default: (props: Map) => null;
3
+ export default _default;
@@ -0,0 +1,40 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/Map/Component/MapView.tsx
20
+ var MapView_exports = {};
21
+ __export(MapView_exports, {
22
+ default: () => MapView_default
23
+ });
24
+ module.exports = __toCommonJS(MapView_exports);
25
+ var import_larkmap = require("@antv/larkmap");
26
+ var import_react = require("react");
27
+ var import_map = require("../../utils/map");
28
+ var MapView_default = (props) => {
29
+ const scene = (0, import_larkmap.useScene)();
30
+ (0, import_react.useEffect)(() => {
31
+ (0, import_map.setMapView)(props, scene);
32
+ }, []);
33
+ (0, import_react.useEffect)(() => {
34
+ (0, import_map.setMapStatus)(props, scene);
35
+ }, [props.enableRotate, props.enableScroll, props.enableZoom]);
36
+ (0, import_react.useEffect)(() => {
37
+ (0, import_map.fitBounds)(props, scene);
38
+ }, [props.includePoints, props.markers, props.polyline, props.includePadding]);
39
+ return null;
40
+ };
@@ -0,0 +1,3 @@
1
+ import type { Map } from '../../types/map';
2
+ declare const _default: (props: Map) => null;
3
+ export default _default;
@@ -0,0 +1,53 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/Map/Component/Marker.tsx
20
+ var Marker_exports = {};
21
+ __export(Marker_exports, {
22
+ default: () => Marker_default
23
+ });
24
+ module.exports = __toCommonJS(Marker_exports);
25
+ var import_larkmap = require("@antv/larkmap");
26
+ var import_react = require("react");
27
+ var import_map = require("../../utils/map");
28
+ var Marker_default = (props) => {
29
+ const scene = (0, import_larkmap.useScene)();
30
+ const [layers, setLayers] = (0, import_react.useState)([]);
31
+ const removeLayers = () => {
32
+ layers.forEach((item) => {
33
+ scene.removeLayer(item);
34
+ });
35
+ };
36
+ (0, import_react.useEffect)(() => {
37
+ var _a;
38
+ if (!props.markers)
39
+ return;
40
+ (_a = (0, import_map.setMapContext)(props, scene)) == null ? void 0 : _a.then(() => {
41
+ const markerLayer = (0, import_map.setMarkers)(props.markers || []);
42
+ removeLayers();
43
+ markerLayer.forEach((item) => {
44
+ scene.addLayer(item);
45
+ });
46
+ setLayers(markerLayer);
47
+ });
48
+ return () => {
49
+ removeLayers();
50
+ };
51
+ }, [props.markers]);
52
+ return null;
53
+ };
@@ -0,0 +1,3 @@
1
+ import type { Map } from '../../types/map';
2
+ declare const _default: (props: Map) => null;
3
+ export default _default;
@@ -0,0 +1,50 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/Map/Component/Polyline.tsx
20
+ var Polyline_exports = {};
21
+ __export(Polyline_exports, {
22
+ default: () => Polyline_default
23
+ });
24
+ module.exports = __toCommonJS(Polyline_exports);
25
+ var import_larkmap = require("@antv/larkmap");
26
+ var import_react = require("react");
27
+ var import_map = require("../../utils/map");
28
+ var Polyline_default = (props) => {
29
+ const scene = (0, import_larkmap.useScene)();
30
+ const [layers, setLayers] = (0, import_react.useState)([]);
31
+ const removeLayers = () => {
32
+ layers.forEach((item) => {
33
+ scene.removeLayer(item);
34
+ });
35
+ };
36
+ (0, import_react.useEffect)(() => {
37
+ if (!props.polyline)
38
+ return;
39
+ const lineLayers = (0, import_map.setPolyline)(props.polyline || []);
40
+ removeLayers();
41
+ lineLayers.forEach((item) => {
42
+ scene.addLayer(item);
43
+ });
44
+ setLayers(lineLayers);
45
+ return () => {
46
+ removeLayers();
47
+ };
48
+ }, [props.polyline]);
49
+ return null;
50
+ };
@@ -0,0 +1,4 @@
1
+ import MapView from './MapView';
2
+ import Marker from './Marker';
3
+ import Polyline from './Polyline';
4
+ export { MapView, Marker, Polyline };
@@ -0,0 +1,45 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/Map/Component/index.tsx
30
+ var Component_exports = {};
31
+ __export(Component_exports, {
32
+ MapView: () => import_MapView.default,
33
+ Marker: () => import_Marker.default,
34
+ Polyline: () => import_Polyline.default
35
+ });
36
+ module.exports = __toCommonJS(Component_exports);
37
+ var import_MapView = __toESM(require("./MapView"));
38
+ var import_Marker = __toESM(require("./Marker"));
39
+ var import_Polyline = __toESM(require("./Polyline"));
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ MapView,
43
+ Marker,
44
+ Polyline
45
+ });
@@ -35,24 +35,14 @@ module.exports = __toCommonJS(Map_exports);
35
35
  var import_larkmap = require("@antv/larkmap");
36
36
  var import_react = __toESM(require("react"));
37
37
  var import_map = require("../utils/map");
38
+ var import_Component = require("./Component/");
38
39
  var Map = (props) => {
39
40
  const { className, containerStyle, children } = props;
40
- const allLayers = [];
41
- const mapConfig = (0, import_map.formatMapStyle)(props);
42
- const onSceneLoaded = async (scene) => {
43
- (0, import_map.setMapView)(props, scene);
44
- await (0, import_map.setMapContext)(props, scene);
45
- if (props.polyline) {
46
- const polylineLayer = (0, import_map.setPolyline)(props.polyline || []);
47
- allLayers.push(...polylineLayer);
41
+ const mapConfig = (0, import_react.useMemo)(() => (0, import_map.formatMapStyle)(props), [props]);
42
+ const onSceneLoaded = async () => {
43
+ if (props.onInitComplete) {
44
+ props.onInitComplete();
48
45
  }
49
- if (props.markers) {
50
- const markerLayer = (0, import_map.setMarkers)(props.markers || []);
51
- allLayers.push(...markerLayer);
52
- }
53
- allLayers.forEach((item) => {
54
- scene.addLayer(item);
55
- });
56
46
  };
57
47
  return /* @__PURE__ */ import_react.default.createElement(
58
48
  import_larkmap.LarkMap,
@@ -62,6 +52,9 @@ var Map = (props) => {
62
52
  ...mapConfig,
63
53
  onSceneLoaded
64
54
  },
55
+ /* @__PURE__ */ import_react.default.createElement(import_Component.MapView, { ...props }),
56
+ /* @__PURE__ */ import_react.default.createElement(import_Component.Marker, { ...props }),
57
+ /* @__PURE__ */ import_react.default.createElement(import_Component.Polyline, { ...props }),
65
58
  children
66
59
  );
67
60
  };
@@ -25,11 +25,11 @@ module.exports = __toCommonJS(useAntdDarkAlgorithm_exports);
25
25
  var import_antd = require("antd");
26
26
  var import_lodash = require("lodash");
27
27
  var import_react = require("react");
28
- var { darkAlgorithm } = import_antd.theme;
29
28
  var useAntdDarkAlgorithm = () => {
30
- var _a;
29
+ var _a, _b;
30
+ const darkAlgorithm = (_a = import_antd.theme) == null ? void 0 : _a.darkAlgorithm;
31
31
  const config = (0, import_react.useContext)(import_antd.ConfigProvider.ConfigContext);
32
- const currentAlgorithm = (_a = config.theme) == null ? void 0 : _a.algorithm;
32
+ const currentAlgorithm = (_b = config.theme) == null ? void 0 : _b.algorithm;
33
33
  if ((0, import_lodash.isArray)(currentAlgorithm) && currentAlgorithm.includes(darkAlgorithm))
34
34
  return true;
35
35
  return currentAlgorithm === darkAlgorithm;
@@ -31,6 +31,9 @@ function setMapContext(props, scene) {
31
31
  return Promise.all(
32
32
  Array.from(icons.values()).map(async (url) => {
33
33
  const id = (0, import_util.urlToMarkerId)(url);
34
+ if (scene.hasImage(id)) {
35
+ return;
36
+ }
34
37
  return await scene.addImage(id, url);
35
38
  })
36
39
  );
@@ -1,3 +1,5 @@
1
1
  import type { Scene } from '@antv/l7';
2
2
  import type { Map } from '../../types/map';
3
3
  export declare const setMapView: (props: Map, scene: Scene) => void;
4
+ export declare const fitBounds: (props: Map, scene: Scene) => void;
5
+ export declare const setMapStatus: (props: Map, scene: Scene) => void;
@@ -19,6 +19,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/utils/map/view.ts
20
20
  var view_exports = {};
21
21
  __export(view_exports, {
22
+ fitBounds: () => fitBounds,
23
+ setMapStatus: () => setMapStatus,
22
24
  setMapView: () => setMapView
23
25
  });
24
26
  module.exports = __toCommonJS(view_exports);
@@ -47,6 +49,10 @@ function fitIncludePoints(includePoints, scene, includePadding) {
47
49
  }
48
50
  }
49
51
  var setMapView = (props, scene) => {
52
+ fitBounds(props, scene);
53
+ setMapStatus(props, scene);
54
+ };
55
+ var fitBounds = (props, scene) => {
50
56
  if (props.includePoints) {
51
57
  fitIncludePoints(props.includePoints, scene, props.includePadding);
52
58
  } else {
@@ -67,6 +73,8 @@ var setMapView = (props, scene) => {
67
73
  fitIncludePoints(points, scene, props.includePadding);
68
74
  }
69
75
  }
76
+ };
77
+ var setMapStatus = (props, scene) => {
70
78
  if (props.enableZoom !== void 0) {
71
79
  scene.setMapStatus({
72
80
  zoomEnable: props.enableZoom
@@ -82,12 +90,10 @@ var setMapView = (props, scene) => {
82
90
  dragEnable: props.enableScroll
83
91
  });
84
92
  }
85
- if (props.onInitComplete) {
86
- scene.off("loaded", props.onInitComplete);
87
- scene.on("loaded", props.onInitComplete);
88
- }
89
93
  };
90
94
  // Annotate the CommonJS export names for ESM import in node:
91
95
  0 && (module.exports = {
96
+ fitBounds,
97
+ setMapStatus,
92
98
  setMapView
93
99
  });
@@ -1,2 +1,2 @@
1
- declare const _default: "0.3.1";
1
+ declare const _default: "0.3.3";
2
2
  export default _default;
@@ -22,4 +22,4 @@ __export(version_exports, {
22
22
  default: () => version_default
23
23
  });
24
24
  module.exports = __toCommonJS(version_exports);
25
- var version_default = "0.3.1";
25
+ var version_default = "0.3.3";
@@ -8,6 +8,6 @@ export declare function useMapConfig<T extends MapProps>(name: Charts, props: T)
8
8
  mapType: string | undefined;
9
9
  token: string | undefined;
10
10
  } & T;
11
- export declare function useGraphConfig<T extends GraphOptions>(name: Charts, defaultConfig: T, props: T): {
11
+ export declare function useGraphConfig<T extends GraphOptions>(name: Charts, ...configs: Partial<T>[]): {
12
12
  [x: string]: any;
13
13
  };
@@ -51,7 +51,10 @@ function useGraphGlobalConfig(name) {
51
51
  var componentConfig = useComponentGlobalConfig(name);
52
52
  return mergeGraphOptions(graphConfig, componentConfig || {});
53
53
  }
54
- export function useGraphConfig(name, defaultConfig, props) {
54
+ export function useGraphConfig(name) {
55
55
  var globalConfig = useGraphGlobalConfig(name);
56
- return mergeGraphOptions(defaultConfig, globalConfig, props);
56
+ for (var _len = arguments.length, configs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
57
+ configs[_key - 1] = arguments[_key];
58
+ }
59
+ return mergeGraphOptions.apply(void 0, [globalConfig].concat(configs));
57
60
  }
@@ -0,0 +1,7 @@
1
+ import type { FlowGraphOptions, G6 } from '@ant-design/graphs';
2
+ /**
3
+ * Adjust graph configuration based on data characteristics.
4
+ * @param data - graph data
5
+ * @returns graph options
6
+ */
7
+ export declare function getGraphOptionsByData(data: G6.GraphData): FlowGraphOptions;
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Adjust graph configuration based on data characteristics.
3
+ * @param data - graph data
4
+ * @returns graph options
5
+ */
6
+ export function getGraphOptionsByData(data) {
7
+ if (isLinearStructure(data)) return {
8
+ node: {
9
+ style: {
10
+ ports: [{
11
+ placement: 'right'
12
+ }, {
13
+ placement: 'left'
14
+ }, {
15
+ placement: 'top'
16
+ }, {
17
+ placement: 'bottom'
18
+ }]
19
+ }
20
+ },
21
+ layout: {
22
+ type: 'snake',
23
+ cols: 3,
24
+ rowGap: 40
25
+ }
26
+ };
27
+ return {};
28
+ }
29
+ function isLinearStructure(data) {
30
+ var _data$nodes = data.nodes,
31
+ nodes = _data$nodes === void 0 ? [] : _data$nodes,
32
+ _data$edges = data.edges,
33
+ edges = _data$edges === void 0 ? [] : _data$edges;
34
+ var inDegree = {};
35
+ var outDegree = {};
36
+ var adjList = {};
37
+ nodes.forEach(function (node) {
38
+ inDegree[node.id] = 0;
39
+ outDegree[node.id] = 0;
40
+ adjList[node.id] = [];
41
+ });
42
+ edges.forEach(function (edge) {
43
+ inDegree[edge.target]++;
44
+ outDegree[edge.source]++;
45
+ adjList[edge.source].push(edge.target);
46
+ });
47
+
48
+ // 检查图是否连通
49
+ // Check if the graph is connected
50
+ var visited = new Set();
51
+ var dfs = function dfs(nodeId) {
52
+ if (visited.has(nodeId)) return;
53
+ visited.add(nodeId);
54
+ adjList[nodeId].forEach(dfs);
55
+ };
56
+ dfs(nodes[0].id);
57
+ if (visited.size !== nodes.length) return false;
58
+
59
+ // 检查是否有且仅有一个源节点和一个汇节点
60
+ // Check if there is exactly one source node and one sink node
61
+ var sourceNodes = nodes.filter(function (node) {
62
+ return inDegree[node.id] === 0;
63
+ });
64
+ var sinkNodes = nodes.filter(function (node) {
65
+ return outDegree[node.id] === 0;
66
+ });
67
+ if (sourceNodes.length !== 1 || sinkNodes.length !== 1) return false;
68
+
69
+ // 检查中间节点是否只有一个前驱和一个后继
70
+ // Check if the middle nodes have only one predecessor and one successor
71
+ var middleNodes = nodes.filter(function (node) {
72
+ return inDegree[node.id] === 1 && outDegree[node.id] === 1;
73
+ });
74
+ if (middleNodes.length !== nodes.length - 2) return false;
75
+ return true;
76
+ }
@@ -6,9 +6,11 @@ import { FlowGraph as ADCFlowGraph, RCNode } from '@ant-design/graphs';
6
6
  import React, { useMemo } from 'react';
7
7
  import { useGraphConfig } from "../ConfigProvider/hooks";
8
8
  import { visGraphData2GraphData } from "../utils/graph";
9
+ import { getGraphOptionsByData } from "./helper";
9
10
  var TextNode = RCNode.TextNode;
10
11
  var defaultConfig = {
11
12
  autoResize: true,
13
+ autoFit: 'center',
12
14
  node: {
13
15
  style: {
14
16
  component: function component(d) {
@@ -21,7 +23,8 @@ var defaultConfig = {
21
23
  style: {
22
24
  fontSize: 12,
23
25
  background: 'linear-gradient(-89deg, #64b7f2 0%, #4c95f3 100%)'
24
- }
26
+ },
27
+ borderWidth: 2
25
28
  });
26
29
  },
27
30
  size: [140, 32]
@@ -67,7 +70,7 @@ var FlowDiagram = function FlowDiagram(props) {
67
70
  var data = useMemo(function () {
68
71
  return visGraphData2GraphData(propsData);
69
72
  }, [propsData]);
70
- var config = useGraphConfig('FlowDiagram', defaultConfig, restProps);
73
+ var config = useGraphConfig('FlowDiagram', defaultConfig, getGraphOptionsByData(data), restProps);
71
74
  return /*#__PURE__*/React.createElement(ADCFlowGraph, _extends({
72
75
  data: data
73
76
  }, config));
@@ -0,0 +1,3 @@
1
+ import type { Map } from '../../types/map';
2
+ declare const _default: (props: Map) => null;
3
+ export default _default;
@@ -0,0 +1,18 @@
1
+ import { useScene } from '@antv/larkmap';
2
+ import { useEffect } from 'react';
3
+ import { fitBounds, setMapStatus, setMapView } from "../../utils/map";
4
+
5
+ // 更新地图视野
6
+ export default (function (props) {
7
+ var scene = useScene();
8
+ useEffect(function () {
9
+ setMapView(props, scene);
10
+ }, []);
11
+ useEffect(function () {
12
+ setMapStatus(props, scene);
13
+ }, [props.enableRotate, props.enableScroll, props.enableZoom]);
14
+ useEffect(function () {
15
+ fitBounds(props, scene);
16
+ }, [props.includePoints, props.markers, props.polyline, props.includePadding]);
17
+ return null;
18
+ });
@@ -0,0 +1,3 @@
1
+ import type { Map } from '../../types/map';
2
+ declare const _default: (props: Map) => null;
3
+ export default _default;