Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: initialize @ant-design/graphs package #2690

Merged
merged 6 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/graphs/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../.babelrc"
}
5 changes: 5 additions & 0 deletions packages/graphs/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist
es
lib
node_modules
tests
3 changes: 3 additions & 0 deletions packages/graphs/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: '../../.eslintrc.js',
};
1 change: 1 addition & 0 deletions packages/graphs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @ant-design/graphs
68 changes: 68 additions & 0 deletions packages/graphs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"name": "@ant-design/graphs",
"version": "1.0.0-alpha.0",
"description": "A React graph library based on G6",
"bugs": {
"url": "https://github.com/ant-design/ant-design-charts/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ant-design/ant-design-charts.git"
},
"main": "lib/index.js",
"unpkg": "dist/graphs.min.js",
"module": "es/index.js",
"types": "es/index.d.ts",
"files": [
"lib",
"dist",
"es",
"src"
],
"scripts": {
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"ci": "run-s lint build test",
"clean": "rimraf lib es dist",
"dev": "vite",
"build": "run-p build:*",
"build:umd": "rimraf ./dist && webpack --config webpack.config.js --mode production",
"build:lib": "rimraf ./lib && tsc -p tsconfig.prod.json --target ES5 --module commonjs --outDir lib",
"build:esm": "rimraf ./es && tsc -p tsconfig.prod.json --target ES5 --module ESNext --outDir es",
"lint:prettier": "npm run prettier && git diff && prettier --version && prettier --check \"src/**/**.{js,jsx,tsx,ts,less,md,json}\" --end-of-line auto",
"lint": "eslint --cache --ext .js,.jsx,.ts,.tsx --fix --format=pretty ./src && npm run lint:prettier",
"prettier": "prettier --write \"**/**.{js,jsx,tsx,ts,less,md,json}\"",
"profile": "webpack --config webpack.config.js --mode production --profile --json > stats.json",
"start": "npm run build:esm --w",
"test": "jest"
},
"keywords": [
"antv",
"g6",
"graph",
"graph analysis",
"graph editor",
"graph visualization",
"relational data",
"react"
],
"dependencies": {
"@antv/g6": "^5.0.21",
"@antv/graphin": "^3.0.2",
"lodash-es": "^4.17.21"
},
"devDependencies": {
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.6",
"antd": "^5.20.5",
"npm-run-all": "^4.1.5",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-router-dom": "^6.26.1",
"vite": "^5.4.3"
},
"peerDependencies": {
"react": ">=16.8.4",
"react-dom": ">=16.8.4"
},
"license": "MIT"
}
5 changes: 5 additions & 0 deletions packages/graphs/src/components/HierarchicalGraph/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';

export const HierarchicalGraph = () => {
return <div>HierarchicalGraph</div>;
};
1 change: 1 addition & 0 deletions packages/graphs/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { HierarchicalGraph } from './HierarchicalGraph';
4 changes: 4 additions & 0 deletions packages/graphs/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import * as G6 from '@antv/g6';

export * from './components';
export { G6 };
5 changes: 5 additions & 0 deletions packages/graphs/tests/demos/error-boundary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';

export const ErrorBoundary = () => {
return <div>ErrorBoundary</div>;
};
1 change: 1 addition & 0 deletions packages/graphs/tests/demos/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ErrorBoundary } from './error-boundary';
18 changes: 18 additions & 0 deletions packages/graphs/tests/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>@ant-design/graphs</title>
<style>
body {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="root"></div>
<script type="module" src="./main.tsx"></script>
</body>
</html>
47 changes: 47 additions & 0 deletions packages/graphs/tests/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Alert, Flex, Select } from 'antd';
import React from 'react';
import { createRoot } from 'react-dom/client';
import { Outlet, RouterProvider, createBrowserRouter, useMatch, useNavigate } from 'react-router-dom';
import * as demos from './demos';

const App = () => {
const navigate = useNavigate();
const match = useMatch('/*');

return (
<Flex vertical>
<Select
value={match?.params['*'] || Object.keys(demos)[0]}
options={Object.keys(demos).map((label) => ({ label, value: label }))}
style={{ width: 200 }}
onChange={(value) => navigate(value)}
/>
<Outlet />
</Flex>
);
};

const NotFound = () => {
return <Alert message="Demo Not Found" type="error" />;
};

const router = createBrowserRouter([
{
path: '/',
element: <App />,
errorElement: <NotFound />,
children: Object.entries(demos).map(([key, Demo]) => ({
path: key,
element: <Demo />,
})),
},
]);

const container = document.getElementById('root')!;
const root = createRoot(container);

root.render(
<React.StrictMode>
<RouterProvider router={router} />
</React.StrictMode>,
);
12 changes: 12 additions & 0 deletions packages/graphs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"isolatedModules": true,
"pretty": true,
"resolveJsonModule": true,
"strict": true,
"paths": {}
},
"exclude": ["node_modules", "dist", "lib", "es"],
"extends": "../../tsconfig.json",
"include": ["src", "tests"]
}
4 changes: 4 additions & 0 deletions packages/graphs/tsconfig.prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src"]
}
16 changes: 16 additions & 0 deletions packages/graphs/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import path from 'path';
import { defineConfig } from 'vite';

export default defineConfig({
root: './tests',
server: {
port: 8084,
open: '/',
},
plugins: [{ name: 'isolation' }],
resolve: {
alias: {
'@ant-design/graphs': path.resolve(__dirname, './src'),
},
},
});
3 changes: 3 additions & 0 deletions packages/graphs/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { getWebpackConfig } = require('../../config/webpack');

module.exports = getWebpackConfig('graphs', 'Graphs');
11 changes: 5 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": false,
"suppressImplicitAnyIndexErrors": true,
"experimentalDecorators": true,
"strict": false,
"skipLibCheck": true,
Expand All @@ -21,7 +20,10 @@
"noUnusedLocals": false,
"noImplicitAny": false,
"noFallthroughCasesInSwitch": true,
"preserveSymlinks": true
"preserveSymlinks": true,
"paths": {
"@@/*": ["src/.umi/*"]
}
},
"exclude": [
"node_modules",
Expand All @@ -48,8 +50,5 @@
"jest.config.js",
"**/fixtures",
"./tests/no-duplicated.ts"
],
"paths": {
"@@/*": ["src/.umi/*"]
}
]
}
Loading