@yanqirenshi/d3.deployment 0.9.1 → 0.11.0
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/README.markdown +10 -3
- package/babel.config.js +14 -14
- package/dist/js/Rectum.js +88 -27
- package/dist/js/datamodels/Edge.js +8 -7
- package/dist/js/datamodels/Node.js +8 -5
- package/jest.config.js +4 -0
- package/package.json +3 -2
package/README.markdown
CHANGED
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
- ノードは `children` で入れ子にできます。宣言サイズより子が大きい場合は親が自動で広がります。
|
|
6
6
|
- ノードはドラッグで移動でき、**親を動かすとサブツリーごと追従**します。
|
|
7
|
+
動かし終えたことは `callbacks.node.dragend(core, node, move)` で受け取れます(v0.11.0+)。
|
|
8
|
+
- 既定値(枠線・背景・線の stroke と矢印・端点の角度 90)は [`@yanqirenshi/model.deployment`](../model.deployment) から取ります。
|
|
9
|
+
インスペクタや保存は model.deployment と組み合わせます(ショーケースの `model.deployment` のデモ)。
|
|
7
10
|
- エッジの取り付け位置はポートの角度で指定します(0=真下・時計回り。90=左 / 180=真上 / 270=右)。
|
|
8
|
-
- **このライブラリは描画のみを行います。**
|
|
11
|
+
- **このライブラリは描画のみを行います。** クリックと右クリックはコールバックで通知するだけで、
|
|
9
12
|
編集 UI は利用側が用意します(ショーケースではインスペクタ `@yanqirenshi/colonoscope` を繋いでいます)。
|
|
10
13
|
|
|
11
14
|
## インストール
|
|
@@ -33,8 +36,12 @@ export default function Graph({ data }) {
|
|
|
33
36
|
transform: { k: 0.6, x: 120, y: 120 }, // 初期のズーム / パン
|
|
34
37
|
callbacks: {
|
|
35
38
|
// 描画は行わず通知のみ。core は入力データそのもの
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
// contextmenu は右クリック。引数は click と同じで、最後に event(MouseEvent)。
|
|
40
|
+
// 渡したときだけブラウザ標準のメニューを止める。ドラッグ中は呼ばれない
|
|
41
|
+
node: { click: (core, node) => {}, contextmenu: (core, node, event) => {},
|
|
42
|
+
// ドラッグの終わり(動いたときだけ)。move は移動量 { dx, dy }。model.deployment の movePatch(core, move) に渡せる
|
|
43
|
+
dragend: (core, node, move) => {} },
|
|
44
|
+
edge: { click: (core, edge) => {}, contextmenu: (core, edge, event) => {} },
|
|
38
45
|
},
|
|
39
46
|
});
|
|
40
47
|
r.data(data);
|
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
|
+
};
|
package/dist/js/Rectum.js
CHANGED
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports["default"] = void 0;
|
|
8
8
|
var d3 = _interopRequireWildcard(require("d3"));
|
|
9
9
|
var _assh0le = require("@yanqirenshi/assh0le");
|
|
10
|
+
var _model = require("@yanqirenshi/model.deployment");
|
|
10
11
|
var _Node = _interopRequireDefault(require("./datamodels/Node.js"));
|
|
11
12
|
var _Edge = _interopRequireDefault(require("./datamodels/Edge.js"));
|
|
12
13
|
var _Port = _interopRequireDefault(require("./datamodels/Port.js"));
|
|
@@ -32,7 +33,27 @@ function _get() { return _get = "undefined" != typeof Reflect && Reflect.get ? R
|
|
|
32
33
|
function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
|
|
33
34
|
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
34
35
|
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
35
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
36
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } // 端点の角度の既定(90=左)は図ごとの知識なので @yanqirenshi/model.deployment が持つ(Foolsgolds/Assholes#146)
|
|
37
|
+
/**
|
|
38
|
+
* click / contextmenu のコールバックを呼ぶ。
|
|
39
|
+
*
|
|
40
|
+
* contextmenu(右クリック)のときだけ次のようにする。
|
|
41
|
+
* - 左ボタンを押したまま(ドラッグ中)の右クリックは通知しない
|
|
42
|
+
* - ブラウザ標準のコンテキストメニューを止める(コールバックがあるときだけ
|
|
43
|
+
* ここに来るので、渡していなければ標準のメニューが出る)
|
|
44
|
+
* - 最後の引数に event を渡す(clientX / clientY を使えるように)
|
|
45
|
+
*/
|
|
46
|
+
var notify = function notify(callback, event, core, datum) {
|
|
47
|
+
if (event.type === 'contextmenu') {
|
|
48
|
+
if (event.buttons & 1) return;
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
event.stopPropagation();
|
|
51
|
+
callback(core, datum, event);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
event.stopPropagation();
|
|
55
|
+
callback(core, datum);
|
|
56
|
+
};
|
|
36
57
|
var Rectum = exports["default"] = /*#__PURE__*/function (_Colon) {
|
|
37
58
|
function Rectum(params) {
|
|
38
59
|
var _this;
|
|
@@ -67,10 +88,14 @@ var Rectum = exports["default"] = /*#__PURE__*/function (_Colon) {
|
|
|
67
88
|
var edge = callbacks.edge || {};
|
|
68
89
|
return {
|
|
69
90
|
node: {
|
|
70
|
-
click: node.click || null
|
|
91
|
+
click: node.click || null,
|
|
92
|
+
contextmenu: node.contextmenu || null,
|
|
93
|
+
// ドラッグの終わり(動いたときだけ)。(core, node, move) を渡す
|
|
94
|
+
dragend: node.dragend || null
|
|
71
95
|
},
|
|
72
96
|
edge: {
|
|
73
|
-
click: edge.click || null
|
|
97
|
+
click: edge.click || null,
|
|
98
|
+
contextmenu: edge.contextmenu || null
|
|
74
99
|
}
|
|
75
100
|
};
|
|
76
101
|
}
|
|
@@ -247,7 +272,9 @@ var Rectum = exports["default"] = /*#__PURE__*/function (_Colon) {
|
|
|
247
272
|
value: function fittingPort(port) {
|
|
248
273
|
var port_pos;
|
|
249
274
|
if (port._type === 'FROM') port_pos = port.edge._core.from.position;else port_pos = port.edge._core.to.position;
|
|
250
|
-
|
|
275
|
+
|
|
276
|
+
// 角度が無ければモデルの既定(90=左)。Geometry.getPortLineTo も同じ値に倒すが、既定の出どころはモデル側
|
|
277
|
+
var position = this.positioningPort(port, (0, _model.degreeOf)(port_pos), port.node);
|
|
251
278
|
port.position = position;
|
|
252
279
|
}
|
|
253
280
|
}, {
|
|
@@ -414,56 +441,61 @@ var Rectum = exports["default"] = /*#__PURE__*/function (_Colon) {
|
|
|
414
441
|
_iterator8.f();
|
|
415
442
|
}
|
|
416
443
|
this.attachNodeDrag(place, data);
|
|
417
|
-
this.
|
|
418
|
-
this.
|
|
444
|
+
this.attachNodeEvent(place, 'click');
|
|
445
|
+
this.attachNodeEvent(place, 'contextmenu');
|
|
446
|
+
this.attachEdgeEvent(place, 'click');
|
|
447
|
+
this.attachEdgeEvent(place, 'contextmenu');
|
|
419
448
|
}
|
|
420
449
|
/**
|
|
421
|
-
* ノードのクリック通知(callbacks.node.click)
|
|
450
|
+
* ノードのクリック通知(callbacks.node.click)と
|
|
451
|
+
* 右クリック通知(callbacks.node.contextmenu)。
|
|
422
452
|
* d3.drag は移動を伴ったクリックを抑止するため、静止クリックだけが届く。
|
|
423
453
|
*
|
|
424
|
-
* コールバックには (core, node) を渡す。
|
|
454
|
+
* コールバックには (core, node) を渡す。contextmenu は最後に event も渡す。
|
|
425
455
|
* core: 入力データそのまま(ライブラリが解釈しないフィールドも落ちない)
|
|
426
456
|
* node: 正規化済みデータ(位置・サイズ等が必要な場合に使う)
|
|
427
457
|
*
|
|
428
458
|
* リンク(a.link-alt)のクリックはリンク側を優先し、コールバックは発火しない。
|
|
459
|
+
*
|
|
460
|
+
* @param {string} type 'click' | 'contextmenu'
|
|
429
461
|
*/
|
|
430
462
|
}, {
|
|
431
|
-
key: "
|
|
432
|
-
value: function
|
|
433
|
-
var callback = this._callbacks.node
|
|
463
|
+
key: "attachNodeEvent",
|
|
464
|
+
value: function attachNodeEvent(place, type) {
|
|
465
|
+
var callback = this._callbacks.node[type];
|
|
434
466
|
if (!callback) return;
|
|
435
|
-
place.selectAll('g.node, g.component').on(
|
|
467
|
+
place.selectAll('g.node, g.component').on(type, function (event, d) {
|
|
436
468
|
var target = event.target;
|
|
437
469
|
if (target && target.closest && target.closest('a.link-alt')) return; // リンク優先(既存の <a target="_blank"> と干渉しない)
|
|
438
470
|
|
|
439
|
-
event.
|
|
440
|
-
callback(d._core, d);
|
|
471
|
+
notify(callback, event, d._core, d);
|
|
441
472
|
});
|
|
442
473
|
}
|
|
443
474
|
/**
|
|
444
|
-
* エッジのクリック通知(callbacks.edge.click)
|
|
475
|
+
* エッジのクリック通知(callbacks.edge.click)と
|
|
476
|
+
* 右クリック通知(callbacks.edge.contextmenu)。
|
|
445
477
|
* エッジ path のほか、両端のポート円からも同じエッジを通知する
|
|
446
478
|
* (細い線より円のほうが掴みやすい)。(core, edge) を渡す契約は
|
|
447
|
-
* node.click と同じ(core = 入力のエッジオブジェクトそのまま)。
|
|
479
|
+
* node.click / node.contextmenu と同じ(core = 入力のエッジオブジェクトそのまま)。
|
|
480
|
+
*
|
|
481
|
+
* @param {string} type 'click' | 'contextmenu'
|
|
448
482
|
*/
|
|
449
483
|
}, {
|
|
450
|
-
key: "
|
|
451
|
-
value: function
|
|
484
|
+
key: "attachEdgeEvent",
|
|
485
|
+
value: function attachEdgeEvent(place, type) {
|
|
452
486
|
var _this5 = this;
|
|
453
|
-
var callback = this._callbacks.edge
|
|
487
|
+
var callback = this._callbacks.edge[type];
|
|
454
488
|
if (!callback) return;
|
|
455
|
-
place.selectAll('path.edge').style('cursor', 'pointer').on(
|
|
489
|
+
place.selectAll('path.edge').style('cursor', 'pointer').on(type, function (event) {
|
|
456
490
|
// path の datum は線分データのため data-edge-id からエッジを引く
|
|
457
491
|
var el = event.currentTarget;
|
|
458
492
|
var id = el && el.getAttribute && el.getAttribute('data-edge-id');
|
|
459
493
|
var edge = _this5.findEdge(id);
|
|
460
494
|
if (!edge) return;
|
|
461
|
-
event.
|
|
462
|
-
callback(edge._core, edge);
|
|
495
|
+
notify(callback, event, edge._core, edge);
|
|
463
496
|
});
|
|
464
|
-
place.selectAll('circle.port').style('cursor', 'pointer').on(
|
|
465
|
-
event.
|
|
466
|
-
callback(d.edge._core, d.edge);
|
|
497
|
+
place.selectAll('circle.port').style('cursor', 'pointer').on(type, function (event, d) {
|
|
498
|
+
notify(callback, event, d.edge._core, d.edge);
|
|
467
499
|
});
|
|
468
500
|
}
|
|
469
501
|
/** id(入力 id。DOM の data-edge-id は文字列)からエッジを引く。 */
|
|
@@ -525,17 +557,46 @@ var Rectum = exports["default"] = /*#__PURE__*/function (_Colon) {
|
|
|
525
557
|
// Next.js(Webpack/SWC)のトランスパイルで `this` が書き換わり得るため、
|
|
526
558
|
// 掴んだ要素は sourceEvent から closest() で取り、クロージャで保持する。
|
|
527
559
|
var grabbed = null;
|
|
528
|
-
|
|
560
|
+
|
|
561
|
+
// dragend(callbacks.node.dragend)で移動量を出すために、掴んだときの位置を覚える
|
|
562
|
+
var origin = null;
|
|
563
|
+
var drag = d3.drag().on('start', function (event, node) {
|
|
529
564
|
grabbed = event.sourceEvent.target.closest('g.node, g.component');
|
|
530
565
|
if (grabbed) grabbed.style.cursor = 'grabbing';
|
|
566
|
+
origin = {
|
|
567
|
+
x: node._position.x,
|
|
568
|
+
y: node._position.y
|
|
569
|
+
};
|
|
531
570
|
}).on('drag', function (event, node) {
|
|
532
571
|
self.moveSubtree(place, data, node, event.dx, event.dy);
|
|
533
|
-
}).on('end', function () {
|
|
572
|
+
}).on('end', function (event, node) {
|
|
534
573
|
if (grabbed) grabbed.style.cursor = 'grab';
|
|
535
574
|
grabbed = null;
|
|
575
|
+
self.notifyDragend(node, origin);
|
|
576
|
+
origin = null;
|
|
536
577
|
});
|
|
537
578
|
place.selectAll('g.node, g.component').style('cursor', 'grab').call(drag);
|
|
538
579
|
}
|
|
580
|
+
/**
|
|
581
|
+
* ドラッグの終わり。動いたときだけ callbacks.node.dragend(core, node, move) を呼ぶ。
|
|
582
|
+
* core: 入力のレコード(node._core)
|
|
583
|
+
* node: 正規化済みのノード(_position は動かしたあとの位置)
|
|
584
|
+
* move: 移動量 { dx, dy }(世界座標)。model.deployment の movePatch(core, move) にそのまま渡せる
|
|
585
|
+
* 動かさずに離したとき(クリック)は呼ばない(保存が走らないように)。
|
|
586
|
+
* 掴んだノード(node / component)についてだけ呼ぶ(子孫はいっしょに動くが、position は親の中での位置なので変わらない)。
|
|
587
|
+
*/
|
|
588
|
+
}, {
|
|
589
|
+
key: "notifyDragend",
|
|
590
|
+
value: function notifyDragend(node, origin) {
|
|
591
|
+
var callback = this._callbacks.node.dragend;
|
|
592
|
+
if (!callback || !origin) return;
|
|
593
|
+
var move = {
|
|
594
|
+
dx: node._position.x - origin.x,
|
|
595
|
+
dy: node._position.y - origin.y
|
|
596
|
+
};
|
|
597
|
+
if (move.dx === 0 && move.dy === 0) return;
|
|
598
|
+
callback(node._core, node, move);
|
|
599
|
+
}
|
|
539
600
|
/** node を根とするサブツリーの node._id 集合を返す。 */
|
|
540
601
|
}, {
|
|
541
602
|
key: "collectSubtree",
|
|
@@ -4,12 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
+
var _model = require("@yanqirenshi/model.deployment");
|
|
7
8
|
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); }
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
8
12
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
9
13
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
10
14
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
11
15
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
12
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // 線の既定(stroke と矢印)は図ごとの知識なので @yanqirenshi/model.deployment が持つ(Foolsgolds/Assholes#146)
|
|
13
17
|
/**
|
|
14
18
|
* Edge のデータクラス。入力データの正規化(既定値補完)を行う。
|
|
15
19
|
* 描画は painters/Edges.js が担当する。
|
|
@@ -41,12 +45,9 @@ var Edge = exports["default"] = /*#__PURE__*/function () {
|
|
|
41
45
|
}
|
|
42
46
|
},
|
|
43
47
|
stroke: {
|
|
44
|
-
color:
|
|
45
|
-
width:
|
|
46
|
-
marker: {
|
|
47
|
-
start: false,
|
|
48
|
-
end: true
|
|
49
|
-
}
|
|
48
|
+
color: _model.EDGE_DEFAULTS.stroke.color,
|
|
49
|
+
width: _model.EDGE_DEFAULTS.stroke.width,
|
|
50
|
+
marker: _objectSpread({}, _model.EDGE_DEFAULTS.stroke.marker)
|
|
50
51
|
},
|
|
51
52
|
_id: null,
|
|
52
53
|
_core: null,
|
|
@@ -5,12 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _assh0le = require("@yanqirenshi/assh0le");
|
|
8
|
+
var _model = require("@yanqirenshi/model.deployment");
|
|
8
9
|
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); }
|
|
9
10
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
10
11
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
11
12
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
12
13
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
13
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // 枠線・背景の既定は図ごとの知識なので @yanqirenshi/model.deployment が持つ(Foolsgolds/Assholes#146)。
|
|
15
|
+
// 値は assh0le の Stroke.template / Background.template と同じ(model.deployment のテストが突き合わせる)。
|
|
14
16
|
/**
|
|
15
17
|
* Node のデータクラス。入力データの正規化(既定値補完)と幾何情報の提供を行う。
|
|
16
18
|
* 描画は painters/Nodes.js が担当する。
|
|
@@ -21,8 +23,6 @@ var Node = exports["default"] = /*#__PURE__*/function () {
|
|
|
21
23
|
this.label = new _assh0le.Label();
|
|
22
24
|
this.rectangle = new _assh0le.Rectangle();
|
|
23
25
|
this.position = new _assh0le.Position();
|
|
24
|
-
this.stroke = new _assh0le.Stroke();
|
|
25
|
-
this.background = new _assh0le.Background();
|
|
26
26
|
this.padding = new _assh0le.Padding();
|
|
27
27
|
}
|
|
28
28
|
///// ////////////////////////////////////////////////////////////////
|
|
@@ -124,9 +124,12 @@ var Node = exports["default"] = /*#__PURE__*/function () {
|
|
|
124
124
|
new_data.label = this.label.build(new_data._core.label);
|
|
125
125
|
new_data.size = this.rectangle.build(new_data._core.size);
|
|
126
126
|
new_data.position = this.position.build(new_data._core.position);
|
|
127
|
-
new_data.border = this.stroke.build(new_data._core.border) || this.stroke.template();
|
|
128
127
|
new_data.padding = this.padding.build(new_data._core.padding);
|
|
129
|
-
|
|
128
|
+
|
|
129
|
+
// 枠線・背景(既定に入力の truthy な項目を重ねる)は model.deployment の nodeStyle
|
|
130
|
+
var style = (0, _model.nodeStyle)(new_data._core);
|
|
131
|
+
new_data.border = style.border;
|
|
132
|
+
new_data.background = style.background;
|
|
130
133
|
data._node = new_data;
|
|
131
134
|
return new_data;
|
|
132
135
|
}
|
package/jest.config.js
CHANGED
|
@@ -10,6 +10,10 @@ module.exports = {
|
|
|
10
10
|
// d3 v7 は ESM-only で CJS ランタイムの jest では読めないため、スタブにマップする
|
|
11
11
|
moduleNameMapper: {
|
|
12
12
|
'^d3$': '<rootDir>/tests/d3-stub.js',
|
|
13
|
+
// model.deployment は ESM のみを main にしている。jest 25 は package.json の exports を見ないので、
|
|
14
|
+
// CommonJS 版(model.deployment の build が dist/cjs/ に出す)へ直接マップする。
|
|
15
|
+
// model.deployment を先にビルドしておくこと(npm run build -w @yanqirenshi/model.deployment)。
|
|
16
|
+
'^@yanqirenshi/model.deployment$': '<rootDir>/../model.deployment/dist/cjs/index.js',
|
|
13
17
|
},
|
|
14
18
|
collectCoverageFrom: [
|
|
15
19
|
"**/src/**/*.js",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yanqirenshi/d3.deployment",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
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": {
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"d3": "^7.9.0",
|
|
15
|
-
"@yanqirenshi/assh0le": "^0.5.0"
|
|
15
|
+
"@yanqirenshi/assh0le": "^0.5.0",
|
|
16
|
+
"@yanqirenshi/model.deployment": "^0.1.0"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
19
|
"@babel/cli": "^7.12.17",
|