From acaa5f5cfb74f7e35ce136334c1257762dde441e Mon Sep 17 00:00:00 2001 From: yvonneyx Date: Thu, 12 Dec 2024 15:14:20 +0800 Subject: [PATCH 1/2] refactor: adjust graph config priority --- package.json | 44 +++++++++++++-------------- src/ConfigProvider/hooks/useConfig.ts | 8 +++-- src/FlowDiagram/index.tsx | 8 ++--- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index 88843d2..a45f527 100644 --- a/package.json +++ b/package.json @@ -53,52 +53,52 @@ "publish-package": "pnpm build && changeset publish" }, "dependencies": { - "@ant-design/graphs": "^2.0.1", - "@ant-design/icons": "^5.4.0", - "@ant-design/plots": "^2.2.5", - "@antv/l7": "^2.22.0", + "@ant-design/graphs": "^2.0.2", + "@ant-design/icons": "^5.5.2", + "@ant-design/plots": "^2.3.2", + "@antv/l7": "^2.22.3", "@antv/larkmap": "^1.5.1", - "@babel/runtime": "^7.18.0", + "@babel/runtime": "^7.26.0", "lodash": "^4.17.21", "react-markdown": "^9.0.1", "rehype-raw": "^7.0.0", "remark-gfm": "^4.0.0", - "styled-components": "^6.0.7" + "styled-components": "^6.1.13" }, "devDependencies": { - "@ant-design/x": "^1.0.1", + "@ant-design/x": "^1.0.2", "@changesets/changelog-github": "^0.5.0", - "@changesets/cli": "^2.27.9", - "@commitlint/cli": "^19.5.0", - "@commitlint/config-conventional": "^19.5.0", + "@changesets/cli": "^2.27.10", + "@commitlint/cli": "^19.6.0", + "@commitlint/config-conventional": "^19.6.0", "@types/jest": "^29.5.14", "@types/lodash": "^4.17.13", - "@types/react": "^18.0.0", + "@types/react": "^18.3.16", "@types/webpack-bundle-analyzer": "^4.7.0", - "antd": "^5.0.0", - "dumi": "^2.4.13", - "eslint": "^9.14.0", + "antd": "^5.22.4", + "dumi": "^2.4.16", + "eslint": "^9.16.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-jest": "^28.9.0", "eslint-plugin-jsx-a11y": "^6.10.2", "eslint-plugin-react": "^7.37.2", - "eslint-plugin-react-hooks": "^5.0.0", + "eslint-plugin-react-hooks": "^5.1.0", "father": "^4.5.1", "gh-pages": "^6.2.0", - "globals": "^15.12.0", - "husky": "^9.1.6", + "globals": "^15.13.0", + "husky": "^9.1.7", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "limit-size": "^0.1.4", - "lint-staged": "^15.2.10", + "lint-staged": "^15.2.11", "npm-run-all": "^4.1.5", - "prettier": "^3.3.3", + "prettier": "^3.4.2", "prettier-plugin-organize-imports": "^4.1.0", - "react": "^18.0.0", + "react": "^18.3.1", "ts-jest": "^29.2.5", "ts-node": "^10.9.2", - "typescript": "^5.6.3", - "typescript-eslint": "^8.13.0", + "typescript": "^5.7.2", + "typescript-eslint": "^8.18.0", "webpack-bundle-analyzer": "^4.10.2" }, "peerDependencies": { diff --git a/src/ConfigProvider/hooks/useConfig.ts b/src/ConfigProvider/hooks/useConfig.ts index 1134a9d..86fb7a0 100644 --- a/src/ConfigProvider/hooks/useConfig.ts +++ b/src/ConfigProvider/hooks/useConfig.ts @@ -86,8 +86,12 @@ function useGraphGlobalConfig(name: Charts) { return mergeGraphOptions(graphConfig, componentConfig || {}); } -export function useGraphConfig(name: Charts, ...configs: Partial[]) { +export function useGraphConfig( + name: Charts, + defaultConfig: Partial, + props: Partial, +) { const globalConfig = useGraphGlobalConfig(name); - return mergeGraphOptions(globalConfig, ...configs); + return mergeGraphOptions(defaultConfig, globalConfig, props); } diff --git a/src/FlowDiagram/index.tsx b/src/FlowDiagram/index.tsx index 60e96b2..2fec447 100644 --- a/src/FlowDiagram/index.tsx +++ b/src/FlowDiagram/index.tsx @@ -3,6 +3,7 @@ import { FlowGraph as ADCFlowGraph, RCNode } from '@ant-design/graphs'; import React, { useMemo } from 'react'; import { useGraphConfig } from '../ConfigProvider/hooks'; import type { GraphProps } from '../types'; +import { mergeGraphOptions } from '../utils/config'; import { visGraphData2GraphData } from '../utils/graph'; import { getGraphOptionsByData } from './helper'; @@ -12,7 +13,7 @@ export interface FlowDiagramProps extends GraphProps {} const defaultConfig: FlowGraphOptions = { autoResize: true, - autoFit: 'center', + autoFit: 'view', node: { style: { component: (d: G6.NodeData) => { @@ -32,7 +33,6 @@ const defaultConfig: FlowGraphOptions = { }, size: [140, 32], }, - animation: { enter: false }, }, edge: { style: { @@ -49,7 +49,6 @@ const defaultConfig: FlowGraphOptions = { stroke: '#001f98', }, }, - animation: { enter: false }, }, behaviors: (prev) => [ ...prev, @@ -72,8 +71,7 @@ const FlowDiagram: React.FC = (props) => { const config = useGraphConfig( 'FlowDiagram', - defaultConfig, - getGraphOptionsByData(data), + mergeGraphOptions(defaultConfig, getGraphOptionsByData(data)), restProps, ); From 3b5dd28d0b02cdb4a28f6dc13dfa0fa35c32d55f Mon Sep 17 00:00:00 2001 From: yvonneyx Date: Thu, 12 Dec 2024 15:17:51 +0800 Subject: [PATCH 2/2] chore: changeset --- .changeset/eighty-zebras-hug.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/eighty-zebras-hug.md diff --git a/.changeset/eighty-zebras-hug.md b/.changeset/eighty-zebras-hug.md new file mode 100644 index 0000000..45580cd --- /dev/null +++ b/.changeset/eighty-zebras-hug.md @@ -0,0 +1,5 @@ +--- +'@antv/gpt-vis': patch +--- + +refactor: adjust graph options priority