@luck-design-biz/luckda 0.0.22-3 → 0.0.22-5
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 -40
- package/es/components/Builder/index.js +1 -1
- package/es/components/LdGrid/index.js +4 -4
- package/es/components/LdGridForm/index.less +7 -7
- package/es/components/LdRuntimeCom/index.js +42 -0
- package/es/components/LdTree/index.less +36 -36
- package/es/helper/action.js +6 -6
- package/es/helper/form.js +14 -14
- package/es/helper/index.less +7 -7
- package/es/index.js +1 -0
- package/es/lowcode/constants/api-url.js +3 -0
- package/es/lowcode/constants/event-topics.js +31 -0
- package/es/lowcode/constants/index.js +12 -0
- package/es/lowcode/engine/factory/DataFactory.js +1 -0
- package/es/lowcode/engine/factory/panel-item-factory/DynamicStrategy.js +60 -0
- package/es/lowcode/engine/factory/panel-item-factory/SegmentedStrategy.js +32 -0
- package/es/lowcode/engine/factory/panel-item-factory/SelectStrategy.js +32 -0
- package/es/lowcode/engine/factory/panel-item-factory/Strategy.js +21 -0
- package/es/lowcode/engine/factory/panel-item-factory/StringStrategy.js +32 -0
- package/es/lowcode/engine/factory/panel-item-factory/SwitchStrategy.js +32 -0
- package/es/lowcode/engine/factory/panel-item-factory/index.js +40 -0
- package/es/lowcode/engine/meta/box.props.default.json +10 -0
- package/es/lowcode/engine/meta/box.props.json +40 -0
- package/es/lowcode/engine/meta/button.props.default.json +16 -0
- package/es/lowcode/engine/meta/button.props.json +117 -0
- package/es/lowcode/engine/meta/cardlist.props.default.json +18 -0
- package/es/lowcode/engine/meta/cardlist.props.json +144 -0
- package/es/lowcode/engine/meta/components-list.json +128 -0
- package/es/lowcode/engine/meta/dialog.props.default.json +19 -0
- package/es/lowcode/engine/meta/dialog.props.json +121 -0
- package/es/lowcode/engine/meta/drawer.props.default.json +18 -0
- package/es/lowcode/engine/meta/drawer.props.json +144 -0
- package/es/lowcode/engine/meta/form.props.default.json +13 -0
- package/es/lowcode/engine/meta/form.props.json +117 -0
- package/es/lowcode/engine/meta/iframe.props.default.json +11 -0
- package/es/lowcode/engine/meta/iframe.props.json +32 -0
- package/es/lowcode/engine/meta/image.props.default.json +16 -0
- package/es/lowcode/engine/meta/image.props.json +114 -0
- package/es/lowcode/engine/meta/imex.props.default.json +12 -0
- package/es/lowcode/engine/meta/imex.props.json +82 -0
- package/es/lowcode/engine/meta/js-editor/auto-complete.json +29 -0
- package/es/lowcode/engine/meta/jsx.props.default.json +10 -0
- package/es/lowcode/engine/meta/jsx.props.json +25 -0
- package/es/lowcode/engine/meta/layout.props.default.json +13 -0
- package/es/lowcode/engine/meta/layout.props.json +108 -0
- package/es/lowcode/engine/meta/link.props.default.json +14 -0
- package/es/lowcode/engine/meta/link.props.json +112 -0
- package/es/lowcode/engine/meta/section.props.default.json +17 -0
- package/es/lowcode/engine/meta/section.props.json +108 -0
- package/es/lowcode/engine/meta/split.props.default.json +13 -0
- package/es/lowcode/engine/meta/split.props.json +72 -0
- package/es/lowcode/engine/meta/table.props.default.json +18 -0
- package/es/lowcode/engine/meta/table.props.json +162 -0
- package/es/lowcode/engine/meta/tabs.props.default.json +18 -0
- package/es/lowcode/engine/meta/tabs.props.json +141 -0
- package/es/lowcode/engine/meta/text.props.default.json +12 -0
- package/es/lowcode/engine/meta/text.props.json +66 -0
- package/es/lowcode/engine/meta/tree.props.default.json +17 -0
- package/es/lowcode/engine/meta/tree.props.json +157 -0
- package/es/lowcode/engine/provider/ContextProvider.js +165 -0
- package/es/lowcode/engine/provider/EventBusProvider.js +120 -0
- package/es/lowcode/engine/tools/dataProcess.js +263 -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 +210 -0
- package/es/lowcode/painter/I18n.js +202 -0
- package/es/lowcode/painter/Outline.js +208 -0
- package/es/lowcode/painter/Panel.js +195 -0
- package/es/lowcode/painter/Ribbon.js +142 -0
- package/es/lowcode/painter/components/PanelItem.js +35 -0
- package/es/lowcode/painter/components/PopConfirm.js +20 -0
- package/es/lowcode/painter/components/PopForm.js +71 -0
- package/es/lowcode/painter/components/RuleInput.js +105 -0
- package/es/lowcode/painter/components/SortBox.js +92 -0
- package/es/lowcode/painter/components/TabEditor.js +88 -0
- package/es/lowcode/painter/components/code-editor/BaseEditor.js +49 -0
- package/es/lowcode/painter/components/code-editor/JSEditor.js +77 -0
- package/es/lowcode/painter/components/code-editor/index.js +2 -0
- package/es/lowcode/painter/index.js +45 -0
- package/es/lowcode/painter/panel-section/Icon.js +48 -0
- package/es/lowcode/painter/panel-section/IconSelector.js +139 -0
- package/es/lowcode/painter/panel-section/LayoutRatio.js +140 -0
- package/es/lowcode/painter/panel-section/TabItems.js +238 -0
- package/es/lowcode/painter/services/I18n.js +85 -0
- package/es/lowcode/painter/style/components.less +90 -0
- package/es/lowcode/painter/style/design.less +82 -0
- package/es/lowcode/painter/style/icon-selector.less +22 -0
- package/es/lowcode/painter/style/icon.less +11 -0
- package/es/lowcode/painter/style/index.less +6 -0
- package/es/lowcode/painter/style/layout-ratio.less +51 -0
- package/es/lowcode/painter/style/outline.less +28 -0
- package/es/lowcode/painter/style/panel-item.less +22 -0
- package/es/lowcode/painter/style/panel.less +119 -0
- package/es/lowcode/painter/style/pop-confirm.less +10 -0
- package/es/lowcode/painter/style/pop-form.less +20 -0
- package/es/lowcode/painter/style/radio.less +24 -0
- package/es/lowcode/painter/style/ribbon.less +5 -0
- package/es/lowcode/painter/style/rule-input.less +13 -0
- package/es/lowcode/painter/style/tabeditor.less +90 -0
- package/es/lowcode/painter/style/tabitems.less +90 -0
- package/es/lowcode/view/Canvas.js +135 -0
- package/es/lowcode/view/Loading.js +23 -0
- package/es/lowcode/view/Page.js +251 -0
- package/es/lowcode/view/index.js +18 -0
- package/es/lowcode/view/lc-components/Box/index.js +24 -0
- package/es/lowcode/view/lc-components/Box/meta.json +40 -0
- package/es/lowcode/view/lc-components/Button/index.js +37 -0
- package/es/lowcode/view/lc-components/Button/meta.json +117 -0
- package/es/lowcode/view/lc-components/CardList/index.js +20 -0
- package/es/lowcode/view/lc-components/CardList/meta.json +144 -0
- package/es/lowcode/view/lc-components/Dialog/index.js +61 -0
- package/es/lowcode/view/lc-components/Dialog/index.less +3 -0
- package/es/lowcode/view/lc-components/Dialog/meta.json +121 -0
- package/es/lowcode/view/lc-components/Drawer/index.js +62 -0
- package/es/lowcode/view/lc-components/Drawer/meta.json +144 -0
- package/es/lowcode/view/lc-components/Drawer/style.less +7 -0
- package/es/lowcode/view/lc-components/Form/index.js +20 -0
- package/es/lowcode/view/lc-components/Form/meta.json +117 -0
- package/es/lowcode/view/lc-components/Iframe/index.js +20 -0
- package/es/lowcode/view/lc-components/Iframe/meta.json +32 -0
- package/es/lowcode/view/lc-components/ImEx/index.js +20 -0
- package/es/lowcode/view/lc-components/ImEx/meta.json +82 -0
- package/es/lowcode/view/lc-components/Image/index.js +20 -0
- package/es/lowcode/view/lc-components/Image/meta.json +114 -0
- package/es/lowcode/view/lc-components/JSX/index.js +20 -0
- package/es/lowcode/view/lc-components/JSX/meta.json +25 -0
- package/es/lowcode/view/lc-components/Layout/index.js +98 -0
- package/es/lowcode/view/lc-components/Layout/index.less +9 -0
- package/es/lowcode/view/lc-components/Layout/meta.json +108 -0
- package/es/lowcode/view/lc-components/Link/index.js +20 -0
- package/es/lowcode/view/lc-components/Link/meta.json +112 -0
- package/es/lowcode/view/lc-components/Section/index.js +34 -0
- package/es/lowcode/view/lc-components/Section/meta.json +108 -0
- package/es/lowcode/view/lc-components/Split/index.js +21 -0
- package/es/lowcode/view/lc-components/Split/meta.json +72 -0
- package/es/lowcode/view/lc-components/Table/index.js +23 -0
- package/es/lowcode/view/lc-components/Table/meta.json +162 -0
- package/es/lowcode/view/lc-components/Tabs/index.js +21 -0
- package/es/lowcode/view/lc-components/Tabs/meta.json +141 -0
- package/es/lowcode/view/lc-components/Text/index.js +23 -0
- package/es/lowcode/view/lc-components/Text/meta.json +66 -0
- package/es/lowcode/view/lc-components/Tree/index.js +20 -0
- package/es/lowcode/view/lc-components/Tree/meta.json +157 -0
- package/es/lowcode/view/lc-components/Wrapper.js +52 -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 +5 -0
- package/es/upload/Form/gridForm.js +24 -6
- package/es/upload/Form/index.less +7 -7
- package/es/upload/FormItem/index.js +30 -18
- package/es/utils/form.js +22 -22
- package/es/utils/grid.js +2 -2
- package/lib/components/Builder/index.js +1 -1
- package/lib/components/LdGrid/index.js +4 -4
- package/lib/components/LdGridForm/index.less +7 -7
- package/lib/components/LdRuntimeCom/index.js +49 -0
- package/lib/components/LdTree/index.less +36 -36
- package/lib/helper/action.js +6 -6
- package/lib/helper/form.js +14 -14
- package/lib/helper/index.less +7 -7
- package/lib/index.js +9 -1
- package/lib/lowcode/constants/api-url.js +9 -0
- package/lib/lowcode/constants/event-topics.js +37 -0
- package/lib/lowcode/constants/index.js +18 -0
- package/lib/lowcode/engine/factory/DataFactory.js +3 -0
- package/lib/lowcode/engine/factory/panel-item-factory/DynamicStrategy.js +73 -0
- package/lib/lowcode/engine/factory/panel-item-factory/SegmentedStrategy.js +38 -0
- package/lib/lowcode/engine/factory/panel-item-factory/SelectStrategy.js +38 -0
- package/lib/lowcode/engine/factory/panel-item-factory/Strategy.js +27 -0
- package/lib/lowcode/engine/factory/panel-item-factory/StringStrategy.js +38 -0
- package/lib/lowcode/engine/factory/panel-item-factory/SwitchStrategy.js +38 -0
- package/lib/lowcode/engine/factory/panel-item-factory/index.js +46 -0
- package/lib/lowcode/engine/meta/box.props.default.json +10 -0
- package/lib/lowcode/engine/meta/box.props.json +40 -0
- package/lib/lowcode/engine/meta/button.props.default.json +16 -0
- package/lib/lowcode/engine/meta/button.props.json +117 -0
- package/lib/lowcode/engine/meta/cardlist.props.default.json +18 -0
- package/lib/lowcode/engine/meta/cardlist.props.json +144 -0
- package/lib/lowcode/engine/meta/components-list.json +128 -0
- package/lib/lowcode/engine/meta/dialog.props.default.json +19 -0
- package/lib/lowcode/engine/meta/dialog.props.json +121 -0
- package/lib/lowcode/engine/meta/drawer.props.default.json +18 -0
- package/lib/lowcode/engine/meta/drawer.props.json +144 -0
- package/lib/lowcode/engine/meta/form.props.default.json +13 -0
- package/lib/lowcode/engine/meta/form.props.json +117 -0
- package/lib/lowcode/engine/meta/iframe.props.default.json +11 -0
- package/lib/lowcode/engine/meta/iframe.props.json +32 -0
- package/lib/lowcode/engine/meta/image.props.default.json +16 -0
- package/lib/lowcode/engine/meta/image.props.json +114 -0
- package/lib/lowcode/engine/meta/imex.props.default.json +12 -0
- package/lib/lowcode/engine/meta/imex.props.json +82 -0
- package/lib/lowcode/engine/meta/js-editor/auto-complete.json +29 -0
- package/lib/lowcode/engine/meta/jsx.props.default.json +10 -0
- package/lib/lowcode/engine/meta/jsx.props.json +25 -0
- package/lib/lowcode/engine/meta/layout.props.default.json +13 -0
- package/lib/lowcode/engine/meta/layout.props.json +108 -0
- package/lib/lowcode/engine/meta/link.props.default.json +14 -0
- package/lib/lowcode/engine/meta/link.props.json +112 -0
- package/lib/lowcode/engine/meta/section.props.default.json +17 -0
- package/lib/lowcode/engine/meta/section.props.json +108 -0
- package/lib/lowcode/engine/meta/split.props.default.json +13 -0
- package/lib/lowcode/engine/meta/split.props.json +72 -0
- package/lib/lowcode/engine/meta/table.props.default.json +18 -0
- package/lib/lowcode/engine/meta/table.props.json +162 -0
- package/lib/lowcode/engine/meta/tabs.props.default.json +18 -0
- package/lib/lowcode/engine/meta/tabs.props.json +141 -0
- package/lib/lowcode/engine/meta/text.props.default.json +12 -0
- package/lib/lowcode/engine/meta/text.props.json +66 -0
- package/lib/lowcode/engine/meta/tree.props.default.json +17 -0
- package/lib/lowcode/engine/meta/tree.props.json +157 -0
- package/lib/lowcode/engine/provider/ContextProvider.js +173 -0
- package/lib/lowcode/engine/provider/EventBusProvider.js +128 -0
- package/lib/lowcode/engine/tools/dataProcess.js +277 -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 +218 -0
- package/lib/lowcode/painter/I18n.js +209 -0
- package/lib/lowcode/painter/Outline.js +216 -0
- package/lib/lowcode/painter/Panel.js +203 -0
- package/lib/lowcode/painter/Ribbon.js +150 -0
- package/lib/lowcode/painter/components/PanelItem.js +41 -0
- package/lib/lowcode/painter/components/PopConfirm.js +26 -0
- package/lib/lowcode/painter/components/PopForm.js +77 -0
- package/lib/lowcode/painter/components/RuleInput.js +112 -0
- package/lib/lowcode/painter/components/SortBox.js +99 -0
- package/lib/lowcode/painter/components/TabEditor.js +94 -0
- package/lib/lowcode/painter/components/code-editor/BaseEditor.js +57 -0
- package/lib/lowcode/painter/components/code-editor/JSEditor.js +88 -0
- package/lib/lowcode/painter/components/code-editor/index.js +20 -0
- package/lib/lowcode/painter/index.js +54 -0
- package/lib/lowcode/painter/panel-section/Icon.js +54 -0
- package/lib/lowcode/painter/panel-section/IconSelector.js +146 -0
- package/lib/lowcode/painter/panel-section/LayoutRatio.js +148 -0
- package/lib/lowcode/painter/panel-section/TabItems.js +246 -0
- package/lib/lowcode/painter/services/I18n.js +95 -0
- package/lib/lowcode/painter/style/components.less +90 -0
- package/lib/lowcode/painter/style/design.less +82 -0
- package/lib/lowcode/painter/style/icon-selector.less +22 -0
- package/lib/lowcode/painter/style/icon.less +11 -0
- package/lib/lowcode/painter/style/index.less +6 -0
- package/lib/lowcode/painter/style/layout-ratio.less +51 -0
- package/lib/lowcode/painter/style/outline.less +28 -0
- package/lib/lowcode/painter/style/panel-item.less +22 -0
- package/lib/lowcode/painter/style/panel.less +119 -0
- package/lib/lowcode/painter/style/pop-confirm.less +10 -0
- package/lib/lowcode/painter/style/pop-form.less +20 -0
- package/lib/lowcode/painter/style/radio.less +24 -0
- package/lib/lowcode/painter/style/ribbon.less +5 -0
- package/lib/lowcode/painter/style/rule-input.less +13 -0
- package/lib/lowcode/painter/style/tabeditor.less +90 -0
- package/lib/lowcode/painter/style/tabitems.less +90 -0
- package/lib/lowcode/view/Canvas.js +150 -0
- package/lib/lowcode/view/Loading.js +30 -0
- package/lib/lowcode/view/Page.js +259 -0
- package/lib/lowcode/view/index.js +25 -0
- package/lib/lowcode/view/lc-components/Box/index.js +32 -0
- package/lib/lowcode/view/lc-components/Box/meta.json +40 -0
- package/lib/lowcode/view/lc-components/Button/index.js +45 -0
- package/lib/lowcode/view/lc-components/Button/meta.json +117 -0
- package/lib/lowcode/view/lc-components/CardList/index.js +28 -0
- package/lib/lowcode/view/lc-components/CardList/meta.json +144 -0
- package/lib/lowcode/view/lc-components/Dialog/index.js +69 -0
- package/lib/lowcode/view/lc-components/Dialog/index.less +3 -0
- package/lib/lowcode/view/lc-components/Dialog/meta.json +121 -0
- package/lib/lowcode/view/lc-components/Drawer/index.js +70 -0
- package/lib/lowcode/view/lc-components/Drawer/meta.json +144 -0
- package/lib/lowcode/view/lc-components/Drawer/style.less +7 -0
- package/lib/lowcode/view/lc-components/Form/index.js +28 -0
- package/lib/lowcode/view/lc-components/Form/meta.json +117 -0
- package/lib/lowcode/view/lc-components/Iframe/index.js +28 -0
- package/lib/lowcode/view/lc-components/Iframe/meta.json +32 -0
- package/lib/lowcode/view/lc-components/ImEx/index.js +28 -0
- package/lib/lowcode/view/lc-components/ImEx/meta.json +82 -0
- package/lib/lowcode/view/lc-components/Image/index.js +28 -0
- package/lib/lowcode/view/lc-components/Image/meta.json +114 -0
- package/lib/lowcode/view/lc-components/JSX/index.js +28 -0
- package/lib/lowcode/view/lc-components/JSX/meta.json +25 -0
- package/lib/lowcode/view/lc-components/Layout/index.js +106 -0
- package/lib/lowcode/view/lc-components/Layout/index.less +9 -0
- package/lib/lowcode/view/lc-components/Layout/meta.json +108 -0
- package/lib/lowcode/view/lc-components/Link/index.js +28 -0
- package/lib/lowcode/view/lc-components/Link/meta.json +112 -0
- package/lib/lowcode/view/lc-components/Section/index.js +42 -0
- package/lib/lowcode/view/lc-components/Section/meta.json +108 -0
- package/lib/lowcode/view/lc-components/Split/index.js +29 -0
- package/lib/lowcode/view/lc-components/Split/meta.json +72 -0
- package/lib/lowcode/view/lc-components/Table/index.js +31 -0
- package/lib/lowcode/view/lc-components/Table/meta.json +162 -0
- package/lib/lowcode/view/lc-components/Tabs/index.js +29 -0
- package/lib/lowcode/view/lc-components/Tabs/meta.json +141 -0
- package/lib/lowcode/view/lc-components/Text/index.js +31 -0
- package/lib/lowcode/view/lc-components/Text/meta.json +66 -0
- package/lib/lowcode/view/lc-components/Tree/index.js +28 -0
- package/lib/lowcode/view/lc-components/Tree/meta.json +157 -0
- package/lib/lowcode/view/lc-components/Wrapper.js +59 -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 +5 -0
- package/lib/upload/Form/gridForm.js +22 -4
- package/lib/upload/Form/index.less +7 -7
- package/lib/upload/FormItem/index.js +29 -17
- package/lib/utils/form.js +22 -22
- package/lib/utils/grid.js +2 -2
- package/lowcode.js +1 -0
- package/package.json +163 -151
- package/upload.js +1 -1
- package/utils.js +1 -1
|
@@ -0,0 +1,277 @@
|
|
|
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.getPathNodesById = getPathNodesById;
|
|
15
|
+
exports.modifyById = modifyById;
|
|
16
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
17
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
18
|
+
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
19
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
20
|
+
var LZString = _interopRequireWildcard(require("lz-string"));
|
|
21
|
+
/**
|
|
22
|
+
* 数据压缩
|
|
23
|
+
* @param {JSON} data
|
|
24
|
+
* @returns 加密后的字符串
|
|
25
|
+
*/
|
|
26
|
+
function compress(data) {
|
|
27
|
+
// 将对象转换为JSON字符串
|
|
28
|
+
var jsonString = JSON.stringify(data);
|
|
29
|
+
// 使用LZ-String压缩JSON字符串
|
|
30
|
+
return LZString.compressToUTF16(jsonString);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 数据解压
|
|
35
|
+
* @param {string} compressedData
|
|
36
|
+
* @returns {json}
|
|
37
|
+
*/
|
|
38
|
+
function decompress(compressedData) {
|
|
39
|
+
// 使用LZ-String解压数据
|
|
40
|
+
var jsonString = LZString.decompressFromUTF16(compressedData);
|
|
41
|
+
// 将JSON字符串转换回对象
|
|
42
|
+
return JSON.parse(jsonString);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 查找指定ID的节点及其父节点。
|
|
47
|
+
*
|
|
48
|
+
* @param {string} id - 要查找的节点ID。
|
|
49
|
+
* @param {Object} current - 当前遍历的JSON对象。
|
|
50
|
+
* @param {Object|null} parent - 当前节点的父节点。
|
|
51
|
+
* @returns {{node: Object|null, parent: Object|null}} 查找结果,包含节点和其父节点。
|
|
52
|
+
*/
|
|
53
|
+
function findNodeAndParent(id, current) {
|
|
54
|
+
var parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
55
|
+
if (!parent && current.props.id === id) {
|
|
56
|
+
return {
|
|
57
|
+
node: current,
|
|
58
|
+
parent: null
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (current.hasOwnProperty('children') && current.children.includes(id)) {
|
|
62
|
+
return {
|
|
63
|
+
node: current[id],
|
|
64
|
+
parent: current
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
for (var key in current) {
|
|
68
|
+
if (current[key] && (0, _typeof2.default)(current[key]) === 'object' && key !== 'props' && key !== 'children') {
|
|
69
|
+
var result = findNodeAndParent(id, current[key], current);
|
|
70
|
+
if (result.node) {
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
node: null,
|
|
77
|
+
parent: null
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 对指定的JSON结构进行节点的添加、修改或删除操作。
|
|
83
|
+
*
|
|
84
|
+
* @param {Object} json - 要操作的JSON对象。
|
|
85
|
+
* @param {string|null} path - 要操作的节点路径,使用'/'分隔。
|
|
86
|
+
* @param {string} id - 操作节点的唯一标识符。
|
|
87
|
+
* @param {Object|null} data - 要添加或修改的数据。如果为null,表示删除操作。
|
|
88
|
+
*/
|
|
89
|
+
function process(json, path, id, data) {
|
|
90
|
+
if (!json) {
|
|
91
|
+
throw new Error("json can not be null");
|
|
92
|
+
}
|
|
93
|
+
if (path && id && data) {
|
|
94
|
+
var paths = path.split('/').filter(function (p) {
|
|
95
|
+
return p;
|
|
96
|
+
});
|
|
97
|
+
var current = json;
|
|
98
|
+
var _iterator = (0, _createForOfIteratorHelper2.default)(paths),
|
|
99
|
+
_step;
|
|
100
|
+
try {
|
|
101
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
102
|
+
var p = _step.value;
|
|
103
|
+
if (!current[p]) {
|
|
104
|
+
throw new Error("Path \"".concat(paths.join('/'), "\" does not exist."));
|
|
105
|
+
}
|
|
106
|
+
if (!current[p].hasOwnProperty('children')) {
|
|
107
|
+
current[p]['children'] = [];
|
|
108
|
+
}
|
|
109
|
+
current = current[p];
|
|
110
|
+
}
|
|
111
|
+
} catch (err) {
|
|
112
|
+
_iterator.e(err);
|
|
113
|
+
} finally {
|
|
114
|
+
_iterator.f();
|
|
115
|
+
}
|
|
116
|
+
if (!current.children.includes(id)) {
|
|
117
|
+
current.children.push(id);
|
|
118
|
+
}
|
|
119
|
+
current[id] = {
|
|
120
|
+
props: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
|
|
121
|
+
id: id,
|
|
122
|
+
parentId: current.id
|
|
123
|
+
})
|
|
124
|
+
};
|
|
125
|
+
} else if (!path && id && data) {
|
|
126
|
+
var _findNodeAndParent = findNodeAndParent(id, json),
|
|
127
|
+
node = _findNodeAndParent.node;
|
|
128
|
+
if (node) {
|
|
129
|
+
node.props = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
|
|
130
|
+
id: id
|
|
131
|
+
});
|
|
132
|
+
} else {
|
|
133
|
+
throw new Error("Node with id \"".concat(id, "\" does not exist."));
|
|
134
|
+
}
|
|
135
|
+
} else if (!path && id && !data) {
|
|
136
|
+
var _findNodeAndParent2 = findNodeAndParent(id, json),
|
|
137
|
+
_node = _findNodeAndParent2.node,
|
|
138
|
+
parent = _findNodeAndParent2.parent;
|
|
139
|
+
if (_node && parent) {
|
|
140
|
+
parent.children = parent.children.filter(function (childId) {
|
|
141
|
+
return childId !== id;
|
|
142
|
+
});
|
|
143
|
+
if (parent.children.length === 0) {
|
|
144
|
+
delete parent['children'];
|
|
145
|
+
}
|
|
146
|
+
delete parent[id];
|
|
147
|
+
} else {
|
|
148
|
+
throw new Error("Node with id \"".concat(id, "\" does not exist."));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 对指定的JSON结构进行节点的添加操作。
|
|
155
|
+
*
|
|
156
|
+
* @param {Object} json - 要操作的JSON对象。
|
|
157
|
+
* @param {string} parentId - 父节点的唯一标识符。
|
|
158
|
+
* @param {string} id - 操作节点的唯一标识符。
|
|
159
|
+
* @param {Object|null} data - 要添加或修改的数据。如果为null,表示删除操作。
|
|
160
|
+
*/
|
|
161
|
+
function add(json, parentId, id, data) {
|
|
162
|
+
process(json, getPathById(json, parentId), id, data);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* 对指定的JSON结构进行节点的修改操作。
|
|
167
|
+
*
|
|
168
|
+
* @param {Object} json - 要操作的JSON对象。
|
|
169
|
+
* @param {string} id - 操作节点的唯一标识符。
|
|
170
|
+
* @param {Object|null} data - 要添加或修改的数据。如果为null,表示删除操作。
|
|
171
|
+
*/
|
|
172
|
+
function modifyById(json, id, data) {
|
|
173
|
+
process(json, null, id, data);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* 删除指定id的节点。
|
|
178
|
+
*
|
|
179
|
+
* @param {Object} json - JSON对象。
|
|
180
|
+
* @param {string} id - 要删除的节点ID。
|
|
181
|
+
*/
|
|
182
|
+
function deleteById(json, id) {
|
|
183
|
+
process(json, null, id);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* 根据ID在给定的JSON结构中查找节点的路径。
|
|
188
|
+
*
|
|
189
|
+
* @param {Object} json - 要搜索的JSON对象。
|
|
190
|
+
* @param {string} id - 要查找的节点ID。
|
|
191
|
+
* @param {string} currentPath - 当前递归到的路径,用于构建返回的路径字符串。
|
|
192
|
+
* @returns {string|null} 如果找到节点,返回节点的路径;否则返回null。
|
|
193
|
+
*/
|
|
194
|
+
function getPathById(json, id) {
|
|
195
|
+
var currentPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
196
|
+
for (var key in json) {
|
|
197
|
+
var newPath = currentPath ? "".concat(currentPath, "/").concat(key) : key;
|
|
198
|
+
if (json[key].props && json[key].props.id === id) {
|
|
199
|
+
return newPath;
|
|
200
|
+
}
|
|
201
|
+
if (json[key].hasOwnProperty('children')) {
|
|
202
|
+
var result = getPathById(json[key], id, newPath);
|
|
203
|
+
if (result) {
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* 在给定的JSON结构中搜索具有特定id的节点,并返回包含该节点及其所有父节点的props属性的路径数组。
|
|
213
|
+
*
|
|
214
|
+
* @param {Object} data - 待搜索的JSON对象,它代表了一个复杂的树状结构,每个节点都可能有props和children属性。
|
|
215
|
+
* @param {string} targetId - 需要找到的目标节点的id。
|
|
216
|
+
* @returns {Array<Object>} 一个包含目标节点及其所有父节点的props属性的数组。如果未找到目标节点,则返回空数组。
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* const data = {
|
|
220
|
+
* props: {
|
|
221
|
+
* id: 'page_root',
|
|
222
|
+
* type: 'Page',
|
|
223
|
+
* name: '页面',
|
|
224
|
+
* hasHeder: true,
|
|
225
|
+
* hasFooter: true,
|
|
226
|
+
* },
|
|
227
|
+
* // ...其他节点
|
|
228
|
+
* };
|
|
229
|
+
*
|
|
230
|
+
* const path = getPathNodesById(data, 'form_jknbjkun');
|
|
231
|
+
* console.log(path);
|
|
232
|
+
* // 输出目标节点及其所有父节点的props属性的数组
|
|
233
|
+
*/
|
|
234
|
+
function getPathNodesById(data, targetId) {
|
|
235
|
+
// 初始化结果数组
|
|
236
|
+
var result = [];
|
|
237
|
+
|
|
238
|
+
// 定义递归函数以搜索路径
|
|
239
|
+
function search(node) {
|
|
240
|
+
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
241
|
+
// 检查当前节点是否是目标节点
|
|
242
|
+
if (node && node.props && node.props.id === targetId) {
|
|
243
|
+
// 如果是,将当前路径和节点自身添加到结果中
|
|
244
|
+
result = [].concat((0, _toConsumableArray2.default)(path), [node.props]);
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// 遍历子节点
|
|
249
|
+
if (node && node.children) {
|
|
250
|
+
var _iterator2 = (0, _createForOfIteratorHelper2.default)(node.children),
|
|
251
|
+
_step2;
|
|
252
|
+
try {
|
|
253
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
254
|
+
var childId = _step2.value;
|
|
255
|
+
// 对每个子节点,首先尝试从当前节点获取子节点数据
|
|
256
|
+
var childNode = node[childId];
|
|
257
|
+
if (search(childNode, [].concat((0, _toConsumableArray2.default)(path), [node.props]))) {
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
} catch (err) {
|
|
262
|
+
_iterator2.e(err);
|
|
263
|
+
} finally {
|
|
264
|
+
_iterator2.f();
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// 从顶层"data"对象开始搜索
|
|
271
|
+
if (search(data)) {
|
|
272
|
+
return result;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// 如果未找到目标节点,返回空数组
|
|
276
|
+
return [];
|
|
277
|
+
}
|
|
@@ -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"));
|
|
@@ -0,0 +1,112 @@
|
|
|
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.default = 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 _antd = require("luck-design/antd");
|
|
13
|
+
var _ahooks = require("ahooks");
|
|
14
|
+
var _utils = require("@luck-design-biz/base/utils");
|
|
15
|
+
var _ContextProvider = require("../engine/provider/ContextProvider");
|
|
16
|
+
var _components = _interopRequireDefault(require("./style/components.less"));
|
|
17
|
+
var _componentsList = _interopRequireDefault(require("../engine/meta/components-list.json"));
|
|
18
|
+
var TabPane = _antd.Tabs.TabPane;
|
|
19
|
+
var Search = _antd.Input.Search;
|
|
20
|
+
var BaseCom = function BaseCom(_ref) {
|
|
21
|
+
var onComponentClick = _ref.onComponentClick;
|
|
22
|
+
var _useState = (0, _react.useState)(''),
|
|
23
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
24
|
+
searchTerm = _useState2[0],
|
|
25
|
+
setSearchTerm = _useState2[1];
|
|
26
|
+
var handleSearch = (0, _ahooks.useMemoizedFn)(function (e) {
|
|
27
|
+
setSearchTerm(e.target.value.toLowerCase());
|
|
28
|
+
});
|
|
29
|
+
var filteredData = (0, _ahooks.useCreation)(function () {
|
|
30
|
+
return _componentsList.default.map(function (group) {
|
|
31
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, group), {}, {
|
|
32
|
+
components: group.components.filter(function (item) {
|
|
33
|
+
return item.name.toLowerCase().includes(searchTerm) || item.desc.toLowerCase().includes(searchTerm);
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
}).filter(function (group) {
|
|
37
|
+
return group.components.length > 0;
|
|
38
|
+
});
|
|
39
|
+
}, [_componentsList.default]);
|
|
40
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
41
|
+
className: _components.default['components-search']
|
|
42
|
+
}, /*#__PURE__*/_react.default.createElement(Search, {
|
|
43
|
+
placeholder: (0, _utils.formatMessage)({
|
|
44
|
+
id: 'luckda.lowcode.painter.components.search',
|
|
45
|
+
label: '搜索组件'
|
|
46
|
+
}),
|
|
47
|
+
onChange: handleSearch
|
|
48
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
49
|
+
className: _components.default['components-content']
|
|
50
|
+
}, filteredData.map(function (group) {
|
|
51
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
52
|
+
key: group.group,
|
|
53
|
+
className: _components.default['components-wrapper']
|
|
54
|
+
}, /*#__PURE__*/_react.default.createElement("h3", null, group.groupName), group.components.map(function (item) {
|
|
55
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
56
|
+
key: item.component,
|
|
57
|
+
className: _components.default['components-item'],
|
|
58
|
+
onClick: function onClick() {
|
|
59
|
+
return onComponentClick(item);
|
|
60
|
+
}
|
|
61
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
62
|
+
className: _components.default['icon-wrapper']
|
|
63
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Icon, {
|
|
64
|
+
type: item.icon || 'home'
|
|
65
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
66
|
+
className: _components.default['text-content']
|
|
67
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, item.name)));
|
|
68
|
+
}));
|
|
69
|
+
})));
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 组件清单
|
|
74
|
+
*/
|
|
75
|
+
var Components = function Components(_ref2) {
|
|
76
|
+
var _ref2$dataset = _ref2.dataset,
|
|
77
|
+
dataset = _ref2$dataset === void 0 ? 'test' : _ref2$dataset;
|
|
78
|
+
var context = (0, _ContextProvider.useLDContext)();
|
|
79
|
+
var onComponentClick = (0, _ahooks.useMemoizedFn)(function (data) {
|
|
80
|
+
context.$publisher(context.topics.COMPONENT_SETTING_CLICK, {
|
|
81
|
+
data: data
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
if (!dataset) return /*#__PURE__*/_react.default.createElement("div", {
|
|
85
|
+
className: _components.default['lc-painter-components'],
|
|
86
|
+
style: {
|
|
87
|
+
paddingTop: '16px'
|
|
88
|
+
}
|
|
89
|
+
}, /*#__PURE__*/_react.default.createElement(BaseCom, {
|
|
90
|
+
onComponentClick: onComponentClick
|
|
91
|
+
}));
|
|
92
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
93
|
+
className: _components.default['lc-painter-components']
|
|
94
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Tabs, {
|
|
95
|
+
defaultActiveKey: "base"
|
|
96
|
+
}, /*#__PURE__*/_react.default.createElement(TabPane, {
|
|
97
|
+
tab: (0, _utils.formatMessage)({
|
|
98
|
+
id: 'ccm.dev.page.set.components.base',
|
|
99
|
+
label: '基础组件'
|
|
100
|
+
}),
|
|
101
|
+
key: "base"
|
|
102
|
+
}, /*#__PURE__*/_react.default.createElement(BaseCom, {
|
|
103
|
+
onComponentClick: onComponentClick
|
|
104
|
+
})), /*#__PURE__*/_react.default.createElement(TabPane, {
|
|
105
|
+
tab: (0, _utils.formatMessage)({
|
|
106
|
+
id: 'ccm.dev.page.set.components.dataset',
|
|
107
|
+
label: '数据集字段'
|
|
108
|
+
}),
|
|
109
|
+
key: "dataset"
|
|
110
|
+
})));
|
|
111
|
+
};
|
|
112
|
+
var _default = exports.default = Components;
|
|
@@ -0,0 +1,218 @@
|
|
|
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.default = void 0;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _ahooks = require("ahooks");
|
|
13
|
+
var _antd = require("luck-design/antd");
|
|
14
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
+
var _lodash = require("lodash");
|
|
16
|
+
var _ContextProvider = require("../engine/provider/ContextProvider");
|
|
17
|
+
var _Page = _interopRequireDefault(require("../view/Page"));
|
|
18
|
+
var _dataProcess = require("../engine/tools/dataProcess");
|
|
19
|
+
var _lcid = _interopRequireDefault(require("../engine/tools/lcid"));
|
|
20
|
+
var _constants = require("../constants");
|
|
21
|
+
var _design = _interopRequireDefault(require("./style/design.less"));
|
|
22
|
+
var setRect = function setRect(page, node, cellNode) {
|
|
23
|
+
var _page$getBoundingClie = page.getBoundingClientRect(),
|
|
24
|
+
pageLeft = _page$getBoundingClie.left,
|
|
25
|
+
pageTop = _page$getBoundingClie.top;
|
|
26
|
+
var _cellNode$getBounding = cellNode.getBoundingClientRect(),
|
|
27
|
+
cellNodeLeft = _cellNode$getBounding.left,
|
|
28
|
+
cellNodeTop = _cellNode$getBounding.top;
|
|
29
|
+
node.style.left = "".concat(cellNodeLeft - pageLeft, "px");
|
|
30
|
+
node.style.top = "".concat(cellNodeTop - pageTop, "px");
|
|
31
|
+
node.style.width = "".concat(cellNode.offsetWidth, "px");
|
|
32
|
+
node.style.height = "".concat(cellNode.offsetHeight, "px");
|
|
33
|
+
};
|
|
34
|
+
var Design = function Design() {
|
|
35
|
+
var context = (0, _ContextProvider.useLDContext)();
|
|
36
|
+
var detectorRef = (0, _react.useRef)(null);
|
|
37
|
+
var selectorRef = (0, _react.useRef)(null);
|
|
38
|
+
var simulatorRef = (0, _react.useRef)(null);
|
|
39
|
+
var hoverCellRef = (0, _react.useRef)(null);
|
|
40
|
+
var activeCellRef = (0, _react.useRef)(null);
|
|
41
|
+
var size = (0, _ahooks.useSize)(simulatorRef);
|
|
42
|
+
var scroll = (0, _ahooks.useScroll)(simulatorRef);
|
|
43
|
+
var _useState = (0, _react.useState)('pc'),
|
|
44
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
45
|
+
activedTarget = _useState2[0],
|
|
46
|
+
setActivedTarget = _useState2[1];
|
|
47
|
+
(0, _ahooks.useEventListener)('mousemove', function (event) {
|
|
48
|
+
var elem = event.target;
|
|
49
|
+
var targetCell = elem.closest(".".concat(_constants.CELL_CLASS_NAME));
|
|
50
|
+
if (targetCell && !targetCell.isEqualNode(hoverCellRef.current) && !targetCell.isEqualNode(activeCellRef.current)) {
|
|
51
|
+
var _id = targetCell.id;
|
|
52
|
+
hoverCellRef.current = targetCell;
|
|
53
|
+
context.$publisher(context.topics.COMPONENT_HOVER, {
|
|
54
|
+
id: _id,
|
|
55
|
+
cellNode: targetCell
|
|
56
|
+
});
|
|
57
|
+
} else if (!targetCell || targetCell.isEqualNode(activeCellRef.current)) {
|
|
58
|
+
hoverCellRef.current = null;
|
|
59
|
+
context.$publisher(context.topics.COMPONENT_HOVER, null);
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
target: simulatorRef
|
|
63
|
+
});
|
|
64
|
+
(0, _ahooks.useEventListener)('mouseleave', function () {
|
|
65
|
+
if (hoverCellRef.current) {
|
|
66
|
+
hoverCellRef.current = null;
|
|
67
|
+
context.$publisher(context.topics.COMPONENT_HOVER, null);
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
target: simulatorRef
|
|
71
|
+
});
|
|
72
|
+
(0, _ahooks.useEventListener)('click', function (event) {
|
|
73
|
+
var elem = event.target;
|
|
74
|
+
var targetCell = elem.closest(".".concat(_constants.CELL_CLASS_NAME));
|
|
75
|
+
if (!targetCell || targetCell.isEqualNode(activeCellRef.current)) return;
|
|
76
|
+
context.$publisher(context.topics.COMPONENT_HOVER, null);
|
|
77
|
+
context.$publisher(context.topics.COMPONENT_ACTIVE, {
|
|
78
|
+
id: targetCell.id,
|
|
79
|
+
cellNode: targetCell
|
|
80
|
+
});
|
|
81
|
+
}, {
|
|
82
|
+
target: simulatorRef
|
|
83
|
+
});
|
|
84
|
+
(0, _react.useEffect)(function () {
|
|
85
|
+
if (selectorRef.current && activeCellRef.current) setRect(simulatorRef.current, selectorRef.current, activeCellRef.current);
|
|
86
|
+
if (detectorRef.current && hoverCellRef.current) setRect(simulatorRef.current, detectorRef.current, hoverCellRef.current);
|
|
87
|
+
}, [size, scroll]);
|
|
88
|
+
(0, _react.useEffect)(function () {
|
|
89
|
+
var hcid = context.$subscriber(context.topics.COMPONENT_HOVER).on(function (payload) {
|
|
90
|
+
if (payload.id) {
|
|
91
|
+
detectorRef.current.style.display = 'block';
|
|
92
|
+
setRect(simulatorRef.current, detectorRef.current, payload.cellNode);
|
|
93
|
+
} else {
|
|
94
|
+
detectorRef.current.style.display = 'none';
|
|
95
|
+
}
|
|
96
|
+
}).watch();
|
|
97
|
+
var acid = context.$subscriber(context.topics.COMPONENT_ACTIVE).on(function (payload) {
|
|
98
|
+
if (payload.id) {
|
|
99
|
+
activeCellRef.current = payload.cellNode;
|
|
100
|
+
hoverCellRef.current = null;
|
|
101
|
+
selectorRef.current.style.display = 'block';
|
|
102
|
+
setRect(simulatorRef.current, selectorRef.current, payload.cellNode);
|
|
103
|
+
} else {
|
|
104
|
+
selectorRef.current.style.display = 'none';
|
|
105
|
+
}
|
|
106
|
+
}).watch();
|
|
107
|
+
return function () {
|
|
108
|
+
context.$unsubscriber(context.topics.COMPONENT_HOVER, hcid);
|
|
109
|
+
context.$unsubscriber(context.topics.COMPONENT_ACTIVE, acid);
|
|
110
|
+
};
|
|
111
|
+
}, [scroll]);
|
|
112
|
+
(0, _react.useEffect)(function () {
|
|
113
|
+
var moid = context.$subscriber(context.topics.MODAL_OPEN).on(function () {
|
|
114
|
+
simulatorRef.current.style['overflow-y'] = 'hidden';
|
|
115
|
+
}).watch();
|
|
116
|
+
var mcid = context.$subscriber(context.topics.MODAL_CLOSE).on(function () {
|
|
117
|
+
simulatorRef.current.style['overflow-y'] = 'auto';
|
|
118
|
+
}).watch();
|
|
119
|
+
return function () {
|
|
120
|
+
context.$unsubscriber(context.topics.MODAL_OPEN, moid);
|
|
121
|
+
context.$unsubscriber(context.topics.MODAL_CLOSE, mcid);
|
|
122
|
+
};
|
|
123
|
+
}, []);
|
|
124
|
+
(0, _react.useEffect)(function () {
|
|
125
|
+
var csid = context.$subscriber(context.topics.COMPONENT_SETTING_CLICK).on(function (_ref) {
|
|
126
|
+
var data = _ref.data;
|
|
127
|
+
if (!activeCellRef.current) {
|
|
128
|
+
_antd.message.info('请在右侧画布选择节点');
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (activeCellRef.current.getAttribute('name') !== 'box') {
|
|
132
|
+
_antd.message.info('该节点不支持添加子节点');
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
var json = require("../engine/meta/".concat(data.component.toLowerCase(), ".props.default.json"));
|
|
136
|
+
var _id = "".concat(data.component.toLowerCase(), "_").concat((0, _lcid.default)());
|
|
137
|
+
var cloneData = (0, _lodash.cloneDeep)(context.pageData);
|
|
138
|
+
(0, _dataProcess.add)(cloneData, activeCellRef.current.id, _id, json);
|
|
139
|
+
context._setPageData(cloneData);
|
|
140
|
+
setTimeout(function () {
|
|
141
|
+
context.$publisher(context.topics.COMPONENT_APPEND, {
|
|
142
|
+
id: _id,
|
|
143
|
+
pageData: (0, _lodash.cloneDeep)(cloneData)
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
}).watch();
|
|
147
|
+
return function () {
|
|
148
|
+
return context.$unsubscriber(context.topics.COMPONENT_SETTING_CLICK, csid);
|
|
149
|
+
};
|
|
150
|
+
}, [context.pageData]);
|
|
151
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
152
|
+
className: _design.default['lc-painter-design']
|
|
153
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
154
|
+
className: _design.default['lc-painter-design-toolbar']
|
|
155
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Select, {
|
|
156
|
+
size: "small",
|
|
157
|
+
defaultValue: "chinese",
|
|
158
|
+
className: _design.default['i18n-selecter'],
|
|
159
|
+
style: {
|
|
160
|
+
fontSize: 12
|
|
161
|
+
}
|
|
162
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Select.Option, {
|
|
163
|
+
value: "chinese"
|
|
164
|
+
}, "\u7B80\u4F53\u4E2D\u6587"), /*#__PURE__*/_react.default.createElement(_antd.Select.Option, {
|
|
165
|
+
value: "endlish"
|
|
166
|
+
}, "English")), /*#__PURE__*/_react.default.createElement("span", {
|
|
167
|
+
className: (0, _classnames.default)(_design.default['toolbar-item'], (0, _defineProperty2.default)({}, _design.default.actived, activedTarget === 'pc')),
|
|
168
|
+
onClick: function onClick() {
|
|
169
|
+
return setActivedTarget('pc');
|
|
170
|
+
}
|
|
171
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Icon, {
|
|
172
|
+
type: "laptop"
|
|
173
|
+
})), /*#__PURE__*/_react.default.createElement("span", {
|
|
174
|
+
className: (0, _classnames.default)(_design.default['toolbar-item'], (0, _defineProperty2.default)({}, _design.default.actived, activedTarget === 'mobile')),
|
|
175
|
+
onClick: function onClick() {
|
|
176
|
+
return setActivedTarget('mobile');
|
|
177
|
+
}
|
|
178
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Icon, {
|
|
179
|
+
type: "mobile"
|
|
180
|
+
})), /*#__PURE__*/_react.default.createElement(_antd.Divider, {
|
|
181
|
+
type: "vertical"
|
|
182
|
+
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
183
|
+
style: {
|
|
184
|
+
width: 'auto',
|
|
185
|
+
fontSize: 12
|
|
186
|
+
},
|
|
187
|
+
className: _design.default['toolbar-item'],
|
|
188
|
+
onClick: function onClick() {
|
|
189
|
+
context.$publisher(context.topics.COMPONENT_ACTIVE, {
|
|
190
|
+
id: _constants.CELL_KEY.PAGE_ROOT,
|
|
191
|
+
cellNode: context.componentMap.get(_constants.CELL_KEY.PAGE_ROOT).dom
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}, "\u9875\u9762\u5C5E\u6027"), /*#__PURE__*/_react.default.createElement(_antd.Divider, {
|
|
195
|
+
type: "vertical"
|
|
196
|
+
}), /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
197
|
+
size: "small",
|
|
198
|
+
type: "primary",
|
|
199
|
+
style: {
|
|
200
|
+
fontSize: 12
|
|
201
|
+
}
|
|
202
|
+
}, "\u4FDD\u5B58")), /*#__PURE__*/_react.default.createElement("div", {
|
|
203
|
+
className: _design.default['lc-painter-design-workspace']
|
|
204
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
205
|
+
id: "lc-detector",
|
|
206
|
+
ref: detectorRef,
|
|
207
|
+
className: _design.default['lc-painter-design-detector']
|
|
208
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
209
|
+
id: "lc-selector",
|
|
210
|
+
ref: selectorRef,
|
|
211
|
+
className: _design.default['lc-painter-design-selector']
|
|
212
|
+
}), /*#__PURE__*/_react.default.createElement(_Page.default, {
|
|
213
|
+
ref: simulatorRef,
|
|
214
|
+
pageCode: "mk2i87qb",
|
|
215
|
+
className: _design.default['lc-painter-design-simulator']
|
|
216
|
+
})));
|
|
217
|
+
};
|
|
218
|
+
var _default = exports.default = Design;
|