@nocobase/plugin-graph-collection-manager 0.11.1-alpha.4 → 0.12.0-alpha.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.
Files changed (100) hide show
  1. package/client.d.ts +2 -3
  2. package/client.js +1 -1
  3. package/dist/client/index.js +65917 -0
  4. package/{lib → dist}/client/utils.d.ts +4 -3
  5. package/{lib → dist}/index.d.ts +1 -0
  6. package/dist/index.js +18 -0
  7. package/dist/locale/en-US.js +19 -0
  8. package/dist/locale/es-ES.js +19 -0
  9. package/dist/locale/fr-FR.js +19 -0
  10. package/dist/locale/ja-JP.js +17 -0
  11. package/dist/locale/pt-BR.js +19 -0
  12. package/dist/locale/zh-CN.js +20 -0
  13. package/dist/server/collections/graphPositions.js +26 -0
  14. package/dist/server/index.js +23 -0
  15. package/package.json +17 -28
  16. package/server.d.ts +2 -3
  17. package/server.js +1 -1
  18. package/lib/client/GraphCollectionProvider.js +0 -51
  19. package/lib/client/GraphCollectionShortcut.js +0 -169
  20. package/lib/client/GraphDrawPage.js +0 -1546
  21. package/lib/client/action-hooks.js +0 -318
  22. package/lib/client/components/AddCollectionAction.js +0 -58
  23. package/lib/client/components/AddFieldAction.js +0 -69
  24. package/lib/client/components/CollectionNodeProvder.js +0 -34
  25. package/lib/client/components/EditCollectionAction.js +0 -47
  26. package/lib/client/components/EditFieldAction.js +0 -63
  27. package/lib/client/components/Entity.js +0 -529
  28. package/lib/client/components/FieldSummary.js +0 -69
  29. package/lib/client/components/OverrideFieldAction.js +0 -64
  30. package/lib/client/components/ViewFieldAction.js +0 -45
  31. package/lib/client/components/ViewNode.js +0 -33
  32. package/lib/client/index.js +0 -27
  33. package/lib/client/locale/index.js +0 -4
  34. package/lib/client/style.js +0 -233
  35. package/lib/client/utils.js +0 -540
  36. package/lib/index.js +0 -13
  37. package/lib/locale/en-US.js +0 -22
  38. package/lib/locale/es-ES.js +0 -22
  39. package/lib/locale/fr-FR.js +0 -22
  40. package/lib/locale/ja-JP.js +0 -20
  41. package/lib/locale/pt-BR.js +0 -22
  42. package/lib/locale/zh-CN.js +0 -23
  43. package/lib/server/collections/graphPositions.js +0 -30
  44. package/lib/server/index.js +0 -37
  45. package/src/client/GraphCollectionProvider.tsx +0 -33
  46. package/src/client/GraphCollectionShortcut.tsx +0 -141
  47. package/src/client/GraphDrawPage.tsx +0 -1382
  48. package/src/client/action-hooks.tsx +0 -237
  49. package/src/client/components/AddCollectionAction.tsx +0 -28
  50. package/src/client/components/AddFieldAction.tsx +0 -37
  51. package/src/client/components/CollectionNodeProvder.tsx +0 -28
  52. package/src/client/components/EditCollectionAction.tsx +0 -21
  53. package/src/client/components/EditFieldAction.tsx +0 -30
  54. package/src/client/components/Entity.tsx +0 -495
  55. package/src/client/components/FieldSummary.tsx +0 -42
  56. package/src/client/components/OverrideFieldAction.tsx +0 -30
  57. package/src/client/components/ViewFieldAction.tsx +0 -12
  58. package/src/client/components/ViewNode.tsx +0 -22
  59. package/src/client/index.tsx +0 -10
  60. package/src/client/locale/index.ts +0 -3
  61. package/src/client/style.tsx +0 -227
  62. package/src/client/utils.tsx +0 -548
  63. package/src/index.ts +0 -1
  64. package/src/locale/en-US.ts +0 -15
  65. package/src/locale/es-ES.ts +0 -15
  66. package/src/locale/fr-FR.ts +0 -15
  67. package/src/locale/ja-JP.ts +0 -13
  68. package/src/locale/pt-BR.ts +0 -15
  69. package/src/locale/zh-CN.ts +0 -16
  70. package/src/server/actions/.gitkeep +0 -0
  71. package/src/server/collections/.gitkeep +0 -0
  72. package/src/server/collections/graphPositions.ts +0 -22
  73. package/src/server/index.ts +0 -13
  74. package/src/server/models/.gitkeep +0 -0
  75. package/src/server/repositories/.gitkeep +0 -0
  76. /package/{lib → dist}/client/GraphCollectionProvider.d.ts +0 -0
  77. /package/{lib → dist}/client/GraphCollectionShortcut.d.ts +0 -0
  78. /package/{lib → dist}/client/GraphDrawPage.d.ts +0 -0
  79. /package/{lib → dist}/client/action-hooks.d.ts +0 -0
  80. /package/{lib → dist}/client/components/AddCollectionAction.d.ts +0 -0
  81. /package/{lib → dist}/client/components/AddFieldAction.d.ts +0 -0
  82. /package/{lib → dist}/client/components/CollectionNodeProvder.d.ts +0 -0
  83. /package/{lib → dist}/client/components/EditCollectionAction.d.ts +0 -0
  84. /package/{lib → dist}/client/components/EditFieldAction.d.ts +0 -0
  85. /package/{lib → dist}/client/components/Entity.d.ts +0 -0
  86. /package/{lib → dist}/client/components/FieldSummary.d.ts +0 -0
  87. /package/{lib → dist}/client/components/OverrideFieldAction.d.ts +0 -0
  88. /package/{lib → dist}/client/components/ViewFieldAction.d.ts +0 -0
  89. /package/{lib → dist}/client/components/ViewNode.d.ts +0 -0
  90. /package/{lib → dist}/client/index.d.ts +0 -0
  91. /package/{lib → dist}/client/locale/index.d.ts +0 -0
  92. /package/{lib → dist}/client/style.d.ts +0 -0
  93. /package/{lib → dist}/locale/en-US.d.ts +0 -0
  94. /package/{lib → dist}/locale/es-ES.d.ts +0 -0
  95. /package/{lib → dist}/locale/fr-FR.d.ts +0 -0
  96. /package/{lib → dist}/locale/ja-JP.d.ts +0 -0
  97. /package/{lib → dist}/locale/pt-BR.d.ts +0 -0
  98. /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
  99. /package/{lib → dist}/server/collections/graphPositions.d.ts +0 -0
  100. /package/{lib → dist}/server/index.d.ts +0 -0
@@ -1,540 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useGCMTranslation = exports.getPopupContainer = exports.getInheritCollections = exports.getDiffNode = exports.getDiffEdge = exports.getChildrenCollections = exports.formatPortData = exports.formatInheritEdgeData = exports.formatData = void 0;
7
- function _client() {
8
- const data = require("@nocobase/utils/client");
9
- _client = function _client() {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _reactI18next() {
15
- const data = require("react-i18next");
16
- _reactI18next = function _reactI18next() {
17
- return data;
18
- };
19
- return data;
20
- }
21
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
22
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
24
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
25
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
26
- const groupBy = _client().lodash.groupBy,
27
- reduce = _client().lodash.reduce,
28
- uniq = _client().lodash.uniq,
29
- uniqBy = _client().lodash.uniqBy;
30
- const shape = {
31
- ER: 'er-rect',
32
- EDGE: 'edge'
33
- };
34
- const useGCMTranslation = () => {
35
- return (0, _reactI18next().useTranslation)('graph-collection-manager');
36
- };
37
- exports.useGCMTranslation = useGCMTranslation;
38
- const getInheritCollections = (collections, name) => {
39
- const parents = [];
40
- const getParents = name => {
41
- const collection = collections === null || collections === void 0 ? void 0 : collections.find(collection => collection.name === name);
42
- if (collection) {
43
- const inherits = collection.inherits;
44
- if (inherits) {
45
- for (let index = 0; index < inherits.length; index++) {
46
- const collectionKey = inherits[index];
47
- parents.push(collectionKey);
48
- getParents(collectionKey);
49
- }
50
- }
51
- }
52
- return uniq(parents);
53
- };
54
- return getParents(name);
55
- };
56
- exports.getInheritCollections = getInheritCollections;
57
- const getChildrenCollections = (collections, name) => {
58
- const childrens = [];
59
- const getChildrens = name => {
60
- const inheritCollections = collections.filter(v => {
61
- var _v$inherits;
62
- return (_v$inherits = v.inherits) === null || _v$inherits === void 0 ? void 0 : _v$inherits.includes(name);
63
- });
64
- inheritCollections.forEach(v => {
65
- const collectionKey = v.name;
66
- childrens.push(v);
67
- return getChildrens(collectionKey);
68
- });
69
- return childrens;
70
- };
71
- return getChildrens(name);
72
- };
73
- exports.getChildrenCollections = getChildrenCollections;
74
- const formatData = data => {
75
- const edgeData = [];
76
- const targetTablekeys = [];
77
- const tableData = data.map((item, index) => {
78
- const ports = [];
79
- const totalFields = [...item.fields];
80
- const inheritCollections = getInheritCollections(data, item.name);
81
- const inheritedFields = reduce(inheritCollections, (result, value) => {
82
- var _data$find;
83
- const arr = result;
84
- const parentFields = (_data$find = data.find(k => k.name === value)) === null || _data$find === void 0 ? void 0 : _data$find.fields.map(v => {
85
- return _objectSpread(_objectSpread({}, v), {}, {
86
- sourceCollectionName: item.name
87
- });
88
- });
89
- return arr.concat(parentFields);
90
- }, []);
91
- uniqBy(totalFields.concat(inheritedFields), 'name').forEach(field => {
92
- field.uiSchema && ports.push(_objectSpread({
93
- id: field.key,
94
- group: 'list'
95
- }, field));
96
- ['obo', 'oho', 'o2o', 'o2m', 'm2o', 'm2m', 'linkTo'].includes(field.interface) && edgeData.push(field);
97
- });
98
- targetTablekeys.push(item.name);
99
- const portsData = formatPortData(ports);
100
- return {
101
- id: item.name,
102
- shape: shape.ER,
103
- name: item.name,
104
- title: item.title,
105
- width: 250,
106
- // height: 40 * portsData.initPorts?.length||40,
107
- ports: [...(portsData.initPorts || []), ...(portsData.morePorts || [])],
108
- item: item
109
- };
110
- });
111
- const edges = formatEdgeData(edgeData, targetTablekeys, tableData);
112
- const inheritEdges = formatInheritEdgeData(data);
113
- return {
114
- nodesData: tableData,
115
- edgesData: edges,
116
- inheritEdges
117
- };
118
- };
119
- exports.formatData = formatData;
120
- const formatPortData = ports => {
121
- const portsData = groupBy(ports, v => {
122
- if (v.isForeignKey || v.primaryKey || ['obo', 'oho', 'o2o', 'o2m', 'm2o', 'm2m', 'linkTo', 'id'].includes(v.interface)) {
123
- return 'initPorts';
124
- } else {
125
- return 'morePorts';
126
- }
127
- });
128
- return portsData;
129
- };
130
- exports.formatPortData = formatPortData;
131
- const formatInheritEdgeData = collections => {
132
- const commonAttrs = {
133
- attrs: {
134
- line: {
135
- strokeWidth: 1,
136
- textAnchor: 'middle',
137
- textVerticalAnchor: 'middle',
138
- stroke: '#ddd',
139
- sourceMarker: null
140
- // targetMarker: null,
141
- }
142
- },
143
-
144
- router: {
145
- name: 'smooth',
146
- args: {
147
- direction: 'H'
148
- }
149
- },
150
- labels: [{
151
- markup: [{
152
- tagName: 'ellipse',
153
- selector: 'labelBody',
154
- style: {
155
- cursor: 'pointer'
156
- }
157
- }, {
158
- tagName: 'text',
159
- selector: 'labelText',
160
- style: {
161
- cursor: 'pointer'
162
- }
163
- }],
164
- attrs: {
165
- labelText: {
166
- text: 'inherits',
167
- fill: 'rgba(0, 0, 0, 0.3)',
168
- textAnchor: 'middle',
169
- textVerticalAnchor: 'middle'
170
- },
171
- labelBody: {
172
- ref: 'labelText',
173
- refWidth: '100%',
174
- refHeight: '100%',
175
- fill: 'var(--nb-box-bg)'
176
- }
177
- },
178
- position: {
179
- distance: 0.5,
180
- args: {
181
- keepGradient: true,
182
- ensureLegibility: true
183
- }
184
- }
185
- }]
186
- };
187
- const inheritEdges = [];
188
- collections.forEach(v => {
189
- const parentCollectonKeys = v.inherits || [];
190
- if (parentCollectonKeys.length) {
191
- parentCollectonKeys.forEach(k => {
192
- inheritEdges.push(_objectSpread({
193
- id: v.name + k,
194
- source: {
195
- cell: v.name,
196
- connectionPoint: 'rect'
197
- },
198
- target: {
199
- cell: k,
200
- connectionPoint: 'rect'
201
- },
202
- connector: 'rounded',
203
- connectionType: 'inherited'
204
- }, commonAttrs));
205
- });
206
- }
207
- });
208
- return inheritEdges;
209
- };
210
- exports.formatInheritEdgeData = formatInheritEdgeData;
211
- const formatEdgeData = (data, targetTables, tableData) => {
212
- const edges = [];
213
- for (let i = 0; i < data.length; i++) {
214
- if (targetTables.includes(data[i].target)) {
215
- const targetTable = tableData.find(v => v.name === data[i].target);
216
- const sourceTable = tableData.find(v => v.name === (data[i].sourceCollectionName || data[i].collectionName));
217
- const commonAttrs = {
218
- attrs: {
219
- line: {
220
- strokeWidth: 1,
221
- textAnchor: 'middle',
222
- textVerticalAnchor: 'middle',
223
- stroke: '#ddd',
224
- sourceMarker: null,
225
- targetMarker: null
226
- }
227
- },
228
- router: sourceTable.id === targetTable.id ? {
229
- name: 'oneSide',
230
- args: {
231
- side: 'left'
232
- }
233
- } : {
234
- name: 'er',
235
- args: {
236
- direction: 'H'
237
- }
238
- },
239
- labels: [{
240
- markup: [{
241
- tagName: 'ellipse',
242
- selector: 'labelBody',
243
- style: {
244
- cursor: 'pointer'
245
- }
246
- }, {
247
- tagName: 'text',
248
- selector: 'labelText',
249
- style: {
250
- cursor: 'pointer'
251
- }
252
- }],
253
- attrs: {
254
- labelText: {
255
- text: getRelationship(data[i].interface)[0],
256
- fill: 'rgba(0, 0, 0, 0.3)',
257
- textAnchor: 'middle',
258
- textVerticalAnchor: 'middle'
259
- },
260
- labelBody: {
261
- ref: 'labelText',
262
- refWidth: '100%',
263
- refHeight: '100%',
264
- stroke: '#ddd',
265
- fill: 'var(--nb-box-bg)',
266
- strokeWidth: 1,
267
- rx: 10,
268
- ry: 10
269
- }
270
- },
271
- position: {
272
- distance: 0.3,
273
- args: {
274
- keepGradient: true,
275
- ensureLegibility: true
276
- }
277
- }
278
- }, {
279
- markup: [{
280
- tagName: 'ellipse',
281
- selector: 'labelBody',
282
- style: {
283
- cursor: 'pointer'
284
- }
285
- }, {
286
- tagName: 'text',
287
- selector: 'labelText',
288
- style: {
289
- cursor: 'pointer'
290
- }
291
- }],
292
- attrs: {
293
- labelText: {
294
- text: getRelationship(data[i].interface)[1],
295
- fill: 'rgba(0, 0, 0, 0.3)',
296
- textAnchor: 'middle',
297
- textVerticalAnchor: 'middle'
298
- },
299
- labelBody: {
300
- ref: 'labelText',
301
- refWidth: '100%',
302
- refHeight: '100%',
303
- stroke: '#ddd',
304
- fill: 'var(--nb-box-bg)',
305
- rx: 10,
306
- ry: 10,
307
- strokeWidth: 1
308
- }
309
- },
310
- position: {
311
- distance: 0.7,
312
- args: {
313
- keepGradient: true,
314
- ensureLegibility: true
315
- }
316
- }
317
- }]
318
- };
319
- const isuniq = id => {
320
- const targetEdge = edges.find(v => v.id === id);
321
- if (targetEdge) {
322
- targetEdge.associated.push(data[i].name);
323
- return false;
324
- }
325
- return true;
326
- };
327
- if (['m2m', 'linkTo'].includes(data[i].interface)) {
328
- const throughTable = tableData.find(v => v.name === data[i].through);
329
- if (throughTable) {
330
- var _sourceTable$ports$fi, _throughTable$ports$f, _targetTable$ports$fi, _throughTable$ports$f2;
331
- const sCellId1 = sourceTable.id;
332
- const tCellId1 = throughTable.id;
333
- const sPortId1 = (_sourceTable$ports$fi = sourceTable.ports.find(v => v.name === data[i].sourceKey)) === null || _sourceTable$ports$fi === void 0 ? void 0 : _sourceTable$ports$fi.id;
334
- const tPortId1 = (_throughTable$ports$f = throughTable.ports.find(v => v.name === data[i].foreignKey)) === null || _throughTable$ports$f === void 0 ? void 0 : _throughTable$ports$f.id;
335
- const sCellId2 = targetTable.id;
336
- const tCellId2 = throughTable.id;
337
- const sPortId2 = (_targetTable$ports$fi = targetTable.ports.find(v => v.name === data[i].targetKey)) === null || _targetTable$ports$fi === void 0 ? void 0 : _targetTable$ports$fi.id;
338
- const tPortId2 = (_throughTable$ports$f2 = throughTable.ports.find(v => v.name === data[i].otherKey)) === null || _throughTable$ports$f2 === void 0 ? void 0 : _throughTable$ports$f2.id;
339
- const id1 = sCellId1 + sPortId1 + tCellId1 + tPortId1;
340
- const id2 = sCellId2 + sPortId2 + tCellId2 + tPortId2;
341
- edges.push(_objectSpread({
342
- id: id1,
343
- source: {
344
- cell: sCellId1,
345
- port: sPortId1,
346
- anchor: {
347
- name: 'right'
348
- }
349
- },
350
- target: {
351
- cell: tCellId1,
352
- port: tPortId1,
353
- anchor: {
354
- name: 'left'
355
- }
356
- },
357
- associated: [data[i].name],
358
- m2m: [id1, id2]
359
- }, commonAttrs));
360
- edges.push(_objectSpread({
361
- id: id2,
362
- source: {
363
- cell: sCellId2,
364
- port: sPortId2,
365
- anchor: {
366
- name: 'right'
367
- }
368
- },
369
- target: {
370
- cell: tCellId2,
371
- port: tPortId2,
372
- anchor: {
373
- name: 'left'
374
- }
375
- },
376
- associated: [data[i].name],
377
- m2m: [id1, id2]
378
- }, commonAttrs));
379
- }
380
- } else {
381
- var _targetTable$ports$fi2, _sourceTable$ports$fi2, _targetTable$ports$fi3;
382
- const isLegalEdge = tableData.find(v => v.name == (data[i].sourceCollectionName || data[i].collectionName)).ports.find(v => v.name === data[i].foreignKey);
383
- const sCellId1 = sourceTable.id;
384
- const tCellId1 = targetTable.id;
385
- const sPortId1 = isLegalEdge === null || isLegalEdge === void 0 ? void 0 : isLegalEdge.id;
386
- const tPortId1 = (_targetTable$ports$fi2 = targetTable.ports.find(v => v.name === data[i].targetKey)) === null || _targetTable$ports$fi2 === void 0 ? void 0 : _targetTable$ports$fi2.id;
387
- const sCellId2 = sourceTable.id;
388
- const tCellId2 = targetTable.id;
389
- const sPortId2 = (_sourceTable$ports$fi2 = sourceTable.ports.find(v => v.name === data[i].sourceKey)) === null || _sourceTable$ports$fi2 === void 0 ? void 0 : _sourceTable$ports$fi2.id;
390
- const tPortId2 = (_targetTable$ports$fi3 = targetTable.ports.find(v => v.name === data[i].foreignKey)) === null || _targetTable$ports$fi3 === void 0 ? void 0 : _targetTable$ports$fi3.id;
391
- const id1 = sCellId1 + sPortId1 + tCellId1 + tPortId1;
392
- const id2 = sCellId2 + sPortId2 + tCellId2 + tPortId2;
393
- isuniq(tCellId1 + tPortId1 + sCellId1 + sPortId1) && isLegalEdge && tPortId1 && edges.push(_objectSpread({
394
- id: id1,
395
- source: {
396
- cell: sCellId1,
397
- port: sPortId1,
398
- anchor: {
399
- name: 'right'
400
- }
401
- },
402
- target: {
403
- cell: tCellId1,
404
- port: tPortId1,
405
- anchor: {
406
- name: 'left'
407
- }
408
- },
409
- associated: [data[i].name]
410
- }, commonAttrs));
411
- isuniq(tCellId2 + tPortId2 + sCellId2 + sPortId2) && sPortId2 && tPortId2 && edges.push(_objectSpread({
412
- id: id2,
413
- source: {
414
- cell: sCellId2,
415
- port: sPortId2,
416
- anchor: {
417
- name: 'right'
418
- }
419
- },
420
- target: {
421
- cell: tCellId2,
422
- port: tPortId2,
423
- anchor: {
424
- name: 'left'
425
- }
426
- },
427
- associated: [data[i].name]
428
- }, commonAttrs));
429
- }
430
- }
431
- }
432
- return uniqBy(edges, 'id');
433
- };
434
- const getRelationship = relatioship => {
435
- switch (relatioship) {
436
- case 'm2m':
437
- case 'linkTo':
438
- return ['1', 'N'];
439
- case 'o2m':
440
- return ['1', 'N'];
441
- case 'm2o':
442
- return ['N', '1'];
443
- case 'obo':
444
- case 'oho':
445
- return ['1', '1'];
446
- default:
447
- return [];
448
- }
449
- };
450
- const getDiffNode = (newNodes, oldNodes) => {
451
- const arr = [];
452
- const length1 = newNodes.length;
453
- const length2 = oldNodes.length;
454
- for (let i = 0; i < length1; i++) {
455
- if (!oldNodes.find(v => v.id === newNodes[i].id)) {
456
- arr.push({
457
- status: 'add',
458
- node: newNodes[i]
459
- });
460
- } else {
461
- const oldNode = oldNodes.find(v => v.id === newNodes[i].id);
462
- const oldPorts = oldNode === null || oldNode === void 0 ? void 0 : oldNode.ports.items;
463
- const newPorts = newNodes[i].ports;
464
- if (oldNode) {
465
- for (let h = 0; h < newPorts.length; h++) {
466
- if (!oldPorts.find(v => v.id === newPorts[h].id)) {
467
- arr.push({
468
- status: 'insertPort',
469
- node: newNodes[i],
470
- port: {
471
- index: h,
472
- port: newPorts[h]
473
- }
474
- });
475
- }
476
- }
477
- for (let k = 0; k < oldPorts.length; k++) {
478
- if (!newPorts.find(v => v.id === oldPorts[k].id)) {
479
- arr.push({
480
- status: 'deletePort',
481
- node: newNodes[i],
482
- port: oldPorts[k]
483
- });
484
- }
485
- }
486
- if (oldNode.title !== newNodes[i].title) {
487
- arr.push({
488
- status: 'updateNode',
489
- node: newNodes[i]
490
- });
491
- }
492
- }
493
- }
494
- }
495
- for (let i = 0; i < length2; i++) {
496
- if (!newNodes.find(v => v.id === oldNodes[i].id)) {
497
- arr.push({
498
- status: 'delete',
499
- node: oldNodes[i]
500
- });
501
- }
502
- }
503
- return arr;
504
- };
505
- exports.getDiffNode = getDiffNode;
506
- const getDiffEdge = (newEdges, oldEdges) => {
507
- const length1 = newEdges.length;
508
- const length2 = oldEdges === null || oldEdges === void 0 ? void 0 : oldEdges.length;
509
- const edges = [];
510
- for (let i = 0; i < length1; i++) {
511
- if (!oldEdges.find(v => v.id === newEdges[i].id)) {
512
- edges.push({
513
- status: 'add',
514
- edge: newEdges[i]
515
- });
516
- }
517
- }
518
- for (let i = 0; i < length2; i++) {
519
- if (!newEdges.find(v => v.id === oldEdges[i].id)) {
520
- edges.push({
521
- status: 'delete',
522
- edge: oldEdges[i]
523
- });
524
- }
525
- }
526
- return edges;
527
- };
528
- exports.getDiffEdge = getDiffEdge;
529
- let graphContainer;
530
- /**
531
- * 所有的 getPopupContainer 都需要保证返回的是唯一的 div。React 18 concurrent 下会反复调用该方法
532
- * 参考:https://ant.design/docs/react/migration-v5-cn#%E5%8D%87%E7%BA%A7%E5%87%86%E5%A4%87
533
- */
534
- const getPopupContainer = () => {
535
- if (graphContainer) {
536
- return graphContainer;
537
- }
538
- return graphContainer = document.getElementById('graph_container');
539
- };
540
- exports.getPopupContainer = getPopupContainer;
package/lib/index.js DELETED
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "default", {
7
- enumerable: true,
8
- get: function get() {
9
- return _server.default;
10
- }
11
- });
12
- var _server = _interopRequireDefault(require("./server"));
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = {
8
- 'Graph Collection': 'Graph Collection',
9
- 'Collection List': 'Collection List',
10
- 'Full Screen': 'Full Screen',
11
- 'Collection Search': 'Collection Search',
12
- 'Create Collection': 'Create Collection',
13
- 'All Fields': 'All Fields',
14
- 'Association Fields': 'Association Fields',
15
- 'Choices fields': 'Choices fields',
16
- 'All relationships': 'All relationships',
17
- 'Entity relationship only': 'Entity relationship only',
18
- 'Inheritance relationship only': 'Inheritance relationship only',
19
- 'Graphical interface': 'Graphical interface',
20
- Selection: 'Selection'
21
- };
22
- exports.default = _default;
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = {
8
- "Graph Collection": "Colección de gráficos",
9
- "Collection List": "Lista de colecciones",
10
- "Full Screen": "Vista completa",
11
- "Collection Search": "Búsqueda de colecciones",
12
- "Create Collection": "Crear colección",
13
- "All Fields": "Todos los campos",
14
- "Association Fields": "Campos de asociación",
15
- "Optional fields": "Campos opcionales",
16
- "All relationships": "Todas las relaciones",
17
- "Entity relationship only": "Sólo relaciones de entidad",
18
- "Inheritance relationship only": "Sólo relaciones de herencia",
19
- "Graphical interface": "Interfaz gráfica",
20
- "Selection": "Selección"
21
- };
22
- exports.default = _default;
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = {
8
- 'Graph Collection': 'Collection de graphiques',
9
- 'Collection List': 'Liste des collections',
10
- 'Full Screen': 'Plein écran',
11
- 'Collection Search': 'Recherche de collection',
12
- 'Create Collection': 'Créer une collection',
13
- 'All Fields': 'Tous les champs',
14
- 'Association Fields': "Champs d'association",
15
- 'Choices fields': 'Champs de choix',
16
- 'All relationships': 'Toutes les relations',
17
- 'Entity relationship only': "Uniquement les relations d'entité",
18
- 'Inheritance relationship only': "Uniquement les relations d'héritage",
19
- 'Graphical interface': 'Interface graphique',
20
- Selection: 'Sélection'
21
- };
22
- exports.default = _default;
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = {
8
- 'Graph Collection': 'グラフ化データテーブル',
9
- 'Collection List': 'データテーブルリスト',
10
- 'Full Screen': 'フルスクリーン',
11
- 'Collection Search': '表フィルタ',
12
- 'Create Collection': 'データテーブルの作成',
13
- 'All Fields': 'すべて',
14
- 'Associations Fields': '関係フィールド',
15
- 'All relationships': 'すべての関係',
16
- 'Entity relationship only': 'エンティティ関係',
17
- 'Inheritance relationship only': '継承関係',
18
- Selection: 'せんたく'
19
- };
20
- exports.default = _default;
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = {
8
- 'Graph Collection': 'Coleção de Gráficos',
9
- 'Collection List': 'Lista de Coleções',
10
- 'Full Screen': 'Tela Cheia',
11
- 'Collection Search': 'Busca de Coleção',
12
- 'Create Collection': 'Criar Coleção',
13
- 'All Fields': 'Todos os Campos',
14
- 'Association Fields': 'Campos de Associação',
15
- 'Choices fields': 'Campos de opções',
16
- 'All relationships': 'Todos os relacionamentos',
17
- 'Entity relationship only': 'Somente relação de Entidade',
18
- 'Inheritance relationship only': 'Somente relação de Herança',
19
- 'Graphical interface': 'Interface Gráfica',
20
- Selection: 'Seleção'
21
- };
22
- exports.default = _default;
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = {
8
- 'Graph Collection': '图形化数据表',
9
- 'Collection List': '数据表列表',
10
- 'Full Screen': '全屏',
11
- 'Collection Search': '表筛选',
12
- 'Create Collection': '创建数据表',
13
- 'All Fields': '全部',
14
- 'Association Fields': '关系字段',
15
- 'Choices fields': '选项字段',
16
- 'All relationships': '所有关系',
17
- 'Entity relationship only': '实体关系',
18
- 'Inheritance relationship only': '继承关系',
19
- 'Graphical interface': '图形化界面',
20
- 'Auto layout': '自动布局',
21
- Selection: '选择模式'
22
- };
23
- exports.default = _default;