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

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 (255) hide show
  1. package/es/components/LDActions/index.js +8 -10
  2. package/es/components/LDActions/index.less +7 -4
  3. package/es/components/LdAutoForm/index.js +26 -8
  4. package/es/components/LdFormList/index.js +37 -22
  5. package/es/components/LdGrid/index.js +14 -7
  6. package/es/components/LdGridForm/index.js +18 -6
  7. package/es/components/LdTree/index.js +33 -15
  8. package/es/helper/form.js +15 -8
  9. package/es/locales/zh-CN.js +16 -10
  10. package/es/lowcode/constants/api-url.js +120 -32
  11. package/es/lowcode/constants/event-topics.js +2 -0
  12. package/es/lowcode/engine/factory/panel-item-factory/SelectStrategy.js +4 -2
  13. package/es/lowcode/engine/factory/panel-item-factory/SwitchStrategy.js +4 -2
  14. package/es/lowcode/engine/meta/box.props.json +3 -3
  15. package/es/lowcode/engine/meta/button.props.json +3 -3
  16. package/es/lowcode/engine/meta/components-list.json +6 -0
  17. package/es/lowcode/engine/meta/dialog.props.default.json +10 -5
  18. package/es/lowcode/engine/meta/dialog.props.json +72 -42
  19. package/es/lowcode/engine/meta/drawer.props.json +8 -20
  20. package/es/lowcode/engine/meta/form.props.json +16 -10
  21. package/es/lowcode/engine/meta/imex.props.default.json +8 -1
  22. package/es/lowcode/engine/meta/imex.props.json +54 -22
  23. package/es/lowcode/engine/meta/js-editor/auto-complete.json +53 -3
  24. package/es/lowcode/engine/meta/layout.props.json +2 -2
  25. package/es/lowcode/engine/meta/page.props.json +2 -2
  26. package/es/lowcode/engine/meta/pagelayout.props.default.json +14 -0
  27. package/es/lowcode/engine/meta/pagelayout.props.json +47 -0
  28. package/es/lowcode/engine/meta/section.props.json +2 -2
  29. package/es/lowcode/engine/meta/split.props.default.json +1 -1
  30. package/es/lowcode/engine/meta/split.props.json +4 -4
  31. package/es/lowcode/engine/meta/table.props.json +17 -11
  32. package/es/lowcode/engine/meta/tabs.props.json +3 -3
  33. package/es/lowcode/engine/meta/tree.props.default.json +2 -0
  34. package/es/lowcode/engine/meta/tree.props.json +62 -6
  35. package/es/lowcode/engine/provider/ContextProvider/index.js +20 -43
  36. package/es/lowcode/engine/provider/RemoteSourceProvider.js +69 -24
  37. package/es/lowcode/engine/tools/dataProcess.js +4 -0
  38. package/es/lowcode/engine/tools/helper.js +2 -3
  39. package/es/lowcode/engine/tools/useCanvasRender.js +3 -2
  40. package/es/lowcode/engine/tools/usePageDataStore.js +176 -0
  41. package/es/lowcode/engine/tools/usePromiseState.js +12 -23
  42. package/es/lowcode/engine/tools/useTodo.js +20 -10
  43. package/es/lowcode/painter/DesignOperator.js +12 -23
  44. package/es/lowcode/painter/DesignToolbar.js +10 -45
  45. package/es/lowcode/painter/Outline.js +2 -4
  46. package/es/lowcode/painter/Panel.js +29 -28
  47. package/es/lowcode/painter/components/ActionBindModal.js +30 -24
  48. package/es/lowcode/painter/components/AdvancePanel.js +6 -1
  49. package/es/lowcode/painter/components/AttrsPanel.js +38 -29
  50. package/es/lowcode/painter/components/DragDrop/DragDropContext.js +1 -1
  51. package/es/lowcode/painter/components/code-editor/BaseEditor.js +3 -2
  52. package/es/lowcode/painter/components/field-setting/CheckFrontRules.js +108 -0
  53. package/es/lowcode/painter/components/field-setting/CheckRules.js +1 -26
  54. package/es/lowcode/painter/components/field-setting/FieldRulesModal.js +33 -13
  55. package/es/lowcode/painter/components/field-setting/SettingUI.js +162 -30
  56. package/es/lowcode/painter/components/field-setting/index.js +32 -63
  57. package/es/lowcode/painter/components/field-setting/meta/frontRules.js +53 -0
  58. package/es/lowcode/painter/panel-section/BlocksEditor/index.js +14 -17
  59. package/es/lowcode/painter/panel-section/ButtonType.js +4 -2
  60. package/es/lowcode/painter/panel-section/DataSetSelector.js +4 -1
  61. package/es/lowcode/painter/panel-section/FieldsSetting.js +53 -8
  62. package/es/lowcode/painter/panel-section/ImpExp.js +93 -6
  63. package/es/lowcode/painter/panel-section/ImpExpAlone.js +109 -0
  64. package/es/lowcode/painter/panel-section/PageLayoutDisplay.js +95 -0
  65. package/es/lowcode/painter/panel-section/SerialsSelector.js +4 -2
  66. package/es/lowcode/painter/panel-section/SplitDisplay.js +25 -110
  67. package/es/lowcode/painter/panel-section/StylePanel/index.js +10 -4
  68. package/es/lowcode/painter/panel-section/TreeRootEditor.js +2 -2
  69. package/es/lowcode/painter/style/action-bind-modal.less +3 -3
  70. package/es/lowcode/painter/style/design.less +1 -1
  71. package/es/lowcode/painter/style/page-layout-display.less +28 -0
  72. package/es/lowcode/painter/style/panel-item.less +1 -1
  73. package/es/lowcode/painter/style/split-display.less +0 -9
  74. package/es/lowcode/preview/index.js +4 -2
  75. package/es/lowcode/view/Canvas.js +6 -7
  76. package/es/lowcode/view/Page.js +2 -3
  77. package/es/lowcode/view/lc-components/Box/FunctionDesign.js +3 -2
  78. package/es/lowcode/view/lc-components/Box/meta.json +3 -3
  79. package/es/lowcode/view/lc-components/Button/index.js +2 -6
  80. package/es/lowcode/view/lc-components/Button/meta.json +3 -3
  81. package/es/lowcode/view/lc-components/Dialog/FunctionDesign.js +3 -10
  82. package/es/lowcode/view/lc-components/Dialog/index.js +114 -19
  83. package/es/lowcode/view/lc-components/Dialog/meta.json +65 -42
  84. package/es/lowcode/view/lc-components/Drawer/meta.json +8 -20
  85. package/es/lowcode/view/lc-components/Form/FunctionDesign.js +23 -33
  86. package/es/lowcode/view/lc-components/Form/FunctionPreview.js +8 -1
  87. package/es/lowcode/view/lc-components/Form/index.js +113 -21
  88. package/es/lowcode/view/lc-components/Form/meta.json +16 -10
  89. package/es/lowcode/view/lc-components/ImEx/FunctionDesign.js +8 -3
  90. package/es/lowcode/view/lc-components/ImEx/index.js +260 -10
  91. package/es/lowcode/view/lc-components/ImEx/index.less +7 -0
  92. package/es/lowcode/view/lc-components/ImEx/meta.json +55 -23
  93. package/es/lowcode/view/lc-components/Layout/FunctionDesign.js +12 -19
  94. package/es/lowcode/view/lc-components/Layout/meta.json +2 -2
  95. package/es/lowcode/view/lc-components/Page/meta.json +2 -2
  96. package/es/lowcode/view/lc-components/PageContent/index.js +8 -9
  97. package/es/lowcode/view/lc-components/PageFooter/index.js +2 -5
  98. package/es/lowcode/view/lc-components/PageHeader/index.js +5 -6
  99. package/es/lowcode/view/lc-components/PageLayout/FunctionDesign.js +63 -0
  100. package/es/lowcode/view/lc-components/PageLayout/FunctionLive.js +10 -0
  101. package/es/lowcode/view/lc-components/PageLayout/FunctionPreview.js +10 -0
  102. package/es/lowcode/view/lc-components/PageLayout/index.js +32 -0
  103. package/es/lowcode/view/lc-components/PageLayout/meta.json +47 -0
  104. package/es/lowcode/view/lc-components/PageModal/index.js +12 -15
  105. package/es/lowcode/view/lc-components/Section/FunctionDesign.js +3 -9
  106. package/es/lowcode/view/lc-components/Section/meta.json +2 -2
  107. package/es/lowcode/view/lc-components/Split/FunctionDesign.js +19 -20
  108. package/es/lowcode/view/lc-components/Split/index.js +5 -9
  109. package/es/lowcode/view/lc-components/Split/meta.json +4 -4
  110. package/es/lowcode/view/lc-components/Table/components/TopImex.js +138 -0
  111. package/es/lowcode/view/lc-components/Table/index.js +124 -39
  112. package/es/lowcode/view/lc-components/Table/meta.json +17 -11
  113. package/es/lowcode/view/lc-components/Tabs/FunctionDesign.js +10 -17
  114. package/es/lowcode/view/lc-components/Tabs/index.js +3 -1
  115. package/es/lowcode/view/lc-components/Tabs/meta.json +3 -3
  116. package/es/lowcode/view/lc-components/Tree/FunctionDesign.js +2 -1
  117. package/es/lowcode/view/lc-components/Tree/index.js +67 -18
  118. package/es/lowcode/view/lc-components/Tree/meta.json +62 -7
  119. package/es/lowcode/view/lc-components/Wrapper.js +9 -11
  120. package/es/services.js +0 -24
  121. package/es/upload/FilesWall/file.png +0 -0
  122. package/es/upload/FilesWall/index.js +422 -0
  123. package/es/upload/FilesWall/index.less +74 -0
  124. package/es/upload/Form/index.js +2 -1
  125. package/es/upload/FormItem/index.js +3 -5
  126. package/es/upload/index.js +2 -1
  127. package/es/utils/action.js +2 -2
  128. package/lib/components/LDActions/index.js +7 -9
  129. package/lib/components/LDActions/index.less +7 -4
  130. package/lib/components/LdAutoForm/index.js +25 -7
  131. package/lib/components/LdFormList/index.js +36 -21
  132. package/lib/components/LdGrid/index.js +14 -7
  133. package/lib/components/LdGridForm/index.js +16 -4
  134. package/lib/components/LdTree/index.js +33 -15
  135. package/lib/helper/form.js +14 -7
  136. package/lib/locales/zh-CN.js +16 -10
  137. package/lib/lowcode/constants/api-url.js +123 -32
  138. package/lib/lowcode/constants/event-topics.js +3 -1
  139. package/lib/lowcode/engine/factory/panel-item-factory/SelectStrategy.js +4 -2
  140. package/lib/lowcode/engine/factory/panel-item-factory/SwitchStrategy.js +4 -2
  141. package/lib/lowcode/engine/meta/box.props.json +3 -3
  142. package/lib/lowcode/engine/meta/button.props.json +3 -3
  143. package/lib/lowcode/engine/meta/components-list.json +6 -0
  144. package/lib/lowcode/engine/meta/dialog.props.default.json +10 -5
  145. package/lib/lowcode/engine/meta/dialog.props.json +72 -42
  146. package/lib/lowcode/engine/meta/drawer.props.json +8 -20
  147. package/lib/lowcode/engine/meta/form.props.json +16 -10
  148. package/lib/lowcode/engine/meta/imex.props.default.json +8 -1
  149. package/lib/lowcode/engine/meta/imex.props.json +54 -22
  150. package/lib/lowcode/engine/meta/js-editor/auto-complete.json +53 -3
  151. package/lib/lowcode/engine/meta/layout.props.json +2 -2
  152. package/lib/lowcode/engine/meta/page.props.json +2 -2
  153. package/lib/lowcode/engine/meta/pagelayout.props.default.json +14 -0
  154. package/lib/lowcode/engine/meta/pagelayout.props.json +47 -0
  155. package/lib/lowcode/engine/meta/section.props.json +2 -2
  156. package/lib/lowcode/engine/meta/split.props.default.json +1 -1
  157. package/lib/lowcode/engine/meta/split.props.json +4 -4
  158. package/lib/lowcode/engine/meta/table.props.json +17 -11
  159. package/lib/lowcode/engine/meta/tabs.props.json +3 -3
  160. package/lib/lowcode/engine/meta/tree.props.default.json +2 -0
  161. package/lib/lowcode/engine/meta/tree.props.json +62 -6
  162. package/lib/lowcode/engine/provider/ContextProvider/index.js +36 -43
  163. package/lib/lowcode/engine/provider/RemoteSourceProvider.js +68 -23
  164. package/lib/lowcode/engine/tools/dataProcess.js +4 -0
  165. package/lib/lowcode/engine/tools/helper.js +2 -3
  166. package/lib/lowcode/engine/tools/useCanvasRender.js +3 -2
  167. package/lib/lowcode/engine/tools/usePageDataStore.js +183 -0
  168. package/lib/lowcode/engine/tools/usePromiseState.js +11 -21
  169. package/lib/lowcode/engine/tools/useTodo.js +19 -9
  170. package/lib/lowcode/painter/DesignOperator.js +11 -22
  171. package/lib/lowcode/painter/DesignToolbar.js +9 -44
  172. package/lib/lowcode/painter/Outline.js +1 -3
  173. package/lib/lowcode/painter/Panel.js +28 -27
  174. package/lib/lowcode/painter/components/ActionBindModal.js +28 -22
  175. package/lib/lowcode/painter/components/AdvancePanel.js +6 -1
  176. package/lib/lowcode/painter/components/AttrsPanel.js +37 -28
  177. package/lib/lowcode/painter/components/DragDrop/DragDropContext.js +1 -1
  178. package/lib/lowcode/painter/components/code-editor/BaseEditor.js +3 -2
  179. package/lib/lowcode/painter/components/field-setting/CheckFrontRules.js +116 -0
  180. package/lib/lowcode/painter/components/field-setting/CheckRules.js +1 -26
  181. package/lib/lowcode/painter/components/field-setting/FieldRulesModal.js +34 -13
  182. package/lib/lowcode/painter/components/field-setting/SettingUI.js +159 -27
  183. package/lib/lowcode/painter/components/field-setting/index.js +32 -63
  184. package/lib/lowcode/painter/components/field-setting/meta/frontRules.js +59 -0
  185. package/lib/lowcode/painter/panel-section/BlocksEditor/index.js +13 -16
  186. package/lib/lowcode/painter/panel-section/ButtonType.js +4 -2
  187. package/lib/lowcode/painter/panel-section/DataSetSelector.js +4 -1
  188. package/lib/lowcode/painter/panel-section/FieldsSetting.js +53 -8
  189. package/lib/lowcode/painter/panel-section/ImpExp.js +92 -5
  190. package/lib/lowcode/painter/panel-section/ImpExpAlone.js +115 -0
  191. package/lib/lowcode/painter/panel-section/PageLayoutDisplay.js +103 -0
  192. package/lib/lowcode/painter/panel-section/SerialsSelector.js +4 -2
  193. package/lib/lowcode/painter/panel-section/SplitDisplay.js +24 -109
  194. package/lib/lowcode/painter/panel-section/StylePanel/index.js +10 -4
  195. package/lib/lowcode/painter/panel-section/TreeRootEditor.js +2 -2
  196. package/lib/lowcode/painter/style/action-bind-modal.less +3 -3
  197. package/lib/lowcode/painter/style/design.less +1 -1
  198. package/lib/lowcode/painter/style/page-layout-display.less +28 -0
  199. package/lib/lowcode/painter/style/panel-item.less +1 -1
  200. package/lib/lowcode/painter/style/split-display.less +0 -9
  201. package/lib/lowcode/preview/index.js +4 -2
  202. package/lib/lowcode/view/Canvas.js +5 -6
  203. package/lib/lowcode/view/Page.js +2 -3
  204. package/lib/lowcode/view/lc-components/Box/FunctionDesign.js +3 -2
  205. package/lib/lowcode/view/lc-components/Box/meta.json +3 -3
  206. package/lib/lowcode/view/lc-components/Button/index.js +2 -6
  207. package/lib/lowcode/view/lc-components/Button/meta.json +3 -3
  208. package/lib/lowcode/view/lc-components/Dialog/FunctionDesign.js +2 -9
  209. package/lib/lowcode/view/lc-components/Dialog/index.js +114 -19
  210. package/lib/lowcode/view/lc-components/Dialog/meta.json +65 -42
  211. package/lib/lowcode/view/lc-components/Drawer/meta.json +8 -20
  212. package/lib/lowcode/view/lc-components/Form/FunctionDesign.js +20 -31
  213. package/lib/lowcode/view/lc-components/Form/FunctionPreview.js +8 -1
  214. package/lib/lowcode/view/lc-components/Form/index.js +110 -18
  215. package/lib/lowcode/view/lc-components/Form/meta.json +16 -10
  216. package/lib/lowcode/view/lc-components/ImEx/FunctionDesign.js +8 -3
  217. package/lib/lowcode/view/lc-components/ImEx/index.js +257 -8
  218. package/lib/lowcode/view/lc-components/ImEx/index.less +7 -0
  219. package/lib/lowcode/view/lc-components/ImEx/meta.json +55 -23
  220. package/lib/lowcode/view/lc-components/Layout/FunctionDesign.js +11 -18
  221. package/lib/lowcode/view/lc-components/Layout/meta.json +2 -2
  222. package/lib/lowcode/view/lc-components/Page/meta.json +2 -2
  223. package/lib/lowcode/view/lc-components/PageContent/index.js +7 -8
  224. package/lib/lowcode/view/lc-components/PageFooter/index.js +2 -5
  225. package/lib/lowcode/view/lc-components/PageHeader/index.js +4 -5
  226. package/lib/lowcode/view/lc-components/PageLayout/FunctionDesign.js +71 -0
  227. package/lib/lowcode/view/lc-components/PageLayout/FunctionLive.js +17 -0
  228. package/lib/lowcode/view/lc-components/PageLayout/FunctionPreview.js +17 -0
  229. package/lib/lowcode/view/lc-components/PageLayout/index.js +40 -0
  230. package/lib/lowcode/view/lc-components/PageLayout/meta.json +47 -0
  231. package/lib/lowcode/view/lc-components/PageModal/index.js +11 -14
  232. package/lib/lowcode/view/lc-components/Section/FunctionDesign.js +2 -8
  233. package/lib/lowcode/view/lc-components/Section/meta.json +2 -2
  234. package/lib/lowcode/view/lc-components/Split/FunctionDesign.js +19 -20
  235. package/lib/lowcode/view/lc-components/Split/index.js +2 -6
  236. package/lib/lowcode/view/lc-components/Split/meta.json +4 -4
  237. package/lib/lowcode/view/lc-components/Table/components/TopImex.js +145 -0
  238. package/lib/lowcode/view/lc-components/Table/index.js +123 -38
  239. package/lib/lowcode/view/lc-components/Table/meta.json +17 -11
  240. package/lib/lowcode/view/lc-components/Tabs/FunctionDesign.js +11 -18
  241. package/lib/lowcode/view/lc-components/Tabs/index.js +3 -1
  242. package/lib/lowcode/view/lc-components/Tabs/meta.json +3 -3
  243. package/lib/lowcode/view/lc-components/Tree/FunctionDesign.js +2 -1
  244. package/lib/lowcode/view/lc-components/Tree/index.js +65 -16
  245. package/lib/lowcode/view/lc-components/Tree/meta.json +62 -7
  246. package/lib/lowcode/view/lc-components/Wrapper.js +8 -10
  247. package/lib/services.js +0 -25
  248. package/lib/upload/FilesWall/file.png +0 -0
  249. package/lib/upload/FilesWall/index.js +429 -0
  250. package/lib/upload/FilesWall/index.less +74 -0
  251. package/lib/upload/Form/index.js +2 -1
  252. package/lib/upload/FormItem/index.js +3 -5
  253. package/lib/upload/index.js +8 -1
  254. package/lib/utils/action.js +2 -2
  255. package/package.json +5 -4
@@ -17,7 +17,18 @@
17
17
  "key": "dataset",
18
18
  "name": "数据集",
19
19
  "desc": "选择系统中的可用树形数据集",
20
- "type": "_DataSetSelector"
20
+ "type": "_DataSetSelector",
21
+ "next": {
22
+ "name": "字段配置",
23
+ "props": [
24
+ {
25
+ "key": "fields",
26
+ "name": "#字段配置器",
27
+ "type": "_FieldsSetting",
28
+ "component": "tree"
29
+ }
30
+ ]
31
+ }
21
32
  },
22
33
  {
23
34
  "key": "title",
@@ -119,6 +130,32 @@
119
130
  }
120
131
  ]
121
132
  },
133
+ {
134
+ "key": "selectSetting",
135
+ "name": "选中设置",
136
+ "type": "group",
137
+ "props": [
138
+ {
139
+ "key": "cancelSelect",
140
+ "name": "取消选中",
141
+ "desc": "是否可以取消选中",
142
+ "type": "switch",
143
+ "default": true
144
+ },
145
+ {
146
+ "key": "defaultSelect",
147
+ "name": "默认选中",
148
+ "desc": "返回默认选中的数据主键",
149
+ "type": "_JSEditor",
150
+ "defaultCode": "function defaultSelect(treeData) { \n return []; \n}",
151
+ "mustConfirm": true,
152
+ "wrapper": "collapse",
153
+ "wrapperProps": {
154
+ "suppressIcon": true
155
+ }
156
+ }
157
+ ]
158
+ },
122
159
  {
123
160
  "key": "IconSetting",
124
161
  "name": "图标设置",
@@ -170,6 +207,13 @@
170
207
  "type": "switch",
171
208
  "default": true
172
209
  },
210
+ {
211
+ "key": "onlyRoot",
212
+ "name": "根节点唯一",
213
+ "desc": "树组件仅一个根节点,如数据根节点数大于0,则不允许根节点新增",
214
+ "type": "switch",
215
+ "default": false
216
+ },
173
217
  {
174
218
  "key": "rootAddSetting",
175
219
  "name": "根节点配置",
@@ -272,31 +316,43 @@
272
316
  "key": "onMount",
273
317
  "name": "组件首次渲染时",
274
318
  "desc": "在组件首次渲染时,执行方法",
275
- "func": "(params)=>{\n\t\n}"
319
+ "func": "function onMount(params) {\n\t\n}"
276
320
  },
277
321
  {
278
322
  "key": "onUnmount",
279
323
  "name": "组件卸载时",
280
324
  "desc": "在组件卸载时,执行方法。",
281
- "func": "()=>{\n\t\n}"
325
+ "func": "function onUnmount() {\n\t\n}"
282
326
  },
283
327
  {
284
328
  "key": "processDataSource",
285
329
  "name": "数据预处理",
286
330
  "desc": "数据渲染前预处理",
287
- "func": "(data)=>{\n\t\n}"
331
+ "func": "function processDataSource(data) {\n\t\n}"
288
332
  },
289
333
  {
290
334
  "key": "onDoubleClick",
291
335
  "name": "双击事件",
292
336
  "desc": "树节点双击事件",
293
- "func": "(e, rowData)=>{\n\t\n}"
337
+ "func": "function onDoubleClick(e, rowData) {\n\t\n}"
294
338
  },
295
339
  {
296
340
  "key": "onCheck",
297
341
  "name": "复选框选择事件",
298
342
  "desc": "点击复选框触发",
299
- "func": "(checkedKeys, e)=>{\n\t\n}"
343
+ "func": "function onCheck(checkedKeys, e) {\n\t\n}"
344
+ },
345
+ {
346
+ "key": "onSelect",
347
+ "name": "选中事件",
348
+ "desc": "节点选中事件",
349
+ "func": "function onSelect(checkedKeys, e) {\n\t\n}"
350
+ },
351
+ {
352
+ "key": "onDrop",
353
+ "name": "拖拽事件",
354
+ "desc": "节点拖拽事件",
355
+ "func": "function onDrop(info, dragInfo) {\n\t\n}"
300
356
  }
301
357
  ]
302
358
  }
@@ -2,63 +2,30 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import React, { createContext, useContext as useReactContext, useRef } from 'react';
4
4
  import { history } from 'umi';
5
- import { useMemoizedFn, useSetState } from 'ahooks';
6
- import { get, isNil, isArray, isFunction, isObject, isString, reduce } from 'lodash';
5
+ import { useMemoizedFn, useSetState, useUpdateEffect, usePrevious } from 'ahooks';
7
6
  import { useLDEventBus } from "../EventBusProvider";
8
7
  import RemoteSourceProvider, { RemoteSourceContext } from "../RemoteSourceProvider";
9
8
  import useTodo from "../../tools/useTodo";
10
- import { findNodeAndParent } from "../../tools/dataProcess";
11
9
  import * as topics from "../../../constants/event-topics";
12
10
  export var Context = /*#__PURE__*/createContext(null);
13
11
  export var useContext = function useContext() {
14
12
  return useReactContext(Context);
15
13
  };
16
- export var usePageData = function usePageData(_) {
17
- var _useReactContext = useReactContext(RemoteSourceContext),
18
- pageData = _useReactContext.pageData,
19
- loading = _useReactContext.loading,
20
- setPageData = _useReactContext.setPageData,
21
- back = _useReactContext.back,
22
- forward = _useReactContext.forward,
23
- backLength = _useReactContext.backLength,
24
- forwardLength = _useReactContext.forwardLength;
25
- var _pageData;
26
- if (isNil(_)) {
27
- _pageData = pageData;
28
- } else if (isFunction(_)) {
29
- _pageData = _(pageData);
30
- } else if (isArray(_)) {
31
- _pageData = reduce(_, function (r, k) {
32
- r.push(get(pageData, k));
33
- return r;
34
- }, []);
35
- } else if (isObject(_) && _.id) {
36
- var _findNodeAndParent;
37
- _pageData = (_findNodeAndParent = findNodeAndParent(_.id, pageData)) === null || _findNodeAndParent === void 0 ? void 0 : _findNodeAndParent.node;
38
- } else if (isString(_)) {
39
- _pageData = get(pageData, _);
40
- }
41
- return [_pageData, {
42
- loading: loading,
43
- setPageData: setPageData,
44
- back: back,
45
- forward: forward,
46
- backLength: backLength,
47
- forwardLength: forwardLength
48
- }];
49
- };
50
14
  export var useRemoteSource = function useRemoteSource() {
51
15
  return useReactContext(RemoteSourceContext);
52
16
  };
17
+ export * from "../../tools/usePageDataStore";
53
18
  var PRIVATE_KEYS = ['componentList', 'componentMap'];
54
19
  export default (function (_ref) {
55
20
  var children = _ref.children,
56
- code = _ref.code;
21
+ code = _ref.code,
22
+ debug = _ref.debug;
57
23
  var eventBus = useLDEventBus();
58
24
  var _useTodo = useTodo(),
59
- _useTodo2 = _slicedToArray(_useTodo, 2),
25
+ _useTodo2 = _slicedToArray(_useTodo, 3),
60
26
  todo = _useTodo2[0],
61
- callBehavior = _useTodo2[1];
27
+ callBehavior = _useTodo2[1],
28
+ loading = _useTodo2[2];
62
29
 
63
30
  /**
64
31
  * 页面公共资源
@@ -66,7 +33,8 @@ export default (function (_ref) {
66
33
  var _useSetState = useSetState(null),
67
34
  _useSetState2 = _slicedToArray(_useSetState, 2),
68
35
  pagePublicResource = _useSetState2[0],
69
- _setPagePublicResource = _useSetState2[1];
36
+ setPagePublicResource = _useSetState2[1];
37
+ var prevPagePublicResource = usePrevious(pagePublicResource);
70
38
 
71
39
  /**
72
40
  * 组件列表
@@ -128,14 +96,22 @@ export default (function (_ref) {
128
96
  * return:object
129
97
  */
130
98
  var getUrlParams = useMemoizedFn(function () {});
99
+ useUpdateEffect(function () {
100
+ eventBus.$publisher(topics.PAGE_PUBLIC_RESOURCE_CHANGED, {
101
+ resource: pagePublicResource,
102
+ prevResource: prevPagePublicResource
103
+ });
104
+ }, [pagePublicResource]);
131
105
  var ctx = new Proxy(_objectSpread({
132
- _setPagePublicResource: _setPagePublicResource,
133
106
  _register: _register,
134
107
  _unregister: _unregister,
135
108
  pagePublicResource: pagePublicResource,
109
+ setPagePublicResource: setPagePublicResource,
110
+ loading: loading,
136
111
  history: history,
137
112
  callBehavior: callBehavior,
138
113
  topics: topics,
114
+ PRIMARY_KEY: window.appConfig.constraintKeys.PRIMARY,
139
115
  getElementById: getElementById,
140
116
  /**
141
117
  * @method
@@ -172,6 +148,7 @@ export default (function (_ref) {
172
148
  value: ctx
173
149
  }, /*#__PURE__*/React.createElement(RemoteSourceProvider, {
174
150
  code: code,
175
- runtime: eventBus.runtime
151
+ runtime: eventBus.runtime,
152
+ debug: debug
176
153
  }, children));
177
154
  });
@@ -9,24 +9,26 @@ import React, { createContext, useRef } from 'react';
9
9
  import { useRequest, useSetState, useAsyncEffect, useMemoizedFn, useCookieState, useCreation, useUnmount } from 'ahooks';
10
10
  import { LuckDaContext } from "../../../components/Builder";
11
11
  import { doAction as doActionUtils } from "../../../helper/action";
12
- import usePromiseState from "../tools/usePromiseState";
12
+ import usePageDataStore from "../tools/usePageDataStore";
13
13
  import { decompress } from "../tools/dataProcess";
14
- import { fetchPageData, fetchDesignModlueData, fetchPreviewModlueData, fetchModlueData, fetchAllDataset, fetchAllSerials } from "../../constants/api-url";
14
+ import { fetchPageData, fetchDesignModlueData, fetchPreviewModlueData, fetchModlueData, fetchAllDataset, fetchAllSerials, fetchAllBehaviorEx } from "../../constants/api-url";
15
15
  import { RUNTIME, COOKIE_RUNTIME_KEY, DATA_MODEL_CODE_KEY } from "../../constants";
16
16
  export var RemoteSourceContext = /*#__PURE__*/createContext(null);
17
17
  export default (function (_ref) {
18
18
  var children = _ref.children,
19
19
  code = _ref.code,
20
- runtime = _ref.runtime;
21
- var _usePromiseState = usePromiseState(null),
22
- _usePromiseState2 = _slicedToArray(_usePromiseState, 3),
23
- pageData = _usePromiseState2[0],
24
- setPageData = _usePromiseState2[1],
25
- _usePromiseState2$ = _usePromiseState2[2],
26
- back = _usePromiseState2$.back,
27
- forward = _usePromiseState2$.forward,
28
- backLength = _usePromiseState2$.backLength,
29
- forwardLength = _usePromiseState2$.forwardLength;
20
+ runtime = _ref.runtime,
21
+ debug = _ref.debug;
22
+ var _usePageDataStore = usePageDataStore(function (state) {
23
+ return {
24
+ initialize: state.initialize,
25
+ initializeModule: state.initializeModule,
26
+ reset: state.reset
27
+ };
28
+ }),
29
+ initialize = _usePageDataStore.initialize,
30
+ initializeModule = _usePageDataStore.initializeModule,
31
+ reset = _usePageDataStore.reset;
30
32
  var _useSetState = useSetState({}),
31
33
  _useSetState2 = _slicedToArray(_useSetState, 2),
32
34
  remoteSource = _useSetState2[0],
@@ -43,6 +45,7 @@ export default (function (_ref) {
43
45
  }
44
46
  }, []);
45
47
  useUnmount(function () {
48
+ !debug && reset();
46
49
  setRuntime(prevRuntime.current);
47
50
  });
48
51
 
@@ -62,6 +65,7 @@ export default (function (_ref) {
62
65
  setRemoteSource({
63
66
  module: data
64
67
  });
68
+ initializeModule(data);
65
69
  }
66
70
  }
67
71
  }),
@@ -103,6 +107,46 @@ export default (function (_ref) {
103
107
  fetchAllSerialsLoading = _useRequest4.loading,
104
108
  runFetchAllSerials = _useRequest4.run,
105
109
  refreshSerials = _useRequest4.refreshAsync;
110
+
111
+ // 获取导入导出行为下拉数据
112
+ var _useRequest5 = useRequest(fetchAllBehaviorEx, {
113
+ manual: true,
114
+ onSuccess: function onSuccess(_ref5) {
115
+ var code = _ref5.code,
116
+ data = _ref5.data;
117
+ if (code === 1) {
118
+ setRemoteSource({
119
+ impTypeList: data.map(function (item) {
120
+ return {
121
+ key: item.uid,
122
+ value: item.uid,
123
+ label: item.name
124
+ };
125
+ })
126
+ });
127
+ }
128
+ }
129
+ }),
130
+ runFetchAllBehaviorImport = _useRequest5.run;
131
+ var _useRequest6 = useRequest(fetchAllBehaviorEx, {
132
+ manual: true,
133
+ onSuccess: function onSuccess(_ref6) {
134
+ var code = _ref6.code,
135
+ data = _ref6.data;
136
+ if (code === 1) {
137
+ setRemoteSource({
138
+ expTypeList: data.map(function (item) {
139
+ return {
140
+ key: item.uid,
141
+ value: item.uid,
142
+ label: item.name
143
+ };
144
+ })
145
+ });
146
+ }
147
+ }
148
+ }),
149
+ runFetchAllBehaviorExport = _useRequest6.run;
106
150
  useAsyncEffect( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
107
151
  var fetchPageDataRes, data, list, detail, _detail$list$, source, info;
108
152
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -115,7 +159,7 @@ export default (function (_ref) {
115
159
  case 2:
116
160
  fetchPageDataRes = _context.sent;
117
161
  if (!(fetchPageDataRes.code === 1)) {
118
- _context.next = 13;
162
+ _context.next = 15;
119
163
  break;
120
164
  }
121
165
  data = fetchPageDataRes.data, list = fetchPageDataRes.list, detail = fetchPageDataRes.detail;
@@ -126,6 +170,14 @@ export default (function (_ref) {
126
170
  moduleCode: data.moduleCode
127
171
  });
128
172
  case 9:
173
+ runFetchAllBehaviorImport({
174
+ behaviorMode: 'IMPORT',
175
+ moduleCode: data.moduleCode
176
+ });
177
+ runFetchAllBehaviorExport({
178
+ behaviorMode: 'EXPORT',
179
+ moduleCode: data.moduleCode
180
+ });
129
181
  runFetchAllDataset({
130
182
  dataModelKey: data.dataModelKey
131
183
  });
@@ -137,8 +189,8 @@ export default (function (_ref) {
137
189
  relationship: data
138
190
  }, info)
139
191
  });
140
- setPageData(decompress(source));
141
- case 13:
192
+ !debug && initialize(decompress(source));
193
+ case 15:
142
194
  case "end":
143
195
  return _context.stop();
144
196
  }
@@ -151,20 +203,13 @@ export default (function (_ref) {
151
203
  });
152
204
  });
153
205
  return /*#__PURE__*/React.createElement(RemoteSourceContext.Provider, {
154
- value: _objectSpread(_objectSpread({
155
- pageData: pageData
156
- }, remoteSource), {}, {
206
+ value: _objectSpread(_objectSpread({}, remoteSource), {}, {
157
207
  loading: fetchPageDataLoading || fetchModlueDataLoading,
158
208
  fetchAllDatasetLoading: fetchAllDatasetLoading,
159
209
  fetchAllSerialsLoading: fetchAllSerialsLoading,
160
210
  refreshModlueData: refreshModlueData,
161
211
  refreshDataset: refreshDataset,
162
- refreshSerials: refreshSerials,
163
- setPageData: setPageData,
164
- back: back,
165
- forward: forward,
166
- backLength: backLength,
167
- forwardLength: forwardLength
212
+ refreshSerials: refreshSerials
168
213
  })
169
214
  }, /*#__PURE__*/React.createElement(LuckDaContext.Provider, {
170
215
  value: _objectSpread(_objectSpread({}, remoteSource.module), {}, {
@@ -39,6 +39,10 @@ export function decompress(compressedData) {
39
39
  */
40
40
  export function findNodeAndParent(id, current) {
41
41
  var parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
42
+ if (!id) return {
43
+ node: null,
44
+ parent: null
45
+ };
42
46
  if (!parent && current.props.id === id) {
43
47
  return {
44
48
  node: current,
@@ -96,9 +96,8 @@ export function listReducer(state, action) {
96
96
  }
97
97
  }
98
98
  export function getCtx(context) {
99
- return omitBy(context, function (_, key) {
100
- return startsWith(key, '_');
101
- });
99
+ return context;
100
+ // return omitBy(context, (_, key) => startsWith(key, '_'));
102
101
  }
103
102
  export function getFuncBody(funcCode) {
104
103
  var regex = /{([\s\S]*?)}(?![\s\S]*})/;
@@ -13,8 +13,9 @@ import { LC_BUILDIN_UNIT_KEY_LIST } from "../../constants";
13
13
  export default function useCanvasRender(data, deps) {
14
14
  var dynamicCompMap = useRef({});
15
15
  var ctx = useContext();
16
- var render = useMemoizedFn(function (_ref) {
17
- var props = _ref.props,
16
+ var render = useMemoizedFn(function () {
17
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
18
+ props = _ref.props,
18
19
  children = _ref.children,
19
20
  childrenMap = _objectWithoutProperties(_ref, _excluded);
20
21
  if (props && !LC_BUILDIN_UNIT_KEY_LIST.includes(props.id)) {
@@ -0,0 +1,176 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
3
+ import { useRef, useEffect, useCallback } from 'react';
4
+ import { create } from 'zustand';
5
+ import { immer } from 'zustand/middleware/immer';
6
+ import { subscribeWithSelector } from 'zustand/middleware';
7
+ import { useShallow } from 'zustand/react/shallow';
8
+ import { isObject, isArray, isNil, isFunction, isString, get, set as _set, assign, forOwn, omit } from 'lodash';
9
+ import { getPathNodesById, findNodeAndParent } from "./dataProcess";
10
+ import { LC_BUILDIN_UNIT_KEY } from "../../constants";
11
+ var findNode = function findNode(obj, id) {
12
+ for (var key in obj) {
13
+ if (!['props', 'children'].includes(key)) {
14
+ if (key === id) {
15
+ return {
16
+ target: obj[key],
17
+ parent: obj
18
+ };
19
+ }
20
+ if (_typeof(obj[key]) === 'object' && !Array.isArray(obj[key])) {
21
+ var result = findNode(obj[key], id);
22
+ if (result) {
23
+ return result;
24
+ }
25
+ }
26
+ }
27
+ }
28
+ return null;
29
+ };
30
+ var usePageDataStore = create()(immer(subscribeWithSelector(function (set) {
31
+ return {
32
+ pageData: null,
33
+ moduleData: null,
34
+ initialize: function initialize(data) {
35
+ return set(function (state) {
36
+ state.pageData = data;
37
+ });
38
+ },
39
+ initializeModule: function initializeModule(data) {
40
+ return set(function (state) {
41
+ state.moduleData = data;
42
+ });
43
+ },
44
+ reset: function reset(data) {
45
+ return set(function (state) {
46
+ state.pageData = data || null;
47
+ });
48
+ }
49
+ };
50
+ })));
51
+ export default usePageDataStore;
52
+ export var resetPageData = function resetPageData(data) {
53
+ usePageDataStore.setState(function (state) {
54
+ state.pageData = data || null;
55
+ });
56
+ };
57
+ export var addNode = function addNode(parentId, id, data) {
58
+ usePageDataStore.setState(function (state) {
59
+ if (parentId === LC_BUILDIN_UNIT_KEY.PAGE_ROOT) {
60
+ state.pageData.children.push(id);
61
+ state.pageData[id] = {
62
+ props: _objectSpread(_objectSpread({}, data), {}, {
63
+ id: id,
64
+ parentId: parentId
65
+ })
66
+ };
67
+ return;
68
+ }
69
+ var _ref = findNode(state.pageData, parentId) || {},
70
+ target = _ref.target;
71
+ if (!target) return;
72
+ if (!target.hasOwnProperty('children')) {
73
+ target.children = [];
74
+ }
75
+ if (!target.children.includes(id)) {
76
+ target.children.push(id);
77
+ target[id] = {
78
+ props: _objectSpread(_objectSpread({}, data), {}, {
79
+ id: id,
80
+ parentId: parentId
81
+ })
82
+ };
83
+ }
84
+ });
85
+ };
86
+ export var deleteNode = function deleteNode(id) {
87
+ usePageDataStore.setState(function (state) {
88
+ var _parent$children;
89
+ var _ref2 = findNode(state.pageData, id) || {},
90
+ parent = _ref2.parent;
91
+ if (!parent || !((_parent$children = parent.children) !== null && _parent$children !== void 0 && _parent$children.length)) return;
92
+ parent.children.splice(parent.children.indexOf(id), 1);
93
+ if (parent.children.length === 0) {
94
+ delete parent['children'];
95
+ }
96
+ delete parent[id];
97
+ });
98
+ };
99
+ export var modifyNode = function modifyNode(id, data) {
100
+ usePageDataStore.setState(function (state) {
101
+ if (id === LC_BUILDIN_UNIT_KEY.PAGE_ROOT) {
102
+ assign(state.pageData.props, omit(data, ['id', 'parentId', 'component', 'buildIn']));
103
+ return;
104
+ }
105
+ var _ref3 = findNode(state.pageData, id) || {},
106
+ target = _ref3.target;
107
+ if (!target) return;
108
+ forOwn(omit(data, ['id', 'parentId', 'component', 'buildIn']), function (_val, _key) {
109
+ _set(target.props, _key, _val);
110
+ });
111
+ });
112
+ };
113
+ export var useTask = function useTask(type) {
114
+ var promiseRef = useRef(null);
115
+ var task = useCallback(function () {
116
+ for (var _len = arguments.length, args = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
117
+ args[_key2] = arguments[_key2];
118
+ }
119
+ return new Promise(function (resolve) {
120
+ promiseRef.current = resolve;
121
+ switch (type) {
122
+ case 'add':
123
+ addNode.apply(void 0, args);
124
+ break;
125
+ case 'update':
126
+ case 'modify':
127
+ modifyNode.apply(void 0, args);
128
+ break;
129
+ case 'delete':
130
+ deleteNode.apply(void 0, args);
131
+ break;
132
+ default:
133
+ break;
134
+ }
135
+ });
136
+ }, []);
137
+ useEffect(function () {
138
+ var unsub = usePageDataStore.subscribe(function (state, prevState) {
139
+ if (!promiseRef.current) {
140
+ return;
141
+ }
142
+ promiseRef.current(state.pageData, prevState.pageData);
143
+ promiseRef.current = null;
144
+ });
145
+ return unsub;
146
+ }, []);
147
+ return task;
148
+ };
149
+ export var useGet = function useGet(_) {
150
+ var result = usePageDataStore(useShallow(function (state) {
151
+ if (isNil(_)) {
152
+ return state.pageData;
153
+ } else if (isFunction(_)) {
154
+ return _(state.pageData);
155
+ } else if (isArray(_)) {
156
+ return _.map(function (k) {
157
+ var _findNode;
158
+ return k.includes('.') ? get(state.pageData, k) : (_findNode = findNode(state.pageData, k)) === null || _findNode === void 0 ? void 0 : _findNode.target;
159
+ });
160
+ } else if (isObject(_) && _.id) {
161
+ var _findNode2;
162
+ var path = _.path;
163
+ var _target = _.id === LC_BUILDIN_UNIT_KEY.PAGE_ROOT ? state.pageData : (_findNode2 = findNode(state.pageData, _.id)) === null || _findNode2 === void 0 ? void 0 : _findNode2.target;
164
+ return isNil(path) ? _target : get(_target, path);
165
+ } else if (isString(_)) {
166
+ return get(state.pageData, _);
167
+ }
168
+ }));
169
+ return result;
170
+ };
171
+ export var getLevelNodes = function getLevelNodes(id) {
172
+ return getPathNodesById(usePageDataStore.getState().pageData, id);
173
+ };
174
+ export var getSelfAndParent = function getSelfAndParent(id) {
175
+ return findNodeAndParent(id, usePageDataStore.getState().pageData);
176
+ };
@@ -1,35 +1,24 @@
1
- import { useRef, useCallback } from 'react';
2
- import { useHistoryTravel, useUpdateLayoutEffect } from 'ahooks';
3
- import { isEqual } from 'lodash';
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import { useRef, useState, useCallback } from 'react';
3
+ import { useUpdateLayoutEffect } from 'ahooks';
4
4
  var usePromiseState = function usePromiseState(initialState) {
5
- var _useHistoryTravel = useHistoryTravel(initialState),
6
- value = _useHistoryTravel.value,
7
- setValue = _useHistoryTravel.setValue,
8
- backLength = _useHistoryTravel.backLength,
9
- forwardLength = _useHistoryTravel.forwardLength,
10
- back = _useHistoryTravel.back,
11
- forward = _useHistoryTravel.forward;
5
+ var _useState = useState(initialState),
6
+ _useState2 = _slicedToArray(_useState, 2),
7
+ state = _useState2[0],
8
+ setState = _useState2[1];
12
9
  var promiseRef = useRef(null);
13
- var setStatePromise = useCallback(function (_value) {
10
+ var setStatePromise = useCallback(function (_state) {
14
11
  return new Promise(function (resolve) {
15
12
  promiseRef.current = resolve;
16
- var _valStr = JSON.stringify(_value);
17
- if (!isEqual(value, _valStr)) {
18
- setValue(_valStr);
19
- }
13
+ setState(_state);
20
14
  });
21
15
  }, []);
22
16
  useUpdateLayoutEffect(function () {
23
17
  if (promiseRef.current) {
24
- promiseRef.current(JSON.parse(value));
18
+ promiseRef.current(state);
25
19
  promiseRef.current = null;
26
20
  }
27
- }, [value]);
28
- return [JSON.parse(value), setStatePromise, {
29
- backLength: backLength - 1,
30
- forwardLength: forwardLength,
31
- back: back,
32
- forward: forward
33
- }];
21
+ }, [state]);
22
+ return [state, setStatePromise];
34
23
  };
35
24
  export default usePromiseState;