@yanqirenshi/d3.ter 0.2.1 → 0.4.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.md +10 -3
- package/dist/index.d.ts +28 -0
- package/dist/js/Entity.js +13 -61
- package/dist/js/Painters/Entities.js +58 -0
- package/dist/js/Port.js +5 -2
- package/dist/js/Relationship.js +10 -10
- package/jest.config.js +4 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -9,6 +9,9 @@ TM(T字形ER手法)の ER 図(TER)を SVG で描画する React コン
|
|
|
9
9
|
- サブセットへの結線は区分コード(=同一 / ×相違)付きの分岐(幹 + バス + 垂下)で描きます。
|
|
10
10
|
- 対応表・対照表・再帰表は、結線の中点の○から垂下線でぶら下げます(`mapping`)。
|
|
11
11
|
- エンティティはドラッグで移動でき、結線・記号・垂下線が追従します。
|
|
12
|
+
動かし終えたことは `callbacks.entity.dragend(core, entity, move)` で受け取れます(v0.4.0+)。
|
|
13
|
+
- 種別バッジ・配色・端点の角度の既定(0=真下)は [`@yanqirenshi/model.tm`](../model.tm) から取ります。
|
|
14
|
+
インスペクタや保存は model.tm と組み合わせます(ショーケースの `model.tm` のデモ)。
|
|
12
15
|
|
|
13
16
|
## インストール
|
|
14
17
|
|
|
@@ -35,9 +38,13 @@ export default function Graph({ data }) {
|
|
|
35
38
|
transform: { k: 0.7, x: 200, y: 60 }, // 初期のズーム / パン
|
|
36
39
|
svg: { style: { background: '#fff' } },
|
|
37
40
|
callbacks: {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
// contextmenu は右クリック。引数は click と同じで、最後に event(MouseEvent)。
|
|
42
|
+
// 渡したときだけブラウザ標準のメニューを止める。ドラッグ中は呼ばれない
|
|
43
|
+
entity: { click: (d) => {}, contextmenu: (d, event) => {},
|
|
44
|
+
// ドラッグの終わり(動いたときだけ)。core は入力の entity、move は移動量 { dx, dy }
|
|
45
|
+
dragend: (core, entity, move) => {} },
|
|
46
|
+
identifier: { click: (d) => {}, contextmenu: (d, event) => {} },
|
|
47
|
+
attribute: { click: (d) => {}, contextmenu: (d, event) => {} },
|
|
41
48
|
relationship: { click: (d) => {} },
|
|
42
49
|
},
|
|
43
50
|
}));
|
package/dist/index.d.ts
CHANGED
|
@@ -184,6 +184,34 @@ export interface TerCallbacks {
|
|
|
184
184
|
entity?: {
|
|
185
185
|
/** エンティティのクリック通知(正規化済みデータが渡される) */
|
|
186
186
|
click?: ((entity: TerEntityDatum) => void) | null;
|
|
187
|
+
/**
|
|
188
|
+
* エンティティの右クリック通知。引数は click と同じで、最後に event が付く。
|
|
189
|
+
* 渡したときだけブラウザ標準のコンテキストメニューを止める。
|
|
190
|
+
* 左ボタンを押したまま(ドラッグ中)の右クリックでは呼ばれない。
|
|
191
|
+
*/
|
|
192
|
+
contextmenu?: ((entity: TerEntityDatum, event: MouseEvent) => void) | null;
|
|
193
|
+
/**
|
|
194
|
+
* エンティティをドラッグして動かし終えたときの通知(動いたときだけ。v0.4.0+)。
|
|
195
|
+
* core は入力の TerEntity、move は移動量 { dx, dy }(世界座標)。
|
|
196
|
+
* @yanqirenshi/model.tm の movePatch(core, move) にそのまま渡せる。
|
|
197
|
+
*/
|
|
198
|
+
dragend?: ((core: TerEntity, entity: TerEntityDatum, move: { dx: number; dy: number }) => void) | null;
|
|
199
|
+
};
|
|
200
|
+
relationship?: {
|
|
201
|
+
/** 結線(線・自己結線のループ)のクリック通知。_core に入力(TerRelationship)が入る */
|
|
202
|
+
click?: ((relationship: { _id: number | string; _core: TerRelationship; [key: string]: unknown }) => void) | null;
|
|
203
|
+
};
|
|
204
|
+
identifier?: {
|
|
205
|
+
/** 識別子の行のクリック通知 */
|
|
206
|
+
click?: ((identifier: unknown) => void) | null;
|
|
207
|
+
/** 識別子の行の右クリック通知(扱いは entity.contextmenu と同じ) */
|
|
208
|
+
contextmenu?: ((identifier: unknown, event: MouseEvent) => void) | null;
|
|
209
|
+
};
|
|
210
|
+
attribute?: {
|
|
211
|
+
/** 属性の行のクリック通知 */
|
|
212
|
+
click?: ((attribute: unknown) => void) | null;
|
|
213
|
+
/** 属性の行の右クリック通知(扱いは entity.contextmenu と同じ) */
|
|
214
|
+
contextmenu?: ((attribute: unknown, event: MouseEvent) => void) | null;
|
|
187
215
|
};
|
|
188
216
|
}
|
|
189
217
|
|
package/dist/js/Entity.js
CHANGED
|
@@ -9,6 +9,7 @@ var _Atman2 = _interopRequireDefault(require("./Atman.js"));
|
|
|
9
9
|
var _IdentifierInstance = _interopRequireDefault(require("./IdentifierInstance.js"));
|
|
10
10
|
var _AttributeInstance = _interopRequireDefault(require("./AttributeInstance.js"));
|
|
11
11
|
var _assh0le = require("@yanqirenshi/assh0le");
|
|
12
|
+
var _model = require("@yanqirenshi/model.tm");
|
|
12
13
|
var _Name = _interopRequireDefault(require("./utils/Name.js"));
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
14
15
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
@@ -28,7 +29,7 @@ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError(
|
|
|
28
29
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
29
30
|
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
30
31
|
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); }
|
|
31
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
32
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } // 種別バッジと配色は図ごとの知識なので model.tm が持つ(Foolsgolds/Assholes#144)
|
|
32
33
|
var Entity = exports["default"] = /*#__PURE__*/function (_Atman) {
|
|
33
34
|
function Entity(data, rectum) {
|
|
34
35
|
var _this;
|
|
@@ -253,78 +254,29 @@ var Entity = exports["default"] = /*#__PURE__*/function (_Atman) {
|
|
|
253
254
|
/** **************************************************************** *
|
|
254
255
|
*
|
|
255
256
|
* **************************************************************** */
|
|
257
|
+
/**
|
|
258
|
+
* 種別バッジ(箱のヘッダ右の文字)。値は model.tm の TYPE_BADGES
|
|
259
|
+
* (Rsc / Evt / 対照 / 対応 / 再帰 / MO / MA。CLASS は意図的にバッジ無し = 空文字)。
|
|
260
|
+
* 知らない種別は例外(model.tm の check でも事前に検出できる)。
|
|
261
|
+
*/
|
|
256
262
|
}, {
|
|
257
263
|
key: "entityTypeContents",
|
|
258
264
|
value: function entityTypeContents() {
|
|
259
265
|
var type = this._core.type;
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
case 'RESOURCE-SUBSET':
|
|
264
|
-
return 'Rsc';
|
|
265
|
-
case 'COMPARATIVE':
|
|
266
|
-
return '対照';
|
|
267
|
-
case 'CORRESPONDENCE':
|
|
268
|
-
return '対応';
|
|
269
|
-
case 'EVENT':
|
|
270
|
-
return 'Evt';
|
|
271
|
-
case 'EVENT-SUBSET':
|
|
272
|
-
return 'Evt';
|
|
273
|
-
case 'RECURSION':
|
|
274
|
-
return '再帰';
|
|
275
|
-
// TM(T字形ER)の多値。MO=多値のOR(配列の正規形)、MA=多値のAND(HDR-DTL 構成)
|
|
276
|
-
case 'MANY-VALUED-OR':
|
|
277
|
-
return 'MO';
|
|
278
|
-
case 'MANY-VALUED-AND':
|
|
279
|
-
return 'MA';
|
|
280
|
-
// TM の「クラス」(モノに混入した別の性質の切り出し。例: 従業員.入社)。
|
|
281
|
-
// 種別バッジを持たない(空文字 = 意図的なバッジ無し)
|
|
282
|
-
case 'CLASS':
|
|
283
|
-
return '';
|
|
284
|
-
default:
|
|
285
|
-
throw new Error(type + " は知らないよ。");
|
|
286
|
-
}
|
|
266
|
+
var badge = _model.TYPE_BADGES[type];
|
|
267
|
+
if (badge === undefined) throw new Error(type + " は知らないよ。");
|
|
268
|
+
return badge;
|
|
287
269
|
}
|
|
288
270
|
/** **************************************************************** *
|
|
289
271
|
*
|
|
290
272
|
* **************************************************************** */
|
|
273
|
+
/** 箱の背景色。値は model.tm の TYPE_COLORS(種別ごと) */
|
|
291
274
|
}, {
|
|
292
275
|
key: "entityBackground",
|
|
293
276
|
value: function entityBackground() {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
color: '#89c3eb'
|
|
297
|
-
},
|
|
298
|
-
"resource-subset": {
|
|
299
|
-
color: '#a0d8ef'
|
|
300
|
-
},
|
|
301
|
-
"event": {
|
|
302
|
-
color: '#f09199'
|
|
303
|
-
},
|
|
304
|
-
"event-subset": {
|
|
305
|
-
color: '#f6bfbc'
|
|
306
|
-
},
|
|
307
|
-
"comparative": {
|
|
308
|
-
color: '#c8d5bb'
|
|
309
|
-
},
|
|
310
|
-
"correspondence": {
|
|
311
|
-
color: '#f2f2b0'
|
|
312
|
-
},
|
|
313
|
-
"recursion": {
|
|
314
|
-
color: '#dbd0e6'
|
|
315
|
-
},
|
|
316
|
-
"many-valued-or": {
|
|
317
|
-
color: '#fddea5'
|
|
318
|
-
},
|
|
319
|
-
"many-valued-and": {
|
|
320
|
-
color: '#9fd5c9'
|
|
321
|
-
},
|
|
322
|
-
"class": {
|
|
323
|
-
color: '#bdc0ba'
|
|
324
|
-
}
|
|
277
|
+
return {
|
|
278
|
+
color: _model.TYPE_COLORS[this._core.type]
|
|
325
279
|
};
|
|
326
|
-
var key = this._core.type.toLowerCase();
|
|
327
|
-
return background[key];
|
|
328
280
|
}
|
|
329
281
|
/** **************************************************************** *
|
|
330
282
|
*
|
|
@@ -8,6 +8,12 @@ var d3 = _interopRequireWildcard(require("d3"));
|
|
|
8
8
|
var _assh0le = require("@yanqirenshi/assh0le");
|
|
9
9
|
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); }
|
|
10
10
|
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); }
|
|
11
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
14
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
11
17
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
12
18
|
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); } }
|
|
13
19
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
@@ -320,6 +326,11 @@ var Entities = exports["default"] = /*#__PURE__*/function () {
|
|
|
320
326
|
start: {
|
|
321
327
|
x: event.x,
|
|
322
328
|
y: event.y
|
|
329
|
+
},
|
|
330
|
+
// dragend で移動量を出すために、掴んだときのエンティティの位置も覚える
|
|
331
|
+
origin: {
|
|
332
|
+
x: entity.position.x,
|
|
333
|
+
y: entity.position.y
|
|
323
334
|
}
|
|
324
335
|
};
|
|
325
336
|
}
|
|
@@ -331,10 +342,26 @@ var Entities = exports["default"] = /*#__PURE__*/function () {
|
|
|
331
342
|
this.moveEntity(entity);
|
|
332
343
|
this.moveEdges(entity);
|
|
333
344
|
}
|
|
345
|
+
/**
|
|
346
|
+
* ドラッグの終わり。動いたときだけ callbacks.entity.dragend(core, entity, move) を呼ぶ。
|
|
347
|
+
* core: 入力のレコード(entity._core。TerEntity)
|
|
348
|
+
* entity: 正規化済みのエンティティ(position は動かしたあとの位置)
|
|
349
|
+
* move: 移動量 { dx, dy }(世界座標)。model.tm の movePatch(core, move) にそのまま渡せる
|
|
350
|
+
* 動かさずに離したとき(クリック)は呼ばない(保存が走らないように)。
|
|
351
|
+
*/
|
|
334
352
|
}, {
|
|
335
353
|
key: "dragEnd",
|
|
336
354
|
value: function dragEnd(event, entity) {
|
|
355
|
+
var origin = entity._drag && entity._drag.origin;
|
|
337
356
|
delete entity._drag;
|
|
357
|
+
if (!origin) return;
|
|
358
|
+
var move = {
|
|
359
|
+
dx: entity.position.x - origin.x,
|
|
360
|
+
dy: entity.position.y - origin.y
|
|
361
|
+
};
|
|
362
|
+
if (move.dx === 0 && move.dy === 0) return;
|
|
363
|
+
var func = this.callbacks().entity.dragend;
|
|
364
|
+
if (func) func(entity._core, entity, move);
|
|
338
365
|
}
|
|
339
366
|
}, {
|
|
340
367
|
key: "addMoveEvents",
|
|
@@ -373,6 +400,7 @@ var Entities = exports["default"] = /*#__PURE__*/function () {
|
|
|
373
400
|
key: "draw",
|
|
374
401
|
value: function draw(entities) {
|
|
375
402
|
var groups = this._box.draw(this.foreground(), entities);
|
|
403
|
+
this.attachContextmenu(groups);
|
|
376
404
|
|
|
377
405
|
// resizing & redraw
|
|
378
406
|
groups.each(function (entity) {
|
|
@@ -381,5 +409,35 @@ var Entities = exports["default"] = /*#__PURE__*/function () {
|
|
|
381
409
|
this.redraw(groups);
|
|
382
410
|
return groups;
|
|
383
411
|
}
|
|
412
|
+
/**
|
|
413
|
+
* 右クリックの通知(callbacks.entity / identifier / attribute の contextmenu)。
|
|
414
|
+
* 引数は click と同じで、最後に event を付ける。
|
|
415
|
+
*
|
|
416
|
+
* CompartmentBox は onClick しか持たないので、描いたあとで click と同じ
|
|
417
|
+
* 要素に付ける(共通基盤の assh0le には手を入れない)。
|
|
418
|
+
* コールバックが無いときと、左ボタンを押したまま(ドラッグ中)のときは
|
|
419
|
+
* 何もしない(ブラウザ標準のコンテキストメニューが出る)。
|
|
420
|
+
*/
|
|
421
|
+
}, {
|
|
422
|
+
key: "attachContextmenu",
|
|
423
|
+
value: function attachContextmenu(groups) {
|
|
424
|
+
var _this3 = this;
|
|
425
|
+
var targets = [['entity', 'rect.entity-title, text.entity-title'], ['identifier', 'text.identifier'], ['attribute', 'text.attribute']];
|
|
426
|
+
var _loop = function _loop() {
|
|
427
|
+
var _targets$_i = _slicedToArray(_targets[_i], 2),
|
|
428
|
+
name = _targets$_i[0],
|
|
429
|
+
selector = _targets$_i[1];
|
|
430
|
+
groups.selectAll(selector).on('contextmenu', function (event, d) {
|
|
431
|
+
var func = (_this3.callbacks()[name] || {}).contextmenu;
|
|
432
|
+
if (!func || event.buttons & 1) return;
|
|
433
|
+
event.preventDefault();
|
|
434
|
+
event.stopPropagation();
|
|
435
|
+
func(d, event);
|
|
436
|
+
});
|
|
437
|
+
};
|
|
438
|
+
for (var _i = 0, _targets = targets; _i < _targets.length; _i++) {
|
|
439
|
+
_loop();
|
|
440
|
+
}
|
|
441
|
+
}
|
|
384
442
|
}]);
|
|
385
443
|
}();
|
package/dist/js/Port.js
CHANGED
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports["default"] = void 0;
|
|
8
8
|
var _Atman2 = _interopRequireDefault(require("./Atman.js"));
|
|
9
9
|
var _assh0le = require("@yanqirenshi/assh0le");
|
|
10
|
+
var _model = require("@yanqirenshi/model.tm");
|
|
10
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
12
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
12
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); } }
|
|
@@ -19,7 +20,7 @@ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError(
|
|
|
19
20
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
20
21
|
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
21
22
|
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); }
|
|
22
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
23
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } // 端点の角度の既定(0=真下)は図ごとの知識なので model.tm が持つ(Foolsgolds/Assholes#144)
|
|
23
24
|
var Port = exports["default"] = /*#__PURE__*/function (_Atman) {
|
|
24
25
|
function Port(type, entity, relatihonship_data, rectum) {
|
|
25
26
|
var _this;
|
|
@@ -79,10 +80,12 @@ var Port = exports["default"] = /*#__PURE__*/function (_Atman) {
|
|
|
79
80
|
value: function core() {
|
|
80
81
|
return this._core;
|
|
81
82
|
}
|
|
83
|
+
/** 取り付け角度。無ければ model.tm の既定(0=真下) */
|
|
82
84
|
}, {
|
|
83
85
|
key: "degree",
|
|
84
86
|
value: function degree() {
|
|
85
|
-
|
|
87
|
+
var position = this._core.position;
|
|
88
|
+
return typeof position === 'number' && Number.isFinite(position) ? position : _model.RELATIONSHIP_DEFAULTS.end.position;
|
|
86
89
|
}
|
|
87
90
|
}, {
|
|
88
91
|
key: "position",
|
package/dist/js/Relationship.js
CHANGED
|
@@ -37,11 +37,11 @@ var Relationship = exports["default"] = /*#__PURE__*/function (_Atman) {
|
|
|
37
37
|
value: function label() {
|
|
38
38
|
return this._core.label || null;
|
|
39
39
|
}
|
|
40
|
-
/**
|
|
41
|
-
* TM のサブセット結線に添える区分コードの表記。
|
|
42
|
-
* =区分コード … 同一のサブセット(kind: 'same')
|
|
43
|
-
* ×区分コード … 相違のサブセット(kind: 'different'。'same' 以外は×扱い)
|
|
44
|
-
* 入力の relationship.subset = { kind, code }。無ければ null(表示なし)。
|
|
40
|
+
/**
|
|
41
|
+
* TM のサブセット結線に添える区分コードの表記。
|
|
42
|
+
* =区分コード … 同一のサブセット(kind: 'same')
|
|
43
|
+
* ×区分コード … 相違のサブセット(kind: 'different'。'same' 以外は×扱い)
|
|
44
|
+
* 入力の relationship.subset = { kind, code }。無ければ null(表示なし)。
|
|
45
45
|
*/
|
|
46
46
|
}, {
|
|
47
47
|
key: "subsetLabel",
|
|
@@ -50,11 +50,11 @@ var Relationship = exports["default"] = /*#__PURE__*/function (_Atman) {
|
|
|
50
50
|
if (!subset || !subset.code) return null;
|
|
51
51
|
return (subset.kind === 'same' ? '=' : '×') + subset.code;
|
|
52
52
|
}
|
|
53
|
-
/**
|
|
54
|
-
* TM の対応表/対照表(mapping)。この結線の中点(○)から垂下線で
|
|
55
|
-
* ぶら下げる対応表(CORRESPONDENCE)/対照表(COMPARATIVE)の Entity。
|
|
56
|
-
* 入力の relationship.mapping = { entity: id } を Rectum が
|
|
57
|
-
* データ構築時に解決してセットする。無ければ null(垂下なし)。
|
|
53
|
+
/**
|
|
54
|
+
* TM の対応表/対照表(mapping)。この結線の中点(○)から垂下線で
|
|
55
|
+
* ぶら下げる対応表(CORRESPONDENCE)/対照表(COMPARATIVE)の Entity。
|
|
56
|
+
* 入力の relationship.mapping = { entity: id } を Rectum が
|
|
57
|
+
* データ構築時に解決してセットする。無ければ null(垂下なし)。
|
|
58
58
|
*/
|
|
59
59
|
}, {
|
|
60
60
|
key: "mapping",
|
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.tm は ESM のみを main にしている。jest 25 は package.json の exports を見ないので、
|
|
14
|
+
// CommonJS 版(model.tm の build が dist/cjs/ に出す)へ直接マップする。
|
|
15
|
+
// model.tm を先にビルドしておくこと(npm run build -w @yanqirenshi/model.tm)。
|
|
16
|
+
'^@yanqirenshi/model.tm$': '<rootDir>/../model.tm/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.ter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"author": "yanqirenshi@gmail.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "TM (T-shaped ER method) diagram renderer — 10 entity kinds, cardinality/optionality markers, and correspondence / comparative / recursion tables hung from a connector",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"d3": "^7.9.0",
|
|
33
33
|
"@yanqirenshi/assh0le": "^0.5.0",
|
|
34
|
+
"@yanqirenshi/model.tm": "^0.1.0",
|
|
34
35
|
"@yanqirenshi/types": "^0.1.0",
|
|
35
36
|
"deepmerge": "^4.2.2"
|
|
36
37
|
},
|