@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.
- package/LICENSE +21 -21
- package/README.md +40 -49
- package/es/components/Builder/index.js +4 -4
- package/es/components/LdAutoForm/index.js +7 -9
- package/es/components/LdCard/index.js +5 -6
- package/es/components/LdCard/model.js +1 -1
- package/es/components/LdCom/index.js +2 -2
- package/es/components/LdFormList/index.js +19 -17
- package/es/components/LdGrid/index.js +11 -12
- package/es/components/LdGrid/model.js +1 -1
- package/es/components/LdGridForm/index.js +10 -10
- package/es/components/LdGridForm/index.less +7 -7
- package/es/components/LdInfoPanel/index.js +2 -2
- package/es/components/LdRuntimeCom/index.js +42 -0
- package/es/components/LdTree/index.js +3 -4
- package/es/components/LdTree/index.less +36 -36
- package/es/helper/FromItems.js +1 -1
- package/es/helper/action.js +8 -8
- package/es/helper/form.js +16 -16
- package/es/helper/index.less +7 -7
- package/es/helper/ldBuilder.js +1 -1
- package/es/helper/ldComBuild.js +4 -4
- package/es/index.js +10 -9
- package/es/lowcode/constants/api-url.js +2 -0
- package/es/lowcode/constants/event-topics.js +23 -0
- package/es/lowcode/constants/index.js +12 -0
- package/es/lowcode/engine/factory/DataFactory.js +1 -0
- package/es/lowcode/engine/meta/button.props.default.json +8 -0
- package/es/lowcode/engine/meta/cardlist.props.default.json +10 -0
- package/es/lowcode/engine/meta/components/button.json +104 -0
- package/es/lowcode/engine/meta/components/card-list.json +143 -0
- package/es/lowcode/engine/meta/components/drawer.json +143 -0
- package/es/lowcode/engine/meta/components/form.json +116 -0
- package/es/lowcode/engine/meta/components/iframe.json +31 -0
- package/es/lowcode/engine/meta/components/image.json +113 -0
- package/es/lowcode/engine/meta/components/imex.json +81 -0
- package/es/lowcode/engine/meta/components/jsx.json +24 -0
- package/es/lowcode/engine/meta/components/layout.json +107 -0
- package/es/lowcode/engine/meta/components/link.json +111 -0
- package/es/lowcode/engine/meta/components/modal.json +120 -0
- package/es/lowcode/engine/meta/components/section.json +107 -0
- package/es/lowcode/engine/meta/components/split.json +71 -0
- package/es/lowcode/engine/meta/components/table.json +161 -0
- package/es/lowcode/engine/meta/components/tabs.json +140 -0
- package/es/lowcode/engine/meta/components/text.json +65 -0
- package/es/lowcode/engine/meta/components/tree.json +156 -0
- package/es/lowcode/engine/meta/components-list.json +122 -0
- package/es/lowcode/engine/meta/drawer.props.default.json +10 -0
- package/es/lowcode/engine/meta/form.props.default.json +5 -0
- package/es/lowcode/engine/meta/iframe.props.default.json +3 -0
- package/es/lowcode/engine/meta/image.props.default.json +8 -0
- package/es/lowcode/engine/meta/imex.props.default.json +4 -0
- package/es/lowcode/engine/meta/jsx.props.default.json +1 -0
- package/es/lowcode/engine/meta/layout.props.default.json +5 -0
- package/es/lowcode/engine/meta/link.props.default.json +6 -0
- package/es/lowcode/engine/meta/modal.props.default.json +11 -0
- package/es/lowcode/engine/meta/section.props.default.json +9 -0
- package/es/lowcode/engine/meta/split.props.default.json +5 -0
- package/es/lowcode/engine/meta/table.props.default.json +10 -0
- package/es/lowcode/engine/meta/tabs.props.default.json +10 -0
- package/es/lowcode/engine/meta/text.props.default.json +4 -0
- package/es/lowcode/engine/meta/tree.props.default.json +9 -0
- package/es/lowcode/engine/provider/ContextProvider.js +164 -0
- package/es/lowcode/engine/provider/EventBusProvider.js +120 -0
- package/es/lowcode/engine/tools/dataProcess.js +188 -0
- package/es/lowcode/engine/tools/helper.js +4 -0
- package/es/lowcode/engine/tools/lcid.js +16 -0
- package/es/lowcode/index.js +3 -0
- package/es/lowcode/painter/Components.js +104 -0
- package/es/lowcode/painter/Design.js +97 -0
- package/es/lowcode/painter/I18n.js +5 -0
- package/es/lowcode/painter/Outline.js +202 -0
- package/es/lowcode/painter/Panel.js +8 -0
- package/es/lowcode/painter/Ribbon.js +136 -0
- package/es/lowcode/painter/components/PanelItem.js +20 -0
- package/es/lowcode/painter/components/RuleInput.js +105 -0
- package/es/lowcode/painter/index.js +19 -0
- package/es/lowcode/painter/panel-section/LayoutRatio.js +123 -0
- package/es/lowcode/painter/panel-section/Radio.js +58 -0
- package/es/lowcode/painter/style/components.less +90 -0
- package/es/lowcode/painter/style/design.less +38 -0
- package/es/lowcode/painter/style/index.less +7 -0
- package/es/lowcode/painter/style/layout-ratio.less +51 -0
- package/es/lowcode/painter/style/outline.less +26 -0
- package/es/lowcode/painter/style/panel-item.less +21 -0
- package/es/lowcode/painter/style/panel.less +5 -0
- package/es/lowcode/painter/style/radio.less +24 -0
- package/es/lowcode/painter/style/ribbon.less +4 -0
- package/es/lowcode/painter/style/rule-input.less +13 -0
- package/es/lowcode/view/Canvas.js +135 -0
- package/es/lowcode/view/Loading.js +23 -0
- package/es/lowcode/view/Page.js +55 -0
- package/es/lowcode/view/index.js +18 -0
- package/es/lowcode/view/lc-components/Box/index.js +21 -0
- package/es/lowcode/view/lc-components/Button/index.js +37 -0
- package/es/lowcode/view/lc-components/CardList/index.js +20 -0
- package/es/lowcode/view/lc-components/Dialog/index.js +50 -0
- package/es/lowcode/view/lc-components/Dialog/index.less +3 -0
- package/es/lowcode/view/lc-components/Drawer/index.js +46 -0
- package/es/lowcode/view/lc-components/Form/index.js +20 -0
- package/es/lowcode/view/lc-components/Iframe/index.js +20 -0
- package/es/lowcode/view/lc-components/ImEx/index.js +20 -0
- package/es/lowcode/view/lc-components/Image/index.js +20 -0
- package/es/lowcode/view/lc-components/JSX/index.js +20 -0
- package/es/lowcode/view/lc-components/Layout/index.js +24 -0
- package/es/lowcode/view/lc-components/Link/index.js +20 -0
- package/es/lowcode/view/lc-components/Section/index.js +34 -0
- package/es/lowcode/view/lc-components/Split/index.js +21 -0
- package/es/lowcode/view/lc-components/Table/index.js +23 -0
- package/es/lowcode/view/lc-components/Tabs/index.js +21 -0
- package/es/lowcode/view/lc-components/Text/index.js +23 -0
- package/es/lowcode/view/lc-components/Tree/index.js +20 -0
- package/es/lowcode/view/lc-components/Wrapper.js +45 -0
- package/es/lowcode/view/style/canvas.less +5 -0
- package/es/lowcode/view/style/loading.less +84 -0
- package/es/lowcode/view/style/page.less +6 -0
- package/es/services.js +1 -1
- package/es/upload/Form/gridForm.js +29 -7
- package/es/upload/Form/index.js +1 -1
- package/es/upload/Form/index.less +7 -7
- package/es/upload/FormItem/index.js +30 -18
- package/es/upload/index.js +3 -3
- package/es/utils/action.js +1 -1
- package/es/utils/form.js +26 -26
- package/es/utils/grid.js +22 -26
- package/es/utils/index.js +3 -3
- package/lib/components/Builder/index.js +3 -5
- package/lib/components/LdAutoForm/index.js +5 -8
- package/lib/components/LdCard/index.js +5 -7
- package/lib/components/LdCom/index.js +6 -11
- package/lib/components/LdFormList/index.js +15 -13
- package/lib/components/LdGrid/index.js +10 -12
- package/lib/components/LdGridForm/index.js +6 -7
- package/lib/components/LdGridForm/index.less +7 -7
- package/lib/components/LdInfoPanel/index.js +2 -3
- package/lib/components/LdPop/index.js +2 -4
- package/lib/components/LdRuntimeCom/index.js +49 -0
- package/lib/components/LdTree/index.js +2 -4
- package/lib/components/LdTree/index.less +36 -36
- package/lib/helper/FromItems.js +15 -29
- package/lib/helper/action.js +9 -11
- package/lib/helper/form.js +18 -20
- package/lib/helper/index.less +7 -7
- package/lib/helper/ldBuilder.js +1 -2
- package/lib/helper/ldComBuild.js +7 -11
- package/lib/index.js +9 -1
- package/lib/lowcode/constants/api-url.js +8 -0
- package/lib/lowcode/constants/event-topics.js +29 -0
- package/lib/lowcode/constants/index.js +18 -0
- package/lib/lowcode/engine/factory/DataFactory.js +3 -0
- package/lib/lowcode/engine/meta/button.props.default.json +8 -0
- package/lib/lowcode/engine/meta/cardlist.props.default.json +10 -0
- package/lib/lowcode/engine/meta/components/button.json +104 -0
- package/lib/lowcode/engine/meta/components/card-list.json +143 -0
- package/lib/lowcode/engine/meta/components/drawer.json +143 -0
- package/lib/lowcode/engine/meta/components/form.json +116 -0
- package/lib/lowcode/engine/meta/components/iframe.json +31 -0
- package/lib/lowcode/engine/meta/components/image.json +113 -0
- package/lib/lowcode/engine/meta/components/imex.json +81 -0
- package/lib/lowcode/engine/meta/components/jsx.json +24 -0
- package/lib/lowcode/engine/meta/components/layout.json +107 -0
- package/lib/lowcode/engine/meta/components/link.json +111 -0
- package/lib/lowcode/engine/meta/components/modal.json +120 -0
- package/lib/lowcode/engine/meta/components/section.json +107 -0
- package/lib/lowcode/engine/meta/components/split.json +71 -0
- package/lib/lowcode/engine/meta/components/table.json +161 -0
- package/lib/lowcode/engine/meta/components/tabs.json +140 -0
- package/lib/lowcode/engine/meta/components/text.json +65 -0
- package/lib/lowcode/engine/meta/components/tree.json +156 -0
- package/lib/lowcode/engine/meta/components-list.json +122 -0
- package/lib/lowcode/engine/meta/drawer.props.default.json +10 -0
- package/lib/lowcode/engine/meta/form.props.default.json +5 -0
- package/lib/lowcode/engine/meta/iframe.props.default.json +3 -0
- package/lib/lowcode/engine/meta/image.props.default.json +8 -0
- package/lib/lowcode/engine/meta/imex.props.default.json +4 -0
- package/lib/lowcode/engine/meta/jsx.props.default.json +1 -0
- package/lib/lowcode/engine/meta/layout.props.default.json +5 -0
- package/lib/lowcode/engine/meta/link.props.default.json +6 -0
- package/lib/lowcode/engine/meta/modal.props.default.json +11 -0
- package/lib/lowcode/engine/meta/section.props.default.json +9 -0
- package/lib/lowcode/engine/meta/split.props.default.json +5 -0
- package/lib/lowcode/engine/meta/table.props.default.json +10 -0
- package/lib/lowcode/engine/meta/tabs.props.default.json +10 -0
- package/lib/lowcode/engine/meta/text.props.default.json +4 -0
- package/lib/lowcode/engine/meta/tree.props.default.json +9 -0
- package/lib/lowcode/engine/provider/ContextProvider.js +172 -0
- package/lib/lowcode/engine/provider/EventBusProvider.js +128 -0
- package/lib/lowcode/engine/tools/dataProcess.js +201 -0
- package/lib/lowcode/engine/tools/helper.js +11 -0
- package/lib/lowcode/engine/tools/lcid.js +22 -0
- package/lib/lowcode/index.js +20 -0
- package/lib/lowcode/painter/Components.js +112 -0
- package/lib/lowcode/painter/Design.js +105 -0
- package/lib/lowcode/painter/I18n.js +12 -0
- package/lib/lowcode/painter/Outline.js +210 -0
- package/lib/lowcode/painter/Panel.js +16 -0
- package/lib/lowcode/painter/Ribbon.js +151 -0
- package/lib/lowcode/painter/components/PanelItem.js +26 -0
- package/lib/lowcode/painter/components/RuleInput.js +112 -0
- package/lib/lowcode/painter/index.js +26 -0
- package/lib/lowcode/painter/panel-section/LayoutRatio.js +131 -0
- package/lib/lowcode/painter/panel-section/Radio.js +65 -0
- package/lib/lowcode/painter/style/components.less +90 -0
- package/lib/lowcode/painter/style/design.less +38 -0
- package/lib/lowcode/painter/style/index.less +7 -0
- package/lib/lowcode/painter/style/layout-ratio.less +51 -0
- package/lib/lowcode/painter/style/outline.less +26 -0
- package/lib/lowcode/painter/style/panel-item.less +21 -0
- package/lib/lowcode/painter/style/panel.less +5 -0
- package/lib/lowcode/painter/style/radio.less +24 -0
- package/lib/lowcode/painter/style/ribbon.less +4 -0
- package/lib/lowcode/painter/style/rule-input.less +13 -0
- package/lib/lowcode/view/Canvas.js +150 -0
- package/lib/lowcode/view/Loading.js +30 -0
- package/lib/lowcode/view/Page.js +63 -0
- package/lib/lowcode/view/index.js +25 -0
- package/lib/lowcode/view/lc-components/Box/index.js +29 -0
- package/lib/lowcode/view/lc-components/Button/index.js +45 -0
- package/lib/lowcode/view/lc-components/CardList/index.js +28 -0
- package/lib/lowcode/view/lc-components/Dialog/index.js +58 -0
- package/lib/lowcode/view/lc-components/Dialog/index.less +3 -0
- package/lib/lowcode/view/lc-components/Drawer/index.js +54 -0
- package/lib/lowcode/view/lc-components/Form/index.js +28 -0
- package/lib/lowcode/view/lc-components/Iframe/index.js +28 -0
- package/lib/lowcode/view/lc-components/ImEx/index.js +28 -0
- package/lib/lowcode/view/lc-components/Image/index.js +28 -0
- package/lib/lowcode/view/lc-components/JSX/index.js +28 -0
- package/lib/lowcode/view/lc-components/Layout/index.js +32 -0
- package/lib/lowcode/view/lc-components/Link/index.js +28 -0
- package/lib/lowcode/view/lc-components/Section/index.js +42 -0
- package/lib/lowcode/view/lc-components/Split/index.js +29 -0
- package/lib/lowcode/view/lc-components/Table/index.js +31 -0
- package/lib/lowcode/view/lc-components/Tabs/index.js +29 -0
- package/lib/lowcode/view/lc-components/Text/index.js +31 -0
- package/lib/lowcode/view/lc-components/Tree/index.js +28 -0
- package/lib/lowcode/view/lc-components/Wrapper.js +52 -0
- package/lib/lowcode/view/style/canvas.less +5 -0
- package/lib/lowcode/view/style/loading.less +84 -0
- package/lib/lowcode/view/style/page.less +6 -0
- package/lib/upload/Form/gridForm.js +27 -6
- package/lib/upload/Form/index.js +1 -2
- package/lib/upload/Form/index.less +7 -7
- package/lib/upload/FormItem/index.js +30 -19
- package/lib/upload/GridCell/index.js +1 -2
- package/lib/utils/form.js +26 -29
- package/lib/utils/grid.js +23 -28
- package/lowcode.js +1 -0
- package/package.json +157 -78
- package/upload.js +1 -1
- package/utils.js +1 -1
- package/README.zh-CN.md +0 -51
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useLDContext = exports.default = exports.Context = void 0;
|
|
9
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _umi = require("umi");
|
|
13
|
+
var _ahooks = require("ahooks");
|
|
14
|
+
var _EventBusProvider = require("./EventBusProvider");
|
|
15
|
+
var topics = _interopRequireWildcard(require("../../constants/event-topics"));
|
|
16
|
+
var Context = exports.Context = /*#__PURE__*/(0, _react.createContext)(null);
|
|
17
|
+
var useLDContext = exports.useLDContext = function useLDContext() {
|
|
18
|
+
return (0, _react.useContext)(Context);
|
|
19
|
+
};
|
|
20
|
+
var PRIVATE_KEYS = ['pageCode', 'moduleCode', 'pageData', 'componentList', 'componentMap'];
|
|
21
|
+
var _default = exports.default = function _default(_ref) {
|
|
22
|
+
var children = _ref.children;
|
|
23
|
+
var eventBus = (0, _EventBusProvider.useLDEventBus)();
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 页面码
|
|
27
|
+
*/
|
|
28
|
+
var _pageCode = (0, _react.useRef)(void 0);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 模块码
|
|
32
|
+
*/
|
|
33
|
+
var _moduleCode = (0, _react.useRef)(void 0);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 页面数据
|
|
37
|
+
*/
|
|
38
|
+
var _pageData = (0, _react.useRef)(null);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 组件列表
|
|
42
|
+
*/
|
|
43
|
+
var _componentList = (0, _react.useRef)([]);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 组件id与组件的映射
|
|
47
|
+
*/
|
|
48
|
+
var _componentMap = (0, _react.useRef)(new Map());
|
|
49
|
+
var _privateGetter = (0, _react.useRef)({
|
|
50
|
+
pageCode: function pageCode() {
|
|
51
|
+
return _pageCode.current;
|
|
52
|
+
},
|
|
53
|
+
moduleCode: function moduleCode() {
|
|
54
|
+
return _moduleCode.current;
|
|
55
|
+
},
|
|
56
|
+
pageData: function pageData() {
|
|
57
|
+
return _pageData.current;
|
|
58
|
+
},
|
|
59
|
+
componentList: function componentList() {
|
|
60
|
+
return _componentList.current;
|
|
61
|
+
},
|
|
62
|
+
componentMap: function componentMap() {
|
|
63
|
+
return _componentMap.current;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 注册组件
|
|
69
|
+
* id:string 组件id
|
|
70
|
+
* component:ReactNode 组件
|
|
71
|
+
*/
|
|
72
|
+
var register = (0, _ahooks.useMemoizedFn)(function (id, component) {
|
|
73
|
+
_componentMap.current.set(id, component);
|
|
74
|
+
_componentList.current.push([id, component]);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 注销组件
|
|
79
|
+
* id:string 组件id
|
|
80
|
+
*/
|
|
81
|
+
var unregister = (0, _ahooks.useMemoizedFn)(function (id) {
|
|
82
|
+
_componentMap.current.delete(id);
|
|
83
|
+
_componentList.current = _componentList.current.filter(function (_ref2) {
|
|
84
|
+
var _ref3 = (0, _slicedToArray2.default)(_ref2, 1),
|
|
85
|
+
_id = _ref3[0];
|
|
86
|
+
return _id !== id;
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 根据组件id获取组件
|
|
92
|
+
* compId:string 组件id
|
|
93
|
+
* return:ReactNode
|
|
94
|
+
*/
|
|
95
|
+
var getElementById = (0, _ahooks.useMemoizedFn)(function (compId) {});
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 根据组件id获取父组件
|
|
99
|
+
* compId:string 组件id
|
|
100
|
+
* return:ReactNode
|
|
101
|
+
*/
|
|
102
|
+
var getParentElement = (0, _ahooks.useMemoizedFn)(function (compId) {});
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 根据组件id获取组件路径
|
|
106
|
+
* compId:string 组件id
|
|
107
|
+
* return:ReactNode
|
|
108
|
+
*/
|
|
109
|
+
var getElementPathById = (0, _ahooks.useMemoizedFn)(function (compId) {});
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 获取当前模块数据
|
|
113
|
+
* return:Object
|
|
114
|
+
*/
|
|
115
|
+
var getModule = (0, _ahooks.useMemoizedFn)(function () {});
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 根据datasetId获取数据集
|
|
119
|
+
* datasetId:string 数据集id
|
|
120
|
+
* return:Object
|
|
121
|
+
*/
|
|
122
|
+
var getDataSetById = (0, _ahooks.useMemoizedFn)(function (datasetId) {});
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 执行actionKey对应的行为
|
|
126
|
+
* actionKey:string 行为key
|
|
127
|
+
* return:Promise
|
|
128
|
+
*/
|
|
129
|
+
var doAction = (0, _ahooks.useMemoizedFn)(function (actionKey) {});
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* 获取url参数
|
|
133
|
+
* return:object
|
|
134
|
+
*/
|
|
135
|
+
var getUrlParams = (0, _ahooks.useMemoizedFn)(function () {});
|
|
136
|
+
return /*#__PURE__*/_react.default.createElement(Context.Provider, {
|
|
137
|
+
value: new Proxy((0, _objectSpread2.default)({
|
|
138
|
+
_pageCode: _pageCode,
|
|
139
|
+
_moduleCode: _moduleCode,
|
|
140
|
+
_pageData: _pageData,
|
|
141
|
+
_componentList: _componentList,
|
|
142
|
+
_componentMap: _componentMap,
|
|
143
|
+
history: _umi.history,
|
|
144
|
+
topics: topics,
|
|
145
|
+
register: register,
|
|
146
|
+
unregister: unregister,
|
|
147
|
+
getElementById: getElementById,
|
|
148
|
+
getParentElement: getParentElement,
|
|
149
|
+
getElementPathById: getElementPathById,
|
|
150
|
+
getModule: getModule,
|
|
151
|
+
getDataSetById: getDataSetById,
|
|
152
|
+
doAction: doAction,
|
|
153
|
+
getUrlParams: getUrlParams
|
|
154
|
+
}, eventBus), {
|
|
155
|
+
get: function get(target, property, receiver) {
|
|
156
|
+
if (PRIVATE_KEYS.includes(property)) {
|
|
157
|
+
var _privateGetter$curren;
|
|
158
|
+
return (_privateGetter$curren = _privateGetter.current) === null || _privateGetter$curren === void 0 ? void 0 : _privateGetter$curren[property]();
|
|
159
|
+
}
|
|
160
|
+
return Reflect.get(target, property, receiver);
|
|
161
|
+
},
|
|
162
|
+
set: function set(target, property, receiver) {
|
|
163
|
+
console.log('set', target, property, receiver);
|
|
164
|
+
if (PRIVATE_KEYS.includes(property)) {
|
|
165
|
+
throw new Error("\u5C5E\u6027 \"".concat(property, "\" \u662F\u53EA\u8BFB\u7684"));
|
|
166
|
+
} else {
|
|
167
|
+
return Reflect.set(target, property, receiver);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
}, children);
|
|
172
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
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.useLDEventBus = exports.default = exports.EventBus = void 0;
|
|
9
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _ahooks = require("ahooks");
|
|
14
|
+
var _lcid = _interopRequireDefault(require("../tools/lcid"));
|
|
15
|
+
var _helper = require("../tools/helper");
|
|
16
|
+
var _excluded = ["topic"];
|
|
17
|
+
var EventBus = exports.EventBus = /*#__PURE__*/(0, _react.createContext)(null);
|
|
18
|
+
var useLDEventBus = exports.useLDEventBus = function useLDEventBus() {
|
|
19
|
+
return (0, _react.useContext)(EventBus);
|
|
20
|
+
};
|
|
21
|
+
function Subscriber(id) {
|
|
22
|
+
function on(hook) {
|
|
23
|
+
this._on = hook;
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
function once(hook) {
|
|
27
|
+
this._once = hook;
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
function before(hook) {
|
|
31
|
+
this._before = hook;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
function after(hook) {
|
|
35
|
+
this._after = hook;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
function off(hook) {
|
|
39
|
+
this._off = hook;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
function watch() {
|
|
43
|
+
return id;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
on: on,
|
|
47
|
+
once: once,
|
|
48
|
+
before: before,
|
|
49
|
+
after: after,
|
|
50
|
+
off: off,
|
|
51
|
+
watch: watch
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
var _default = exports.default = function _default(_ref) {
|
|
55
|
+
var children = _ref.children,
|
|
56
|
+
runtime = _ref.runtime;
|
|
57
|
+
var event$ = (0, _ahooks.useEventEmitter)();
|
|
58
|
+
var subscriberPool = (0, _ahooks.useCreation)(function () {
|
|
59
|
+
return new Map();
|
|
60
|
+
}, []);
|
|
61
|
+
event$.useSubscription(function (_ref2) {
|
|
62
|
+
var topic = _ref2.topic,
|
|
63
|
+
payload = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
|
|
64
|
+
if (!subscriberPool.has(topic)) return;
|
|
65
|
+
subscriberPool.get(topic).forEach(function (_ref3) {
|
|
66
|
+
var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
67
|
+
_id = _ref4[0],
|
|
68
|
+
_subscriber = _ref4[1];
|
|
69
|
+
var temp = _subscriber._before ? _subscriber._before(payload) : null;
|
|
70
|
+
if (_subscriber._before && !(0, _helper.isPromise)(temp)) {
|
|
71
|
+
console.error('before hook must return a promise');
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
var _before = temp || Promise.resolve(true);
|
|
75
|
+
_before.then(function (flag) {
|
|
76
|
+
if (!flag) return flag;
|
|
77
|
+
var func = _subscriber._once || _subscriber._on;
|
|
78
|
+
if (!func) return;
|
|
79
|
+
return func(payload);
|
|
80
|
+
}).then(function (flag) {
|
|
81
|
+
if (flag === false || !_subscriber._after) return;
|
|
82
|
+
return _subscriber._after(payload);
|
|
83
|
+
}).finally(function () {
|
|
84
|
+
if (_subscriber._once) {
|
|
85
|
+
$unsubscriber(topic, _id);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
var $publisher = (0, _ahooks.useMemoizedFn)(function (topic, payload) {
|
|
91
|
+
event$.emit((0, _objectSpread2.default)({
|
|
92
|
+
topic: topic,
|
|
93
|
+
runtime: runtime
|
|
94
|
+
}, payload));
|
|
95
|
+
});
|
|
96
|
+
var $subscriber = (0, _ahooks.useMemoizedFn)(function (topic) {
|
|
97
|
+
if (!subscriberPool.has(topic)) subscriberPool.set(topic, []);
|
|
98
|
+
var id = (0, _lcid.default)();
|
|
99
|
+
var _subscriber = Subscriber(id);
|
|
100
|
+
subscriberPool.get(topic).push([id, _subscriber]);
|
|
101
|
+
return _subscriber;
|
|
102
|
+
});
|
|
103
|
+
var $unsubscriber = (0, _ahooks.useMemoizedFn)(function (topic, id) {
|
|
104
|
+
if (!subscriberPool.has(topic)) return;
|
|
105
|
+
subscriberPool.get(topic).forEach(function (_ref5, index) {
|
|
106
|
+
var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
|
|
107
|
+
_id = _ref6[0],
|
|
108
|
+
_subscriber = _ref6[1];
|
|
109
|
+
if (_id === id) {
|
|
110
|
+
var _subscriber$_off, _subscriber2;
|
|
111
|
+
subscriberPool.get(topic).splice(index, 1);
|
|
112
|
+
if (!subscriberPool.get(topic).length) {
|
|
113
|
+
subscriberPool.delete(topic);
|
|
114
|
+
}
|
|
115
|
+
(_subscriber$_off = (_subscriber2 = _subscriber)._off) === null || _subscriber$_off === void 0 || _subscriber$_off.call(_subscriber2);
|
|
116
|
+
_subscriber = null;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
return /*#__PURE__*/_react.default.createElement(EventBus.Provider, {
|
|
121
|
+
value: {
|
|
122
|
+
runtime: runtime,
|
|
123
|
+
$publisher: $publisher,
|
|
124
|
+
$subscriber: $subscriber,
|
|
125
|
+
$unsubscriber: $unsubscriber
|
|
126
|
+
}
|
|
127
|
+
}, children);
|
|
128
|
+
};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.add = add;
|
|
9
|
+
exports.compress = compress;
|
|
10
|
+
exports.decompress = decompress;
|
|
11
|
+
exports.deleteById = deleteById;
|
|
12
|
+
exports.findNodeAndParent = findNodeAndParent;
|
|
13
|
+
exports.getPathById = getPathById;
|
|
14
|
+
exports.modifyById = modifyById;
|
|
15
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
16
|
+
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
17
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
18
|
+
var LZString = _interopRequireWildcard(require("lz-string"));
|
|
19
|
+
/**
|
|
20
|
+
* 数据压缩
|
|
21
|
+
* @param {JSON} data
|
|
22
|
+
* @returns 加密后的字符串
|
|
23
|
+
*/
|
|
24
|
+
function compress(data) {
|
|
25
|
+
// 将对象转换为JSON字符串
|
|
26
|
+
var jsonString = JSON.stringify(data);
|
|
27
|
+
// 使用LZ-String压缩JSON字符串
|
|
28
|
+
return LZString.compressToUTF16(jsonString);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 数据解压
|
|
33
|
+
* @param {string} compressedData
|
|
34
|
+
* @returns {json}
|
|
35
|
+
*/
|
|
36
|
+
function decompress(compressedData) {
|
|
37
|
+
// 使用LZ-String解压数据
|
|
38
|
+
var jsonString = LZString.decompressFromUTF16(compressedData);
|
|
39
|
+
// 将JSON字符串转换回对象
|
|
40
|
+
return JSON.parse(jsonString);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 查找指定ID的节点及其父节点。
|
|
45
|
+
*
|
|
46
|
+
* @param {string} id - 要查找的节点ID。
|
|
47
|
+
* @param {Object} current - 当前遍历的JSON对象。
|
|
48
|
+
* @param {Object|null} parent - 当前节点的父节点。
|
|
49
|
+
* @returns {{node: Object|null, parent: Object|null}} 查找结果,包含节点和其父节点。
|
|
50
|
+
*/
|
|
51
|
+
function findNodeAndParent(id, current) {
|
|
52
|
+
var parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
53
|
+
if (current.hasOwnProperty('children') && current.children.includes(id)) {
|
|
54
|
+
return {
|
|
55
|
+
node: current[id],
|
|
56
|
+
parent: current
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
for (var key in current) {
|
|
60
|
+
if (current[key] && (0, _typeof2.default)(current[key]) === 'object' && key !== 'props') {
|
|
61
|
+
var result = findNodeAndParent(id, current[key], current);
|
|
62
|
+
if (result.node) {
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
node: null,
|
|
69
|
+
parent: null
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 对指定的JSON结构进行节点的添加、修改或删除操作。
|
|
75
|
+
*
|
|
76
|
+
* @param {Object} json - 要操作的JSON对象。
|
|
77
|
+
* @param {string|null} path - 要操作的节点路径,使用'/'分隔。
|
|
78
|
+
* @param {string} id - 操作节点的唯一标识符。
|
|
79
|
+
* @param {Object|null} data - 要添加或修改的数据。如果为null,表示删除操作。
|
|
80
|
+
*/
|
|
81
|
+
function process(json, path, id, data) {
|
|
82
|
+
if (!json) {
|
|
83
|
+
throw new Error("json can not be null");
|
|
84
|
+
}
|
|
85
|
+
if (path && id && data) {
|
|
86
|
+
var paths = path.split('/').filter(function (p) {
|
|
87
|
+
return p;
|
|
88
|
+
});
|
|
89
|
+
var current = json;
|
|
90
|
+
var _iterator = (0, _createForOfIteratorHelper2.default)(paths),
|
|
91
|
+
_step;
|
|
92
|
+
try {
|
|
93
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
94
|
+
var p = _step.value;
|
|
95
|
+
if (!current[p]) {
|
|
96
|
+
throw new Error("Path \"".concat(paths.join('/'), "\" does not exist."));
|
|
97
|
+
}
|
|
98
|
+
if (!current[p].hasOwnProperty('children')) {
|
|
99
|
+
current[p]['children'] = [];
|
|
100
|
+
}
|
|
101
|
+
current = current[p];
|
|
102
|
+
}
|
|
103
|
+
} catch (err) {
|
|
104
|
+
_iterator.e(err);
|
|
105
|
+
} finally {
|
|
106
|
+
_iterator.f();
|
|
107
|
+
}
|
|
108
|
+
if (!current.children.includes(id)) {
|
|
109
|
+
current.children.push(id);
|
|
110
|
+
}
|
|
111
|
+
current[id] = {
|
|
112
|
+
props: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
|
|
113
|
+
id: id,
|
|
114
|
+
parentId: current.id
|
|
115
|
+
})
|
|
116
|
+
};
|
|
117
|
+
} else if (!path && id && data) {
|
|
118
|
+
var _findNodeAndParent = findNodeAndParent(id, json),
|
|
119
|
+
node = _findNodeAndParent.node;
|
|
120
|
+
if (node) {
|
|
121
|
+
node.props = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
|
|
122
|
+
id: id
|
|
123
|
+
});
|
|
124
|
+
} else {
|
|
125
|
+
throw new Error("Node with id \"".concat(id, "\" does not exist."));
|
|
126
|
+
}
|
|
127
|
+
} else if (!path && id && !data) {
|
|
128
|
+
var _findNodeAndParent2 = findNodeAndParent(id, json),
|
|
129
|
+
_node = _findNodeAndParent2.node,
|
|
130
|
+
parent = _findNodeAndParent2.parent;
|
|
131
|
+
if (_node && parent) {
|
|
132
|
+
parent.children = parent.children.filter(function (childId) {
|
|
133
|
+
return childId !== id;
|
|
134
|
+
});
|
|
135
|
+
if (parent.children.length === 0) {
|
|
136
|
+
delete parent['children'];
|
|
137
|
+
}
|
|
138
|
+
delete parent[id];
|
|
139
|
+
} else {
|
|
140
|
+
throw new Error("Node with id \"".concat(id, "\" does not exist."));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 对指定的JSON结构进行节点的添加操作。
|
|
147
|
+
*
|
|
148
|
+
* @param {Object} json - 要操作的JSON对象。
|
|
149
|
+
* @param {string|null} path - 要操作的节点路径,使用'/'分隔。
|
|
150
|
+
* @param {string} id - 操作节点的唯一标识符。
|
|
151
|
+
* @param {Object|null} data - 要添加或修改的数据。如果为null,表示删除操作。
|
|
152
|
+
*/
|
|
153
|
+
function add(json, path, id, data) {
|
|
154
|
+
process(json, path, id, data);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 对指定的JSON结构进行节点的修改操作。
|
|
159
|
+
*
|
|
160
|
+
* @param {Object} json - 要操作的JSON对象。
|
|
161
|
+
* @param {string} id - 操作节点的唯一标识符。
|
|
162
|
+
* @param {Object|null} data - 要添加或修改的数据。如果为null,表示删除操作。
|
|
163
|
+
*/
|
|
164
|
+
function modifyById(json, id, data) {
|
|
165
|
+
process(json, null, id, data);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* 查找指定ID的节点及其父节点。
|
|
170
|
+
*
|
|
171
|
+
* @param {Object} json - JSON对象。
|
|
172
|
+
* @param {string} id - 要删除的节点ID。
|
|
173
|
+
*/
|
|
174
|
+
function deleteById(json, id) {
|
|
175
|
+
process(json, null, id);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* 根据ID在给定的JSON结构中查找节点的路径。
|
|
180
|
+
*
|
|
181
|
+
* @param {Object} json - 要搜索的JSON对象。
|
|
182
|
+
* @param {string} id - 要查找的节点ID。
|
|
183
|
+
* @param {string} currentPath - 当前递归到的路径,用于构建返回的路径字符串。
|
|
184
|
+
* @returns {string|null} 如果找到节点,返回节点的路径;否则返回null。
|
|
185
|
+
*/
|
|
186
|
+
function getPathById(json, id) {
|
|
187
|
+
var currentPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
188
|
+
for (var key in json) {
|
|
189
|
+
var newPath = currentPath ? "".concat(currentPath, "/").concat(key) : key;
|
|
190
|
+
if (json[key].props && json[key].props.id === id) {
|
|
191
|
+
return newPath;
|
|
192
|
+
}
|
|
193
|
+
if (json[key].hasOwnProperty('children')) {
|
|
194
|
+
var result = getPathById(json[key], id, newPath);
|
|
195
|
+
if (result) {
|
|
196
|
+
return result;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.isPromise = isPromise;
|
|
8
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
|
+
function isPromise(value) {
|
|
10
|
+
return !!value && (0, _typeof2.default)(value) === 'object' && typeof value.then === 'function';
|
|
11
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = generateShortUuid;
|
|
7
|
+
var _uuid = require("uuid");
|
|
8
|
+
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'];
|
|
9
|
+
function generateShortUuid() {
|
|
10
|
+
var toLowerCase = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
11
|
+
var shortBuffer = '';
|
|
12
|
+
var uuid = (0, _uuid.v4)().replace(/-/g, '');
|
|
13
|
+
for (var i = 0; i < 8; i++) {
|
|
14
|
+
var str = uuid.substring(i * 4, i * 4 + 4);
|
|
15
|
+
var x = parseInt(str, 16);
|
|
16
|
+
shortBuffer += chars[x % 0x3e];
|
|
17
|
+
}
|
|
18
|
+
if (toLowerCase) {
|
|
19
|
+
return shortBuffer.toLowerCase();
|
|
20
|
+
}
|
|
21
|
+
return shortBuffer;
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "Painter", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _painter.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "View", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _view.default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
var _painter = _interopRequireDefault(require("./painter"));
|
|
20
|
+
var _view = _interopRequireDefault(require("./view"));
|