@luck-design-biz/luckda 1.0.6-13tl → 1.0.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 (169) hide show
  1. package/es/components/Builder/index.js +37 -27
  2. package/es/components/ComplexItem/index.js +5 -3
  3. package/es/components/ComplexItem/service.js +6 -3
  4. package/es/components/LdAutoForm/index.js +25 -12
  5. package/es/components/LdCard/index.js +10 -8
  6. package/es/components/LdCom/index.js +3 -2
  7. package/es/components/LdFormList/index.js +5 -4
  8. package/es/components/LdGrid/index.js +29 -20
  9. package/es/components/LdGridForm/index.js +16 -7
  10. package/es/components/LdInfoPanel/index.js +16 -10
  11. package/es/helper/FromItems.js +64 -5
  12. package/es/helper/form.js +8 -2
  13. package/es/helper/ldBuilder.js +9 -5
  14. package/es/helper/ldComBuild.js +16 -11
  15. package/es/locales/zh-CN.js +40 -4
  16. package/es/lowcode/constants/api-url.js +202 -175
  17. package/es/lowcode/constants/event-topics.js +2 -0
  18. package/es/lowcode/constants/index.js +5 -4
  19. package/es/lowcode/engine/meta/components-list.json +6 -0
  20. package/es/lowcode/engine/meta/fielddate.props.default.json +1 -0
  21. package/es/lowcode/engine/meta/fielddate.props.json +48 -0
  22. package/es/lowcode/engine/meta/js-editor/auto-complete.json +5 -0
  23. package/es/lowcode/engine/meta/pagecomponent.props.default.json +8 -0
  24. package/es/lowcode/engine/meta/pagecomponent.props.json +41 -0
  25. package/es/lowcode/engine/meta/proxy.props.default.json +15 -0
  26. package/es/lowcode/engine/meta/proxy.props.json +66 -0
  27. package/es/lowcode/engine/provider/ContextProvider/index.js +45 -9
  28. package/es/lowcode/engine/provider/ContextProvider/usePageDataStore.js +36 -30
  29. package/es/lowcode/engine/provider/ContextProvider/usePageVar.js +11 -5
  30. package/es/lowcode/engine/provider/ContextProvider/useTodo.js +2 -4
  31. package/es/lowcode/engine/provider/EventBusProvider.js +14 -4
  32. package/es/lowcode/engine/provider/PageProxyProvider.js +95 -0
  33. package/es/lowcode/engine/provider/RemoteSourceProvider.js +10 -12
  34. package/es/lowcode/engine/tools/helper.js +44 -5
  35. package/es/lowcode/engine/tools/initDS.js +4 -4
  36. package/es/lowcode/painter/Design.js +1 -0
  37. package/es/lowcode/painter/DesignOperator.js +129 -27
  38. package/es/lowcode/painter/DesignToolbar.js +88 -173
  39. package/es/lowcode/painter/components/AdvancePanel.js +28 -10
  40. package/es/lowcode/painter/components/TipIcon.js +12 -4
  41. package/es/lowcode/painter/components/field-setting/SettingUI.js +56 -4
  42. package/es/lowcode/painter/components/field-setting/index.js +24 -1
  43. package/es/lowcode/painter/components/shortcut-modal/KeyIcon.js +11 -0
  44. package/es/lowcode/painter/components/shortcut-modal/index.js +208 -0
  45. package/es/lowcode/painter/panel-section/BlockEditor/index.js +10 -19
  46. package/es/lowcode/painter/panel-section/BlocksEditor/index.js +4 -1
  47. package/es/lowcode/painter/panel-section/ConditionCheck.js +0 -1
  48. package/es/lowcode/painter/panel-section/DataSetSelector.js +6 -3
  49. package/es/lowcode/painter/panel-section/FieldsSetting.js +1 -1
  50. package/es/lowcode/painter/panel-section/IconConditionSelector.js +2 -1
  51. package/es/lowcode/painter/panel-section/JSEditor/ToolBar.js +7 -4
  52. package/es/lowcode/painter/panel-section/JSEditor/index.js +15 -5
  53. package/es/lowcode/painter/panel-section/JSEditor/index.less +4 -0
  54. package/es/lowcode/painter/panel-section/ProxyLinker.js +137 -0
  55. package/es/lowcode/painter/panel-section/ProxyParams.js +28 -0
  56. package/es/lowcode/painter/panel-section/ProxyParamsSetter.js +240 -0
  57. package/es/lowcode/painter/style/panel-item.less +1 -0
  58. package/es/lowcode/preview/DebugTool.js +78 -0
  59. package/es/lowcode/preview/DebugToolDetail.js +103 -0
  60. package/es/lowcode/preview/index.js +10 -17
  61. package/es/lowcode/preview/useDebugSettings.js +62 -0
  62. package/es/lowcode/view/Canvas.js +5 -1
  63. package/es/lowcode/view/Page.js +8 -3
  64. package/es/lowcode/view/lc-components/CardList/index.js +3 -0
  65. package/es/lowcode/view/lc-components/Dialog/index.js +9 -7
  66. package/es/lowcode/view/lc-components/Drawer/index.js +2 -0
  67. package/es/lowcode/view/lc-components/FieldDate/meta.json +48 -0
  68. package/es/lowcode/view/lc-components/Form/index.js +3 -0
  69. package/es/lowcode/view/lc-components/Proxy/FunctionDesign.js +17 -0
  70. package/es/lowcode/view/lc-components/Proxy/FunctionLive.js +23 -0
  71. package/es/lowcode/view/lc-components/Proxy/FunctionPreview.js +23 -0
  72. package/es/lowcode/view/lc-components/Proxy/index.js +42 -0
  73. package/es/lowcode/view/lc-components/Proxy/index.less +5 -0
  74. package/es/lowcode/view/lc-components/Proxy/meta.json +66 -0
  75. package/es/lowcode/view/lc-components/Table/components/TopImex.js +5 -23
  76. package/es/lowcode/view/lc-components/Table/index.js +12 -6
  77. package/es/lowcode/view/lc-components/Tabs/index.js +6 -2
  78. package/es/lowcode/view/lc-components/Tree/index.js +3 -0
  79. package/es/lowcode/view/lc-components/Wrapper.js +7 -1
  80. package/es/services.js +25 -7
  81. package/es/utils/action.js +3 -2
  82. package/es/utils/form.js +37 -4
  83. package/es/utils/grid.js +2 -1
  84. package/lib/components/Builder/index.js +36 -26
  85. package/lib/components/ComplexItem/index.js +5 -3
  86. package/lib/components/ComplexItem/service.js +6 -3
  87. package/lib/components/LdAutoForm/index.js +22 -9
  88. package/lib/components/LdCard/index.js +10 -8
  89. package/lib/components/LdCom/index.js +3 -2
  90. package/lib/components/LdFormList/index.js +4 -3
  91. package/lib/components/LdGrid/index.js +29 -20
  92. package/lib/components/LdGridForm/index.js +13 -4
  93. package/lib/components/LdInfoPanel/index.js +15 -9
  94. package/lib/helper/FromItems.js +64 -5
  95. package/lib/helper/form.js +8 -2
  96. package/lib/helper/ldBuilder.js +8 -5
  97. package/lib/helper/ldComBuild.js +14 -9
  98. package/lib/locales/zh-CN.js +40 -4
  99. package/lib/lowcode/constants/api-url.js +204 -175
  100. package/lib/lowcode/constants/event-topics.js +3 -1
  101. package/lib/lowcode/constants/index.js +6 -5
  102. package/lib/lowcode/engine/meta/components-list.json +6 -0
  103. package/lib/lowcode/engine/meta/fielddate.props.default.json +1 -0
  104. package/lib/lowcode/engine/meta/fielddate.props.json +48 -0
  105. package/lib/lowcode/engine/meta/js-editor/auto-complete.json +5 -0
  106. package/lib/lowcode/engine/meta/pagecomponent.props.default.json +8 -0
  107. package/lib/lowcode/engine/meta/pagecomponent.props.json +41 -0
  108. package/lib/lowcode/engine/meta/proxy.props.default.json +15 -0
  109. package/lib/lowcode/engine/meta/proxy.props.json +66 -0
  110. package/lib/lowcode/engine/provider/ContextProvider/index.js +50 -13
  111. package/lib/lowcode/engine/provider/ContextProvider/usePageDataStore.js +37 -31
  112. package/lib/lowcode/engine/provider/ContextProvider/usePageVar.js +10 -4
  113. package/lib/lowcode/engine/provider/ContextProvider/useTodo.js +1 -3
  114. package/lib/lowcode/engine/provider/EventBusProvider.js +14 -4
  115. package/lib/lowcode/engine/provider/PageProxyProvider.js +103 -0
  116. package/lib/lowcode/engine/provider/RemoteSourceProvider.js +10 -12
  117. package/lib/lowcode/engine/tools/helper.js +44 -4
  118. package/lib/lowcode/engine/tools/initDS.js +4 -4
  119. package/lib/lowcode/painter/Design.js +1 -0
  120. package/lib/lowcode/painter/DesignOperator.js +126 -24
  121. package/lib/lowcode/painter/DesignToolbar.js +84 -169
  122. package/lib/lowcode/painter/components/AdvancePanel.js +27 -9
  123. package/lib/lowcode/painter/components/TipIcon.js +12 -4
  124. package/lib/lowcode/painter/components/field-setting/SettingUI.js +55 -3
  125. package/lib/lowcode/painter/components/field-setting/index.js +24 -1
  126. package/lib/lowcode/painter/components/shortcut-modal/KeyIcon.js +18 -0
  127. package/lib/lowcode/painter/components/shortcut-modal/index.js +215 -0
  128. package/lib/lowcode/painter/panel-section/BlockEditor/index.js +9 -18
  129. package/lib/lowcode/painter/panel-section/BlocksEditor/index.js +4 -1
  130. package/lib/lowcode/painter/panel-section/ConditionCheck.js +0 -1
  131. package/lib/lowcode/painter/panel-section/DataSetSelector.js +6 -3
  132. package/lib/lowcode/painter/panel-section/FieldsSetting.js +1 -1
  133. package/lib/lowcode/painter/panel-section/IconConditionSelector.js +2 -1
  134. package/lib/lowcode/painter/panel-section/JSEditor/ToolBar.js +7 -4
  135. package/lib/lowcode/painter/panel-section/JSEditor/index.js +14 -4
  136. package/lib/lowcode/painter/panel-section/JSEditor/index.less +4 -0
  137. package/lib/lowcode/painter/panel-section/ProxyLinker.js +145 -0
  138. package/lib/lowcode/painter/panel-section/ProxyParams.js +35 -0
  139. package/lib/lowcode/painter/panel-section/ProxyParamsSetter.js +248 -0
  140. package/lib/lowcode/painter/style/panel-item.less +1 -0
  141. package/lib/lowcode/preview/DebugTool.js +86 -0
  142. package/lib/lowcode/preview/DebugToolDetail.js +111 -0
  143. package/lib/lowcode/preview/index.js +10 -18
  144. package/lib/lowcode/preview/useDebugSettings.js +69 -0
  145. package/lib/lowcode/view/Canvas.js +5 -1
  146. package/lib/lowcode/view/Page.js +8 -3
  147. package/lib/lowcode/view/lc-components/CardList/index.js +3 -0
  148. package/lib/lowcode/view/lc-components/Dialog/index.js +9 -7
  149. package/lib/lowcode/view/lc-components/Drawer/index.js +2 -0
  150. package/lib/lowcode/view/lc-components/FieldDate/meta.json +48 -0
  151. package/lib/lowcode/view/lc-components/Form/index.js +3 -0
  152. package/lib/lowcode/view/lc-components/Proxy/FunctionDesign.js +24 -0
  153. package/lib/lowcode/view/lc-components/Proxy/FunctionLive.js +30 -0
  154. package/lib/lowcode/view/lc-components/Proxy/FunctionPreview.js +30 -0
  155. package/lib/lowcode/view/lc-components/Proxy/index.js +50 -0
  156. package/lib/lowcode/view/lc-components/Proxy/index.less +5 -0
  157. package/lib/lowcode/view/lc-components/Proxy/meta.json +66 -0
  158. package/lib/lowcode/view/lc-components/Table/components/TopImex.js +4 -22
  159. package/lib/lowcode/view/lc-components/Table/index.js +12 -6
  160. package/lib/lowcode/view/lc-components/Tabs/index.js +5 -1
  161. package/lib/lowcode/view/lc-components/Tree/index.js +3 -0
  162. package/lib/lowcode/view/lc-components/Wrapper.js +6 -0
  163. package/lib/services.js +26 -7
  164. package/lib/utils/action.js +6 -0
  165. package/lib/utils/form.js +38 -4
  166. package/lib/utils/grid.js +2 -1
  167. package/package.json +1 -1
  168. package/es/lowcode/engine/meta/button.api.json +0 -0
  169. package/lib/lowcode/engine/meta/button.api.json +0 -0
@@ -0,0 +1,240 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import React, { useRef, useEffect } from 'react';
5
+ import { useMap, useMemoizedFn } from 'ahooks';
6
+ import { Button, Collapse, Icon, Form, Input, Select, InputNumber, Switch } from 'luck-design/antd';
7
+ import styled from 'styled-components';
8
+ import { formatMessage, suid } from '@luck-design-biz/base/utils';
9
+ var SmallForm = styled(Form).withConfig({
10
+ displayName: "SmallForm",
11
+ componentId: "luckda-6530__sc-1aq87r3-0"
12
+ })(["font-size:12px;padding-top:8px;.ant-form-item{font-size:12px;margin-bottom:8px;.ant-form-item-label,.ant-form-item-control{height:24px;line-height:24px !important;}.ant-form-item-control.has-error{height:36px;.ant-form-explain{font-size:12px;}}label{font-size:12px;}}"]);
13
+ var SmallCollapse = styled(Collapse).withConfig({
14
+ displayName: "SmallCollapse",
15
+ componentId: "luckda-6530__sc-1aq87r3-1"
16
+ })(["font-size:12px;margin-bottom:8px;& > .ant-collapse-item > .ant-collapse-header{padding:4px 8px 4px 36px;}.ant-collapse-content > .ant-collapse-content-box{padding:4px 8px;}"]);
17
+ var ButtonWrapper = styled.div.withConfig({
18
+ displayName: "ButtonWrapper",
19
+ componentId: "luckda-6530__sc-1aq87r3-2"
20
+ })(["display:grid;grid-template-columns:1fr 1fr;gap:8px;"]);
21
+ var _I18N_PREFIX_ = 'luckda.lowcode.painter.panel-section.proxy-params-setter';
22
+ var _OPTIONS_ = [{
23
+ label: formatMessage({
24
+ id: "".concat(_I18N_PREFIX_, ".param-origin.state"),
25
+ label: '页面全局状态'
26
+ }),
27
+ value: 'state'
28
+ }, {
29
+ label: formatMessage({
30
+ id: "".concat(_I18N_PREFIX_, ".param-origin.global"),
31
+ label: '页面全局变量'
32
+ }),
33
+ value: 'global'
34
+ }, {
35
+ label: formatMessage({
36
+ id: "".concat(_I18N_PREFIX_, ".param-origin.url"),
37
+ label: '页面URL参数'
38
+ }),
39
+ value: 'url'
40
+ }, {
41
+ label: formatMessage({
42
+ id: "".concat(_I18N_PREFIX_, ".param-origin.string"),
43
+ label: '字符串常量'
44
+ }),
45
+ value: 'string'
46
+ }, {
47
+ label: formatMessage({
48
+ id: "".concat(_I18N_PREFIX_, ".param-origin.num"),
49
+ label: '数字常量'
50
+ }),
51
+ value: 'num'
52
+ }, {
53
+ label: formatMessage({
54
+ id: "".concat(_I18N_PREFIX_, ".param-origin.bool"),
55
+ label: '布尔常量'
56
+ }),
57
+ value: 'bool'
58
+ }];
59
+ var ParamForm = Form.create({
60
+ name: 'param_form',
61
+ onValuesChange: function onValuesChange(props, _, allValues) {
62
+ props.onChange(props.id, allValues);
63
+ }
64
+ })(function (_ref) {
65
+ var form = _ref.form,
66
+ getForm = _ref.getForm,
67
+ defaultValue = _ref.defaultValue;
68
+ useEffect(function () {
69
+ getForm(form);
70
+ }, []);
71
+ var formItemCol = {
72
+ labelCol: {
73
+ span: 8
74
+ },
75
+ wrapperCol: {
76
+ span: 16
77
+ }
78
+ };
79
+ return /*#__PURE__*/React.createElement(SmallForm, {
80
+ hideRequiredMark: true,
81
+ layout: "horizontal"
82
+ }, /*#__PURE__*/React.createElement(Form.Item, _extends({
83
+ label: formatMessage({
84
+ id: "".concat(_I18N_PREFIX_, ".param-name"),
85
+ label: '参数名称'
86
+ })
87
+ }, formItemCol), form.getFieldDecorator('name', {
88
+ initialValue: defaultValue.name,
89
+ rules: [{
90
+ required: true,
91
+ message: formatMessage({
92
+ id: "".concat(_I18N_PREFIX_, ".warn.param-name"),
93
+ label: '请输入参数名称'
94
+ })
95
+ }]
96
+ })( /*#__PURE__*/React.createElement(Input, {
97
+ size: "small"
98
+ }))), /*#__PURE__*/React.createElement(Form.Item, _extends({
99
+ label: formatMessage({
100
+ id: "".concat(_I18N_PREFIX_, ".param-origin"),
101
+ label: '参数来源'
102
+ })
103
+ }, formItemCol), form.getFieldDecorator('origin', {
104
+ initialValue: defaultValue.origin || 'state'
105
+ })( /*#__PURE__*/React.createElement(Select, {
106
+ size: "small"
107
+ }, _OPTIONS_.map(function (item) {
108
+ return /*#__PURE__*/React.createElement(Select.Option, {
109
+ key: item.value,
110
+ value: item.value
111
+ }, item.label);
112
+ })))), ['state', 'global', 'url', 'string'].includes(form.getFieldValue('origin')) && /*#__PURE__*/React.createElement(Form.Item, _extends({
113
+ label: formatMessage({
114
+ id: "".concat(_I18N_PREFIX_, ".param-value"),
115
+ label: '值或变量名'
116
+ })
117
+ }, formItemCol), form.getFieldDecorator('value', {
118
+ initialValue: defaultValue.value,
119
+ rules: [{
120
+ required: true,
121
+ message: formatMessage({
122
+ id: "".concat(_I18N_PREFIX_, ".warn.param-value"),
123
+ label: '请输入参数值或变量名'
124
+ })
125
+ }]
126
+ })( /*#__PURE__*/React.createElement(Input, {
127
+ size: "small"
128
+ }))), form.getFieldValue('origin') === 'num' && /*#__PURE__*/React.createElement(Form.Item, _extends({
129
+ label: formatMessage({
130
+ id: "".concat(_I18N_PREFIX_, ".param-value"),
131
+ label: '值或变量名'
132
+ })
133
+ }, formItemCol), form.getFieldDecorator('value', {
134
+ initialValue: defaultValue.value || 0
135
+ })( /*#__PURE__*/React.createElement(InputNumber, {
136
+ size: "small"
137
+ }))), form.getFieldValue('origin') === 'bool' && /*#__PURE__*/React.createElement(Form.Item, _extends({
138
+ label: formatMessage({
139
+ id: "".concat(_I18N_PREFIX_, ".param-value"),
140
+ label: '值或变量名'
141
+ })
142
+ }, formItemCol), form.getFieldDecorator('value', {
143
+ initialValue: defaultValue.value || false,
144
+ valuePropName: 'checked'
145
+ })( /*#__PURE__*/React.createElement(Switch, {
146
+ size: "small"
147
+ }))));
148
+ });
149
+ var ProxyParamsSetter = function ProxyParamsSetter(_ref2) {
150
+ var defaultValue = _ref2.defaultValue,
151
+ onChange = _ref2.onChange;
152
+ var formsRef = useRef([]);
153
+ var _useMap = useMap(defaultValue.map(function (item) {
154
+ return [item.id, item];
155
+ })),
156
+ _useMap2 = _slicedToArray(_useMap, 2),
157
+ map = _useMap2[0],
158
+ _useMap2$ = _useMap2[1],
159
+ set = _useMap2$.set,
160
+ remove = _useMap2$.remove;
161
+ var handleAdd = useMemoizedFn(function () {
162
+ var _id = suid();
163
+ set(_id, {
164
+ id: _id,
165
+ origin: 'state'
166
+ });
167
+ });
168
+ var handleSave = useMemoizedFn(function () {
169
+ var isValid = true;
170
+ formsRef.current.some(function (_form) {
171
+ _form.validateFields(function (err, val) {
172
+ isValid = !err;
173
+ });
174
+ return !isValid;
175
+ });
176
+ if (!isValid) return;
177
+ onChange(Array.from(map).map(function (_ref3) {
178
+ var _ref4 = _slicedToArray(_ref3, 2),
179
+ id = _ref4[0],
180
+ item = _ref4[1];
181
+ return _objectSpread(_objectSpread({}, item), {}, {
182
+ id: id
183
+ });
184
+ }));
185
+ });
186
+ var handleChange = useMemoizedFn(function (id, val) {
187
+ set(id, val);
188
+ });
189
+ var handleDelete = useMemoizedFn(function (id, index) {
190
+ formsRef.current = [];
191
+ remove(id);
192
+ });
193
+ return /*#__PURE__*/React.createElement("div", null, Array.from(map).map(function (_ref5, index) {
194
+ var _ref6 = _slicedToArray(_ref5, 2),
195
+ id = _ref6[0],
196
+ item = _ref6[1];
197
+ return /*#__PURE__*/React.createElement(SmallCollapse, {
198
+ key: id,
199
+ activeKey: "panel"
200
+ }, /*#__PURE__*/React.createElement(Collapse.Panel, {
201
+ header: "".concat(formatMessage({
202
+ id: "".concat(_I18N_PREFIX_, ".param"),
203
+ label: "\u9875\u9762\u53C2\u6570"
204
+ })).concat(index + 1),
205
+ key: "panel",
206
+ extra: /*#__PURE__*/React.createElement(Icon, {
207
+ type: "minus-circle",
208
+ style: {
209
+ color: 'var(--luck-color-danger)'
210
+ },
211
+ onClick: function onClick() {
212
+ return handleDelete(id);
213
+ }
214
+ })
215
+ }, /*#__PURE__*/React.createElement(ParamForm, {
216
+ id: id,
217
+ defaultValue: item,
218
+ getForm: function getForm(_form) {
219
+ return formsRef.current[index] = _form;
220
+ },
221
+ onChange: handleChange
222
+ })));
223
+ }), /*#__PURE__*/React.createElement(ButtonWrapper, null, /*#__PURE__*/React.createElement(Button, {
224
+ size: "small",
225
+ block: true,
226
+ onClick: handleAdd
227
+ }, formatMessage({
228
+ id: "".concat(_I18N_PREFIX_, ".add"),
229
+ label: '添加参数'
230
+ })), /*#__PURE__*/React.createElement(Button, {
231
+ size: "small",
232
+ block: true,
233
+ type: "primary",
234
+ onClick: handleSave
235
+ }, formatMessage({
236
+ id: "".concat(_I18N_PREFIX_, ".save"),
237
+ label: '保存并返回'
238
+ }))));
239
+ };
240
+ export default ProxyParamsSetter;
@@ -19,6 +19,7 @@
19
19
  align-items: center;
20
20
  gap: 4px;
21
21
  user-select: none;
22
+ flex-shrink: 0;
22
23
  }
23
24
 
24
25
  .item-component {
@@ -0,0 +1,78 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React, { useRef, useState } from 'react';
3
+ import { useMemoizedFn, useDrag, useBoolean } from 'ahooks';
4
+ import { Icon, Drawer } from 'luck-design/antd';
5
+ import styled from 'styled-components';
6
+ import { formatMessage } from '@luck-design-biz/base/utils';
7
+ import DebugToolDetail from "./DebugToolDetail";
8
+ var Wrapper = styled.div.withConfig({
9
+ displayName: "Wrapper",
10
+ componentId: "luckda-6530__sc-1x7h5jv-0"
11
+ })(["position:fixed;border-top-left-radius:16px;border-bottom-left-radius:16px;cursor:pointer;z-index:1000;background:rgba(40,40,40,0.5);backdrop-filter:blur(6px);display:flex;align-items:center;justify-content:center;transition:right 0.4s ease-in-out;"]);
12
+ var MoveIcon = styled.div.withConfig({
13
+ displayName: "MoveIcon",
14
+ componentId: "luckda-6530__sc-1x7h5jv-1"
15
+ })(["height:46px;border-left:1px solid rgb(191,191,191,0.4);cursor:move;&:hover{background:transparent;backdrop-filter:blur(6px);}"]);
16
+ var DebugTool = function DebugTool() {
17
+ var dragRef = useRef();
18
+ var _useState = useState([-32, 100]),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ _useState2$ = _slicedToArray(_useState2[0], 2),
21
+ right = _useState2$[0],
22
+ top = _useState2$[1],
23
+ setPostion = _useState2[1];
24
+ var _useBoolean = useBoolean(false),
25
+ _useBoolean2 = _slicedToArray(_useBoolean, 2),
26
+ show = _useBoolean2[0],
27
+ _useBoolean2$ = _useBoolean2[1],
28
+ setTrue = _useBoolean2$.setTrue,
29
+ setFalse = _useBoolean2$.setFalse;
30
+ var handleMouseEnter = useMemoizedFn(function () {
31
+ setPostion([0, top]);
32
+ });
33
+ var handleMouseLeave = useMemoizedFn(function () {
34
+ setPostion([-32, top]);
35
+ });
36
+ var handleDragEnd = useMemoizedFn(function (event) {
37
+ setPostion([right, event.y]);
38
+ });
39
+ useDrag('', dragRef, {
40
+ onDragEnd: handleDragEnd
41
+ });
42
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Wrapper, {
43
+ style: {
44
+ right: right,
45
+ top: "".concat(top, "px")
46
+ },
47
+ onMouseEnter: handleMouseEnter,
48
+ onMouseLeave: handleMouseLeave
49
+ }, /*#__PURE__*/React.createElement(Icon, {
50
+ type: "bug",
51
+ style: {
52
+ padding: '16px 8px 16px 16px'
53
+ },
54
+ onClick: setTrue
55
+ }), /*#__PURE__*/React.createElement(MoveIcon, {
56
+ ref: dragRef
57
+ }, /*#__PURE__*/React.createElement("svg", {
58
+ viewBox: "0 0 1024 1024",
59
+ width: "20",
60
+ height: "46"
61
+ }, /*#__PURE__*/React.createElement("path", {
62
+ d: "M320 64a64 64 0 1 0 0 128 64 64 0 0 0 0-128zM704 64a64 64 0 1 0 0 128 64 64 0 0 0 0-128zM256 384a64 64 0 1 1 128 0 64 64 0 0 1-128 0zM704 320a64 64 0 1 0 0 128 64 64 0 0 0 0-128zM256 640a64 64 0 1 1 128 0 64 64 0 0 1-128 0zM320 832a64 64 0 1 0 0 128 64 64 0 0 0 0-128zM640 640a64 64 0 1 1 128 0 64 64 0 0 1-128 0zM704 832a64 64 0 1 0 0 128 64 64 0 0 0 0-128z",
63
+ fill: "#bfbfbf"
64
+ })))), /*#__PURE__*/React.createElement(Drawer, {
65
+ title: formatMessage({
66
+ id: 'luckda.lowcode.design.toolbar.debugTool',
67
+ label: '调试工具'
68
+ }),
69
+ visible: show,
70
+ onClose: setFalse,
71
+ footer: false,
72
+ mask: false,
73
+ bodyStyle: {
74
+ padding: '4px 16px'
75
+ }
76
+ }, /*#__PURE__*/React.createElement(DebugToolDetail, null)));
77
+ };
78
+ export default DebugTool;
@@ -0,0 +1,103 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
+ import React, { useState } from 'react';
6
+ import { useDebounceFn } from 'ahooks';
7
+ import { Form, Select } from 'luck-design/antd';
8
+ import { formatMessage } from '@luck-design-biz/base/utils';
9
+ import useDebugSettings from "./useDebugSettings";
10
+ import { fetchSearchUser } from "../constants/api-url";
11
+ var DebugToolDetail = function DebugToolDetail(_ref) {
12
+ var form = _ref.form;
13
+ var _useDebugSettings = useDebugSettings(),
14
+ _useDebugSettings2 = _slicedToArray(_useDebugSettings, 2),
15
+ debugSettings = _useDebugSettings2[0],
16
+ setDebugSetting = _useDebugSettings2[1];
17
+ var _useState = useState([]),
18
+ _useState2 = _slicedToArray(_useState, 2),
19
+ userOptions = _useState2[0],
20
+ setUserOptions = _useState2[1];
21
+ var _useDebounceFn = useDebounceFn( /*#__PURE__*/function () {
22
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(value) {
23
+ var _yield$fetchSearchUse, code, list, detail;
24
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
25
+ while (1) switch (_context.prev = _context.next) {
26
+ case 0:
27
+ _context.next = 2;
28
+ return fetchSearchUser({
29
+ sname: value
30
+ });
31
+ case 2:
32
+ _yield$fetchSearchUse = _context.sent;
33
+ code = _yield$fetchSearchUse.code;
34
+ list = _yield$fetchSearchUse.list;
35
+ detail = _yield$fetchSearchUse.detail;
36
+ if (code === 1) {
37
+ setUserOptions(list.map(function (id) {
38
+ var item = detail[id];
39
+ return _objectSpread(_objectSpread({}, item), {}, {
40
+ key: "".concat(item.sloginid),
41
+ label: item.sname
42
+ });
43
+ }));
44
+ }
45
+ case 7:
46
+ case "end":
47
+ return _context.stop();
48
+ }
49
+ }, _callee);
50
+ }));
51
+ return function (_x) {
52
+ return _ref2.apply(this, arguments);
53
+ };
54
+ }(), {
55
+ wait: 500
56
+ }),
57
+ handleSearch = _useDebounceFn.run;
58
+ return /*#__PURE__*/React.createElement(Form, {
59
+ layout: "vertical"
60
+ }, /*#__PURE__*/React.createElement(Form.Item, {
61
+ label: formatMessage({
62
+ id: 'luckda.lowcode.design.toolbar.selectUser',
63
+ label: '模拟登录人'
64
+ })
65
+ }, form.getFieldDecorator('account')( /*#__PURE__*/React.createElement(Select, {
66
+ placeholder: formatMessage({
67
+ id: 'luckda.lowcode.design.toolbar.placeholder.selectUser',
68
+ label: '请选择模拟登录人'
69
+ }),
70
+ allowClear: true,
71
+ size: "small",
72
+ style: {
73
+ width: '100%'
74
+ },
75
+ filterOption: false,
76
+ labelInValue: true,
77
+ defaultValue: debugSettings.account ? {
78
+ value: debugSettings.account,
79
+ label: debugSettings.accountName
80
+ } : void 0,
81
+ showSearch: true,
82
+ onSearch: handleSearch,
83
+ onChange: function onChange(_opt) {
84
+ if (_opt) {
85
+ setDebugSetting('account', _opt.key);
86
+ setDebugSetting('accountName', _opt.label);
87
+ } else {
88
+ setDebugSetting('account', void 0);
89
+ setDebugSetting('accountName', void 0);
90
+ }
91
+ }
92
+ }, userOptions.map(function (_ref3) {
93
+ var key = _ref3.key,
94
+ label = _ref3.label;
95
+ return /*#__PURE__*/React.createElement(Select.Option, {
96
+ key: key,
97
+ value: key
98
+ }, label);
99
+ })))));
100
+ };
101
+ export default Form.create({
102
+ name: 'debug_tool'
103
+ })(DebugToolDetail);
@@ -1,28 +1,21 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import React, { useState } from 'react';
3
- import { useUpdateEffect } from 'ahooks';
2
+ import React from 'react';
4
3
  import EventBusProvider from "../engine/provider/EventBusProvider";
5
4
  import ContextProvider from "../engine/provider/ContextProvider";
6
5
  import Page from "../view/Page";
7
6
  import { RUNTIME } from "../constants/index";
7
+ import DebugTool from "./DebugTool";
8
+ import useDebugSettings from "./useDebugSettings";
8
9
  var Preview = function Preview(_ref) {
9
- var code = _ref.code,
10
- userId = _ref.userId;
11
- var _useState = useState(userId),
12
- _useState2 = _slicedToArray(_useState, 2),
13
- currentKey = _useState2[0],
14
- setCurrentKey = _useState2[1];
15
- useUpdateEffect(function () {
16
- setCurrentKey(void 0);
17
- setTimeout(function () {
18
- setCurrentKey(userId);
19
- });
20
- }, [userId]);
21
- return code && currentKey ? /*#__PURE__*/React.createElement(EventBusProvider, {
22
- key: code,
10
+ var code = _ref.code;
11
+ var _useDebugSettings = useDebugSettings(),
12
+ _useDebugSettings2 = _slicedToArray(_useDebugSettings, 1),
13
+ debugSettings = _useDebugSettings2[0];
14
+ return /*#__PURE__*/React.createElement(EventBusProvider, {
15
+ key: "".concat(code, ":").concat(debugSettings.account),
23
16
  runtime: RUNTIME.PREVIEW
24
17
  }, /*#__PURE__*/React.createElement(ContextProvider, {
25
18
  code: code
26
- }, /*#__PURE__*/React.createElement(Page, null))) : null;
19
+ }, /*#__PURE__*/React.createElement(Page, null), /*#__PURE__*/React.createElement(DebugTool, null)));
27
20
  };
28
21
  export default Preview;
@@ -0,0 +1,62 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import { create } from 'zustand';
4
+ import { immer } from 'zustand/middleware/immer';
5
+ import { subscribeWithSelector } from 'zustand/middleware';
6
+ import { useMemoizedFn, useAsyncEffect } from 'ahooks';
7
+ import { isNil } from 'lodash';
8
+ import { COOKIE_VIRTUAL_ACCOUNT_KEY } from "../constants";
9
+ import { fetchSearchUser } from "../constants/api-url";
10
+ export var useDebugSettingsStore = create()(immer(subscribeWithSelector(function () {
11
+ return {
12
+ account: window.cookie.get(COOKIE_VIRTUAL_ACCOUNT_KEY)
13
+ };
14
+ })));
15
+ var useDebugSettings = function useDebugSettings() {
16
+ var debugSettings = useDebugSettingsStore(function (store) {
17
+ return store;
18
+ });
19
+ useAsyncEffect( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
20
+ var _yield$fetchSearchUse, code, list, detail;
21
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
22
+ while (1) switch (_context.prev = _context.next) {
23
+ case 0:
24
+ if (!(debugSettings.account && isNil(debugSettings.accountName))) {
25
+ _context.next = 8;
26
+ break;
27
+ }
28
+ _context.next = 3;
29
+ return fetchSearchUser({
30
+ sloginidListIn: [debugSettings.account]
31
+ });
32
+ case 3:
33
+ _yield$fetchSearchUse = _context.sent;
34
+ code = _yield$fetchSearchUse.code;
35
+ list = _yield$fetchSearchUse.list;
36
+ detail = _yield$fetchSearchUse.detail;
37
+ if (code === 1) {
38
+ useDebugSettingsStore.setState(function (store) {
39
+ store.accountName = detail[list[0]].sname;
40
+ });
41
+ }
42
+ case 8:
43
+ case "end":
44
+ return _context.stop();
45
+ }
46
+ }, _callee);
47
+ })), []);
48
+ var setDebugSetting = useMemoizedFn(function (key, value) {
49
+ useDebugSettingsStore.setState(function (store) {
50
+ if (key === 'account') {
51
+ window.cookie.set(COOKIE_VIRTUAL_ACCOUNT_KEY, value);
52
+ }
53
+ if (isNil(value)) {
54
+ delete store[key];
55
+ } else {
56
+ store[key] = value;
57
+ }
58
+ });
59
+ });
60
+ return [debugSettings, setDebugSetting];
61
+ };
62
+ export default useDebugSettings;
@@ -48,7 +48,11 @@ var Canvas = function Canvas(_ref) {
48
48
  return function () {
49
49
  var _advance$events3;
50
50
  unsub();
51
- useStateStore.getState().clear();
51
+ var varKeys = (pageVars || []).map(function (v) {
52
+ return v.name;
53
+ });
54
+ useStateStore.getState().clear(varKeys);
55
+ ctx._deleteRemoteApis(varKeys);
52
56
  ctx.doAction(advance === null || advance === void 0 || (_advance$events3 = advance.events) === null || _advance$events3 === void 0 ? void 0 : _advance$events3.onPageUnmount);
53
57
  };
54
58
  }, []);
@@ -8,6 +8,7 @@ import { useMemoizedFn, useCreation, useBoolean } from 'ahooks';
8
8
  import { Skeleton } from 'luck-design/antd';
9
9
  import classNames from 'classnames';
10
10
  import { useRemoteSource, useContext } from "../engine/provider/ContextProvider";
11
+ import { usePageProxyContext } from "../engine/provider/PageProxyProvider";
11
12
  import initDS from "../engine/tools/initDS";
12
13
  import Loading from "./Loading";
13
14
  import Wrapper from "./lc-components/Wrapper";
@@ -28,12 +29,16 @@ var LCPage = /*#__PURE__*/forwardRef(function (_ref, ref) {
28
29
  loadMount = _useBoolean2[0],
29
30
  setTrue = _useBoolean2[1].setTrue;
30
31
  var ctx = useContext();
31
- var handlePageLoadMount = useMemoizedFn(function () {
32
- _dsRef.current = initDS(ctx);
32
+ var ppCtx = usePageProxyContext();
33
+ var handlePageLoadMount = useMemoizedFn(function (_ref2, topId) {
34
+ var proxyCode = _ref2.proxyCode;
35
+ if ((ppCtx === null || ppCtx === void 0 ? void 0 : ppCtx.proxyCode) !== proxyCode) return;
36
+ _dsRef.current = initDS(ctx, ppCtx === null || ppCtx === void 0 ? void 0 : ppCtx.proxyCode);
33
37
  setTrue();
38
+ ctx.$unsubscriber(ctx.topics.PAGE_LOAD_MOUNT, topId);
34
39
  });
35
40
  useCreation(function () {
36
- ctx.$subscriber(ctx.topics.PAGE_LOAD_MOUNT).once(handlePageLoadMount).watch();
41
+ ctx.$subscriber(ctx.topics.PAGE_LOAD_MOUNT).on(handlePageLoadMount).watch();
37
42
  }, []);
38
43
  var getTargetDom = useMemoizedFn(function () {
39
44
  return _rootRef.current;
@@ -7,6 +7,7 @@ import classNames from 'classnames';
7
7
  import { isNil, keyBy } from 'lodash';
8
8
  import { Modal, recheck, IconFont } from '@luck-design-biz/base';
9
9
  import { useContext } from "../../../engine/provider/ContextProvider";
10
+ import { usePageProxyContext } from "../../../engine/provider/PageProxyProvider";
10
11
  import Wrapper from "../Wrapper";
11
12
  import { LdCard, LDActions } from "../../../../index";
12
13
  import TopFilter from "../Table/components/TopFilter";
@@ -45,6 +46,7 @@ var LCCardList = /*#__PURE__*/forwardRef(function (_ref, ref) {
45
46
  renderContent = _ref.renderContent,
46
47
  describeLines = _ref.describeLines;
47
48
  var ctx = useContext();
49
+ var ppCtx = usePageProxyContext();
48
50
  var apiRef = useRef();
49
51
  var wrapperRef = useRef();
50
52
  var instanceRef = useCombinedRefs(ref);
@@ -253,6 +255,7 @@ var LCCardList = /*#__PURE__*/forwardRef(function (_ref, ref) {
253
255
  ref: instanceRef,
254
256
  wrapper: wrapperRef,
255
257
  wrapperProps: _wrapperProps,
258
+ pageProxy: ppCtx,
256
259
  _loading: ctx.loading,
257
260
  className: classNames(_defineProperty({}, className, !!className)),
258
261
  ldId: id,
@@ -71,6 +71,7 @@ var LCDialog = function LCDialog(_ref) {
71
71
  if (open) {
72
72
  ctx.doAction(advance.events.onOpen);
73
73
  } else {
74
+ _setTitle(title);
74
75
  ctx.doAction(advance.events.onClose);
75
76
  setLoading(false);
76
77
  }
@@ -82,18 +83,19 @@ var LCDialog = function LCDialog(_ref) {
82
83
  return _regeneratorRuntime().wrap(function _callee$(_context) {
83
84
  while (1) switch (_context.prev = _context.next) {
84
85
  case 0:
85
- _context.prev = 0;
86
- _context.next = 3;
86
+ setLoading(true);
87
+ _context.prev = 1;
88
+ _context.next = 4;
87
89
  return ctx.doAction(advance.events.onOk);
88
- case 3:
89
- _context.prev = 3;
90
+ case 4:
91
+ _context.prev = 4;
90
92
  setLoading(false);
91
- return _context.finish(3);
92
- case 6:
93
+ return _context.finish(4);
94
+ case 7:
93
95
  case "end":
94
96
  return _context.stop();
95
97
  }
96
- }, _callee, null, [[0,, 3, 6]]);
98
+ }, _callee, null, [[1,, 4, 7]]);
97
99
  })));
98
100
  var _footer = useCreation(function () {
99
101
  if (isBoolean(footer) && !footer || isObject(footer) && !footer.checked || isObject(footer) && footer.code && !executeCode(ctx, footer.code)) return {
@@ -71,7 +71,9 @@ var LCDrawer = function LCDrawer(_ref) {
71
71
  if (open) {
72
72
  ctx.doAction(advance.events.onOpen);
73
73
  } else {
74
+ _setTitle(title);
74
75
  ctx.doAction(advance.events.onClose);
76
+ setLoading(false);
75
77
  }
76
78
  }, [open]);
77
79
  useUpdateEffect(function () {