@luck-design-biz/luckda 0.0.25-6 → 0.0.25-7

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 (141) hide show
  1. package/es/components/LDActions/index.less +1 -1
  2. package/es/components/LdAutoForm/index.js +24 -8
  3. package/es/components/LdFormList/index.js +25 -18
  4. package/es/components/LdGrid/index.js +3 -2
  5. package/es/components/LdGridForm/index.js +16 -6
  6. package/es/components/LdTree/index.js +3 -2
  7. package/es/helper/form.js +6 -3
  8. package/es/locales/zh-CN.js +1 -0
  9. package/es/lowcode/constants/api-url.js +13 -11
  10. package/es/lowcode/engine/factory/panel-item-factory/SelectStrategy.js +4 -2
  11. package/es/lowcode/engine/factory/panel-item-factory/SwitchStrategy.js +4 -2
  12. package/es/lowcode/engine/meta/dialog.props.default.json +10 -5
  13. package/es/lowcode/engine/meta/dialog.props.json +72 -42
  14. package/es/lowcode/engine/meta/form.props.json +3 -3
  15. package/es/lowcode/engine/meta/table.props.json +4 -4
  16. package/es/lowcode/engine/meta/tree.props.default.json +1 -0
  17. package/es/lowcode/engine/meta/tree.props.json +7 -0
  18. package/es/lowcode/engine/provider/ContextProvider/index.js +8 -40
  19. package/es/lowcode/engine/provider/RemoteSourceProvider.js +16 -20
  20. package/es/lowcode/engine/tools/helper.js +2 -3
  21. package/es/lowcode/engine/tools/useCanvasRender.js +3 -2
  22. package/es/lowcode/engine/tools/usePageDataStore.js +174 -0
  23. package/es/lowcode/engine/tools/usePromiseState.js +12 -23
  24. package/es/lowcode/engine/tools/useTodo.js +20 -10
  25. package/es/lowcode/painter/DesignOperator.js +11 -22
  26. package/es/lowcode/painter/DesignToolbar.js +8 -44
  27. package/es/lowcode/painter/Outline.js +2 -4
  28. package/es/lowcode/painter/Panel.js +26 -25
  29. package/es/lowcode/painter/components/ActionBindModal.js +5 -11
  30. package/es/lowcode/painter/components/AttrsPanel.js +26 -19
  31. package/es/lowcode/painter/components/DragDrop/DragDropContext.js +1 -1
  32. package/es/lowcode/painter/components/code-editor/BaseEditor.js +3 -2
  33. package/es/lowcode/painter/components/field-setting/SettingUI.js +7 -7
  34. package/es/lowcode/painter/panel-section/BlocksEditor/index.js +11 -11
  35. package/es/lowcode/painter/panel-section/ButtonType.js +4 -2
  36. package/es/lowcode/painter/panel-section/DataSetSelector.js +4 -1
  37. package/es/lowcode/painter/panel-section/FieldsSetting.js +5 -1
  38. package/es/lowcode/painter/panel-section/SerialsSelector.js +4 -2
  39. package/es/lowcode/painter/panel-section/TreeRootEditor.js +2 -2
  40. package/es/lowcode/painter/style/design.less +1 -1
  41. package/es/lowcode/painter/style/panel-item.less +1 -1
  42. package/es/lowcode/view/Canvas.js +6 -7
  43. package/es/lowcode/view/Page.js +2 -3
  44. package/es/lowcode/view/lc-components/Dialog/FunctionDesign.js +3 -10
  45. package/es/lowcode/view/lc-components/Dialog/index.js +89 -19
  46. package/es/lowcode/view/lc-components/Dialog/meta.json +65 -42
  47. package/es/lowcode/view/lc-components/Form/FunctionDesign.js +23 -33
  48. package/es/lowcode/view/lc-components/Form/index.js +20 -6
  49. package/es/lowcode/view/lc-components/Form/meta.json +3 -3
  50. package/es/lowcode/view/lc-components/Layout/FunctionDesign.js +12 -19
  51. package/es/lowcode/view/lc-components/PageContent/index.js +8 -9
  52. package/es/lowcode/view/lc-components/PageFooter/index.js +2 -5
  53. package/es/lowcode/view/lc-components/PageHeader/index.js +5 -6
  54. package/es/lowcode/view/lc-components/PageModal/index.js +12 -15
  55. package/es/lowcode/view/lc-components/Section/FunctionDesign.js +3 -9
  56. package/es/lowcode/view/lc-components/Split/FunctionDesign.js +11 -18
  57. package/es/lowcode/view/lc-components/Table/index.js +67 -25
  58. package/es/lowcode/view/lc-components/Table/meta.json +4 -4
  59. package/es/lowcode/view/lc-components/Tabs/FunctionDesign.js +9 -17
  60. package/es/lowcode/view/lc-components/Tree/index.js +8 -1
  61. package/es/lowcode/view/lc-components/Tree/meta.json +7 -0
  62. package/es/lowcode/view/lc-components/Wrapper.js +9 -11
  63. package/es/services.js +0 -24
  64. package/es/upload/FilesWall/file.png +0 -0
  65. package/es/upload/FilesWall/index.js +422 -0
  66. package/es/upload/FilesWall/index.less +74 -0
  67. package/es/upload/Form/index.js +2 -1
  68. package/es/upload/FormItem/index.js +2 -1
  69. package/es/upload/index.js +2 -1
  70. package/es/utils/action.js +2 -2
  71. package/lib/components/LDActions/index.less +1 -1
  72. package/lib/components/LdAutoForm/index.js +23 -7
  73. package/lib/components/LdFormList/index.js +25 -18
  74. package/lib/components/LdGrid/index.js +3 -2
  75. package/lib/components/LdGridForm/index.js +14 -4
  76. package/lib/components/LdTree/index.js +3 -2
  77. package/lib/helper/form.js +6 -3
  78. package/lib/locales/zh-CN.js +1 -0
  79. package/lib/lowcode/constants/api-url.js +14 -10
  80. package/lib/lowcode/engine/factory/panel-item-factory/SelectStrategy.js +4 -2
  81. package/lib/lowcode/engine/factory/panel-item-factory/SwitchStrategy.js +4 -2
  82. package/lib/lowcode/engine/meta/dialog.props.default.json +10 -5
  83. package/lib/lowcode/engine/meta/dialog.props.json +72 -42
  84. package/lib/lowcode/engine/meta/form.props.json +3 -3
  85. package/lib/lowcode/engine/meta/table.props.json +4 -4
  86. package/lib/lowcode/engine/meta/tree.props.default.json +1 -0
  87. package/lib/lowcode/engine/meta/tree.props.json +7 -0
  88. package/lib/lowcode/engine/provider/ContextProvider/index.js +25 -41
  89. package/lib/lowcode/engine/provider/RemoteSourceProvider.js +16 -20
  90. package/lib/lowcode/engine/tools/helper.js +2 -3
  91. package/lib/lowcode/engine/tools/useCanvasRender.js +3 -2
  92. package/lib/lowcode/engine/tools/usePageDataStore.js +181 -0
  93. package/lib/lowcode/engine/tools/usePromiseState.js +11 -21
  94. package/lib/lowcode/engine/tools/useTodo.js +19 -9
  95. package/lib/lowcode/painter/DesignOperator.js +10 -21
  96. package/lib/lowcode/painter/DesignToolbar.js +7 -43
  97. package/lib/lowcode/painter/Outline.js +1 -3
  98. package/lib/lowcode/painter/Panel.js +25 -24
  99. package/lib/lowcode/painter/components/ActionBindModal.js +5 -11
  100. package/lib/lowcode/painter/components/AttrsPanel.js +26 -19
  101. package/lib/lowcode/painter/components/DragDrop/DragDropContext.js +1 -1
  102. package/lib/lowcode/painter/components/code-editor/BaseEditor.js +3 -2
  103. package/lib/lowcode/painter/components/field-setting/SettingUI.js +7 -7
  104. package/lib/lowcode/painter/panel-section/BlocksEditor/index.js +10 -10
  105. package/lib/lowcode/painter/panel-section/ButtonType.js +4 -2
  106. package/lib/lowcode/painter/panel-section/DataSetSelector.js +4 -1
  107. package/lib/lowcode/painter/panel-section/FieldsSetting.js +5 -1
  108. package/lib/lowcode/painter/panel-section/SerialsSelector.js +4 -2
  109. package/lib/lowcode/painter/panel-section/TreeRootEditor.js +2 -2
  110. package/lib/lowcode/painter/style/design.less +1 -1
  111. package/lib/lowcode/painter/style/panel-item.less +1 -1
  112. package/lib/lowcode/view/Canvas.js +5 -6
  113. package/lib/lowcode/view/Page.js +2 -3
  114. package/lib/lowcode/view/lc-components/Dialog/FunctionDesign.js +2 -9
  115. package/lib/lowcode/view/lc-components/Dialog/index.js +89 -19
  116. package/lib/lowcode/view/lc-components/Dialog/meta.json +65 -42
  117. package/lib/lowcode/view/lc-components/Form/FunctionDesign.js +20 -31
  118. package/lib/lowcode/view/lc-components/Form/index.js +20 -6
  119. package/lib/lowcode/view/lc-components/Form/meta.json +3 -3
  120. package/lib/lowcode/view/lc-components/Layout/FunctionDesign.js +11 -18
  121. package/lib/lowcode/view/lc-components/PageContent/index.js +7 -8
  122. package/lib/lowcode/view/lc-components/PageFooter/index.js +2 -5
  123. package/lib/lowcode/view/lc-components/PageHeader/index.js +4 -5
  124. package/lib/lowcode/view/lc-components/PageModal/index.js +11 -14
  125. package/lib/lowcode/view/lc-components/Section/FunctionDesign.js +2 -8
  126. package/lib/lowcode/view/lc-components/Split/FunctionDesign.js +10 -17
  127. package/lib/lowcode/view/lc-components/Table/index.js +66 -24
  128. package/lib/lowcode/view/lc-components/Table/meta.json +4 -4
  129. package/lib/lowcode/view/lc-components/Tabs/FunctionDesign.js +8 -16
  130. package/lib/lowcode/view/lc-components/Tree/index.js +8 -1
  131. package/lib/lowcode/view/lc-components/Tree/meta.json +7 -0
  132. package/lib/lowcode/view/lc-components/Wrapper.js +8 -10
  133. package/lib/services.js +0 -25
  134. package/lib/upload/FilesWall/file.png +0 -0
  135. package/lib/upload/FilesWall/index.js +429 -0
  136. package/lib/upload/FilesWall/index.less +74 -0
  137. package/lib/upload/Form/index.js +2 -1
  138. package/lib/upload/FormItem/index.js +2 -1
  139. package/lib/upload/index.js +8 -1
  140. package/lib/utils/action.js +2 -2
  141. package/package.json +4 -3
@@ -5,56 +5,37 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.useRemoteSource = exports.usePageData = exports.useContext = exports.default = exports.Context = void 0;
8
+ var _exportNames = {
9
+ Context: true,
10
+ useContext: true,
11
+ useRemoteSource: true
12
+ };
13
+ exports.useRemoteSource = exports.useContext = exports.default = exports.Context = void 0;
9
14
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
15
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
16
  var _react = _interopRequireWildcard(require("react"));
12
17
  var _umi = require("umi");
13
18
  var _ahooks = require("ahooks");
14
- var _lodash = require("lodash");
15
19
  var _EventBusProvider = require("../EventBusProvider");
16
20
  var _RemoteSourceProvider = _interopRequireWildcard(require("../RemoteSourceProvider"));
17
21
  var _useTodo3 = _interopRequireDefault(require("../../tools/useTodo"));
18
- var _dataProcess = require("../../tools/dataProcess");
19
22
  var topics = _interopRequireWildcard(require("../../../constants/event-topics"));
23
+ var _usePageDataStore = require("../../tools/usePageDataStore");
24
+ Object.keys(_usePageDataStore).forEach(function (key) {
25
+ if (key === "default" || key === "__esModule") return;
26
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
27
+ if (key in exports && exports[key] === _usePageDataStore[key]) return;
28
+ Object.defineProperty(exports, key, {
29
+ enumerable: true,
30
+ get: function get() {
31
+ return _usePageDataStore[key];
32
+ }
33
+ });
34
+ });
20
35
  var Context = exports.Context = /*#__PURE__*/(0, _react.createContext)(null);
21
36
  var useContext = exports.useContext = function useContext() {
22
37
  return (0, _react.useContext)(Context);
23
38
  };
24
- var usePageData = exports.usePageData = function usePageData(_) {
25
- var _useReactContext = (0, _react.useContext)(_RemoteSourceProvider.RemoteSourceContext),
26
- pageData = _useReactContext.pageData,
27
- loading = _useReactContext.loading,
28
- setPageData = _useReactContext.setPageData,
29
- back = _useReactContext.back,
30
- forward = _useReactContext.forward,
31
- backLength = _useReactContext.backLength,
32
- forwardLength = _useReactContext.forwardLength;
33
- var _pageData;
34
- if ((0, _lodash.isNil)(_)) {
35
- _pageData = pageData;
36
- } else if ((0, _lodash.isFunction)(_)) {
37
- _pageData = _(pageData);
38
- } else if ((0, _lodash.isArray)(_)) {
39
- _pageData = (0, _lodash.reduce)(_, function (r, k) {
40
- r.push((0, _lodash.get)(pageData, k));
41
- return r;
42
- }, []);
43
- } else if ((0, _lodash.isObject)(_) && _.id) {
44
- var _findNodeAndParent;
45
- _pageData = (_findNodeAndParent = (0, _dataProcess.findNodeAndParent)(_.id, pageData)) === null || _findNodeAndParent === void 0 ? void 0 : _findNodeAndParent.node;
46
- } else if ((0, _lodash.isString)(_)) {
47
- _pageData = (0, _lodash.get)(pageData, _);
48
- }
49
- return [_pageData, {
50
- loading: loading,
51
- setPageData: setPageData,
52
- back: back,
53
- forward: forward,
54
- backLength: backLength,
55
- forwardLength: forwardLength
56
- }];
57
- };
58
39
  var useRemoteSource = exports.useRemoteSource = function useRemoteSource() {
59
40
  return (0, _react.useContext)(_RemoteSourceProvider.RemoteSourceContext);
60
41
  };
@@ -64,9 +45,10 @@ var _default = exports.default = function _default(_ref) {
64
45
  code = _ref.code;
65
46
  var eventBus = (0, _EventBusProvider.useLDEventBus)();
66
47
  var _useTodo = (0, _useTodo3.default)(),
67
- _useTodo2 = (0, _slicedToArray2.default)(_useTodo, 2),
48
+ _useTodo2 = (0, _slicedToArray2.default)(_useTodo, 3),
68
49
  todo = _useTodo2[0],
69
- callBehavior = _useTodo2[1];
50
+ callBehavior = _useTodo2[1],
51
+ loading = _useTodo2[2];
70
52
 
71
53
  /**
72
54
  * 页面公共资源
@@ -74,7 +56,7 @@ var _default = exports.default = function _default(_ref) {
74
56
  var _useSetState = (0, _ahooks.useSetState)(null),
75
57
  _useSetState2 = (0, _slicedToArray2.default)(_useSetState, 2),
76
58
  pagePublicResource = _useSetState2[0],
77
- _setPagePublicResource = _useSetState2[1];
59
+ setPagePublicResource = _useSetState2[1];
78
60
 
79
61
  /**
80
62
  * 组件列表
@@ -137,13 +119,15 @@ var _default = exports.default = function _default(_ref) {
137
119
  */
138
120
  var getUrlParams = (0, _ahooks.useMemoizedFn)(function () {});
139
121
  var ctx = new Proxy((0, _objectSpread2.default)({
140
- _setPagePublicResource: _setPagePublicResource,
141
122
  _register: _register,
142
123
  _unregister: _unregister,
143
124
  pagePublicResource: pagePublicResource,
125
+ setPagePublicResource: setPagePublicResource,
126
+ loading: loading,
144
127
  history: _umi.history,
145
128
  callBehavior: callBehavior,
146
129
  topics: topics,
130
+ PRIMARY_KEY: window.appConfig.constraintKeys.PRIMARY,
147
131
  getElementById: getElementById,
148
132
  /**
149
133
  * @method
@@ -16,7 +16,7 @@ var _react = _interopRequireWildcard(require("react"));
16
16
  var _ahooks = require("ahooks");
17
17
  var _Builder = require("../../../components/Builder");
18
18
  var _action2 = require("../../../helper/action");
19
- var _usePromiseState3 = _interopRequireDefault(require("../tools/usePromiseState"));
19
+ var _usePageDataStore2 = _interopRequireDefault(require("../tools/usePageDataStore"));
20
20
  var _dataProcess = require("../tools/dataProcess");
21
21
  var _apiUrl = require("../../constants/api-url");
22
22
  var _constants = require("../../constants");
@@ -26,15 +26,16 @@ var _default = exports.default = function _default(_ref) {
26
26
  var children = _ref.children,
27
27
  code = _ref.code,
28
28
  runtime = _ref.runtime;
29
- var _usePromiseState = (0, _usePromiseState3.default)(null),
30
- _usePromiseState2 = (0, _slicedToArray2.default)(_usePromiseState, 3),
31
- pageData = _usePromiseState2[0],
32
- setPageData = _usePromiseState2[1],
33
- _usePromiseState2$ = _usePromiseState2[2],
34
- back = _usePromiseState2$.back,
35
- forward = _usePromiseState2$.forward,
36
- backLength = _usePromiseState2$.backLength,
37
- forwardLength = _usePromiseState2$.forwardLength;
29
+ var _usePageDataStore = (0, _usePageDataStore2.default)(function (state) {
30
+ return {
31
+ initialize: state.initialize,
32
+ initializeModule: state.initializeModule,
33
+ reset: state.reset
34
+ };
35
+ }),
36
+ initialize = _usePageDataStore.initialize,
37
+ initializeModule = _usePageDataStore.initializeModule,
38
+ reset = _usePageDataStore.reset;
38
39
  var _useSetState = (0, _ahooks.useSetState)({}),
39
40
  _useSetState2 = (0, _slicedToArray2.default)(_useSetState, 2),
40
41
  remoteSource = _useSetState2[0],
@@ -51,6 +52,7 @@ var _default = exports.default = function _default(_ref) {
51
52
  }
52
53
  }, []);
53
54
  (0, _ahooks.useUnmount)(function () {
55
+ reset();
54
56
  setRuntime(prevRuntime.current);
55
57
  });
56
58
 
@@ -70,6 +72,7 @@ var _default = exports.default = function _default(_ref) {
70
72
  setRemoteSource({
71
73
  module: data
72
74
  });
75
+ initializeModule(data);
73
76
  }
74
77
  }
75
78
  }),
@@ -145,7 +148,7 @@ var _default = exports.default = function _default(_ref) {
145
148
  relationship: data
146
149
  }, info)
147
150
  });
148
- setPageData((0, _dataProcess.decompress)(source));
151
+ initialize((0, _dataProcess.decompress)(source));
149
152
  case 13:
150
153
  case "end":
151
154
  return _context.stop();
@@ -159,20 +162,13 @@ var _default = exports.default = function _default(_ref) {
159
162
  });
160
163
  });
161
164
  return /*#__PURE__*/_react.default.createElement(RemoteSourceContext.Provider, {
162
- value: (0, _objectSpread2.default)((0, _objectSpread2.default)({
163
- pageData: pageData
164
- }, remoteSource), {}, {
165
+ value: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, remoteSource), {}, {
165
166
  loading: fetchPageDataLoading || fetchModlueDataLoading,
166
167
  fetchAllDatasetLoading: fetchAllDatasetLoading,
167
168
  fetchAllSerialsLoading: fetchAllSerialsLoading,
168
169
  refreshModlueData: refreshModlueData,
169
170
  refreshDataset: refreshDataset,
170
- refreshSerials: refreshSerials,
171
- setPageData: setPageData,
172
- back: back,
173
- forward: forward,
174
- backLength: backLength,
175
- forwardLength: forwardLength
171
+ refreshSerials: refreshSerials
176
172
  })
177
173
  }, /*#__PURE__*/_react.default.createElement(_Builder.LuckDaContext.Provider, {
178
174
  value: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, remoteSource.module), {}, {
@@ -110,9 +110,8 @@ function listReducer(state, action) {
110
110
  }
111
111
  }
112
112
  function getCtx(context) {
113
- return (0, _lodash.omitBy)(context, function (_, key) {
114
- return (0, _lodash.startsWith)(key, '_');
115
- });
113
+ return context;
114
+ // return omitBy(context, (_, key) => startsWith(key, '_'));
116
115
  }
117
116
  function getFuncBody(funcCode) {
118
117
  var regex = /{([\s\S]*?)}(?![\s\S]*})/;
@@ -22,8 +22,9 @@ var _excluded = ["props", "children"],
22
22
  function useCanvasRender(data, deps) {
23
23
  var dynamicCompMap = (0, _react.useRef)({});
24
24
  var ctx = (0, _ContextProvider.useContext)();
25
- var render = (0, _ahooks.useMemoizedFn)(function (_ref) {
26
- var props = _ref.props,
25
+ var render = (0, _ahooks.useMemoizedFn)(function () {
26
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
27
+ props = _ref.props,
27
28
  children = _ref.children,
28
29
  childrenMap = (0, _objectWithoutProperties2.default)(_ref, _excluded);
29
30
  if (props && !_constants.LC_BUILDIN_UNIT_KEY_LIST.includes(props.id)) {
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useTask = exports.useGet = exports.resetPageData = exports.modifyNode = exports.getSelfAndParent = exports.getLevelNodes = exports.deleteNode = exports.default = exports.addNode = void 0;
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
10
+ var _react = require("react");
11
+ var _zustand = require("zustand");
12
+ var _immer = require("zustand/middleware/immer");
13
+ var _middleware = require("zustand/middleware");
14
+ var _shallow = require("zustand/react/shallow");
15
+ var _lodash = require("lodash");
16
+ var _dataProcess = require("./dataProcess");
17
+ var _constants = require("../../constants");
18
+ var findNode = function findNode(obj, id) {
19
+ for (var key in obj) {
20
+ if (!['props', 'children'].includes(key)) {
21
+ if (key === id) {
22
+ return {
23
+ target: obj[key],
24
+ parent: obj
25
+ };
26
+ }
27
+ if ((0, _typeof2.default)(obj[key]) === 'object' && !Array.isArray(obj[key])) {
28
+ var result = findNode(obj[key], id);
29
+ if (result) {
30
+ return result;
31
+ }
32
+ }
33
+ }
34
+ }
35
+ return null;
36
+ };
37
+ var usePageDataStore = (0, _zustand.create)()((0, _immer.immer)((0, _middleware.subscribeWithSelector)(function (set) {
38
+ return {
39
+ pageData: null,
40
+ moduleData: null,
41
+ initialize: function initialize(data) {
42
+ return set(function (state) {
43
+ state.pageData = data;
44
+ });
45
+ },
46
+ initializeModule: function initializeModule(data) {
47
+ return set(function (state) {
48
+ state.moduleData = data;
49
+ });
50
+ },
51
+ reset: function reset(data) {
52
+ return set(function (state) {
53
+ state.pageData = data || null;
54
+ });
55
+ }
56
+ };
57
+ })));
58
+ var _default = exports.default = usePageDataStore;
59
+ var resetPageData = exports.resetPageData = function resetPageData(data) {
60
+ usePageDataStore.setState(function (state) {
61
+ state.pageData = data || null;
62
+ });
63
+ };
64
+ var addNode = exports.addNode = function addNode(parentId, id, data) {
65
+ usePageDataStore.setState(function (state) {
66
+ if (parentId === _constants.LC_BUILDIN_UNIT_KEY.PAGE_ROOT) {
67
+ state.pageData.children.push(id);
68
+ state.pageData[id] = {
69
+ props: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
70
+ id: id,
71
+ parentId: parentId
72
+ })
73
+ };
74
+ return;
75
+ }
76
+ var _ref = findNode(state.pageData, parentId) || {},
77
+ target = _ref.target;
78
+ if (!target) return;
79
+ if (!target.hasOwnProperty('children')) {
80
+ target.children = [];
81
+ }
82
+ if (!target.children.includes(id)) {
83
+ target.children.push(id);
84
+ target[id] = {
85
+ props: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
86
+ id: id,
87
+ parentId: parentId
88
+ })
89
+ };
90
+ }
91
+ });
92
+ };
93
+ var deleteNode = exports.deleteNode = function deleteNode(id) {
94
+ usePageDataStore.setState(function (state) {
95
+ var _parent$children;
96
+ var _ref2 = findNode(state.pageData, id) || {},
97
+ parent = _ref2.parent;
98
+ if (!parent || !((_parent$children = parent.children) !== null && _parent$children !== void 0 && _parent$children.length)) return;
99
+ parent.children.splice(parent.children.indexOf(id), 1);
100
+ if (parent.children.length === 0) {
101
+ delete parent['children'];
102
+ }
103
+ delete parent[id];
104
+ });
105
+ };
106
+ var modifyNode = exports.modifyNode = function modifyNode(id, data) {
107
+ usePageDataStore.setState(function (state) {
108
+ if (id === _constants.LC_BUILDIN_UNIT_KEY.PAGE_ROOT) {
109
+ assign(state.pageData.props, (0, _lodash.omit)(data, ['id', 'parentId', 'component', 'buildIn']));
110
+ return;
111
+ }
112
+ var _ref3 = findNode(state.pageData, id) || {},
113
+ target = _ref3.target;
114
+ if (!target) return;
115
+ (0, _lodash.forOwn)((0, _lodash.omit)(data, ['id', 'parentId', 'component', 'buildIn']), function (_val, _key) {
116
+ (0, _lodash.set)(target.props, _key, _val);
117
+ });
118
+ });
119
+ };
120
+ var useTask = exports.useTask = function useTask(type) {
121
+ var promiseRef = (0, _react.useRef)(null);
122
+ var task = (0, _react.useCallback)(function () {
123
+ for (var _len = arguments.length, args = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
124
+ args[_key2] = arguments[_key2];
125
+ }
126
+ return new Promise(function (resolve) {
127
+ promiseRef.current = resolve;
128
+ switch (type) {
129
+ case 'add':
130
+ addNode.apply(void 0, args);
131
+ break;
132
+ case 'update':
133
+ case 'modify':
134
+ modifyNode.apply(void 0, args);
135
+ break;
136
+ case 'delete':
137
+ deleteNode.apply(void 0, args);
138
+ break;
139
+ default:
140
+ break;
141
+ }
142
+ });
143
+ }, []);
144
+ (0, _react.useEffect)(function () {
145
+ var unsub = usePageDataStore.subscribe(function (state, prevState) {
146
+ if (!promiseRef.current) {
147
+ return;
148
+ }
149
+ promiseRef.current(state.pageData, prevState.pageData);
150
+ promiseRef.current = null;
151
+ });
152
+ return unsub;
153
+ }, []);
154
+ return task;
155
+ };
156
+ var useGet = exports.useGet = function useGet(_) {
157
+ var result = usePageDataStore((0, _shallow.useShallow)(function (state) {
158
+ if ((0, _lodash.isNil)(_)) {
159
+ return state.pageData;
160
+ } else if ((0, _lodash.isFunction)(_)) {
161
+ return _(state.pageData);
162
+ } else if ((0, _lodash.isArray)(_)) {
163
+ return _.map(function (k) {
164
+ var _findNode;
165
+ return k.includes('.') ? (0, _lodash.get)(state.pageData, k) : (_findNode = findNode(state.pageData, k)) === null || _findNode === void 0 ? void 0 : _findNode.target;
166
+ });
167
+ } else if ((0, _lodash.isObject)(_) && _.id) {
168
+ var _findNode2;
169
+ return _.id === _constants.LC_BUILDIN_UNIT_KEY.PAGE_ROOT ? state.pageData : (_findNode2 = findNode(state.pageData, _.id)) === null || _findNode2 === void 0 ? void 0 : _findNode2.target;
170
+ } else if ((0, _lodash.isString)(_)) {
171
+ return (0, _lodash.get)(state.pageData, _);
172
+ }
173
+ }));
174
+ return result;
175
+ };
176
+ var getLevelNodes = exports.getLevelNodes = function getLevelNodes(id) {
177
+ return (0, _dataProcess.getPathNodesById)(usePageDataStore.getState().pageData, id);
178
+ };
179
+ var getSelfAndParent = exports.getSelfAndParent = function getSelfAndParent(id) {
180
+ return (0, _dataProcess.findNodeAndParent)(id, usePageDataStore.getState().pageData);
181
+ };
@@ -1,41 +1,31 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = void 0;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
7
9
  var _react = require("react");
8
10
  var _ahooks = require("ahooks");
9
- var _lodash = require("lodash");
10
11
  var usePromiseState = function usePromiseState(initialState) {
11
- var _useHistoryTravel = (0, _ahooks.useHistoryTravel)(initialState),
12
- value = _useHistoryTravel.value,
13
- setValue = _useHistoryTravel.setValue,
14
- backLength = _useHistoryTravel.backLength,
15
- forwardLength = _useHistoryTravel.forwardLength,
16
- back = _useHistoryTravel.back,
17
- forward = _useHistoryTravel.forward;
12
+ var _useState = (0, _react.useState)(initialState),
13
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
14
+ state = _useState2[0],
15
+ setState = _useState2[1];
18
16
  var promiseRef = (0, _react.useRef)(null);
19
- var setStatePromise = (0, _react.useCallback)(function (_value) {
17
+ var setStatePromise = (0, _react.useCallback)(function (_state) {
20
18
  return new Promise(function (resolve) {
21
19
  promiseRef.current = resolve;
22
- var _valStr = JSON.stringify(_value);
23
- if (!(0, _lodash.isEqual)(value, _valStr)) {
24
- setValue(_valStr);
25
- }
20
+ setState(_state);
26
21
  });
27
22
  }, []);
28
23
  (0, _ahooks.useUpdateLayoutEffect)(function () {
29
24
  if (promiseRef.current) {
30
- promiseRef.current(JSON.parse(value));
25
+ promiseRef.current(state);
31
26
  promiseRef.current = null;
32
27
  }
33
- }, [value]);
34
- return [JSON.parse(value), setStatePromise, {
35
- backLength: backLength - 1,
36
- forwardLength: forwardLength,
37
- back: back,
38
- forward: forward
39
- }];
28
+ }, [state]);
29
+ return [state, setStatePromise];
40
30
  };
41
31
  var _default = exports.default = usePromiseState;
@@ -12,6 +12,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
12
12
  var _ahooks = require("ahooks");
13
13
  var _antd = require("luck-design/antd");
14
14
  var _lodash = require("lodash");
15
+ var _usePageDataStore = _interopRequireDefault(require("./usePageDataStore"));
15
16
  var _helper = require("./helper");
16
17
  var _apiUrl = require("../../constants/api-url");
17
18
  var _excluded = ["datasetCode"];
@@ -32,10 +33,13 @@ var useTodo = function useTodo() {
32
33
  behaviorKey: behaviorKey
33
34
  }, params), data);
34
35
  });
36
+ var moduleData = (0, _usePageDataStore.default)(function (state) {
37
+ return state.moduleData;
38
+ });
35
39
  var todo = (0, _ahooks.useMemoizedFn)(function (ctx, actionPool) {
36
40
  var argsMap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
37
41
  if ((0, _lodash.isNil)(actionPool)) {
38
- return;
42
+ return Promise.resolve();
39
43
  }
40
44
  var dsCode = argsMap.datasetCode,
41
45
  args = (0, _objectWithoutProperties2.default)(argsMap, _excluded);
@@ -54,21 +58,27 @@ var useTodo = function useTodo() {
54
58
  return Promise.resolve(_helper.executeCode.apply(void 0, [ctx, info.code, argsName].concat((0, _toConsumableArray2.default)(_args))));
55
59
  case 'page-action':
56
60
  {
57
- var _JSON$parse = JSON.parse(info.code || '{}'),
58
- moduleCode = _JSON$parse.moduleCode,
59
- datasetCode = _JSON$parse.datasetCode,
60
- params = _JSON$parse.params,
61
- data = _JSON$parse.data;
61
+ var _ref4 = _helper.executeCode.apply(void 0, [ctx, info.code, argsName].concat((0, _toConsumableArray2.default)(_args))) || {},
62
+ moduleCode = _ref4.moduleCode,
63
+ datasetCode = _ref4.datasetCode,
64
+ params = _ref4.params,
65
+ data = _ref4.data,
66
+ after = _ref4.after;
67
+ var _moduleCode = moduleCode || moduleData.moduleCode;
62
68
  var _dscode = datasetCode || dsCode;
63
- if (!moduleCode || !_dscode) {
69
+ if (!_moduleCode || !_dscode) {
64
70
  _antd.message.warning('接口重要参数(模块编码或数据集编码)丢失');
65
71
  return;
66
72
  }
67
73
  return callBehavior({
68
74
  datasetCode: _dscode,
69
- moduleCode: moduleCode,
75
+ moduleCode: _moduleCode,
70
76
  behaviorKey: actionKey
71
- }, params, data);
77
+ }, params, data).then(function (res) {
78
+ if ((0, _lodash.isFunction)(after)) {
79
+ after(ctx, res);
80
+ }
81
+ });
72
82
  }
73
83
  case 'trigger':
74
84
  return Promise.resolve();
@@ -13,7 +13,6 @@ var _ahooks = require("ahooks");
13
13
  var _antd = require("luck-design/antd");
14
14
  var _utils = require("@luck-design-biz/base/utils");
15
15
  var _ContextProvider = require("../engine/provider/ContextProvider");
16
- var _dataProcess = require("../engine/tools/dataProcess");
17
16
  var _constants = require("../constants");
18
17
  var _design = _interopRequireDefault(require("./style/design.less"));
19
18
  var _MODAL_COMPONENT_ = ['Dialog', 'Drawer'];
@@ -36,10 +35,6 @@ var DesignOperator = function DesignOperator(_ref) {
36
35
  var _getDomById, _getDomById2;
37
36
  var target = _ref.target;
38
37
  var context = (0, _ContextProvider.useContext)();
39
- var _usePageData = (0, _ContextProvider.usePageData)(),
40
- _usePageData2 = (0, _slicedToArray2.default)(_usePageData, 2),
41
- pageData = _usePageData2[0],
42
- setPageData = _usePageData2[1].setPageData;
43
38
  var size = (0, _ahooks.useSize)(target);
44
39
  var _useState = (0, _react.useState)((0, _utils.suid)()),
45
40
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -71,27 +66,24 @@ var DesignOperator = function DesignOperator(_ref) {
71
66
  var handleDelete = (0, _ahooks.useMemoizedFn)(function (_ref2) {
72
67
  var id = _ref2.id;
73
68
  context.$publisher(context.topics.COMPONENT_DELETE, {
74
- id: id,
75
- pageData: pageData
69
+ id: id
76
70
  });
77
71
  });
78
72
  var addComponent = (0, _ahooks.useMemoizedFn)(function (data, targetId) {
79
- var json = require("../engine/meta/".concat(data.component.toLowerCase(), ".props.default.json"));
80
- var _id = "".concat(data.component.toLowerCase(), "_").concat((0, _utils.suid)());
81
- (0, _dataProcess.add)(pageData, targetId, _id, json);
82
73
  context.$subscriber(context.topics.COMPONENT_MOUNT).once(function (_ref3) {
83
74
  var mountCompId = _ref3.id;
84
75
  if (mountCompId === _id) {
85
76
  context.$publisher(context.topics.COMPONENT_APPEND, {
86
- id: _id,
87
- pageData: pageData
77
+ id: _id
88
78
  });
89
79
  context.$publisher(context.topics.COMPONENT_ACTIVE, {
90
80
  id: _id
91
81
  });
92
82
  }
93
83
  }).watch();
94
- setPageData(pageData);
84
+ var json = require("../engine/meta/".concat(data.component.toLowerCase(), ".props.default.json"));
85
+ var _id = "".concat(data.component.toLowerCase(), "_").concat((0, _utils.suid)());
86
+ (0, _ContextProvider.addNode)(targetId, _id, json);
95
87
  });
96
88
  var acticeProps = (0, _ahooks.useCreation)(function () {
97
89
  if (!operatorId.selector) return null;
@@ -198,8 +190,7 @@ var DesignOperator = function DesignOperator(_ref) {
198
190
  }).watch();
199
191
  var acid = context.$subscriber(context.topics.COMPONENT_ACTIVE).on(function (payload) {
200
192
  if (payload.id) {
201
- var _context$componentMap2 = context.componentMap.get(payload.id).api.getSelfAndParentLCData(),
202
- node = _context$componentMap2.node;
193
+ var node = context.componentMap.get(payload.id).api.getSelfData();
203
194
  setOperatorId({
204
195
  selector: payload.id,
205
196
  deletable: node.props.buildIn !== true,
@@ -214,14 +205,14 @@ var DesignOperator = function DesignOperator(_ref) {
214
205
  var cmtid = context.$subscriber(context.topics.COMPONENT_MODAL_TOGGLE).on(function (_ref6) {
215
206
  var toggle = _ref6.toggle,
216
207
  id = _ref6.id;
217
- if (toggle) {
208
+ if (toggle && id !== currentModal.current) {
218
209
  target.current.style.setProperty('overflow', 'hidden');
219
210
  var _modal = context.componentMap.get(id);
220
211
  var _prevModal = currentModal.current ? context.componentMap.get(currentModal.current) : null;
221
212
  _prevModal === null || _prevModal === void 0 || _prevModal.api.doClose();
222
213
  _modal.api.doOpen();
223
214
  currentModal.current = id;
224
- } else {
215
+ } else if (!toggle) {
225
216
  target.current.style.removeProperty('overflow');
226
217
  var _id = id || currentModal.current;
227
218
  if (_id) {
@@ -232,13 +223,11 @@ var DesignOperator = function DesignOperator(_ref) {
232
223
  }
233
224
  }).watch();
234
225
  var cdid = context.$subscriber(context.topics.COMPONENT_DELETE).on(function (_ref7) {
235
- var id = _ref7.id,
236
- pageData = _ref7.pageData;
226
+ var id = _ref7.id;
237
227
  if (lastSelectorId.current === id) {
238
228
  context.$publisher(context.topics.COMPONENT_ACTIVE, null);
239
229
  }
240
- (0, _dataProcess.deleteById)(pageData, id);
241
- setPageData(pageData);
230
+ (0, _ContextProvider.deleteNode)(id);
242
231
  });
243
232
  return function () {
244
233
  context.$unsubscriber(context.topics.COMPONENT_SETTING_CLICK, csid);