@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
package/client.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
- export * from './lib/client';
3
- export { default } from './lib/client';
1
+ export * from './src/client';
2
+ export { default } from './src/client';
4
3
 
package/client.js CHANGED
@@ -1,30 +1 @@
1
- "use strict";
2
-
3
- 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); }
4
-
5
- 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; }
6
-
7
- var _index = _interopRequireWildcard(require("./lib/client"));
8
-
9
- Object.defineProperty(exports, "__esModule", {
10
- value: true
11
- });
12
- var _exportNames = {};
13
- Object.defineProperty(exports, "default", {
14
- enumerable: true,
15
- get: function get() {
16
- return _index.default;
17
- }
18
- });
19
-
20
- Object.keys(_index).forEach(function (key) {
21
- if (key === "default" || key === "__esModule") return;
22
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
23
- if (key in exports && exports[key] === _index[key]) return;
24
- Object.defineProperty(exports, key, {
25
- enumerable: true,
26
- get: function get() {
27
- return _index[key];
28
- }
29
- });
30
- });
1
+ module.exports = require('./lib/client/index.js');
@@ -20,7 +20,6 @@ function _react() {
20
20
  }
21
21
  var _GraphCollectionShortcut = require("./GraphCollectionShortcut");
22
22
  var _utils = require("./utils");
23
- const _excluded = ["routes", "components"];
24
23
  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); }
25
24
  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; }
26
25
  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; }
@@ -28,14 +27,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
28
27
  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; }
29
28
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
30
29
  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); }
31
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
32
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
33
30
  const GraphCollectionProvider = _react().default.memo(props => {
34
31
  const ctx = (0, _react().useContext)(_client().PluginManagerContext);
35
- const _useContext = (0, _react().useContext)(_client().RouteSwitchContext),
36
- routes = _useContext.routes,
37
- components = _useContext.components,
38
- others = _objectWithoutProperties(_useContext, _excluded);
39
32
  // i18n.addResources('en-US', 'graphPositions', enUS);
40
33
  // i18n.addResources('ja-JP', 'graphPositions', jaJP);
41
34
  // i18n.addResources('zh-CN', 'graphPositions', zhCN);
@@ -52,13 +45,7 @@ const GraphCollectionProvider = _react().default.memo(props => {
52
45
  value: {
53
46
  components: _objectSpread({}, ctx === null || ctx === void 0 ? void 0 : ctx.components)
54
47
  }
55
- }, _react().default.createElement(_client().RouteSwitchContext.Provider, {
56
- value: _objectSpread(_objectSpread({
57
- components: _objectSpread({}, components)
58
- }, others), {}, {
59
- routes
60
- })
61
- }, props.children)));
48
+ }, props.children));
62
49
  });
63
50
  exports.GraphCollectionProvider = GraphCollectionProvider;
64
51
  GraphCollectionProvider.displayName = 'GraphCollectionProvider';
@@ -11,13 +11,6 @@ function _icons() {
11
11
  };
12
12
  return data;
13
13
  }
14
- function _css() {
15
- const data = require("@emotion/css");
16
- _css = function _css() {
17
- return data;
18
- };
19
- return data;
20
- }
21
14
  function _shared() {
22
15
  const data = require("@formily/shared");
23
16
  _shared = function _shared() {
@@ -39,8 +32,8 @@ function _react() {
39
32
  };
40
33
  return data;
41
34
  }
42
- var _GraphDrawPage = require("./GraphDrawPage");
43
35
  var _actionHooks = require("./action-hooks");
36
+ var _GraphDrawPage = require("./GraphDrawPage");
44
37
  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); }
45
38
  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; }
46
39
  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; }
@@ -145,7 +138,7 @@ const useCollectionValues = options => {
145
138
  };
146
139
  const GraphCollectionPane = () => {
147
140
  return _react().default.createElement("div", {
148
- className: (0, _css().css)`
141
+ className: (0, _client().css)`
149
142
  height: calc(100vh - 160px);
150
143
  overflow: auto;
151
144
  margin: calc(var(--nb-spacing) * -1);
@@ -19,13 +19,6 @@ function _x4() {
19
19
  return data;
20
20
  }
21
21
  require("@antv/x6-react-shape");
22
- function _css() {
23
- const data = require("@emotion/css");
24
- _css = function _css() {
25
- return data;
26
- };
27
- return data;
28
- }
29
22
  function _react() {
30
23
  const data = require("@formily/react");
31
24
  _react = function _react() {
@@ -40,6 +33,13 @@ function _client() {
40
33
  };
41
34
  return data;
42
35
  }
36
+ function _client2() {
37
+ const data = require("@nocobase/utils/client");
38
+ _client2 = function _client2() {
39
+ return data;
40
+ };
41
+ return data;
42
+ }
43
43
  function _ahooks() {
44
44
  const data = require("ahooks");
45
45
  _ahooks = function _ahooks() {
@@ -61,13 +61,6 @@ function _dagre() {
61
61
  };
62
62
  return data;
63
63
  }
64
- function _lodash() {
65
- const data = require("lodash");
66
- _lodash = function _lodash() {
67
- return data;
68
- };
69
- return data;
70
- }
71
64
  function _react2() {
72
65
  const data = _interopRequireWildcard(require("react"));
73
66
  _react2 = function _react2() {
@@ -79,7 +72,7 @@ var _actionHooks = require("./action-hooks");
79
72
  var _AddCollectionAction = require("./components/AddCollectionAction");
80
73
  var _Entity = _interopRequireDefault(require("./components/Entity"));
81
74
  var _ViewNode = require("./components/ViewNode");
82
- var _style = require("./style");
75
+ var _style = _interopRequireDefault(require("./style"));
83
76
  var _utils = require("./utils");
84
77
  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); }
85
78
  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; }
@@ -97,6 +90,12 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
97
90
  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); }
98
91
  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); } }
99
92
  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); }); }; }
93
+ const drop = _client2().lodash.drop,
94
+ groupBy = _client2().lodash.groupBy,
95
+ last = _client2().lodash.last,
96
+ maxBy = _client2().lodash.maxBy,
97
+ minBy = _client2().lodash.minBy,
98
+ take = _client2().lodash.take;
100
99
  const LINE_HEIGHT = 40;
101
100
  const NODE_WIDTH = 250;
102
101
  let targetGraph;
@@ -184,7 +183,7 @@ function _layout() {
184
183
  });
185
184
  targetGraph.unfreeze();
186
185
  if (targetNode) {
187
- typeof targetNode === 'string' ? targetGraph.positionCell((0, _lodash().last)(nodes), 'top', {
186
+ typeof targetNode === 'string' ? targetGraph.positionCell(last(nodes), 'top', {
188
187
  padding: 100
189
188
  }) : targetGraph.positionCell(targetNode, 'top', {
190
189
  padding: 100
@@ -307,7 +306,7 @@ const formatNodeData = () => {
307
306
  layoutNodes.push(edge.getSourceCellId());
308
307
  layoutNodes.push(edge.getTargetCellId());
309
308
  });
310
- const nodeGroup = (0, _lodash().groupBy)(nodes, v => {
309
+ const nodeGroup = groupBy(nodes, v => {
311
310
  if (layoutNodes.includes(v.id)) {
312
311
  return 'linkNodes';
313
312
  } else {
@@ -357,8 +356,8 @@ const handelResetLayout = () => {
357
356
  _dagre().default.layout(g);
358
357
  targetGraph.freeze();
359
358
  const gNodes = g.nodes();
360
- const nodeWithEdges = (0, _lodash().take)(gNodes, linkNodes.length);
361
- const nodeWithoutEdges = (0, _lodash().drop)(gNodes, linkNodes.length);
359
+ const nodeWithEdges = take(gNodes, linkNodes.length);
360
+ const nodeWithoutEdges = drop(gNodes, linkNodes.length);
362
361
  nodeWithEdges.forEach(id => {
363
362
  var _positions$find;
364
363
  const node = targetGraph.getCell(id);
@@ -375,25 +374,25 @@ const handelResetLayout = () => {
375
374
  });
376
375
  if (nodeWithEdges.length) {
377
376
  var _targetGraph$getCell;
378
- maxY = targetGraph.getCellById((0, _lodash().maxBy)(nodeWithEdges, k => {
377
+ maxY = targetGraph.getCellById(maxBy(nodeWithEdges, k => {
379
378
  return targetGraph.getCellById(k).position().y;
380
379
  })).position().y;
381
- minX = targetGraph.getCellById((0, _lodash().minBy)(nodeWithEdges, k => {
380
+ minX = targetGraph.getCellById(minBy(nodeWithEdges, k => {
382
381
  return targetGraph.getCellById(k).position().x;
383
382
  })).position().x;
384
- const maxX = targetGraph.getCellById((0, _lodash().maxBy)(nodeWithEdges, k => {
383
+ const maxX = targetGraph.getCellById(maxBy(nodeWithEdges, k => {
385
384
  return targetGraph.getCellById(k).position().x;
386
385
  })).position().x;
387
386
  const yNodes = nodeWithEdges.filter(v => {
388
387
  return Math.abs(targetGraph.getCellById(v).position().y - maxY) < 50;
389
388
  });
390
- const referenceNode = (_targetGraph$getCell = targetGraph.getCell((0, _lodash().maxBy)(yNodes, k => targetGraph.getCellById(k).position().x))) === null || _targetGraph$getCell === void 0 ? void 0 : _targetGraph$getCell.position();
389
+ const referenceNode = (_targetGraph$getCell = targetGraph.getCell(maxBy(yNodes, k => targetGraph.getCellById(k).position().x))) === null || _targetGraph$getCell === void 0 ? void 0 : _targetGraph$getCell.position();
391
390
  num = Math.round(maxX / 320) || 1;
392
391
  alternateNum = Math.floor((4500 - (maxX + 100 - referenceNode.x)) / 280);
393
392
  rawEntity = getGridData(num, rawNodes);
394
393
  if (alternateNum >= 1) {
395
- const alternateNodes = (0, _lodash().take)(nodeWithoutEdges, alternateNum);
396
- rawEntity = getGridData(num, (0, _lodash().drop)(nodeWithoutEdges, alternateNum));
394
+ const alternateNodes = take(nodeWithoutEdges, alternateNum);
395
+ rawEntity = getGridData(num, drop(nodeWithoutEdges, alternateNum));
397
396
  alternateNodes.forEach((id, index) => {
398
397
  const node = targetGraph.getCell(id);
399
398
  if (node) {
@@ -450,6 +449,10 @@ const handelResetLayout = () => {
450
449
  };
451
450
  const GraphDrawPage = _react2().default.memo(() => {
452
451
  var _targetGraph7;
452
+ const _useGlobalTheme = (0, _client().useGlobalTheme)(),
453
+ theme = _useGlobalTheme.theme;
454
+ const _useStyles = (0, _style.default)(),
455
+ styles = _useStyles.styles;
453
456
  const options = (0, _react2().useContext)(_react().SchemaOptionsContext);
454
457
  const ctx = (0, _react2().useContext)(_client().CollectionManagerContext);
455
458
  const api = (0, _client().useAPIClient)();
@@ -635,6 +638,8 @@ const GraphDrawPage = _react2().default.memo(() => {
635
638
  collections: (_targetGraph2 = targetGraph) === null || _targetGraph2 === void 0 ? void 0 : _targetGraph2.collections,
636
639
  refreshCM: refreshGM,
637
640
  interfaces: ctx.interfaces
641
+ }, _react2().default.createElement(_antd().ConfigProvider, {
642
+ theme: theme
638
643
  }, _react2().default.createElement("div", {
639
644
  style: {
640
645
  height: 'auto'
@@ -643,7 +648,7 @@ const GraphDrawPage = _react2().default.memo(() => {
643
648
  node: node,
644
649
  setTargetNode: setTargetNode,
645
650
  targetGraph: targetGraph
646
- })))))));
651
+ }))))))));
647
652
  },
648
653
  ports: {
649
654
  groups: {
@@ -711,7 +716,7 @@ const GraphDrawPage = _react2().default.memo(() => {
711
716
  });
712
717
  targetGraph.on('blank:click', e => {
713
718
  var _targetGraph3, _targetGraph$collapse;
714
- if ((_targetGraph3 = targetGraph) === null || _targetGraph3 === void 0 ? void 0 : _targetGraph3.activeEdge) {
719
+ if ((_targetGraph3 = targetGraph) !== null && _targetGraph3 !== void 0 && _targetGraph3.activeEdge) {
715
720
  var _targetGraph4;
716
721
  handleEdgeUnActive((_targetGraph4 = targetGraph) === null || _targetGraph4 === void 0 ? void 0 : _targetGraph4.activeEdge);
717
722
  }
@@ -861,7 +866,7 @@ const GraphDrawPage = _react2().default.memo(() => {
861
866
  inheritEdges = _formatData2.inheritEdges;
862
867
  const currentNodes = targetGraph.getNodes().map(v => v.store.data);
863
868
  const totalEdges = targetGraph.getEdges().map(v => v.store.data);
864
- const currentEdgesGroup = (0, _lodash().groupBy)(totalEdges, v => {
869
+ const currentEdgesGroup = groupBy(totalEdges, v => {
865
870
  if (v.connectionType) {
866
871
  return 'currentInheritEdges';
867
872
  } else {
@@ -879,15 +884,15 @@ const GraphDrawPage = _react2().default.memo(() => {
879
884
  const updateNode = targetGraph.getCellById(node.id);
880
885
  switch (status) {
881
886
  case 'add':
882
- const maxY = (0, _lodash().maxBy)(positions, 'y').y;
887
+ const maxY = maxBy(positions, 'y').y;
883
888
  const yNodes = positions.filter(v => {
884
889
  return Math.abs(v.y - maxY) < 100;
885
890
  });
886
- let referenceNode = (0, _lodash().maxBy)(yNodes, 'x');
891
+ let referenceNode = maxBy(yNodes, 'x');
887
892
  let position;
888
893
  if (referenceNode.x > 4500) {
889
- const minX = (0, _lodash().minBy)(positions, 'x').x;
890
- referenceNode = (0, _lodash().minBy)(yNodes, 'x');
894
+ const minX = minBy(positions, 'x').x;
895
+ referenceNode = minBy(yNodes, 'x');
891
896
  position = {
892
897
  x: minX,
893
898
  y: referenceNode.y + 400
@@ -990,7 +995,7 @@ const GraphDrawPage = _react2().default.memo(() => {
990
995
  const connectedEdges = targetGraph.getConnectedEdges(node);
991
996
  const visibleEdges = connectedEdges.filter(v => {
992
997
  var _v$store$data;
993
- return !((_v$store$data = v.store.data) === null || _v$store$data === void 0 ? void 0 : _v$store$data.connectionType) && v.getTargetCellId() === key;
998
+ return !((_v$store$data = v.store.data) !== null && _v$store$data !== void 0 && _v$store$data.connectionType) && v.getTargetCellId() === key;
994
999
  });
995
1000
  visibleEdges.forEach(v => {
996
1001
  var _node$store$data$attr2;
@@ -1001,7 +1006,7 @@ const GraphDrawPage = _react2().default.memo(() => {
1001
1006
  var _node$store$data$attr;
1002
1007
  const sourceId = m2mEdge.getSourceCellId();
1003
1008
  const node = targetGraph.getCellById(sourceId);
1004
- if (!((_node$store$data$attr = node.store.data.attrs) === null || _node$store$data$attr === void 0 ? void 0 : _node$store$data$attr.hightLight)) {
1009
+ if (!((_node$store$data$attr = node.store.data.attrs) !== null && _node$store$data$attr !== void 0 && _node$store$data$attr.hightLight)) {
1005
1010
  node.setAttrs({
1006
1011
  hightLight: true,
1007
1012
  direction: DirectionType.Target,
@@ -1014,7 +1019,7 @@ const GraphDrawPage = _react2().default.memo(() => {
1014
1019
  }
1015
1020
  const sourceId = v.getSourceCellId();
1016
1021
  const node = targetGraph.getCellById(sourceId);
1017
- if (!((_node$store$data$attr2 = node.store.data.attrs) === null || _node$store$data$attr2 === void 0 ? void 0 : _node$store$data$attr2.hightLight)) {
1022
+ if (!((_node$store$data$attr2 = node.store.data.attrs) !== null && _node$store$data$attr2 !== void 0 && _node$store$data$attr2.hightLight)) {
1018
1023
  node.setAttrs({
1019
1024
  hightLight: true,
1020
1025
  direction: DirectionType.Target,
@@ -1030,7 +1035,7 @@ const GraphDrawPage = _react2().default.memo(() => {
1030
1035
  const connectedEdges = targetGraph.getConnectedEdges(node);
1031
1036
  const visibleEdges = connectedEdges.filter(v => {
1032
1037
  var _v$store$data2;
1033
- return !((_v$store$data2 = v.store.data) === null || _v$store$data2 === void 0 ? void 0 : _v$store$data2.connectionType) && v.getSourceCellId() === key;
1038
+ return !((_v$store$data2 = v.store.data) !== null && _v$store$data2 !== void 0 && _v$store$data2.connectionType) && v.getSourceCellId() === key;
1034
1039
  });
1035
1040
  visibleEdges.forEach(v => {
1036
1041
  var _node$store$data$attr4;
@@ -1041,7 +1046,7 @@ const GraphDrawPage = _react2().default.memo(() => {
1041
1046
  var _node$store$data$attr3;
1042
1047
  const targetId = m2mEdge.getTargetCellId();
1043
1048
  const node = targetGraph.getCellById(targetId);
1044
- if (!((_node$store$data$attr3 = node.store.data.attrs) === null || _node$store$data$attr3 === void 0 ? void 0 : _node$store$data$attr3.hightLight)) {
1049
+ if (!((_node$store$data$attr3 = node.store.data.attrs) !== null && _node$store$data$attr3 !== void 0 && _node$store$data$attr3.hightLight)) {
1045
1050
  node.setAttrs({
1046
1051
  hightLight: true,
1047
1052
  direction: DirectionType.Source,
@@ -1054,7 +1059,7 @@ const GraphDrawPage = _react2().default.memo(() => {
1054
1059
  }
1055
1060
  const targetId = v.getTargetCellId();
1056
1061
  const node = targetGraph.getCellById(targetId);
1057
- if (!((_node$store$data$attr4 = node.store.data.attrs) === null || _node$store$data$attr4 === void 0 ? void 0 : _node$store$data$attr4.hightLight)) {
1062
+ if (!((_node$store$data$attr4 = node.store.data.attrs) !== null && _node$store$data$attr4 !== void 0 && _node$store$data$attr4.hightLight)) {
1058
1063
  node.setAttrs({
1059
1064
  hightLight: true,
1060
1065
  direction: DirectionType.Source,
@@ -1194,7 +1199,7 @@ const GraphDrawPage = _react2().default.memo(() => {
1194
1199
  };
1195
1200
  }();
1196
1201
  return _react2().default.createElement(_antd().Layout, null, _react2().default.createElement("div", {
1197
- className: (0, _css().cx)(_style.graphCollectionContainerClass)
1202
+ className: styles.graphCollectionContainerClass
1198
1203
  }, _react2().default.createElement(_client().CollectionManagerProvider, {
1199
1204
  collections: (_targetGraph7 = targetGraph) === null || _targetGraph7 === void 0 ? void 0 : _targetGraph7.collections,
1200
1205
  refreshCM: refreshGM
@@ -1204,11 +1209,11 @@ const GraphDrawPage = _react2().default.memo(() => {
1204
1209
  handleSearchCollection
1205
1210
  }
1206
1211
  }, _react2().default.createElement("div", {
1207
- className: (0, _css().cx)(_style.collectionListClass)
1212
+ className: (0, _client().cx)(styles.collectionListClass)
1208
1213
  }, _react2().default.createElement(_client().SchemaComponent, {
1209
1214
  components: {
1210
1215
  Select: props => _react2().default.createElement(_client().Select, _objectSpread(_objectSpread({
1211
- dropdownMatchSelectWidth: false
1216
+ popupMatchSelectWidth: false
1212
1217
  }, props), {}, {
1213
1218
  getPopupContainer: _utils.getPopupContainer
1214
1219
  })),
@@ -1299,7 +1304,7 @@ const GraphDrawPage = _react2().default.memo(() => {
1299
1304
  }), _react2().default.createElement(_antd().Menu, {
1300
1305
  selectedKeys: selectedKeys,
1301
1306
  selectable: true,
1302
- className: (0, _css().css)`
1307
+ className: (0, _client().css)`
1303
1308
  .ant-menu-item {
1304
1309
  height: 32px;
1305
1310
  line-height: 32px;
@@ -1335,7 +1340,7 @@ const GraphDrawPage = _react2().default.memo(() => {
1335
1340
  placement: "bottomRight",
1336
1341
  trigger: ['click'],
1337
1342
  getPopupContainer: _utils.getPopupContainer,
1338
- overlayClassName: (0, _css().css)`
1343
+ overlayClassName: (0, _client().css)`
1339
1344
  .ant-popover-inner-content {
1340
1345
  padding: 0;
1341
1346
  }
@@ -1388,7 +1393,7 @@ const GraphDrawPage = _react2().default.memo(() => {
1388
1393
  const content = _react2().default.createElement("div", null, _react2().default.createElement(_antd().Menu, {
1389
1394
  defaultSelectedKeys: [ConnectionType.Both],
1390
1395
  selectable: true,
1391
- className: (0, _css().css)`
1396
+ className: (0, _client().css)`
1392
1397
  .ant-menu-item {
1393
1398
  height: 32px;
1394
1399
  line-height: 32px;
@@ -1421,7 +1426,7 @@ const GraphDrawPage = _react2().default.memo(() => {
1421
1426
  placement: "bottomRight",
1422
1427
  trigger: ['click'],
1423
1428
  getPopupContainer: _utils.getPopupContainer,
1424
- overlayClassName: (0, _css().css)`
1429
+ overlayClassName: (0, _client().css)`
1425
1430
  .ant-popover-inner-content {
1426
1431
  padding: 0;
1427
1432
  }
@@ -1453,7 +1458,7 @@ const GraphDrawPage = _react2().default.memo(() => {
1453
1458
  const content = _react2().default.createElement("div", null, _react2().default.createElement(_antd().Menu, {
1454
1459
  defaultSelectedKeys: [DirectionType.Target],
1455
1460
  selectable: true,
1456
- className: (0, _css().css)`
1461
+ className: (0, _client().css)`
1457
1462
  .ant-menu-item {
1458
1463
  height: 32px;
1459
1464
  line-height: 32px;
@@ -1487,7 +1492,7 @@ const GraphDrawPage = _react2().default.memo(() => {
1487
1492
  placement: "bottomRight",
1488
1493
  trigger: ['click'],
1489
1494
  getPopupContainer: _utils.getPopupContainer,
1490
- overlayClassName: (0, _css().css)`
1495
+ overlayClassName: (0, _client().css)`
1491
1496
  .ant-popover-inner-content {
1492
1497
  padding: 0;
1493
1498
  }
@@ -1527,6 +1532,7 @@ const GraphDrawPage = _react2().default.memo(() => {
1527
1532
  }
1528
1533
  }), _react2().default.createElement("div", {
1529
1534
  id: "graph-minimap",
1535
+ className: styles.graphMinimap,
1530
1536
  style: {
1531
1537
  width: '300px',
1532
1538
  height: '250px',
@@ -1,5 +1,18 @@
1
1
  import React from 'react';
2
- export declare const useValuesFromRecord: (options: any, data: any) => any;
2
+ export declare const useValuesFromRecord: (options: any, data: any) => {
3
+ state: {};
4
+ setState: import("ahooks/lib/useSetState").SetState<{}>;
5
+ loading: boolean;
6
+ data?: unknown;
7
+ error?: Error;
8
+ params: any;
9
+ cancel: () => void;
10
+ refresh: () => void;
11
+ refreshAsync: () => Promise<unknown>;
12
+ run: (...params: any) => void;
13
+ runAsync: (...params: any) => Promise<unknown>;
14
+ mutate: (data?: unknown) => void;
15
+ };
3
16
  export declare const SourceCollection: React.MemoExoticComponent<import("@formily/react").ReactFC<unknown>>;
4
17
  export declare const useCancelAction: () => {
5
18
  run(): Promise<void>;
@@ -25,16 +25,16 @@ function _client() {
25
25
  };
26
26
  return data;
27
27
  }
28
- function _antd() {
29
- const data = require("antd");
30
- _antd = function _antd() {
28
+ function _client2() {
29
+ const data = require("@nocobase/utils/client");
30
+ _client2 = function _client2() {
31
31
  return data;
32
32
  };
33
33
  return data;
34
34
  }
35
- function _omit() {
36
- const data = _interopRequireDefault(require("lodash/omit"));
37
- _omit = function _omit() {
35
+ function _antd() {
36
+ const data = require("antd");
37
+ _antd = function _antd() {
38
38
  return data;
39
39
  };
40
40
  return data;
@@ -56,7 +56,6 @@ function _reactI18next() {
56
56
  var _CollectionNodeProvder = require("./components/CollectionNodeProvder");
57
57
  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); }
58
58
  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; }
59
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
60
59
  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); } }
61
60
  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); }); }; }
62
61
  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; }
@@ -84,7 +83,7 @@ const SourceCollection = (0, _react().observer)(() => {
84
83
  record = _useContext.record;
85
84
  const compile = (0, _client().useCompile)();
86
85
  return _react2().default.createElement("div", null, _react2().default.createElement(_antd().Select, {
87
- dropdownMatchSelectWidth: false,
86
+ popupMatchSelectWidth: false,
88
87
  disabled: true,
89
88
  value: record.name,
90
89
  options: [{
@@ -147,7 +146,7 @@ const useCreateAction = (collectionName, targetId) => {
147
146
  return _asyncToGenerator(function* () {
148
147
  yield form.submit();
149
148
  const values = getValues();
150
- const formValues = (0, _omit().default)(values, ['key', 'uiSchemaUid', 'collectionName', 'autoCreateReverseField', 'uiSchema.x-uid', 'reverseField.key', 'reverseField.uiSchemaUid']);
149
+ const formValues = _client2().lodash.omit(values, ['key', 'uiSchemaUid', 'collectionName', 'autoCreateReverseField', 'uiSchema.x-uid', 'reverseField.key', 'reverseField.uiSchemaUid']);
151
150
  const isOpenPorts = !['obo', 'oho', 'o2o', 'o2m', 'm2o', 'm2m', 'linkTo', 'id'].includes(values.interface);
152
151
  const _yield$api$resource$c = yield api.resource('collections.fields', collectionName).create({
153
152
  values: formValues
@@ -223,7 +222,7 @@ const useUpdateCollectionActionAndRefreshCM = () => {
223
222
  yield form.submit();
224
223
  yield api.resource('collections').update({
225
224
  filterByTk: name,
226
- values: _objectSpread({}, (0, _omit().default)(form.values, ['fields']))
225
+ values: _objectSpread({}, _client2().lodash.omit(form.values, ['fields']))
227
226
  });
228
227
  ctx.setVisible(false);
229
228
  _antd().message.success(t('Saved successfully'));
@@ -311,7 +310,9 @@ const useAsyncDataSource = service => {
311
310
  service(targetScope).then(_reactive().action.bound(data => {
312
311
  field.dataSource = data;
313
312
  field.loading = false;
314
- }));
313
+ })).catch(err => {
314
+ (0, _client2().error)(err);
315
+ });
315
316
  };
316
317
  };
317
318
  exports.useAsyncDataSource = useAsyncDataSource;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
- export declare const EditCollectionAction: ({ item: record }: {
2
+ export declare const EditCollectionAction: ({ item: record, className }: {
3
3
  item: any;
4
+ className: any;
4
5
  }) => React.JSX.Element;
@@ -11,13 +11,6 @@ function _icons() {
11
11
  };
12
12
  return data;
13
13
  }
14
- function _css() {
15
- const data = require("@emotion/css");
16
- _css = function _css() {
17
- return data;
18
- };
19
- return data;
20
- }
21
14
  function _client() {
22
15
  const data = require("@nocobase/client");
23
16
  _client = function _client() {
@@ -36,7 +29,8 @@ var _actionHooks = require("../action-hooks");
36
29
  var _utils = require("../utils");
37
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
38
31
  const EditCollectionAction = ({
39
- item: record
32
+ item: record,
33
+ className
40
34
  }) => {
41
35
  return _react().default.createElement(_client().EditCollection, {
42
36
  item: record,
@@ -47,17 +41,7 @@ const EditCollectionAction = ({
47
41
  },
48
42
  getContainer: _utils.getPopupContainer
49
43
  }, _react().default.createElement(_icons().EditOutlined, {
50
- className: (0, _css().css)`
51
- border-color: transparent;
52
- color: rgb(78 89 105);
53
- height: 20px;
54
- width: 22px;
55
- margin: 0px 5px 4px;
56
- line-height: 25px;
57
- &:hover {
58
- background-color: rgb(229 230 235);
59
- }
60
- `
44
+ className: className
61
45
  }));
62
46
  };
63
47
  exports.EditCollectionAction = EditCollectionAction;