@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.
- package/es/components/Builder/index.js +37 -27
- package/es/components/ComplexItem/index.js +5 -3
- package/es/components/ComplexItem/service.js +6 -3
- package/es/components/LdAutoForm/index.js +25 -12
- package/es/components/LdCard/index.js +10 -8
- package/es/components/LdCom/index.js +3 -2
- package/es/components/LdFormList/index.js +5 -4
- package/es/components/LdGrid/index.js +29 -20
- package/es/components/LdGridForm/index.js +16 -7
- package/es/components/LdInfoPanel/index.js +16 -10
- package/es/helper/FromItems.js +64 -5
- package/es/helper/form.js +8 -2
- package/es/helper/ldBuilder.js +9 -5
- package/es/helper/ldComBuild.js +16 -11
- package/es/locales/zh-CN.js +40 -4
- package/es/lowcode/constants/api-url.js +202 -175
- package/es/lowcode/constants/event-topics.js +2 -0
- package/es/lowcode/constants/index.js +5 -4
- package/es/lowcode/engine/meta/components-list.json +6 -0
- package/es/lowcode/engine/meta/fielddate.props.default.json +1 -0
- package/es/lowcode/engine/meta/fielddate.props.json +48 -0
- package/es/lowcode/engine/meta/js-editor/auto-complete.json +5 -0
- package/es/lowcode/engine/meta/pagecomponent.props.default.json +8 -0
- package/es/lowcode/engine/meta/pagecomponent.props.json +41 -0
- package/es/lowcode/engine/meta/proxy.props.default.json +15 -0
- package/es/lowcode/engine/meta/proxy.props.json +66 -0
- package/es/lowcode/engine/provider/ContextProvider/index.js +45 -9
- package/es/lowcode/engine/provider/ContextProvider/usePageDataStore.js +36 -30
- package/es/lowcode/engine/provider/ContextProvider/usePageVar.js +11 -5
- package/es/lowcode/engine/provider/ContextProvider/useTodo.js +2 -4
- package/es/lowcode/engine/provider/EventBusProvider.js +14 -4
- package/es/lowcode/engine/provider/PageProxyProvider.js +95 -0
- package/es/lowcode/engine/provider/RemoteSourceProvider.js +10 -12
- package/es/lowcode/engine/tools/helper.js +44 -5
- package/es/lowcode/engine/tools/initDS.js +4 -4
- package/es/lowcode/painter/Design.js +1 -0
- package/es/lowcode/painter/DesignOperator.js +129 -27
- package/es/lowcode/painter/DesignToolbar.js +88 -173
- package/es/lowcode/painter/components/AdvancePanel.js +28 -10
- package/es/lowcode/painter/components/TipIcon.js +12 -4
- package/es/lowcode/painter/components/field-setting/SettingUI.js +56 -4
- package/es/lowcode/painter/components/field-setting/index.js +24 -1
- package/es/lowcode/painter/components/shortcut-modal/KeyIcon.js +11 -0
- package/es/lowcode/painter/components/shortcut-modal/index.js +208 -0
- package/es/lowcode/painter/panel-section/BlockEditor/index.js +10 -19
- package/es/lowcode/painter/panel-section/BlocksEditor/index.js +4 -1
- package/es/lowcode/painter/panel-section/ConditionCheck.js +0 -1
- package/es/lowcode/painter/panel-section/DataSetSelector.js +6 -3
- package/es/lowcode/painter/panel-section/FieldsSetting.js +1 -1
- package/es/lowcode/painter/panel-section/IconConditionSelector.js +2 -1
- package/es/lowcode/painter/panel-section/JSEditor/ToolBar.js +7 -4
- package/es/lowcode/painter/panel-section/JSEditor/index.js +15 -5
- package/es/lowcode/painter/panel-section/JSEditor/index.less +4 -0
- package/es/lowcode/painter/panel-section/ProxyLinker.js +137 -0
- package/es/lowcode/painter/panel-section/ProxyParams.js +28 -0
- package/es/lowcode/painter/panel-section/ProxyParamsSetter.js +240 -0
- package/es/lowcode/painter/style/panel-item.less +1 -0
- package/es/lowcode/preview/DebugTool.js +78 -0
- package/es/lowcode/preview/DebugToolDetail.js +103 -0
- package/es/lowcode/preview/index.js +10 -17
- package/es/lowcode/preview/useDebugSettings.js +62 -0
- package/es/lowcode/view/Canvas.js +5 -1
- package/es/lowcode/view/Page.js +8 -3
- package/es/lowcode/view/lc-components/CardList/index.js +3 -0
- package/es/lowcode/view/lc-components/Dialog/index.js +9 -7
- package/es/lowcode/view/lc-components/Drawer/index.js +2 -0
- package/es/lowcode/view/lc-components/FieldDate/meta.json +48 -0
- package/es/lowcode/view/lc-components/Form/index.js +3 -0
- package/es/lowcode/view/lc-components/Proxy/FunctionDesign.js +17 -0
- package/es/lowcode/view/lc-components/Proxy/FunctionLive.js +23 -0
- package/es/lowcode/view/lc-components/Proxy/FunctionPreview.js +23 -0
- package/es/lowcode/view/lc-components/Proxy/index.js +42 -0
- package/es/lowcode/view/lc-components/Proxy/index.less +5 -0
- package/es/lowcode/view/lc-components/Proxy/meta.json +66 -0
- package/es/lowcode/view/lc-components/Table/components/TopImex.js +5 -23
- package/es/lowcode/view/lc-components/Table/index.js +12 -6
- package/es/lowcode/view/lc-components/Tabs/index.js +6 -2
- package/es/lowcode/view/lc-components/Tree/index.js +3 -0
- package/es/lowcode/view/lc-components/Wrapper.js +7 -1
- package/es/services.js +25 -7
- package/es/utils/action.js +3 -2
- package/es/utils/form.js +37 -4
- package/es/utils/grid.js +2 -1
- package/lib/components/Builder/index.js +36 -26
- package/lib/components/ComplexItem/index.js +5 -3
- package/lib/components/ComplexItem/service.js +6 -3
- package/lib/components/LdAutoForm/index.js +22 -9
- package/lib/components/LdCard/index.js +10 -8
- package/lib/components/LdCom/index.js +3 -2
- package/lib/components/LdFormList/index.js +4 -3
- package/lib/components/LdGrid/index.js +29 -20
- package/lib/components/LdGridForm/index.js +13 -4
- package/lib/components/LdInfoPanel/index.js +15 -9
- package/lib/helper/FromItems.js +64 -5
- package/lib/helper/form.js +8 -2
- package/lib/helper/ldBuilder.js +8 -5
- package/lib/helper/ldComBuild.js +14 -9
- package/lib/locales/zh-CN.js +40 -4
- package/lib/lowcode/constants/api-url.js +204 -175
- package/lib/lowcode/constants/event-topics.js +3 -1
- package/lib/lowcode/constants/index.js +6 -5
- package/lib/lowcode/engine/meta/components-list.json +6 -0
- package/lib/lowcode/engine/meta/fielddate.props.default.json +1 -0
- package/lib/lowcode/engine/meta/fielddate.props.json +48 -0
- package/lib/lowcode/engine/meta/js-editor/auto-complete.json +5 -0
- package/lib/lowcode/engine/meta/pagecomponent.props.default.json +8 -0
- package/lib/lowcode/engine/meta/pagecomponent.props.json +41 -0
- package/lib/lowcode/engine/meta/proxy.props.default.json +15 -0
- package/lib/lowcode/engine/meta/proxy.props.json +66 -0
- package/lib/lowcode/engine/provider/ContextProvider/index.js +50 -13
- package/lib/lowcode/engine/provider/ContextProvider/usePageDataStore.js +37 -31
- package/lib/lowcode/engine/provider/ContextProvider/usePageVar.js +10 -4
- package/lib/lowcode/engine/provider/ContextProvider/useTodo.js +1 -3
- package/lib/lowcode/engine/provider/EventBusProvider.js +14 -4
- package/lib/lowcode/engine/provider/PageProxyProvider.js +103 -0
- package/lib/lowcode/engine/provider/RemoteSourceProvider.js +10 -12
- package/lib/lowcode/engine/tools/helper.js +44 -4
- package/lib/lowcode/engine/tools/initDS.js +4 -4
- package/lib/lowcode/painter/Design.js +1 -0
- package/lib/lowcode/painter/DesignOperator.js +126 -24
- package/lib/lowcode/painter/DesignToolbar.js +84 -169
- package/lib/lowcode/painter/components/AdvancePanel.js +27 -9
- package/lib/lowcode/painter/components/TipIcon.js +12 -4
- package/lib/lowcode/painter/components/field-setting/SettingUI.js +55 -3
- package/lib/lowcode/painter/components/field-setting/index.js +24 -1
- package/lib/lowcode/painter/components/shortcut-modal/KeyIcon.js +18 -0
- package/lib/lowcode/painter/components/shortcut-modal/index.js +215 -0
- package/lib/lowcode/painter/panel-section/BlockEditor/index.js +9 -18
- package/lib/lowcode/painter/panel-section/BlocksEditor/index.js +4 -1
- package/lib/lowcode/painter/panel-section/ConditionCheck.js +0 -1
- package/lib/lowcode/painter/panel-section/DataSetSelector.js +6 -3
- package/lib/lowcode/painter/panel-section/FieldsSetting.js +1 -1
- package/lib/lowcode/painter/panel-section/IconConditionSelector.js +2 -1
- package/lib/lowcode/painter/panel-section/JSEditor/ToolBar.js +7 -4
- package/lib/lowcode/painter/panel-section/JSEditor/index.js +14 -4
- package/lib/lowcode/painter/panel-section/JSEditor/index.less +4 -0
- package/lib/lowcode/painter/panel-section/ProxyLinker.js +145 -0
- package/lib/lowcode/painter/panel-section/ProxyParams.js +35 -0
- package/lib/lowcode/painter/panel-section/ProxyParamsSetter.js +248 -0
- package/lib/lowcode/painter/style/panel-item.less +1 -0
- package/lib/lowcode/preview/DebugTool.js +86 -0
- package/lib/lowcode/preview/DebugToolDetail.js +111 -0
- package/lib/lowcode/preview/index.js +10 -18
- package/lib/lowcode/preview/useDebugSettings.js +69 -0
- package/lib/lowcode/view/Canvas.js +5 -1
- package/lib/lowcode/view/Page.js +8 -3
- package/lib/lowcode/view/lc-components/CardList/index.js +3 -0
- package/lib/lowcode/view/lc-components/Dialog/index.js +9 -7
- package/lib/lowcode/view/lc-components/Drawer/index.js +2 -0
- package/lib/lowcode/view/lc-components/FieldDate/meta.json +48 -0
- package/lib/lowcode/view/lc-components/Form/index.js +3 -0
- package/lib/lowcode/view/lc-components/Proxy/FunctionDesign.js +24 -0
- package/lib/lowcode/view/lc-components/Proxy/FunctionLive.js +30 -0
- package/lib/lowcode/view/lc-components/Proxy/FunctionPreview.js +30 -0
- package/lib/lowcode/view/lc-components/Proxy/index.js +50 -0
- package/lib/lowcode/view/lc-components/Proxy/index.less +5 -0
- package/lib/lowcode/view/lc-components/Proxy/meta.json +66 -0
- package/lib/lowcode/view/lc-components/Table/components/TopImex.js +4 -22
- package/lib/lowcode/view/lc-components/Table/index.js +12 -6
- package/lib/lowcode/view/lc-components/Tabs/index.js +5 -1
- package/lib/lowcode/view/lc-components/Tree/index.js +3 -0
- package/lib/lowcode/view/lc-components/Wrapper.js +6 -0
- package/lib/services.js +26 -7
- package/lib/utils/action.js +6 -0
- package/lib/utils/form.js +38 -4
- package/lib/utils/grid.js +2 -1
- package/package.json +1 -1
- package/es/lowcode/engine/meta/button.api.json +0 -0
- package/lib/lowcode/engine/meta/button.api.json +0 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.usePageProxyContext = exports.default = exports.Context = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _ahooks = require("ahooks");
|
|
11
|
+
var _antd = require("luck-design/antd");
|
|
12
|
+
var _lodash = require("lodash");
|
|
13
|
+
var _utils = require("@luck-design-biz/base/utils");
|
|
14
|
+
var _ContextProvider = require("./ContextProvider");
|
|
15
|
+
var _usePageDataStore = _interopRequireDefault(require("./ContextProvider/usePageDataStore"));
|
|
16
|
+
var _dataProcess = require("../tools/dataProcess");
|
|
17
|
+
var _apiUrl = require("../../constants/api-url");
|
|
18
|
+
var Context = exports.Context = /*#__PURE__*/(0, _react.createContext)(null);
|
|
19
|
+
var usePageProxyContext = exports.usePageProxyContext = function usePageProxyContext() {
|
|
20
|
+
return (0, _react.useContext)(Context);
|
|
21
|
+
};
|
|
22
|
+
var _default = exports.default = function _default(_ref) {
|
|
23
|
+
var children = _ref.children,
|
|
24
|
+
id = _ref.id,
|
|
25
|
+
proxyCode = _ref.proxyCode,
|
|
26
|
+
destroyOnUnmount = _ref.destroyOnUnmount,
|
|
27
|
+
proxyParams = _ref.proxyParams;
|
|
28
|
+
if ((0, _lodash.isNil)(proxyCode)) return /*#__PURE__*/_react.default.createElement(_antd.Empty, {
|
|
29
|
+
description: (0, _utils.formatMessage)({
|
|
30
|
+
id: 'luckda.lowcode.view.lc-component.design.nocode',
|
|
31
|
+
label: '缺少页面代理编码配置'
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
var ctx = (0, _ContextProvider.useContext)();
|
|
35
|
+
var _useRequest = (0, _ahooks.useRequest)(_apiUrl.fetchPageData, {
|
|
36
|
+
defaultParams: [{
|
|
37
|
+
code: proxyCode
|
|
38
|
+
}],
|
|
39
|
+
ready: !_usePageDataStore.default.getState()[proxyCode],
|
|
40
|
+
onFinally: function onFinally() {
|
|
41
|
+
ctx.$publisher(ctx.topics.PAGE_LOAD_MOUNT, {
|
|
42
|
+
proxyCode: proxyCode
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
onSuccess: function onSuccess(_ref2) {
|
|
46
|
+
var code = _ref2.code,
|
|
47
|
+
data = _ref2.data,
|
|
48
|
+
list = _ref2.list,
|
|
49
|
+
detail = _ref2.detail;
|
|
50
|
+
if (code === 1) {
|
|
51
|
+
_usePageDataStore.default.setState(function (state) {
|
|
52
|
+
var source = detail[list[0]].source;
|
|
53
|
+
state[proxyCode] = (0, _dataProcess.decompress)(source);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}),
|
|
58
|
+
loading = _useRequest.loading;
|
|
59
|
+
(0, _react.useEffect)(function () {
|
|
60
|
+
if (_usePageDataStore.default.getState()[proxyCode]) {
|
|
61
|
+
ctx.$publisher(ctx.topics.PAGE_LOAD_MOUNT, {
|
|
62
|
+
proxyCode: proxyCode
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return function () {
|
|
66
|
+
if (destroyOnUnmount) {
|
|
67
|
+
_usePageDataStore.default.setState(function (state) {
|
|
68
|
+
state[proxyCode] = null;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}, []);
|
|
73
|
+
var _proxyParams = (0, _ahooks.useCreation)(function () {
|
|
74
|
+
return (0, _lodash.reduce)(proxyParams, function (ret, param) {
|
|
75
|
+
switch (param.origin) {
|
|
76
|
+
case 'state':
|
|
77
|
+
ret[param.name] = ctx.state[param.value];
|
|
78
|
+
return ret;
|
|
79
|
+
case 'golbal':
|
|
80
|
+
ret[param.name] = ctx.global[param.value];
|
|
81
|
+
return ret;
|
|
82
|
+
case 'url':
|
|
83
|
+
ret[param.name] = ctx.router.getQuery(param.value);
|
|
84
|
+
return ret;
|
|
85
|
+
case 'string':
|
|
86
|
+
case 'num':
|
|
87
|
+
case 'bool':
|
|
88
|
+
default:
|
|
89
|
+
ret[param.name] = param.value;
|
|
90
|
+
return ret;
|
|
91
|
+
}
|
|
92
|
+
}, {});
|
|
93
|
+
}, []);
|
|
94
|
+
return /*#__PURE__*/_react.default.createElement(Context.Provider, {
|
|
95
|
+
value: {
|
|
96
|
+
id: id,
|
|
97
|
+
proxyCode: proxyCode,
|
|
98
|
+
params: _proxyParams
|
|
99
|
+
}
|
|
100
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Spin, {
|
|
101
|
+
spinning: loading
|
|
102
|
+
}, children));
|
|
103
|
+
};
|
|
@@ -8,12 +8,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = exports.RemoteSourceContext = void 0;
|
|
9
9
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
10
|
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
|
|
11
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
12
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
14
15
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
16
|
var _ahooks = require("ahooks");
|
|
16
17
|
var _umi = require("umi");
|
|
18
|
+
var _lodash = require("lodash");
|
|
17
19
|
var _launcher = _interopRequireDefault(require("../launcher"));
|
|
18
20
|
var _Builder = require("../../../components/Builder");
|
|
19
21
|
var _action2 = require("../../../helper/action");
|
|
@@ -31,12 +33,10 @@ var _default = exports.default = function _default(_ref) {
|
|
|
31
33
|
var _usePageDataStore = (0, _usePageDataStore2.default)(function (state) {
|
|
32
34
|
return {
|
|
33
35
|
initialize: state.initialize,
|
|
34
|
-
initializeModule: state.initializeModule,
|
|
35
36
|
reset: state.reset
|
|
36
37
|
};
|
|
37
38
|
}),
|
|
38
39
|
initialize = _usePageDataStore.initialize,
|
|
39
|
-
initializeModule = _usePageDataStore.initializeModule,
|
|
40
40
|
reset = _usePageDataStore.reset;
|
|
41
41
|
var _useTemporalStore = (0, _usePageDataStore2.useTemporalStore)(function (state) {
|
|
42
42
|
return {
|
|
@@ -78,7 +78,6 @@ var _default = exports.default = function _default(_ref) {
|
|
|
78
78
|
setRemoteSource({
|
|
79
79
|
module: data
|
|
80
80
|
});
|
|
81
|
-
initializeModule(data);
|
|
82
81
|
}
|
|
83
82
|
}
|
|
84
83
|
}),
|
|
@@ -161,7 +160,7 @@ var _default = exports.default = function _default(_ref) {
|
|
|
161
160
|
}),
|
|
162
161
|
runFetchAllBehaviorExport = _useRequest6.run;
|
|
163
162
|
(0, _ahooks.useAsyncEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
|
|
164
|
-
var fetchPageDataRes, data, list, detail, source;
|
|
163
|
+
var fetchPageDataRes, data, list, detail, source, _pageData;
|
|
165
164
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
|
166
165
|
while (1) switch (_context.prev = _context.next) {
|
|
167
166
|
case 0:
|
|
@@ -181,16 +180,17 @@ var _default = exports.default = function _default(_ref) {
|
|
|
181
180
|
break;
|
|
182
181
|
}
|
|
183
182
|
_umi.history.replace('/404');
|
|
184
|
-
_context.next =
|
|
183
|
+
_context.next = 21;
|
|
185
184
|
break;
|
|
186
185
|
case 9:
|
|
187
|
-
source = detail[list[0]].source;
|
|
188
186
|
(0, _helper.setMetaAttrs)(_constants.META_TAG_NAME, data);
|
|
189
|
-
|
|
187
|
+
source = detail[list[0]].source;
|
|
188
|
+
_pageData = (0, _dataProcess.decompress)(source);
|
|
189
|
+
_context.next = 14;
|
|
190
190
|
return runFetchModlueData(data.dataModelKey, {
|
|
191
|
-
moduleCode: data.moduleCode
|
|
191
|
+
moduleCode: [data.moduleCode].concat((0, _toConsumableArray2.default)((0, _lodash.values)(_pageData.props.proxy))).join(',')
|
|
192
192
|
});
|
|
193
|
-
case
|
|
193
|
+
case 14:
|
|
194
194
|
runFetchAllBehaviorImport({
|
|
195
195
|
behaviorMode: 'IMPORT',
|
|
196
196
|
moduleCode: data.moduleCode
|
|
@@ -205,11 +205,9 @@ var _default = exports.default = function _default(_ref) {
|
|
|
205
205
|
runFetchAllSerials({
|
|
206
206
|
uid: data.moduleId
|
|
207
207
|
});
|
|
208
|
-
initialize(
|
|
208
|
+
initialize(_pageData);
|
|
209
209
|
resume();
|
|
210
210
|
eventBus.$publisher(_eventTopics.PAGE_LOAD_MOUNT);
|
|
211
|
-
case 20:
|
|
212
|
-
;
|
|
213
211
|
case 21:
|
|
214
212
|
case "end":
|
|
215
213
|
return _context.stop();
|
|
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.dataToTree = dataToTree;
|
|
7
8
|
exports.executeCode = executeCode;
|
|
8
9
|
exports.extractKeywords = extractKeywords;
|
|
9
10
|
exports.findFirstLeafNode = findFirstLeafNode;
|
|
@@ -19,6 +20,7 @@ exports.omitBadProps = omitBadProps;
|
|
|
19
20
|
exports.parseCSS = parseCSS;
|
|
20
21
|
exports.setMetaAttrs = setMetaAttrs;
|
|
21
22
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
23
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
22
24
|
var _construct2 = _interopRequireDefault(require("@babel/runtime/helpers/construct"));
|
|
23
25
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
24
26
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
@@ -186,22 +188,36 @@ function setMetaAttrs(name, data) {
|
|
|
186
188
|
meta.content = (0, _lodash.isString)(data) ? data : new URLSearchParams(data).toString().replaceAll('&', ',');
|
|
187
189
|
document.head.appendChild(meta);
|
|
188
190
|
}
|
|
191
|
+
function normalize(val) {
|
|
192
|
+
if (val === 'null') return null;
|
|
193
|
+
if (val === 'undefined') return undefined;
|
|
194
|
+
if (val === 'true') return true;
|
|
195
|
+
if (val === 'false') return false;
|
|
196
|
+
if (/^-?\d+(\.\d+)?$/.test(val)) return Number(val);
|
|
197
|
+
return val;
|
|
198
|
+
}
|
|
189
199
|
function getMetaAttr(name, _) {
|
|
190
200
|
if ((0, _lodash.isNil)(name)) return void 0;
|
|
191
201
|
var meta = document.querySelector("meta[name=\"".concat(name, "\"]"));
|
|
202
|
+
if ((0, _lodash.isNil)(meta)) return void 0;
|
|
192
203
|
if (meta.content.includes(',')) {
|
|
193
204
|
var data = new URLSearchParams(meta.content.replaceAll(',', '&'));
|
|
194
205
|
if ((0, _lodash.isNil)(_)) {
|
|
195
|
-
return Object.fromEntries(data.entries())
|
|
206
|
+
return Object.fromEntries(Array.from(data.entries()).map(function (_ref) {
|
|
207
|
+
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
208
|
+
k = _ref2[0],
|
|
209
|
+
v = _ref2[1];
|
|
210
|
+
return [k, normalize(v)];
|
|
211
|
+
}));
|
|
196
212
|
}
|
|
197
213
|
if ((0, _lodash.isArray)(_)) {
|
|
198
214
|
return _.map(function (n) {
|
|
199
|
-
return data.get(n);
|
|
215
|
+
return normalize(data.get(n));
|
|
200
216
|
});
|
|
201
217
|
}
|
|
202
|
-
return data.get(_);
|
|
218
|
+
return normalize(data.get(_));
|
|
203
219
|
}
|
|
204
|
-
return meta.content;
|
|
220
|
+
return normalize(meta.content);
|
|
205
221
|
}
|
|
206
222
|
function getLDMetaAttr(_) {
|
|
207
223
|
return getMetaAttr(_constants.META_TAG_NAME, _);
|
|
@@ -282,4 +298,28 @@ function findFirstLeafNode(node) {
|
|
|
282
298
|
_iterator2.f();
|
|
283
299
|
}
|
|
284
300
|
return null;
|
|
301
|
+
}
|
|
302
|
+
function dataToTree(data, params) {
|
|
303
|
+
var _ref3 = params || {},
|
|
304
|
+
_ref3$parentKey = _ref3.parentKey,
|
|
305
|
+
parentKey = _ref3$parentKey === void 0 ? 'parentId' : _ref3$parentKey,
|
|
306
|
+
_ref3$childKey = _ref3.childKey,
|
|
307
|
+
childKey = _ref3$childKey === void 0 ? 'children' : _ref3$childKey,
|
|
308
|
+
_ref3$rootId = _ref3.rootId,
|
|
309
|
+
rootId = _ref3$rootId === void 0 ? '0' : _ref3$rootId,
|
|
310
|
+
_ref3$id = _ref3.id,
|
|
311
|
+
id = _ref3$id === void 0 ? 'id' : _ref3$id,
|
|
312
|
+
_ref3$stain = _ref3.stain,
|
|
313
|
+
stain = _ref3$stain === void 0 ? false : _ref3$stain;
|
|
314
|
+
var _data = stain ? data : (0, _lodash.cloneDeep)(data);
|
|
315
|
+
var groupedByParents = (0, _lodash.groupBy)(_data, parentKey);
|
|
316
|
+
var itemsById = (0, _lodash.keyBy)(_data, id);
|
|
317
|
+
try {
|
|
318
|
+
(0, _lodash.each)((0, _lodash.omit)(groupedByParents, rootId), function (children, parentId) {
|
|
319
|
+
itemsById[parentId][childKey] = children;
|
|
320
|
+
});
|
|
321
|
+
} catch (e) {
|
|
322
|
+
console.error('helper.dataToTree error', e);
|
|
323
|
+
}
|
|
324
|
+
return groupedByParents[rootId];
|
|
285
325
|
}
|
|
@@ -147,8 +147,8 @@ var wrapPromise = function wrapPromise(promise) {
|
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
149
|
};
|
|
150
|
-
function initialize(ctx) {
|
|
151
|
-
var pageVars = _usePageDataStore.default.getState()
|
|
150
|
+
function initialize(ctx, proxyCode) {
|
|
151
|
+
var pageVars = _usePageDataStore.default.getState()[proxyCode || 'pageData'].props.vars;
|
|
152
152
|
if ((0, _lodash.isNil)(pageVars)) return null;
|
|
153
153
|
var remoteApis = new Map();
|
|
154
154
|
var _reduce = (0, _lodash.reduce)(pageVars, function (ret, val) {
|
|
@@ -177,8 +177,8 @@ function initialize(ctx) {
|
|
|
177
177
|
_reduce2 = (0, _toArray2.default)(_reduce),
|
|
178
178
|
variables = _reduce2[0],
|
|
179
179
|
autoTasks = _reduce2.slice(1);
|
|
180
|
-
_usePageVar.useStateStore.getState().initialize(variables);
|
|
181
|
-
ctx._initRemoteApiMap(remoteApis);
|
|
180
|
+
_usePageVar.useStateStore.getState().initialize(variables, !!proxyCode);
|
|
181
|
+
ctx._initRemoteApiMap(remoteApis, !!proxyCode);
|
|
182
182
|
function run() {
|
|
183
183
|
return _run2.apply(this, arguments);
|
|
184
184
|
}
|
|
@@ -73,6 +73,7 @@ var Design = function Design() {
|
|
|
73
73
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
74
74
|
className: _design.default['lc-painter-design']
|
|
75
75
|
}, /*#__PURE__*/_react.default.createElement(_DesignToolbar.default, {
|
|
76
|
+
canvas: simulatorRef,
|
|
76
77
|
locale: locale,
|
|
77
78
|
onLangChange: handleLangChange
|
|
78
79
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _umi = require("umi");
|
|
11
12
|
var _lodash = require("lodash");
|
|
12
13
|
var _ahooks = require("ahooks");
|
|
13
14
|
var _antd = require("luck-design/antd");
|
|
@@ -50,6 +51,18 @@ var DesignOperator = function DesignOperator(_ref) {
|
|
|
50
51
|
setOperatorId = _useSetState2[1];
|
|
51
52
|
var lastSelectorId = (0, _ahooks.useLatest)(operatorId.selector);
|
|
52
53
|
var currentModal = (0, _react.useRef)(null);
|
|
54
|
+
var _useTemporalStore = (0, _ContextProvider.useTemporalStore)(function (state) {
|
|
55
|
+
return {
|
|
56
|
+
undo: state.undo,
|
|
57
|
+
redo: state.redo,
|
|
58
|
+
pastStates: state.pastStates,
|
|
59
|
+
futureStates: state.futureStates
|
|
60
|
+
};
|
|
61
|
+
}),
|
|
62
|
+
canUndo = _useTemporalStore.canUndo,
|
|
63
|
+
canRedo = _useTemporalStore.canRedo,
|
|
64
|
+
undo = _useTemporalStore.undo,
|
|
65
|
+
redo = _useTemporalStore.redo;
|
|
53
66
|
var getElement = (0, _ahooks.useMemoizedFn)(function (_target) {
|
|
54
67
|
var _context$componentMap;
|
|
55
68
|
return (0, _lodash.isString)(_target) ? (_context$componentMap = context.componentMap.get(_target)) === null || _context$componentMap === void 0 ? void 0 : _context$componentMap.api.getSelfDom() : _target;
|
|
@@ -70,9 +83,109 @@ var DesignOperator = function DesignOperator(_ref) {
|
|
|
70
83
|
id: id
|
|
71
84
|
});
|
|
72
85
|
});
|
|
86
|
+
var handleShortcutEmit = (0, _ahooks.useMemoizedFn)(function (_ref3) {
|
|
87
|
+
var key = _ref3.key;
|
|
88
|
+
switch (key) {
|
|
89
|
+
case 'meta.s':
|
|
90
|
+
case 'ctrl.s':
|
|
91
|
+
context.$publisher(context.topics.DESIGN_OPERATE_SAVE);
|
|
92
|
+
break;
|
|
93
|
+
case 'meta.p':
|
|
94
|
+
case 'ctrl.p':
|
|
95
|
+
{
|
|
96
|
+
var _getCreateHistoryOpti = (0, _umi.getCreateHistoryOptions)(),
|
|
97
|
+
basename = _getCreateHistoryOpti.basename;
|
|
98
|
+
var previewUrl = "".concat(basename === '/' ? '' : basename, "/byteman/preview/").concat(context.router.getQuery('code'));
|
|
99
|
+
window.open(previewUrl, '_blank');
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
case 'meta.z':
|
|
103
|
+
case 'ctrl.z':
|
|
104
|
+
canUndo && undo();
|
|
105
|
+
break;
|
|
106
|
+
case 'meta.shift.z':
|
|
107
|
+
case 'ctrl.shift.z':
|
|
108
|
+
canRedo && redo();
|
|
109
|
+
break;
|
|
110
|
+
case 'meta.c':
|
|
111
|
+
case 'ctrl.c':
|
|
112
|
+
if (operatorId.selector) {
|
|
113
|
+
var _context$$$api$getSel = context.$(operatorId.selector).api.getSelfAndParentData(),
|
|
114
|
+
node = _context$$$api$getSel.node,
|
|
115
|
+
parent = _context$$$api$getSel.parent;
|
|
116
|
+
if (_constants.CONTAINER_UNITS.includes(parent === null || parent === void 0 ? void 0 : parent.props.component)) {
|
|
117
|
+
addComponent((0, _lodash.omit)(node.props), parent.props.id);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
case 'backspace':
|
|
122
|
+
if (operatorId.selector && operatorId.deletable) {
|
|
123
|
+
handleDelete({
|
|
124
|
+
id: operatorId.selector
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
case 'uparrow':
|
|
129
|
+
if (operatorId.selector) {
|
|
130
|
+
var _context$$$api$getSel2 = context.$(operatorId.selector).api.getSelfAndParentData(),
|
|
131
|
+
_parent = _context$$$api$getSel2.parent;
|
|
132
|
+
if (_parent) {
|
|
133
|
+
handleSelect(_parent.props.id);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
case 'downarrow':
|
|
138
|
+
if (operatorId.selector) {
|
|
139
|
+
var _node$children;
|
|
140
|
+
var _node = context.$(operatorId.selector).api.getSelfData();
|
|
141
|
+
if (_node !== null && _node !== void 0 && (_node$children = _node.children) !== null && _node$children !== void 0 && _node$children.length) {
|
|
142
|
+
handleSelect(_node.children[0]);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
case 'leftarrow':
|
|
147
|
+
case 'rightarrow':
|
|
148
|
+
if (operatorId.selector) {
|
|
149
|
+
var _parent2$children;
|
|
150
|
+
var _context$$$api$getSel3 = context.$(operatorId.selector).api.getSelfAndParentData(),
|
|
151
|
+
_parent2 = _context$$$api$getSel3.parent;
|
|
152
|
+
if (_parent2 !== null && _parent2 !== void 0 && (_parent2$children = _parent2.children) !== null && _parent2$children !== void 0 && _parent2$children.length) {
|
|
153
|
+
var index = _parent2.children.findIndex(function (c) {
|
|
154
|
+
return c === operatorId.selector;
|
|
155
|
+
});
|
|
156
|
+
if (key === 'leftarrow' && index > 0) {
|
|
157
|
+
handleSelect(_parent2.children[index - 1]);
|
|
158
|
+
} else if (key === 'rightarrow' && index < _parent2.children.length - 1) {
|
|
159
|
+
handleSelect(_parent2.children[index + 1]);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
case 'alt.leftarrow':
|
|
165
|
+
case 'alt.rightarrow':
|
|
166
|
+
if (operatorId.selector) {
|
|
167
|
+
var _parent3$children;
|
|
168
|
+
var _context$$$api$getSel4 = context.$(operatorId.selector).api.getSelfAndParentData(),
|
|
169
|
+
_parent3 = _context$$$api$getSel4.parent;
|
|
170
|
+
if (_parent3 !== null && _parent3 !== void 0 && (_parent3$children = _parent3.children) !== null && _parent3$children !== void 0 && _parent3$children.length) {
|
|
171
|
+
var _index = _parent3.children.findIndex(function (c) {
|
|
172
|
+
return c === operatorId.selector;
|
|
173
|
+
});
|
|
174
|
+
if (key === 'alt.leftarrow' && _index > 0) {
|
|
175
|
+
(0, _ContextProvider.moveNode)(_parent3.children[_index], _parent3.children[_index - 1], 'left');
|
|
176
|
+
} else if (key === 'alt.rightarrow' && _index < _parent3.children.length - 1) {
|
|
177
|
+
(0, _ContextProvider.moveNode)(_parent3.children[_index], _parent3.children[_index + 1], 'right');
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
default:
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
73
186
|
var addComponent = (0, _ahooks.useMemoizedFn)(function (data, targetId) {
|
|
74
|
-
context.$subscriber(context.topics.COMPONENT_MOUNT).once(function (
|
|
75
|
-
var mountCompId =
|
|
187
|
+
context.$subscriber(context.topics.COMPONENT_MOUNT).once(function (_ref4) {
|
|
188
|
+
var mountCompId = _ref4.id;
|
|
76
189
|
if (mountCompId === _id) {
|
|
77
190
|
context.$publisher(context.topics.COMPONENT_APPEND, {
|
|
78
191
|
id: _id
|
|
@@ -133,19 +246,6 @@ var DesignOperator = function DesignOperator(_ref) {
|
|
|
133
246
|
var _last;
|
|
134
247
|
return operatorId.detector && (0, _lodash.isString)(operatorId.detector) ? (_last = (0, _lodash.last)(context.componentMap.get(operatorId.detector).api.getLevelNodes())) === null || _last === void 0 ? void 0 : _last.name : void 0;
|
|
135
248
|
}, [operatorId.detector]);
|
|
136
|
-
(0, _ahooks.useKeyPress)('backspace', function () {
|
|
137
|
-
if (operatorId.selector && operatorId.deletable) {
|
|
138
|
-
handleDelete({
|
|
139
|
-
id: operatorId.selector
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}, {
|
|
143
|
-
target: canvas
|
|
144
|
-
});
|
|
145
|
-
(0, _ahooks.useKeyPress)('ctrl.s', function (e) {
|
|
146
|
-
e.preventDefault();
|
|
147
|
-
context.$publisher(context.topics.DESIGN_OPERATE_SAVE);
|
|
148
|
-
});
|
|
149
249
|
(0, _ahooks.useEventListener)('mousemove', function (event) {
|
|
150
250
|
var elem = event.target;
|
|
151
251
|
var targetFormItem = elem.closest("[".concat(_constants.LC_COMPONENT_UNIT_KEY, "=\"").concat(_constants.LC_FORMITEM_UNIT, "\"]"));
|
|
@@ -208,11 +308,11 @@ var DesignOperator = function DesignOperator(_ref) {
|
|
|
208
308
|
target: canvas
|
|
209
309
|
});
|
|
210
310
|
(0, _react.useEffect)(function () {
|
|
211
|
-
var csid = context.$subscriber(context.topics.COMPONENT_SETTING_CLICK).on(function (
|
|
212
|
-
var data =
|
|
311
|
+
var csid = context.$subscriber(context.topics.COMPONENT_SETTING_CLICK).on(function (_ref5) {
|
|
312
|
+
var data = _ref5.data;
|
|
213
313
|
if (_MODAL_COMPONENT_.includes(data.component)) {
|
|
214
|
-
context.$subscriber(context.topics.COMPONENT_APPEND).once(function (
|
|
215
|
-
var compId =
|
|
314
|
+
context.$subscriber(context.topics.COMPONENT_APPEND).once(function (_ref6) {
|
|
315
|
+
var compId = _ref6.id;
|
|
216
316
|
context.$publisher(context.topics.COMPONENT_MODAL_TOGGLE, {
|
|
217
317
|
toggle: true,
|
|
218
318
|
id: compId
|
|
@@ -268,9 +368,9 @@ var DesignOperator = function DesignOperator(_ref) {
|
|
|
268
368
|
});
|
|
269
369
|
}
|
|
270
370
|
}).watch();
|
|
271
|
-
var cmtid = context.$subscriber(context.topics.COMPONENT_MODAL_TOGGLE).on(function (
|
|
272
|
-
var toggle =
|
|
273
|
-
id =
|
|
371
|
+
var cmtid = context.$subscriber(context.topics.COMPONENT_MODAL_TOGGLE).on(function (_ref7) {
|
|
372
|
+
var toggle = _ref7.toggle,
|
|
373
|
+
id = _ref7.id;
|
|
274
374
|
if (toggle && id !== currentModal.current) {
|
|
275
375
|
var _canvas$current2;
|
|
276
376
|
(_canvas$current2 = canvas.current) === null || _canvas$current2 === void 0 || _canvas$current2.style.setProperty('overflow', 'hidden');
|
|
@@ -290,19 +390,21 @@ var DesignOperator = function DesignOperator(_ref) {
|
|
|
290
390
|
}
|
|
291
391
|
}
|
|
292
392
|
}).watch();
|
|
293
|
-
var cdid = context.$subscriber(context.topics.COMPONENT_DELETE).on(function (
|
|
294
|
-
var id =
|
|
393
|
+
var cdid = context.$subscriber(context.topics.COMPONENT_DELETE).on(function (_ref8) {
|
|
394
|
+
var id = _ref8.id;
|
|
295
395
|
if (lastSelectorId.current === id) {
|
|
296
396
|
handleSelect();
|
|
297
397
|
}
|
|
298
398
|
(0, _ContextProvider.deleteNode)(id);
|
|
299
399
|
});
|
|
400
|
+
var dseid = context.$subscriber(context.topics.DESIGN_SHORTCUT_EMIT).on(handleShortcutEmit);
|
|
300
401
|
return function () {
|
|
301
402
|
context.$unsubscriber(context.topics.COMPONENT_SETTING_CLICK, csid);
|
|
302
403
|
context.$unsubscriber(context.topics.COMPONENT_HOVER, hcid);
|
|
303
404
|
context.$unsubscriber(context.topics.COMPONENT_ACTIVE, acid);
|
|
304
405
|
context.$unsubscriber(context.topics.MODAL_OPEN, cmtid);
|
|
305
406
|
context.$unsubscriber(context.topics.COMPONENT_DELETE, cdid);
|
|
407
|
+
context.$unsubscriber(context.topics.COMPONENT_DELETE, dseid);
|
|
306
408
|
};
|
|
307
409
|
}, []);
|
|
308
410
|
(0, _react.useEffect)(function () {
|