@luck-design-biz/luckda 0.0.22 → 0.0.23

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 (251) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +40 -49
  3. package/es/components/Builder/index.js +4 -4
  4. package/es/components/LdAutoForm/index.js +7 -9
  5. package/es/components/LdCard/index.js +5 -6
  6. package/es/components/LdCard/model.js +1 -1
  7. package/es/components/LdCom/index.js +2 -2
  8. package/es/components/LdFormList/index.js +19 -17
  9. package/es/components/LdGrid/index.js +11 -12
  10. package/es/components/LdGrid/model.js +1 -1
  11. package/es/components/LdGridForm/index.js +10 -10
  12. package/es/components/LdGridForm/index.less +7 -7
  13. package/es/components/LdInfoPanel/index.js +2 -2
  14. package/es/components/LdRuntimeCom/index.js +42 -0
  15. package/es/components/LdTree/index.js +3 -4
  16. package/es/components/LdTree/index.less +36 -36
  17. package/es/helper/FromItems.js +1 -1
  18. package/es/helper/action.js +8 -8
  19. package/es/helper/form.js +16 -16
  20. package/es/helper/index.less +7 -7
  21. package/es/helper/ldBuilder.js +1 -1
  22. package/es/helper/ldComBuild.js +4 -4
  23. package/es/index.js +10 -9
  24. package/es/lowcode/constants/api-url.js +2 -0
  25. package/es/lowcode/constants/event-topics.js +23 -0
  26. package/es/lowcode/constants/index.js +12 -0
  27. package/es/lowcode/engine/factory/DataFactory.js +1 -0
  28. package/es/lowcode/engine/meta/button.props.default.json +8 -0
  29. package/es/lowcode/engine/meta/cardlist.props.default.json +10 -0
  30. package/es/lowcode/engine/meta/components/button.json +104 -0
  31. package/es/lowcode/engine/meta/components/card-list.json +143 -0
  32. package/es/lowcode/engine/meta/components/drawer.json +143 -0
  33. package/es/lowcode/engine/meta/components/form.json +116 -0
  34. package/es/lowcode/engine/meta/components/iframe.json +31 -0
  35. package/es/lowcode/engine/meta/components/image.json +113 -0
  36. package/es/lowcode/engine/meta/components/imex.json +81 -0
  37. package/es/lowcode/engine/meta/components/jsx.json +24 -0
  38. package/es/lowcode/engine/meta/components/layout.json +107 -0
  39. package/es/lowcode/engine/meta/components/link.json +111 -0
  40. package/es/lowcode/engine/meta/components/modal.json +120 -0
  41. package/es/lowcode/engine/meta/components/section.json +107 -0
  42. package/es/lowcode/engine/meta/components/split.json +71 -0
  43. package/es/lowcode/engine/meta/components/table.json +161 -0
  44. package/es/lowcode/engine/meta/components/tabs.json +140 -0
  45. package/es/lowcode/engine/meta/components/text.json +65 -0
  46. package/es/lowcode/engine/meta/components/tree.json +156 -0
  47. package/es/lowcode/engine/meta/components-list.json +122 -0
  48. package/es/lowcode/engine/meta/drawer.props.default.json +10 -0
  49. package/es/lowcode/engine/meta/form.props.default.json +5 -0
  50. package/es/lowcode/engine/meta/iframe.props.default.json +3 -0
  51. package/es/lowcode/engine/meta/image.props.default.json +8 -0
  52. package/es/lowcode/engine/meta/imex.props.default.json +4 -0
  53. package/es/lowcode/engine/meta/jsx.props.default.json +1 -0
  54. package/es/lowcode/engine/meta/layout.props.default.json +5 -0
  55. package/es/lowcode/engine/meta/link.props.default.json +6 -0
  56. package/es/lowcode/engine/meta/modal.props.default.json +11 -0
  57. package/es/lowcode/engine/meta/section.props.default.json +9 -0
  58. package/es/lowcode/engine/meta/split.props.default.json +5 -0
  59. package/es/lowcode/engine/meta/table.props.default.json +10 -0
  60. package/es/lowcode/engine/meta/tabs.props.default.json +10 -0
  61. package/es/lowcode/engine/meta/text.props.default.json +4 -0
  62. package/es/lowcode/engine/meta/tree.props.default.json +9 -0
  63. package/es/lowcode/engine/provider/ContextProvider.js +164 -0
  64. package/es/lowcode/engine/provider/EventBusProvider.js +120 -0
  65. package/es/lowcode/engine/tools/dataProcess.js +188 -0
  66. package/es/lowcode/engine/tools/helper.js +4 -0
  67. package/es/lowcode/engine/tools/lcid.js +16 -0
  68. package/es/lowcode/index.js +3 -0
  69. package/es/lowcode/painter/Components.js +104 -0
  70. package/es/lowcode/painter/Design.js +97 -0
  71. package/es/lowcode/painter/I18n.js +5 -0
  72. package/es/lowcode/painter/Outline.js +202 -0
  73. package/es/lowcode/painter/Panel.js +8 -0
  74. package/es/lowcode/painter/Ribbon.js +136 -0
  75. package/es/lowcode/painter/components/PanelItem.js +20 -0
  76. package/es/lowcode/painter/components/RuleInput.js +105 -0
  77. package/es/lowcode/painter/index.js +19 -0
  78. package/es/lowcode/painter/panel-section/LayoutRatio.js +123 -0
  79. package/es/lowcode/painter/panel-section/Radio.js +58 -0
  80. package/es/lowcode/painter/style/components.less +90 -0
  81. package/es/lowcode/painter/style/design.less +38 -0
  82. package/es/lowcode/painter/style/index.less +7 -0
  83. package/es/lowcode/painter/style/layout-ratio.less +51 -0
  84. package/es/lowcode/painter/style/outline.less +26 -0
  85. package/es/lowcode/painter/style/panel-item.less +21 -0
  86. package/es/lowcode/painter/style/panel.less +5 -0
  87. package/es/lowcode/painter/style/radio.less +24 -0
  88. package/es/lowcode/painter/style/ribbon.less +4 -0
  89. package/es/lowcode/painter/style/rule-input.less +13 -0
  90. package/es/lowcode/view/Canvas.js +135 -0
  91. package/es/lowcode/view/Loading.js +23 -0
  92. package/es/lowcode/view/Page.js +55 -0
  93. package/es/lowcode/view/index.js +18 -0
  94. package/es/lowcode/view/lc-components/Box/index.js +21 -0
  95. package/es/lowcode/view/lc-components/Button/index.js +37 -0
  96. package/es/lowcode/view/lc-components/CardList/index.js +20 -0
  97. package/es/lowcode/view/lc-components/Dialog/index.js +50 -0
  98. package/es/lowcode/view/lc-components/Dialog/index.less +3 -0
  99. package/es/lowcode/view/lc-components/Drawer/index.js +46 -0
  100. package/es/lowcode/view/lc-components/Form/index.js +20 -0
  101. package/es/lowcode/view/lc-components/Iframe/index.js +20 -0
  102. package/es/lowcode/view/lc-components/ImEx/index.js +20 -0
  103. package/es/lowcode/view/lc-components/Image/index.js +20 -0
  104. package/es/lowcode/view/lc-components/JSX/index.js +20 -0
  105. package/es/lowcode/view/lc-components/Layout/index.js +24 -0
  106. package/es/lowcode/view/lc-components/Link/index.js +20 -0
  107. package/es/lowcode/view/lc-components/Section/index.js +34 -0
  108. package/es/lowcode/view/lc-components/Split/index.js +21 -0
  109. package/es/lowcode/view/lc-components/Table/index.js +23 -0
  110. package/es/lowcode/view/lc-components/Tabs/index.js +21 -0
  111. package/es/lowcode/view/lc-components/Text/index.js +23 -0
  112. package/es/lowcode/view/lc-components/Tree/index.js +20 -0
  113. package/es/lowcode/view/lc-components/Wrapper.js +45 -0
  114. package/es/lowcode/view/style/canvas.less +5 -0
  115. package/es/lowcode/view/style/loading.less +84 -0
  116. package/es/lowcode/view/style/page.less +6 -0
  117. package/es/services.js +1 -1
  118. package/es/upload/Form/gridForm.js +29 -7
  119. package/es/upload/Form/index.js +1 -1
  120. package/es/upload/Form/index.less +7 -7
  121. package/es/upload/FormItem/index.js +30 -18
  122. package/es/upload/index.js +3 -3
  123. package/es/utils/action.js +1 -1
  124. package/es/utils/form.js +26 -26
  125. package/es/utils/grid.js +22 -26
  126. package/es/utils/index.js +3 -3
  127. package/lib/components/Builder/index.js +3 -5
  128. package/lib/components/LdAutoForm/index.js +5 -8
  129. package/lib/components/LdCard/index.js +5 -7
  130. package/lib/components/LdCom/index.js +6 -11
  131. package/lib/components/LdFormList/index.js +15 -13
  132. package/lib/components/LdGrid/index.js +10 -12
  133. package/lib/components/LdGridForm/index.js +6 -7
  134. package/lib/components/LdGridForm/index.less +7 -7
  135. package/lib/components/LdInfoPanel/index.js +2 -3
  136. package/lib/components/LdPop/index.js +2 -4
  137. package/lib/components/LdRuntimeCom/index.js +49 -0
  138. package/lib/components/LdTree/index.js +2 -4
  139. package/lib/components/LdTree/index.less +36 -36
  140. package/lib/helper/FromItems.js +15 -29
  141. package/lib/helper/action.js +9 -11
  142. package/lib/helper/form.js +18 -20
  143. package/lib/helper/index.less +7 -7
  144. package/lib/helper/ldBuilder.js +1 -2
  145. package/lib/helper/ldComBuild.js +7 -11
  146. package/lib/index.js +9 -1
  147. package/lib/lowcode/constants/api-url.js +8 -0
  148. package/lib/lowcode/constants/event-topics.js +29 -0
  149. package/lib/lowcode/constants/index.js +18 -0
  150. package/lib/lowcode/engine/factory/DataFactory.js +3 -0
  151. package/lib/lowcode/engine/meta/button.props.default.json +8 -0
  152. package/lib/lowcode/engine/meta/cardlist.props.default.json +10 -0
  153. package/lib/lowcode/engine/meta/components/button.json +104 -0
  154. package/lib/lowcode/engine/meta/components/card-list.json +143 -0
  155. package/lib/lowcode/engine/meta/components/drawer.json +143 -0
  156. package/lib/lowcode/engine/meta/components/form.json +116 -0
  157. package/lib/lowcode/engine/meta/components/iframe.json +31 -0
  158. package/lib/lowcode/engine/meta/components/image.json +113 -0
  159. package/lib/lowcode/engine/meta/components/imex.json +81 -0
  160. package/lib/lowcode/engine/meta/components/jsx.json +24 -0
  161. package/lib/lowcode/engine/meta/components/layout.json +107 -0
  162. package/lib/lowcode/engine/meta/components/link.json +111 -0
  163. package/lib/lowcode/engine/meta/components/modal.json +120 -0
  164. package/lib/lowcode/engine/meta/components/section.json +107 -0
  165. package/lib/lowcode/engine/meta/components/split.json +71 -0
  166. package/lib/lowcode/engine/meta/components/table.json +161 -0
  167. package/lib/lowcode/engine/meta/components/tabs.json +140 -0
  168. package/lib/lowcode/engine/meta/components/text.json +65 -0
  169. package/lib/lowcode/engine/meta/components/tree.json +156 -0
  170. package/lib/lowcode/engine/meta/components-list.json +122 -0
  171. package/lib/lowcode/engine/meta/drawer.props.default.json +10 -0
  172. package/lib/lowcode/engine/meta/form.props.default.json +5 -0
  173. package/lib/lowcode/engine/meta/iframe.props.default.json +3 -0
  174. package/lib/lowcode/engine/meta/image.props.default.json +8 -0
  175. package/lib/lowcode/engine/meta/imex.props.default.json +4 -0
  176. package/lib/lowcode/engine/meta/jsx.props.default.json +1 -0
  177. package/lib/lowcode/engine/meta/layout.props.default.json +5 -0
  178. package/lib/lowcode/engine/meta/link.props.default.json +6 -0
  179. package/lib/lowcode/engine/meta/modal.props.default.json +11 -0
  180. package/lib/lowcode/engine/meta/section.props.default.json +9 -0
  181. package/lib/lowcode/engine/meta/split.props.default.json +5 -0
  182. package/lib/lowcode/engine/meta/table.props.default.json +10 -0
  183. package/lib/lowcode/engine/meta/tabs.props.default.json +10 -0
  184. package/lib/lowcode/engine/meta/text.props.default.json +4 -0
  185. package/lib/lowcode/engine/meta/tree.props.default.json +9 -0
  186. package/lib/lowcode/engine/provider/ContextProvider.js +172 -0
  187. package/lib/lowcode/engine/provider/EventBusProvider.js +128 -0
  188. package/lib/lowcode/engine/tools/dataProcess.js +201 -0
  189. package/lib/lowcode/engine/tools/helper.js +11 -0
  190. package/lib/lowcode/engine/tools/lcid.js +22 -0
  191. package/lib/lowcode/index.js +20 -0
  192. package/lib/lowcode/painter/Components.js +112 -0
  193. package/lib/lowcode/painter/Design.js +105 -0
  194. package/lib/lowcode/painter/I18n.js +12 -0
  195. package/lib/lowcode/painter/Outline.js +210 -0
  196. package/lib/lowcode/painter/Panel.js +16 -0
  197. package/lib/lowcode/painter/Ribbon.js +151 -0
  198. package/lib/lowcode/painter/components/PanelItem.js +26 -0
  199. package/lib/lowcode/painter/components/RuleInput.js +112 -0
  200. package/lib/lowcode/painter/index.js +26 -0
  201. package/lib/lowcode/painter/panel-section/LayoutRatio.js +131 -0
  202. package/lib/lowcode/painter/panel-section/Radio.js +65 -0
  203. package/lib/lowcode/painter/style/components.less +90 -0
  204. package/lib/lowcode/painter/style/design.less +38 -0
  205. package/lib/lowcode/painter/style/index.less +7 -0
  206. package/lib/lowcode/painter/style/layout-ratio.less +51 -0
  207. package/lib/lowcode/painter/style/outline.less +26 -0
  208. package/lib/lowcode/painter/style/panel-item.less +21 -0
  209. package/lib/lowcode/painter/style/panel.less +5 -0
  210. package/lib/lowcode/painter/style/radio.less +24 -0
  211. package/lib/lowcode/painter/style/ribbon.less +4 -0
  212. package/lib/lowcode/painter/style/rule-input.less +13 -0
  213. package/lib/lowcode/view/Canvas.js +150 -0
  214. package/lib/lowcode/view/Loading.js +30 -0
  215. package/lib/lowcode/view/Page.js +63 -0
  216. package/lib/lowcode/view/index.js +25 -0
  217. package/lib/lowcode/view/lc-components/Box/index.js +29 -0
  218. package/lib/lowcode/view/lc-components/Button/index.js +45 -0
  219. package/lib/lowcode/view/lc-components/CardList/index.js +28 -0
  220. package/lib/lowcode/view/lc-components/Dialog/index.js +58 -0
  221. package/lib/lowcode/view/lc-components/Dialog/index.less +3 -0
  222. package/lib/lowcode/view/lc-components/Drawer/index.js +54 -0
  223. package/lib/lowcode/view/lc-components/Form/index.js +28 -0
  224. package/lib/lowcode/view/lc-components/Iframe/index.js +28 -0
  225. package/lib/lowcode/view/lc-components/ImEx/index.js +28 -0
  226. package/lib/lowcode/view/lc-components/Image/index.js +28 -0
  227. package/lib/lowcode/view/lc-components/JSX/index.js +28 -0
  228. package/lib/lowcode/view/lc-components/Layout/index.js +32 -0
  229. package/lib/lowcode/view/lc-components/Link/index.js +28 -0
  230. package/lib/lowcode/view/lc-components/Section/index.js +42 -0
  231. package/lib/lowcode/view/lc-components/Split/index.js +29 -0
  232. package/lib/lowcode/view/lc-components/Table/index.js +31 -0
  233. package/lib/lowcode/view/lc-components/Tabs/index.js +29 -0
  234. package/lib/lowcode/view/lc-components/Text/index.js +31 -0
  235. package/lib/lowcode/view/lc-components/Tree/index.js +28 -0
  236. package/lib/lowcode/view/lc-components/Wrapper.js +52 -0
  237. package/lib/lowcode/view/style/canvas.less +5 -0
  238. package/lib/lowcode/view/style/loading.less +84 -0
  239. package/lib/lowcode/view/style/page.less +6 -0
  240. package/lib/upload/Form/gridForm.js +27 -6
  241. package/lib/upload/Form/index.js +1 -2
  242. package/lib/upload/Form/index.less +7 -7
  243. package/lib/upload/FormItem/index.js +30 -19
  244. package/lib/upload/GridCell/index.js +1 -2
  245. package/lib/utils/form.js +26 -29
  246. package/lib/utils/grid.js +23 -28
  247. package/lowcode.js +1 -0
  248. package/package.json +157 -78
  249. package/upload.js +1 -1
  250. package/utils.js +1 -1
  251. package/README.zh-CN.md +0 -51
@@ -0,0 +1,164 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+ import React, { createContext, useContext, useRef } from 'react';
4
+ import { history } from 'umi';
5
+ import { useMemoizedFn } from 'ahooks';
6
+ import { useLDEventBus } from "./EventBusProvider";
7
+ import * as topics from "../../constants/event-topics";
8
+ export var Context = /*#__PURE__*/createContext(null);
9
+ export var useLDContext = function useLDContext() {
10
+ return useContext(Context);
11
+ };
12
+ var PRIVATE_KEYS = ['pageCode', 'moduleCode', 'pageData', 'componentList', 'componentMap'];
13
+ export default (function (_ref) {
14
+ var children = _ref.children;
15
+ var eventBus = useLDEventBus();
16
+
17
+ /**
18
+ * 页面码
19
+ */
20
+ var _pageCode = useRef(void 0);
21
+
22
+ /**
23
+ * 模块码
24
+ */
25
+ var _moduleCode = useRef(void 0);
26
+
27
+ /**
28
+ * 页面数据
29
+ */
30
+ var _pageData = useRef(null);
31
+
32
+ /**
33
+ * 组件列表
34
+ */
35
+ var _componentList = useRef([]);
36
+
37
+ /**
38
+ * 组件id与组件的映射
39
+ */
40
+ var _componentMap = useRef(new Map());
41
+ var _privateGetter = useRef({
42
+ pageCode: function pageCode() {
43
+ return _pageCode.current;
44
+ },
45
+ moduleCode: function moduleCode() {
46
+ return _moduleCode.current;
47
+ },
48
+ pageData: function pageData() {
49
+ return _pageData.current;
50
+ },
51
+ componentList: function componentList() {
52
+ return _componentList.current;
53
+ },
54
+ componentMap: function componentMap() {
55
+ return _componentMap.current;
56
+ }
57
+ });
58
+
59
+ /**
60
+ * 注册组件
61
+ * id:string 组件id
62
+ * component:ReactNode 组件
63
+ */
64
+ var register = useMemoizedFn(function (id, component) {
65
+ _componentMap.current.set(id, component);
66
+ _componentList.current.push([id, component]);
67
+ });
68
+
69
+ /**
70
+ * 注销组件
71
+ * id:string 组件id
72
+ */
73
+ var unregister = useMemoizedFn(function (id) {
74
+ _componentMap.current.delete(id);
75
+ _componentList.current = _componentList.current.filter(function (_ref2) {
76
+ var _ref3 = _slicedToArray(_ref2, 1),
77
+ _id = _ref3[0];
78
+ return _id !== id;
79
+ });
80
+ });
81
+
82
+ /**
83
+ * 根据组件id获取组件
84
+ * compId:string 组件id
85
+ * return:ReactNode
86
+ */
87
+ var getElementById = useMemoizedFn(function (compId) {});
88
+
89
+ /**
90
+ * 根据组件id获取父组件
91
+ * compId:string 组件id
92
+ * return:ReactNode
93
+ */
94
+ var getParentElement = useMemoizedFn(function (compId) {});
95
+
96
+ /**
97
+ * 根据组件id获取组件路径
98
+ * compId:string 组件id
99
+ * return:ReactNode
100
+ */
101
+ var getElementPathById = useMemoizedFn(function (compId) {});
102
+
103
+ /**
104
+ * 获取当前模块数据
105
+ * return:Object
106
+ */
107
+ var getModule = useMemoizedFn(function () {});
108
+
109
+ /**
110
+ * 根据datasetId获取数据集
111
+ * datasetId:string 数据集id
112
+ * return:Object
113
+ */
114
+ var getDataSetById = useMemoizedFn(function (datasetId) {});
115
+
116
+ /**
117
+ * 执行actionKey对应的行为
118
+ * actionKey:string 行为key
119
+ * return:Promise
120
+ */
121
+ var doAction = useMemoizedFn(function (actionKey) {});
122
+
123
+ /**
124
+ * 获取url参数
125
+ * return:object
126
+ */
127
+ var getUrlParams = useMemoizedFn(function () {});
128
+ return /*#__PURE__*/React.createElement(Context.Provider, {
129
+ value: new Proxy(_objectSpread({
130
+ _pageCode: _pageCode,
131
+ _moduleCode: _moduleCode,
132
+ _pageData: _pageData,
133
+ _componentList: _componentList,
134
+ _componentMap: _componentMap,
135
+ history: history,
136
+ topics: topics,
137
+ register: register,
138
+ unregister: unregister,
139
+ getElementById: getElementById,
140
+ getParentElement: getParentElement,
141
+ getElementPathById: getElementPathById,
142
+ getModule: getModule,
143
+ getDataSetById: getDataSetById,
144
+ doAction: doAction,
145
+ getUrlParams: getUrlParams
146
+ }, eventBus), {
147
+ get: function get(target, property, receiver) {
148
+ if (PRIVATE_KEYS.includes(property)) {
149
+ var _privateGetter$curren;
150
+ return (_privateGetter$curren = _privateGetter.current) === null || _privateGetter$curren === void 0 ? void 0 : _privateGetter$curren[property]();
151
+ }
152
+ return Reflect.get(target, property, receiver);
153
+ },
154
+ set: function set(target, property, receiver) {
155
+ console.log('set', target, property, receiver);
156
+ if (PRIVATE_KEYS.includes(property)) {
157
+ throw new Error("\u5C5E\u6027 \"".concat(property, "\" \u662F\u53EA\u8BFB\u7684"));
158
+ } else {
159
+ return Reflect.set(target, property, receiver);
160
+ }
161
+ }
162
+ })
163
+ }, children);
164
+ });
@@ -0,0 +1,120 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
+ var _excluded = ["topic"];
5
+ import React, { createContext, useContext } from 'react';
6
+ import { useEventEmitter, useCreation, useMemoizedFn } from 'ahooks';
7
+ import lcid from "../tools/lcid";
8
+ import { isPromise } from "../tools/helper";
9
+ export var EventBus = /*#__PURE__*/createContext(null);
10
+ export var useLDEventBus = function useLDEventBus() {
11
+ return useContext(EventBus);
12
+ };
13
+ function Subscriber(id) {
14
+ function on(hook) {
15
+ this._on = hook;
16
+ return this;
17
+ }
18
+ function once(hook) {
19
+ this._once = hook;
20
+ return this;
21
+ }
22
+ function before(hook) {
23
+ this._before = hook;
24
+ return this;
25
+ }
26
+ function after(hook) {
27
+ this._after = hook;
28
+ return this;
29
+ }
30
+ function off(hook) {
31
+ this._off = hook;
32
+ return this;
33
+ }
34
+ function watch() {
35
+ return id;
36
+ }
37
+ return {
38
+ on: on,
39
+ once: once,
40
+ before: before,
41
+ after: after,
42
+ off: off,
43
+ watch: watch
44
+ };
45
+ }
46
+ export default (function (_ref) {
47
+ var children = _ref.children,
48
+ runtime = _ref.runtime;
49
+ var event$ = useEventEmitter();
50
+ var subscriberPool = useCreation(function () {
51
+ return new Map();
52
+ }, []);
53
+ event$.useSubscription(function (_ref2) {
54
+ var topic = _ref2.topic,
55
+ payload = _objectWithoutProperties(_ref2, _excluded);
56
+ if (!subscriberPool.has(topic)) return;
57
+ subscriberPool.get(topic).forEach(function (_ref3) {
58
+ var _ref4 = _slicedToArray(_ref3, 2),
59
+ _id = _ref4[0],
60
+ _subscriber = _ref4[1];
61
+ var temp = _subscriber._before ? _subscriber._before(payload) : null;
62
+ if (_subscriber._before && !isPromise(temp)) {
63
+ console.error('before hook must return a promise');
64
+ return;
65
+ }
66
+ var _before = temp || Promise.resolve(true);
67
+ _before.then(function (flag) {
68
+ if (!flag) return flag;
69
+ var func = _subscriber._once || _subscriber._on;
70
+ if (!func) return;
71
+ return func(payload);
72
+ }).then(function (flag) {
73
+ if (flag === false || !_subscriber._after) return;
74
+ return _subscriber._after(payload);
75
+ }).finally(function () {
76
+ if (_subscriber._once) {
77
+ $unsubscriber(topic, _id);
78
+ }
79
+ });
80
+ });
81
+ });
82
+ var $publisher = useMemoizedFn(function (topic, payload) {
83
+ event$.emit(_objectSpread({
84
+ topic: topic,
85
+ runtime: runtime
86
+ }, payload));
87
+ });
88
+ var $subscriber = useMemoizedFn(function (topic) {
89
+ if (!subscriberPool.has(topic)) subscriberPool.set(topic, []);
90
+ var id = lcid();
91
+ var _subscriber = Subscriber(id);
92
+ subscriberPool.get(topic).push([id, _subscriber]);
93
+ return _subscriber;
94
+ });
95
+ var $unsubscriber = useMemoizedFn(function (topic, id) {
96
+ if (!subscriberPool.has(topic)) return;
97
+ subscriberPool.get(topic).forEach(function (_ref5, index) {
98
+ var _ref6 = _slicedToArray(_ref5, 2),
99
+ _id = _ref6[0],
100
+ _subscriber = _ref6[1];
101
+ if (_id === id) {
102
+ var _subscriber$_off, _subscriber2;
103
+ subscriberPool.get(topic).splice(index, 1);
104
+ if (!subscriberPool.get(topic).length) {
105
+ subscriberPool.delete(topic);
106
+ }
107
+ (_subscriber$_off = (_subscriber2 = _subscriber)._off) === null || _subscriber$_off === void 0 || _subscriber$_off.call(_subscriber2);
108
+ _subscriber = null;
109
+ }
110
+ });
111
+ });
112
+ return /*#__PURE__*/React.createElement(EventBus.Provider, {
113
+ value: {
114
+ runtime: runtime,
115
+ $publisher: $publisher,
116
+ $subscriber: $subscriber,
117
+ $unsubscriber: $unsubscriber
118
+ }
119
+ }, children);
120
+ });
@@ -0,0 +1,188 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
3
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
4
+ import * as LZString from 'lz-string';
5
+
6
+ /**
7
+ * 数据压缩
8
+ * @param {JSON} data
9
+ * @returns 加密后的字符串
10
+ */
11
+ export function compress(data) {
12
+ // 将对象转换为JSON字符串
13
+ var jsonString = JSON.stringify(data);
14
+ // 使用LZ-String压缩JSON字符串
15
+ return LZString.compressToUTF16(jsonString);
16
+ }
17
+
18
+ /**
19
+ * 数据解压
20
+ * @param {string} compressedData
21
+ * @returns {json}
22
+ */
23
+ export function decompress(compressedData) {
24
+ // 使用LZ-String解压数据
25
+ var jsonString = LZString.decompressFromUTF16(compressedData);
26
+ // 将JSON字符串转换回对象
27
+ return JSON.parse(jsonString);
28
+ }
29
+
30
+ /**
31
+ * 查找指定ID的节点及其父节点。
32
+ *
33
+ * @param {string} id - 要查找的节点ID。
34
+ * @param {Object} current - 当前遍历的JSON对象。
35
+ * @param {Object|null} parent - 当前节点的父节点。
36
+ * @returns {{node: Object|null, parent: Object|null}} 查找结果,包含节点和其父节点。
37
+ */
38
+ export function findNodeAndParent(id, current) {
39
+ var parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
40
+ if (current.hasOwnProperty('children') && current.children.includes(id)) {
41
+ return {
42
+ node: current[id],
43
+ parent: current
44
+ };
45
+ }
46
+ for (var key in current) {
47
+ if (current[key] && _typeof(current[key]) === 'object' && key !== 'props') {
48
+ var result = findNodeAndParent(id, current[key], current);
49
+ if (result.node) {
50
+ return result;
51
+ }
52
+ }
53
+ }
54
+ return {
55
+ node: null,
56
+ parent: null
57
+ };
58
+ }
59
+
60
+ /**
61
+ * 对指定的JSON结构进行节点的添加、修改或删除操作。
62
+ *
63
+ * @param {Object} json - 要操作的JSON对象。
64
+ * @param {string|null} path - 要操作的节点路径,使用'/'分隔。
65
+ * @param {string} id - 操作节点的唯一标识符。
66
+ * @param {Object|null} data - 要添加或修改的数据。如果为null,表示删除操作。
67
+ */
68
+ function process(json, path, id, data) {
69
+ if (!json) {
70
+ throw new Error("json can not be null");
71
+ }
72
+ if (path && id && data) {
73
+ var paths = path.split('/').filter(function (p) {
74
+ return p;
75
+ });
76
+ var current = json;
77
+ var _iterator = _createForOfIteratorHelper(paths),
78
+ _step;
79
+ try {
80
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
81
+ var p = _step.value;
82
+ if (!current[p]) {
83
+ throw new Error("Path \"".concat(paths.join('/'), "\" does not exist."));
84
+ }
85
+ if (!current[p].hasOwnProperty('children')) {
86
+ current[p]['children'] = [];
87
+ }
88
+ current = current[p];
89
+ }
90
+ } catch (err) {
91
+ _iterator.e(err);
92
+ } finally {
93
+ _iterator.f();
94
+ }
95
+ if (!current.children.includes(id)) {
96
+ current.children.push(id);
97
+ }
98
+ current[id] = {
99
+ props: _objectSpread(_objectSpread({}, data), {}, {
100
+ id: id,
101
+ parentId: current.id
102
+ })
103
+ };
104
+ } else if (!path && id && data) {
105
+ var _findNodeAndParent = findNodeAndParent(id, json),
106
+ node = _findNodeAndParent.node;
107
+ if (node) {
108
+ node.props = _objectSpread(_objectSpread({}, data), {}, {
109
+ id: id
110
+ });
111
+ } else {
112
+ throw new Error("Node with id \"".concat(id, "\" does not exist."));
113
+ }
114
+ } else if (!path && id && !data) {
115
+ var _findNodeAndParent2 = findNodeAndParent(id, json),
116
+ _node = _findNodeAndParent2.node,
117
+ parent = _findNodeAndParent2.parent;
118
+ if (_node && parent) {
119
+ parent.children = parent.children.filter(function (childId) {
120
+ return childId !== id;
121
+ });
122
+ if (parent.children.length === 0) {
123
+ delete parent['children'];
124
+ }
125
+ delete parent[id];
126
+ } else {
127
+ throw new Error("Node with id \"".concat(id, "\" does not exist."));
128
+ }
129
+ }
130
+ }
131
+
132
+ /**
133
+ * 对指定的JSON结构进行节点的添加操作。
134
+ *
135
+ * @param {Object} json - 要操作的JSON对象。
136
+ * @param {string|null} path - 要操作的节点路径,使用'/'分隔。
137
+ * @param {string} id - 操作节点的唯一标识符。
138
+ * @param {Object|null} data - 要添加或修改的数据。如果为null,表示删除操作。
139
+ */
140
+ export function add(json, path, id, data) {
141
+ process(json, path, id, data);
142
+ }
143
+
144
+ /**
145
+ * 对指定的JSON结构进行节点的修改操作。
146
+ *
147
+ * @param {Object} json - 要操作的JSON对象。
148
+ * @param {string} id - 操作节点的唯一标识符。
149
+ * @param {Object|null} data - 要添加或修改的数据。如果为null,表示删除操作。
150
+ */
151
+ export function modifyById(json, id, data) {
152
+ process(json, null, id, data);
153
+ }
154
+
155
+ /**
156
+ * 查找指定ID的节点及其父节点。
157
+ *
158
+ * @param {Object} json - JSON对象。
159
+ * @param {string} id - 要删除的节点ID。
160
+ */
161
+ export function deleteById(json, id) {
162
+ process(json, null, id);
163
+ }
164
+
165
+ /**
166
+ * 根据ID在给定的JSON结构中查找节点的路径。
167
+ *
168
+ * @param {Object} json - 要搜索的JSON对象。
169
+ * @param {string} id - 要查找的节点ID。
170
+ * @param {string} currentPath - 当前递归到的路径,用于构建返回的路径字符串。
171
+ * @returns {string|null} 如果找到节点,返回节点的路径;否则返回null。
172
+ */
173
+ export function getPathById(json, id) {
174
+ var currentPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
175
+ for (var key in json) {
176
+ var newPath = currentPath ? "".concat(currentPath, "/").concat(key) : key;
177
+ if (json[key].props && json[key].props.id === id) {
178
+ return newPath;
179
+ }
180
+ if (json[key].hasOwnProperty('children')) {
181
+ var result = getPathById(json[key], id, newPath);
182
+ if (result) {
183
+ return result;
184
+ }
185
+ }
186
+ }
187
+ return null;
188
+ }
@@ -0,0 +1,4 @@
1
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
2
+ export function isPromise(value) {
3
+ return !!value && _typeof(value) === 'object' && typeof value.then === 'function';
4
+ }
@@ -0,0 +1,16 @@
1
+ import { v4 as uuidv4 } from 'uuid';
2
+ var chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
3
+ export default function generateShortUuid() {
4
+ var toLowerCase = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
5
+ var shortBuffer = '';
6
+ var uuid = uuidv4().replace(/-/g, '');
7
+ for (var i = 0; i < 8; i++) {
8
+ var str = uuid.substring(i * 4, i * 4 + 4);
9
+ var x = parseInt(str, 16);
10
+ shortBuffer += chars[x % 0x3e];
11
+ }
12
+ if (toLowerCase) {
13
+ return shortBuffer.toLowerCase();
14
+ }
15
+ return shortBuffer;
16
+ }
@@ -0,0 +1,3 @@
1
+ export { default as Painter } from "./painter";
2
+ export { default as View } from "./view";
3
+ // export * as dataProcess from './engine/tools/dataProcess';
@@ -0,0 +1,104 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+ import React, { useState } from 'react';
4
+ import { Icon, Input, Tabs } from 'luck-design/antd';
5
+ import { useMemoizedFn, useCreation } from 'ahooks';
6
+ import { formatMessage } from '@luck-design-biz/base/utils';
7
+ import { useLDContext } from "../engine/provider/ContextProvider";
8
+ import styles from "./style/components.less";
9
+ import data from "../engine/meta/components-list.json";
10
+ var TabPane = Tabs.TabPane;
11
+ var Search = Input.Search;
12
+ var BaseCom = function BaseCom(_ref) {
13
+ var onComponentClick = _ref.onComponentClick;
14
+ var _useState = useState(''),
15
+ _useState2 = _slicedToArray(_useState, 2),
16
+ searchTerm = _useState2[0],
17
+ setSearchTerm = _useState2[1];
18
+ var handleSearch = useMemoizedFn(function (e) {
19
+ setSearchTerm(e.target.value.toLowerCase());
20
+ });
21
+ var filteredData = useCreation(function () {
22
+ return data.map(function (group) {
23
+ return _objectSpread(_objectSpread({}, group), {}, {
24
+ components: group.components.filter(function (item) {
25
+ return item.name.toLowerCase().includes(searchTerm) || item.desc.toLowerCase().includes(searchTerm);
26
+ })
27
+ });
28
+ }).filter(function (group) {
29
+ return group.components.length > 0;
30
+ });
31
+ }, [data]);
32
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
33
+ className: styles['components-search']
34
+ }, /*#__PURE__*/React.createElement(Search, {
35
+ placeholder: formatMessage({
36
+ id: 'luckda.lowcode.painter.components.search',
37
+ label: '搜索组件'
38
+ }),
39
+ onChange: handleSearch
40
+ })), /*#__PURE__*/React.createElement("div", {
41
+ className: styles['components-content']
42
+ }, filteredData.map(function (group) {
43
+ return /*#__PURE__*/React.createElement("div", {
44
+ key: group.group,
45
+ className: styles['components-wrapper']
46
+ }, /*#__PURE__*/React.createElement("h3", null, group.groupName), group.components.map(function (item) {
47
+ return /*#__PURE__*/React.createElement("div", {
48
+ key: item.component,
49
+ className: styles['components-item'],
50
+ onClick: function onClick() {
51
+ return onComponentClick(item);
52
+ }
53
+ }, /*#__PURE__*/React.createElement("div", {
54
+ className: styles['icon-wrapper']
55
+ }, /*#__PURE__*/React.createElement(Icon, {
56
+ type: item.icon || 'home'
57
+ })), /*#__PURE__*/React.createElement("div", {
58
+ className: styles['text-content']
59
+ }, /*#__PURE__*/React.createElement("span", null, item.name)));
60
+ }));
61
+ })));
62
+ };
63
+
64
+ /**
65
+ * 组件清单
66
+ */
67
+ var Components = function Components(_ref2) {
68
+ var _ref2$dataset = _ref2.dataset,
69
+ dataset = _ref2$dataset === void 0 ? 'test' : _ref2$dataset;
70
+ var context = useLDContext();
71
+ var onComponentClick = useMemoizedFn(function (data) {
72
+ context.$publisher(context.topics.COMPONENT_SETTING_CLICK, {
73
+ data: data
74
+ });
75
+ });
76
+ if (!dataset) return /*#__PURE__*/React.createElement("div", {
77
+ className: styles['lc-painter-components'],
78
+ style: {
79
+ paddingTop: '16px'
80
+ }
81
+ }, /*#__PURE__*/React.createElement(BaseCom, {
82
+ onComponentClick: onComponentClick
83
+ }));
84
+ return /*#__PURE__*/React.createElement("div", {
85
+ className: styles['lc-painter-components']
86
+ }, /*#__PURE__*/React.createElement(Tabs, {
87
+ defaultActiveKey: "base"
88
+ }, /*#__PURE__*/React.createElement(TabPane, {
89
+ tab: formatMessage({
90
+ id: 'ccm.dev.page.set.components.base',
91
+ label: '基础组件'
92
+ }),
93
+ key: "base"
94
+ }, /*#__PURE__*/React.createElement(BaseCom, {
95
+ onComponentClick: onComponentClick
96
+ })), /*#__PURE__*/React.createElement(TabPane, {
97
+ tab: formatMessage({
98
+ id: 'ccm.dev.page.set.components.dataset',
99
+ label: '数据集字段'
100
+ }),
101
+ key: "dataset"
102
+ })));
103
+ };
104
+ export default Components;
@@ -0,0 +1,97 @@
1
+ import React, { useRef, useEffect } from 'react';
2
+ import { useEventListener } from 'ahooks';
3
+ import { useLDContext } from "../engine/provider/ContextProvider";
4
+ import Page from "../view/Page";
5
+ import { CELL_CLASS_NAME } from "../constants";
6
+ import styles from "./style/design.less";
7
+ var Design = function Design() {
8
+ var context = useLDContext();
9
+ var detectorRef = useRef(null);
10
+ var selectorRef = useRef(null);
11
+ var simulatorRef = useRef(null);
12
+ var hoverCellRef = useRef(null);
13
+ var activeCellRef = useRef(null);
14
+ useEventListener('mousemove', function (event) {
15
+ var elem = event.target;
16
+ var targetCell = elem.closest(".".concat(CELL_CLASS_NAME));
17
+ if (targetCell && !targetCell.isEqualNode(hoverCellRef.current) && !targetCell.isEqualNode(activeCellRef.current)) {
18
+ var _id = targetCell.id;
19
+ hoverCellRef.current = targetCell;
20
+ context.$publisher(context.topics.COMPONENT_HOVER, {
21
+ id: _id,
22
+ cellNode: targetCell
23
+ });
24
+ } else if (!targetCell || targetCell.isEqualNode(activeCellRef.current)) {
25
+ hoverCellRef.current = null;
26
+ context.$publisher(context.topics.COMPONENT_HOVER, null);
27
+ }
28
+ }, {
29
+ target: simulatorRef
30
+ });
31
+ useEventListener('mouseleave', function () {
32
+ if (hoverCellRef.current) {
33
+ hoverCellRef.current = null;
34
+ context.$publisher(context.topics.COMPONENT_HOVER, null);
35
+ }
36
+ }, {
37
+ target: simulatorRef
38
+ });
39
+ useEventListener('click', function (event) {
40
+ var elem = event.target;
41
+ var targetCell = elem.closest(".".concat(CELL_CLASS_NAME));
42
+ if (!targetCell || targetCell.isEqualNode(activeCellRef.current)) return;
43
+ activeCellRef.current = targetCell;
44
+ hoverCellRef.current = null;
45
+ context.$publisher(context.topics.COMPONENT_HOVER, null);
46
+ context.$publisher(context.topics.COMPONENT_ACTIVE, {
47
+ id: activeCellRef.current.id,
48
+ cellNode: activeCellRef.current
49
+ });
50
+ }, {
51
+ target: simulatorRef
52
+ });
53
+ useEffect(function () {
54
+ var setRect = function setRect(node, cellNode) {
55
+ node.style.left = "".concat(cellNode.offsetLeft, "px");
56
+ node.style.top = "".concat(cellNode.offsetTop, "px");
57
+ node.style.width = "".concat(cellNode.offsetWidth, "px");
58
+ node.style.height = "".concat(cellNode.offsetHeight, "px");
59
+ };
60
+ var hcid = context.$subscriber(context.topics.COMPONENT_HOVER).on(function (payload) {
61
+ if (payload.id) {
62
+ detectorRef.current.style.display = 'block';
63
+ setRect(detectorRef.current, payload.cellNode);
64
+ } else {
65
+ detectorRef.current.style.display = 'none';
66
+ }
67
+ }).watch();
68
+ var acid = context.$subscriber(context.topics.COMPONENT_ACTIVE).on(function (payload) {
69
+ if (payload.id) {
70
+ selectorRef.current.style.display = 'block';
71
+ setRect(selectorRef.current, payload.cellNode);
72
+ } else {
73
+ selectorRef.current.style.display = 'none';
74
+ }
75
+ }).watch();
76
+ return function () {
77
+ context.$unsubscriber(context.topics.COMPONENT_HOVER, hcid);
78
+ context.$unsubscriber(context.topics.COMPONENT_ACTIVE, acid);
79
+ };
80
+ }, []);
81
+ return /*#__PURE__*/React.createElement("div", {
82
+ className: styles['lc-painter-design']
83
+ }, /*#__PURE__*/React.createElement("div", {
84
+ id: "lc-detector",
85
+ ref: detectorRef,
86
+ className: styles.detector
87
+ }), /*#__PURE__*/React.createElement("div", {
88
+ id: "lc-selector",
89
+ ref: selectorRef,
90
+ className: styles.selector
91
+ }), /*#__PURE__*/React.createElement(Page, {
92
+ ref: simulatorRef,
93
+ pageCode: "mk2i87qb",
94
+ className: styles.simulator
95
+ }));
96
+ };
97
+ export default Design;