@yanqirenshi/d3.deployment 0.9.0 → 0.9.1
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/LICENSE +21 -0
- package/README.markdown +108 -15
- package/babel.config.js +14 -14
- package/dist/components/D3Deployment.js +3 -4
- package/package.json +7 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018-2026 Satoshi Iwasaki (yanqirenshi@gmail.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.markdown
CHANGED
|
@@ -1,15 +1,108 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
# @yanqirenshi/d3.deployment
|
|
2
|
+
|
|
3
|
+
デプロイメント図(ノード・エッジ・ポート)を SVG で描画する React コンポーネントです。
|
|
4
|
+
|
|
5
|
+
- ノードは `children` で入れ子にできます。宣言サイズより子が大きい場合は親が自動で広がります。
|
|
6
|
+
- ノードはドラッグで移動でき、**親を動かすとサブツリーごと追従**します。
|
|
7
|
+
- エッジの取り付け位置はポートの角度で指定します(0=真下・時計回り。90=左 / 180=真上 / 270=右)。
|
|
8
|
+
- **このライブラリは描画のみを行います。** クリックはコールバックで通知するだけで、
|
|
9
|
+
編集 UI は利用側が用意します(ショーケースではインスペクタ `@yanqirenshi/colonoscope` を繋いでいます)。
|
|
10
|
+
|
|
11
|
+
## インストール
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @yanqirenshi/d3.deployment
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
React 18 / 19 に対応しています(`peerDependencies`)。
|
|
18
|
+
|
|
19
|
+
## 使い方
|
|
20
|
+
|
|
21
|
+
描画の管理オブジェクト `Rectum` を作って React コンポーネント `D3Deployment` に渡し、
|
|
22
|
+
`data()` でデータを流し込みます。
|
|
23
|
+
|
|
24
|
+
```jsx
|
|
25
|
+
import React from 'react';
|
|
26
|
+
import D3Deployment, { Rectum } from '@yanqirenshi/d3.deployment';
|
|
27
|
+
|
|
28
|
+
export default function Graph({ data }) {
|
|
29
|
+
const [rectum, setRectum] = React.useState(null);
|
|
30
|
+
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
const r = new Rectum({
|
|
33
|
+
transform: { k: 0.6, x: 120, y: 120 }, // 初期のズーム / パン
|
|
34
|
+
callbacks: {
|
|
35
|
+
// 描画は行わず通知のみ。core は入力データそのもの
|
|
36
|
+
node: { click: (core, node) => {} },
|
|
37
|
+
edge: { click: (core, edge) => {} },
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
r.data(data);
|
|
41
|
+
setRectum(r);
|
|
42
|
+
}, [data]);
|
|
43
|
+
|
|
44
|
+
if (!rectum) return null;
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div style={{ width: '100%', height: '100%' }}>
|
|
48
|
+
<D3Deployment rectum={rectum} />
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 描画後にポートの角度を変える
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
rectum.setEdgePorts(edge_id, { from: 0, to: 180 }); // 省略した側は変更しない
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
入力データ側(`_core`)の角度を書き換えてから再フィットするので、
|
|
61
|
+
以後の再描画やコンポーネントの remount でも維持されます。
|
|
62
|
+
|
|
63
|
+
## 入力データ
|
|
64
|
+
|
|
65
|
+
`{ nodes, edges }` の連想配列です。
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
{
|
|
69
|
+
nodes: [
|
|
70
|
+
{
|
|
71
|
+
type: 'NODE', id: 1,
|
|
72
|
+
label: { text: 'NODE 01', position: { x: 20, y: 20 }, font: { size: 16, color: '#333333' } },
|
|
73
|
+
description: 'ホバー時のツールチップに出る(任意)',
|
|
74
|
+
link: { url: 'https://example.com/' }, // 任意。ボックス左下に表示
|
|
75
|
+
padding: 40, // 任意。数値・全辺共通
|
|
76
|
+
size: { w: 150, h: 150 }, position: { x: 0, y: 0 },
|
|
77
|
+
children: [ /* 入れ子のノード */ ],
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
edges: [
|
|
81
|
+
{ id: 100, from: { id: 1, position: 0 }, to: { id: 2, position: 180 } },
|
|
82
|
+
],
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`edges[].from.id` / `to.id` は `nodes[].id` を参照します(入れ子の内側のノードも指定できます)。
|
|
87
|
+
|
|
88
|
+
フィールドの詳細はショーケースの d3.deployment のページ(「データ」タブ)を参照してください。
|
|
89
|
+
サンプルの実データは `showcase/src/demos/data/deployment-sample.js` です。
|
|
90
|
+
|
|
91
|
+
## 開発
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npm run transpile -w @yanqirenshi/d3.deployment # src -> dist(dist はコミット対象)
|
|
95
|
+
npm test -w @yanqirenshi/d3.deployment # jest
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Author
|
|
99
|
+
|
|
100
|
+
Satoshi Iwasaki (yanqirenshi@gmail.com)
|
|
101
|
+
|
|
102
|
+
## Copyright
|
|
103
|
+
|
|
104
|
+
Copyright (c) 2018-2026 Satoshi Iwasaki (yanqirenshi@gmail.com)
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
Licensed under the MIT License.
|
package/babel.config.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
presets: [
|
|
3
|
-
[
|
|
4
|
-
"@babel/preset-env"
|
|
5
|
-
]
|
|
6
|
-
],
|
|
7
|
-
env: {
|
|
8
|
-
test: {
|
|
9
|
-
plugins: [
|
|
10
|
-
"babel-plugin-transform-es2015-modules-commonjs",
|
|
11
|
-
],
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
};
|
|
1
|
+
module.exports = {
|
|
2
|
+
presets: [
|
|
3
|
+
[
|
|
4
|
+
"@babel/preset-env"
|
|
5
|
+
]
|
|
6
|
+
],
|
|
7
|
+
env: {
|
|
8
|
+
test: {
|
|
9
|
+
plugins: [
|
|
10
|
+
"babel-plugin-transform-es2015-modules-commonjs",
|
|
11
|
+
],
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports["default"] = D3Deployment;
|
|
8
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
8
|
var _assh0le = _interopRequireDefault(require("@yanqirenshi/assh0le"));
|
|
10
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
12
10
|
function D3Deployment(props) {
|
|
13
11
|
var rectum = props.rectum;
|
|
12
|
+
var id = props.id || "d3-deployment-graph";
|
|
14
13
|
return /*#__PURE__*/_react["default"].createElement(_assh0le["default"], {
|
|
15
|
-
id:
|
|
14
|
+
id: id,
|
|
16
15
|
rectum: rectum
|
|
17
16
|
});
|
|
18
17
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yanqirenshi/d3.deployment",
|
|
3
|
-
"version": "0.9.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.9.1",
|
|
4
|
+
"description": "Deployment diagram renderer (nestable nodes / edges / ports) — dragging a parent moves its whole subtree",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"directories": {
|
|
7
7
|
"doc": "docs"
|
|
@@ -26,19 +26,20 @@
|
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"test": "jest",
|
|
29
|
-
"transpile": "babel src -d dist --copy-files",
|
|
29
|
+
"transpile": "babel src -d dist --copy-files --delete-dir-on-start",
|
|
30
30
|
"prepublishOnly": "npm run transpile"
|
|
31
31
|
},
|
|
32
32
|
"repository": {
|
|
33
33
|
"type": "git",
|
|
34
|
-
"url": "git+https://github.com/
|
|
34
|
+
"url": "git+https://github.com/Foolsgolds/Assholes.git",
|
|
35
|
+
"directory": "packages/d3.deployment"
|
|
35
36
|
},
|
|
36
37
|
"author": "yanqirenshi@gmail.com",
|
|
37
38
|
"license": "MIT",
|
|
38
39
|
"bugs": {
|
|
39
|
-
"url": "https://github.com/
|
|
40
|
+
"url": "https://github.com/Foolsgolds/Assholes/issues"
|
|
40
41
|
},
|
|
41
|
-
"homepage": "https://github.com/
|
|
42
|
+
"homepage": "https://github.com/Foolsgolds/Assholes/tree/main/packages/d3.deployment#readme",
|
|
42
43
|
"publishConfig": {
|
|
43
44
|
"access": "public"
|
|
44
45
|
}
|