@nocobase/plugin-graph-collection-manager 0.10.1-alpha.1 → 0.11.1-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 (51) hide show
  1. package/client.d.ts +2 -3
  2. package/client.js +1 -30
  3. package/lib/client/GraphCollectionProvider.js +1 -14
  4. package/lib/client/GraphCollectionShortcut.js +2 -9
  5. package/lib/client/GraphDrawPage.js +53 -47
  6. package/lib/client/action-hooks.d.ts +14 -1
  7. package/lib/client/action-hooks.js +12 -11
  8. package/lib/client/components/EditCollectionAction.d.ts +2 -1
  9. package/lib/client/components/EditCollectionAction.js +3 -19
  10. package/lib/client/components/Entity.js +28 -47
  11. package/lib/client/components/FieldSummary.d.ts +1 -1
  12. package/lib/client/components/FieldSummary.js +9 -16
  13. package/lib/client/index.d.ts +5 -1
  14. package/lib/client/index.js +21 -6
  15. package/lib/client/style.d.ts +12 -9
  16. package/lib/client/style.js +211 -196
  17. package/lib/client/utils.d.ts +3 -3
  18. package/lib/client/utils.js +15 -11
  19. package/package.json +27 -6
  20. package/server.d.ts +2 -3
  21. package/server.js +1 -30
  22. package/src/client/GraphCollectionProvider.tsx +33 -0
  23. package/src/client/GraphCollectionShortcut.tsx +141 -0
  24. package/src/client/GraphDrawPage.tsx +1382 -0
  25. package/src/client/action-hooks.tsx +237 -0
  26. package/src/client/components/AddCollectionAction.tsx +28 -0
  27. package/src/client/components/AddFieldAction.tsx +37 -0
  28. package/src/client/components/CollectionNodeProvder.tsx +28 -0
  29. package/src/client/components/EditCollectionAction.tsx +21 -0
  30. package/src/client/components/EditFieldAction.tsx +30 -0
  31. package/src/client/components/Entity.tsx +495 -0
  32. package/src/client/components/FieldSummary.tsx +42 -0
  33. package/src/client/components/OverrideFieldAction.tsx +30 -0
  34. package/src/client/components/ViewFieldAction.tsx +12 -0
  35. package/src/client/components/ViewNode.tsx +22 -0
  36. package/src/client/index.tsx +10 -0
  37. package/src/client/locale/en-US.ts +15 -0
  38. package/src/client/locale/es-ES.ts +15 -0
  39. package/src/client/locale/index.ts +3 -0
  40. package/src/client/locale/ja-JP.ts +13 -0
  41. package/src/client/locale/pt-BR.ts +15 -0
  42. package/src/client/locale/zh-CN.ts +16 -0
  43. package/src/client/style.tsx +227 -0
  44. package/src/client/utils.tsx +548 -0
  45. package/src/index.ts +1 -0
  46. package/src/server/actions/.gitkeep +0 -0
  47. package/src/server/collections/.gitkeep +0 -0
  48. package/src/server/collections/graphPositions.ts +22 -0
  49. package/src/server/index.ts +13 -0
  50. package/src/server/models/.gitkeep +0 -0
  51. package/src/server/repositories/.gitkeep +0 -0
@@ -12,13 +12,6 @@ function _icons() {
12
12
  return data;
13
13
  }
14
14
  require("@antv/x6-react-shape");
15
- function _css() {
16
- const data = require("@emotion/css");
17
- _css = function _css() {
18
- return data;
19
- };
20
- return data;
21
- }
22
15
  function _shared() {
23
16
  const data = require("@formily/shared");
24
17
  _shared = function _shared() {
@@ -33,16 +26,16 @@ function _client() {
33
26
  };
34
27
  return data;
35
28
  }
36
- function _antd() {
37
- const data = require("antd");
38
- _antd = function _antd() {
29
+ function _client2() {
30
+ const data = require("@nocobase/utils/client");
31
+ _client2 = function _client2() {
39
32
  return data;
40
33
  };
41
34
  return data;
42
35
  }
43
- function _lodash() {
44
- const data = require("lodash");
45
- _lodash = function _lodash() {
36
+ function _antd() {
37
+ const data = require("antd");
38
+ _antd = function _antd() {
46
39
  return data;
47
40
  };
48
41
  return data;
@@ -55,7 +48,7 @@ function _react() {
55
48
  return data;
56
49
  }
57
50
  var _actionHooks = require("../action-hooks");
58
- var _style = require("../style");
51
+ var _style = _interopRequireDefault(require("../style"));
59
52
  var _utils = require("../utils");
60
53
  var _AddFieldAction = require("./AddFieldAction");
61
54
  var _CollectionNodeProvder = require("./CollectionNodeProvder");
@@ -64,6 +57,7 @@ var _EditFieldAction = require("./EditFieldAction");
64
57
  var _FieldSummary = require("./FieldSummary");
65
58
  var _OverrideFieldAction = require("./OverrideFieldAction");
66
59
  var _ViewFieldAction = require("./ViewFieldAction");
60
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
67
61
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
68
62
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
69
63
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -80,6 +74,8 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
80
74
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
81
75
  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); }
82
76
  const Entity = props => {
77
+ const _useStyles = (0, _style.default)(),
78
+ styles = _useStyles.styles;
83
79
  const node = props.node,
84
80
  setTargetNode = props.setTargetNode,
85
81
  targetGraph = props.targetGraph;
@@ -130,13 +126,14 @@ const Entity = props => {
130
126
  loadCollections
131
127
  };
132
128
  return _react().default.createElement("div", {
133
- className: (0, _css().cx)(_style.entityContainer),
129
+ className: styles.entityContainer,
134
130
  style: {
135
131
  boxShadow: attrs === null || attrs === void 0 ? void 0 : attrs.boxShadow,
136
132
  border: select ? '2px dashed #f5a20a' : 0
137
133
  }
138
134
  }, category.map((v, index) => {
139
135
  return _react().default.createElement(_antd().Badge.Ribbon, {
136
+ key: index,
140
137
  color: v.color,
141
138
  style: {
142
139
  width: '103%',
@@ -147,15 +144,15 @@ const Entity = props => {
147
144
  placement: "start"
148
145
  });
149
146
  }), _react().default.createElement("div", {
150
- className: _style.headClass,
147
+ className: styles.headClass,
151
148
  style: {
152
- background: (attrs === null || attrs === void 0 ? void 0 : attrs.hightLight) ? '#1890ff' : null,
149
+ background: attrs !== null && attrs !== void 0 && attrs.hightLight ? '#1890ff' : null,
153
150
  paddingTop: category.length * 3
154
151
  }
155
152
  }, _react().default.createElement("span", {
156
- className: _style.tableNameClass
153
+ className: styles.tableNameClass
157
154
  }, compile(title)), _react().default.createElement("div", {
158
- className: _style.tableBtnClass
155
+ className: styles.tableBtnClass
159
156
  }, _react().default.createElement(_client().SchemaComponentProvider, null, _react().default.createElement(_CollectionNodeProvder.CollectionNodeProvder, {
160
157
  setTargetNode: setTargetNode,
161
158
  node: node
@@ -192,7 +189,8 @@ const Entity = props => {
192
189
  'x-component': 'EditCollectionAction',
193
190
  'x-component-props': {
194
191
  type: 'primary',
195
- item: collectionData.current
192
+ item: collectionData.current,
193
+ className: 'btn-edit-in-head'
196
194
  }
197
195
  },
198
196
  delete: {
@@ -202,16 +200,7 @@ const Entity = props => {
202
200
  'x-component-props': {
203
201
  component: _icons().DeleteOutlined,
204
202
  icon: 'DeleteOutlined',
205
- className: (0, _css().css)`
206
- background-color: rgb(255 236 232);
207
- border-color: transparent;
208
- color: #e31c1c;
209
- height: 20px;
210
- padding: 5px;
211
- &:hover {
212
- background-color: rgb(253 205 197);
213
- }
214
- `,
203
+ className: 'btn-del',
215
204
  confirm: {
216
205
  title: "{{t('Delete record')}}",
217
206
  getContainer: _utils.getPopupContainer,
@@ -252,7 +241,7 @@ const PortsCom = _react().default.memo(({
252
241
  t = _useGCMTranslation.t;
253
242
  const compile = (0, _client().useCompile)();
254
243
  const database = (0, _client().useCurrentAppInfo)();
255
- const portsData = (0, _lodash().groupBy)(ports.items, v => {
244
+ const portsData = _client2().lodash.groupBy(ports.items, v => {
256
245
  if (v.isForeignKey || v.primaryKey || ['obo', 'oho', 'o2o', 'o2m', 'm2o', 'm2m', 'linkTo', 'id'].includes(v.interface)) {
257
246
  return 'initPorts';
258
247
  } else {
@@ -263,13 +252,15 @@ const PortsCom = _react().default.memo(({
263
252
  return `${prefix || ''}${(0, _shared().uid)()}`;
264
253
  };
265
254
  const CollectionConten = data => {
255
+ const _useStyles2 = (0, _style.default)(),
256
+ styles = _useStyles2.styles;
266
257
  const type = data.type,
267
258
  name = data.name,
268
259
  primaryKey = data.primaryKey,
269
260
  allowNull = data.allowNull,
270
261
  autoIncrement = data.autoIncrement;
271
262
  return _react().default.createElement("div", {
272
- className: (0, _css().cx)(_style.collectiionPopoverClass)
263
+ className: styles.collectionPopoverClass
273
264
  }, _react().default.createElement("div", {
274
265
  className: "field-content"
275
266
  }, _react().default.createElement("div", null, _react().default.createElement("span", null, "name"), ": ", _react().default.createElement("span", {
@@ -305,7 +296,7 @@ const PortsCom = _react().default.memo(({
305
296
  Form: _client().Form,
306
297
  ResourceActionProvider: _client().ResourceActionProvider,
307
298
  Select: props => _react().default.createElement(_client().Select, _objectSpread(_objectSpread({
308
- dropdownMatchSelectWidth: false
299
+ popupMatchSelectWidth: false
309
300
  }, props), {}, {
310
301
  getPopupContainer: _utils.getPopupContainer
311
302
  })),
@@ -375,17 +366,7 @@ const PortsCom = _react().default.memo(({
375
366
  'x-component-props': {
376
367
  component: _icons().DeleteOutlined,
377
368
  icon: 'DeleteOutlined',
378
- className: (0, _css().css)`
379
- background-color: rgb(255 236 232);
380
- border-color: transparent;
381
- color: #e31c1c;
382
- height: 20px;
383
- width: 20px;
384
- padding: 5px;
385
- &:hover {
386
- background-color: rgb(253 205 197);
387
- }
388
- `,
369
+ className: 'btn-del',
389
370
  confirm: {
390
371
  title: "{{t('Delete record')}}",
391
372
  getContainer: _utils.getPopupContainer,
@@ -474,7 +455,7 @@ const PortsCom = _react().default.memo(({
474
455
  key: property.id,
475
456
  id: property.id,
476
457
  style: {
477
- background: targetPort || sourcePort === property.id || (associated === null || associated === void 0 ? void 0 : associated.includes(property.name)) ? '#e6f7ff' : null
458
+ background: targetPort || sourcePort === property.id || associated !== null && associated !== void 0 && associated.includes(property.name) ? '#e6f7ff' : null
478
459
  }
479
460
  }, _react().default.createElement("div", {
480
461
  className: "name"
@@ -507,7 +488,7 @@ const PortsCom = _react().default.memo(({
507
488
  key: property.id,
508
489
  id: property.id,
509
490
  style: {
510
- background: targetPort || sourcePort === property.id || (associated === null || associated === void 0 ? void 0 : associated.includes(property.name)) ? '#e6f7ff' : null
491
+ background: targetPort || sourcePort === property.id || associated !== null && associated !== void 0 && associated.includes(property.name) ? '#e6f7ff' : null
511
492
  }
512
493
  }, _react().default.createElement("div", {
513
494
  className: "name"
@@ -519,7 +500,7 @@ const PortsCom = _react().default.memo(({
519
500
  property: property
520
501
  })));
521
502
  }))), _react().default.createElement("a", {
522
- className: (0, _css().css)`
503
+ className: (0, _client().css)`
523
504
  display: block;
524
505
  color: #958f8f;
525
506
  padding: 10px 5px;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const FieldSummary: React.MemoExoticComponent<import("@formily/react").ReactFC<Pick<any, string | number | symbol>>>;
2
+ export declare const FieldSummary: React.MemoExoticComponent<import("@formily/react").ReactFC<Omit<any, "ref">>>;
@@ -4,16 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.FieldSummary = void 0;
7
- function _css() {
8
- const data = require("@emotion/css");
9
- _css = function _css() {
7
+ function _react() {
8
+ const data = require("@formily/react");
9
+ _react = function _react() {
10
10
  return data;
11
11
  };
12
12
  return data;
13
13
  }
14
- function _react() {
15
- const data = require("@formily/react");
16
- _react = function _react() {
14
+ function _client() {
15
+ const data = require("@nocobase/client");
16
+ _client = function _client() {
17
17
  return data;
18
18
  };
19
19
  return data;
@@ -39,13 +39,6 @@ function _reactI18next() {
39
39
  };
40
40
  return data;
41
41
  }
42
- function _client() {
43
- const data = require("@nocobase/client");
44
- _client = function _client() {
45
- return data;
46
- };
47
- return data;
48
- }
49
42
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
50
43
  const FieldSummary = (0, _react().observer)(props => {
51
44
  const schemaKey = props.schemaKey;
@@ -57,15 +50,15 @@ const FieldSummary = (0, _react().observer)(props => {
57
50
  const schema = getInterface(schemaKey);
58
51
  if (!schema) return null;
59
52
  return _react2().default.createElement("div", {
60
- className: (0, _css().css)`
53
+ className: (0, _client().css)`
61
54
  background: #f6f6f6;
62
55
  margin-bottom: 24px;
63
56
  padding: 16px;
64
57
  `
65
58
  }, _react2().default.createElement("div", {
66
- className: (0, _css().css)``
59
+ className: (0, _client().css)``
67
60
  }, t('Field interface'), ": ", _react2().default.createElement(_antd().Tag, null, compile(schema.title))), schema.description ? _react2().default.createElement("div", {
68
- className: (0, _css().css)`
61
+ className: (0, _client().css)`
69
62
  margin-top: 8px;
70
63
  color: rgba(0, 0, 0, 0.45);
71
64
  `
@@ -1 +1,5 @@
1
- export { GraphCollectionProvider as default } from './GraphCollectionProvider';
1
+ import { Plugin } from '@nocobase/client';
2
+ export declare class GraphCollectionPlugin extends Plugin {
3
+ load(): Promise<void>;
4
+ }
5
+ export default GraphCollectionPlugin;
@@ -3,10 +3,25 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "default", {
7
- enumerable: true,
8
- get: function get() {
9
- return _GraphCollectionProvider.GraphCollectionProvider;
6
+ exports.default = exports.GraphCollectionPlugin = void 0;
7
+ function _client() {
8
+ const data = require("@nocobase/client");
9
+ _client = function _client() {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ var _GraphCollectionProvider = require("./GraphCollectionProvider");
15
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
16
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
17
+ class GraphCollectionPlugin extends _client().Plugin {
18
+ load() {
19
+ var _this = this;
20
+ return _asyncToGenerator(function* () {
21
+ _this.app.use(_GraphCollectionProvider.GraphCollectionProvider);
22
+ })();
10
23
  }
11
- });
12
- var _GraphCollectionProvider = require("./GraphCollectionProvider");
24
+ }
25
+ exports.GraphCollectionPlugin = GraphCollectionPlugin;
26
+ var _default = GraphCollectionPlugin;
27
+ exports.default = _default;
@@ -1,9 +1,12 @@
1
- export declare const nodeSubtreeClass: string;
2
- export declare const addButtonClass: string;
3
- export declare const entityContainer: string;
4
- export declare const headClass: string;
5
- export declare const tableNameClass: string;
6
- export declare const tableBtnClass: string;
7
- export declare const collectiionPopoverClass: string;
8
- export declare const collectionListClass: string;
9
- export declare const graphCollectionContainerClass: string;
1
+ declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
+ graphMinimap: import("antd-style").SerializedStyles;
3
+ addButtonClass: import("antd-style").SerializedStyles;
4
+ entityContainer: import("antd-style").SerializedStyles;
5
+ headClass: import("antd-style").SerializedStyles;
6
+ tableNameClass: import("antd-style").SerializedStyles;
7
+ tableBtnClass: import("antd-style").SerializedStyles;
8
+ collectionPopoverClass: import("antd-style").SerializedStyles;
9
+ collectionListClass: import("antd-style").SerializedStyles;
10
+ graphCollectionContainerClass: import("antd-style").SerializedStyles;
11
+ }>;
12
+ export default useStyles;