@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,263 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
4
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
5
|
+
import * as LZString from 'lz-string';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 数据压缩
|
|
9
|
+
* @param {JSON} data
|
|
10
|
+
* @returns 加密后的字符串
|
|
11
|
+
*/
|
|
12
|
+
export function compress(data) {
|
|
13
|
+
// 将对象转换为JSON字符串
|
|
14
|
+
var jsonString = JSON.stringify(data);
|
|
15
|
+
// 使用LZ-String压缩JSON字符串
|
|
16
|
+
return LZString.compressToUTF16(jsonString);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 数据解压
|
|
21
|
+
* @param {string} compressedData
|
|
22
|
+
* @returns {json}
|
|
23
|
+
*/
|
|
24
|
+
export function decompress(compressedData) {
|
|
25
|
+
// 使用LZ-String解压数据
|
|
26
|
+
var jsonString = LZString.decompressFromUTF16(compressedData);
|
|
27
|
+
// 将JSON字符串转换回对象
|
|
28
|
+
return JSON.parse(jsonString);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 查找指定ID的节点及其父节点。
|
|
33
|
+
*
|
|
34
|
+
* @param {string} id - 要查找的节点ID。
|
|
35
|
+
* @param {Object} current - 当前遍历的JSON对象。
|
|
36
|
+
* @param {Object|null} parent - 当前节点的父节点。
|
|
37
|
+
* @returns {{node: Object|null, parent: Object|null}} 查找结果,包含节点和其父节点。
|
|
38
|
+
*/
|
|
39
|
+
export function findNodeAndParent(id, current) {
|
|
40
|
+
var parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
41
|
+
if (!parent && current.props.id === id) {
|
|
42
|
+
return {
|
|
43
|
+
node: current,
|
|
44
|
+
parent: null
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (current.hasOwnProperty('children') && current.children.includes(id)) {
|
|
48
|
+
return {
|
|
49
|
+
node: current[id],
|
|
50
|
+
parent: current
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
for (var key in current) {
|
|
54
|
+
if (current[key] && _typeof(current[key]) === 'object' && key !== 'props' && key !== 'children') {
|
|
55
|
+
var result = findNodeAndParent(id, current[key], current);
|
|
56
|
+
if (result.node) {
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
node: null,
|
|
63
|
+
parent: null
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 对指定的JSON结构进行节点的添加、修改或删除操作。
|
|
69
|
+
*
|
|
70
|
+
* @param {Object} json - 要操作的JSON对象。
|
|
71
|
+
* @param {string|null} path - 要操作的节点路径,使用'/'分隔。
|
|
72
|
+
* @param {string} id - 操作节点的唯一标识符。
|
|
73
|
+
* @param {Object|null} data - 要添加或修改的数据。如果为null,表示删除操作。
|
|
74
|
+
*/
|
|
75
|
+
function process(json, path, id, data) {
|
|
76
|
+
if (!json) {
|
|
77
|
+
throw new Error("json can not be null");
|
|
78
|
+
}
|
|
79
|
+
if (path && id && data) {
|
|
80
|
+
var paths = path.split('/').filter(function (p) {
|
|
81
|
+
return p;
|
|
82
|
+
});
|
|
83
|
+
var current = json;
|
|
84
|
+
var _iterator = _createForOfIteratorHelper(paths),
|
|
85
|
+
_step;
|
|
86
|
+
try {
|
|
87
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
88
|
+
var p = _step.value;
|
|
89
|
+
if (!current[p]) {
|
|
90
|
+
throw new Error("Path \"".concat(paths.join('/'), "\" does not exist."));
|
|
91
|
+
}
|
|
92
|
+
if (!current[p].hasOwnProperty('children')) {
|
|
93
|
+
current[p]['children'] = [];
|
|
94
|
+
}
|
|
95
|
+
current = current[p];
|
|
96
|
+
}
|
|
97
|
+
} catch (err) {
|
|
98
|
+
_iterator.e(err);
|
|
99
|
+
} finally {
|
|
100
|
+
_iterator.f();
|
|
101
|
+
}
|
|
102
|
+
if (!current.children.includes(id)) {
|
|
103
|
+
current.children.push(id);
|
|
104
|
+
}
|
|
105
|
+
current[id] = {
|
|
106
|
+
props: _objectSpread(_objectSpread({}, data), {}, {
|
|
107
|
+
id: id,
|
|
108
|
+
parentId: current.id
|
|
109
|
+
})
|
|
110
|
+
};
|
|
111
|
+
} else if (!path && id && data) {
|
|
112
|
+
var _findNodeAndParent = findNodeAndParent(id, json),
|
|
113
|
+
node = _findNodeAndParent.node;
|
|
114
|
+
if (node) {
|
|
115
|
+
node.props = _objectSpread(_objectSpread({}, data), {}, {
|
|
116
|
+
id: id
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
throw new Error("Node with id \"".concat(id, "\" does not exist."));
|
|
120
|
+
}
|
|
121
|
+
} else if (!path && id && !data) {
|
|
122
|
+
var _findNodeAndParent2 = findNodeAndParent(id, json),
|
|
123
|
+
_node = _findNodeAndParent2.node,
|
|
124
|
+
parent = _findNodeAndParent2.parent;
|
|
125
|
+
if (_node && parent) {
|
|
126
|
+
parent.children = parent.children.filter(function (childId) {
|
|
127
|
+
return childId !== id;
|
|
128
|
+
});
|
|
129
|
+
if (parent.children.length === 0) {
|
|
130
|
+
delete parent['children'];
|
|
131
|
+
}
|
|
132
|
+
delete parent[id];
|
|
133
|
+
} else {
|
|
134
|
+
throw new Error("Node with id \"".concat(id, "\" does not exist."));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 对指定的JSON结构进行节点的添加操作。
|
|
141
|
+
*
|
|
142
|
+
* @param {Object} json - 要操作的JSON对象。
|
|
143
|
+
* @param {string} parentId - 父节点的唯一标识符。
|
|
144
|
+
* @param {string} id - 操作节点的唯一标识符。
|
|
145
|
+
* @param {Object|null} data - 要添加或修改的数据。如果为null,表示删除操作。
|
|
146
|
+
*/
|
|
147
|
+
export function add(json, parentId, id, data) {
|
|
148
|
+
process(json, getPathById(json, parentId), id, data);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* 对指定的JSON结构进行节点的修改操作。
|
|
153
|
+
*
|
|
154
|
+
* @param {Object} json - 要操作的JSON对象。
|
|
155
|
+
* @param {string} id - 操作节点的唯一标识符。
|
|
156
|
+
* @param {Object|null} data - 要添加或修改的数据。如果为null,表示删除操作。
|
|
157
|
+
*/
|
|
158
|
+
export function modifyById(json, id, data) {
|
|
159
|
+
process(json, null, id, data);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* 删除指定id的节点。
|
|
164
|
+
*
|
|
165
|
+
* @param {Object} json - JSON对象。
|
|
166
|
+
* @param {string} id - 要删除的节点ID。
|
|
167
|
+
*/
|
|
168
|
+
export function deleteById(json, id) {
|
|
169
|
+
process(json, null, id);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 根据ID在给定的JSON结构中查找节点的路径。
|
|
174
|
+
*
|
|
175
|
+
* @param {Object} json - 要搜索的JSON对象。
|
|
176
|
+
* @param {string} id - 要查找的节点ID。
|
|
177
|
+
* @param {string} currentPath - 当前递归到的路径,用于构建返回的路径字符串。
|
|
178
|
+
* @returns {string|null} 如果找到节点,返回节点的路径;否则返回null。
|
|
179
|
+
*/
|
|
180
|
+
export function getPathById(json, id) {
|
|
181
|
+
var currentPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
182
|
+
for (var key in json) {
|
|
183
|
+
var newPath = currentPath ? "".concat(currentPath, "/").concat(key) : key;
|
|
184
|
+
if (json[key].props && json[key].props.id === id) {
|
|
185
|
+
return newPath;
|
|
186
|
+
}
|
|
187
|
+
if (json[key].hasOwnProperty('children')) {
|
|
188
|
+
var result = getPathById(json[key], id, newPath);
|
|
189
|
+
if (result) {
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* 在给定的JSON结构中搜索具有特定id的节点,并返回包含该节点及其所有父节点的props属性的路径数组。
|
|
199
|
+
*
|
|
200
|
+
* @param {Object} data - 待搜索的JSON对象,它代表了一个复杂的树状结构,每个节点都可能有props和children属性。
|
|
201
|
+
* @param {string} targetId - 需要找到的目标节点的id。
|
|
202
|
+
* @returns {Array<Object>} 一个包含目标节点及其所有父节点的props属性的数组。如果未找到目标节点,则返回空数组。
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* const data = {
|
|
206
|
+
* props: {
|
|
207
|
+
* id: 'page_root',
|
|
208
|
+
* type: 'Page',
|
|
209
|
+
* name: '页面',
|
|
210
|
+
* hasHeder: true,
|
|
211
|
+
* hasFooter: true,
|
|
212
|
+
* },
|
|
213
|
+
* // ...其他节点
|
|
214
|
+
* };
|
|
215
|
+
*
|
|
216
|
+
* const path = getPathNodesById(data, 'form_jknbjkun');
|
|
217
|
+
* console.log(path);
|
|
218
|
+
* // 输出目标节点及其所有父节点的props属性的数组
|
|
219
|
+
*/
|
|
220
|
+
export function getPathNodesById(data, targetId) {
|
|
221
|
+
// 初始化结果数组
|
|
222
|
+
var result = [];
|
|
223
|
+
|
|
224
|
+
// 定义递归函数以搜索路径
|
|
225
|
+
function search(node) {
|
|
226
|
+
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
227
|
+
// 检查当前节点是否是目标节点
|
|
228
|
+
if (node && node.props && node.props.id === targetId) {
|
|
229
|
+
// 如果是,将当前路径和节点自身添加到结果中
|
|
230
|
+
result = [].concat(_toConsumableArray(path), [node.props]);
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// 遍历子节点
|
|
235
|
+
if (node && node.children) {
|
|
236
|
+
var _iterator2 = _createForOfIteratorHelper(node.children),
|
|
237
|
+
_step2;
|
|
238
|
+
try {
|
|
239
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
240
|
+
var childId = _step2.value;
|
|
241
|
+
// 对每个子节点,首先尝试从当前节点获取子节点数据
|
|
242
|
+
var childNode = node[childId];
|
|
243
|
+
if (search(childNode, [].concat(_toConsumableArray(path), [node.props]))) {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
} catch (err) {
|
|
248
|
+
_iterator2.e(err);
|
|
249
|
+
} finally {
|
|
250
|
+
_iterator2.f();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// 从顶层"data"对象开始搜索
|
|
257
|
+
if (search(data)) {
|
|
258
|
+
return result;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// 如果未找到目标节点,返回空数组
|
|
262
|
+
return [];
|
|
263
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
var chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
|
|
3
|
+
export default function generateShortUuid() {
|
|
4
|
+
var toLowerCase = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
5
|
+
var shortBuffer = '';
|
|
6
|
+
var uuid = uuidv4().replace(/-/g, '');
|
|
7
|
+
for (var i = 0; i < 8; i++) {
|
|
8
|
+
var str = uuid.substring(i * 4, i * 4 + 4);
|
|
9
|
+
var x = parseInt(str, 16);
|
|
10
|
+
shortBuffer += chars[x % 0x3e];
|
|
11
|
+
}
|
|
12
|
+
if (toLowerCase) {
|
|
13
|
+
return shortBuffer.toLowerCase();
|
|
14
|
+
}
|
|
15
|
+
return shortBuffer;
|
|
16
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
|
+
import { Icon, Input, Tabs } from 'luck-design/antd';
|
|
5
|
+
import { useMemoizedFn, useCreation } from 'ahooks';
|
|
6
|
+
import { formatMessage } from '@luck-design-biz/base/utils';
|
|
7
|
+
import { useLDContext } from "../engine/provider/ContextProvider";
|
|
8
|
+
import styles from "./style/components.less";
|
|
9
|
+
import data from "../engine/meta/components-list.json";
|
|
10
|
+
var TabPane = Tabs.TabPane;
|
|
11
|
+
var Search = Input.Search;
|
|
12
|
+
var BaseCom = function BaseCom(_ref) {
|
|
13
|
+
var onComponentClick = _ref.onComponentClick;
|
|
14
|
+
var _useState = useState(''),
|
|
15
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
16
|
+
searchTerm = _useState2[0],
|
|
17
|
+
setSearchTerm = _useState2[1];
|
|
18
|
+
var handleSearch = useMemoizedFn(function (e) {
|
|
19
|
+
setSearchTerm(e.target.value.toLowerCase());
|
|
20
|
+
});
|
|
21
|
+
var filteredData = useCreation(function () {
|
|
22
|
+
return data.map(function (group) {
|
|
23
|
+
return _objectSpread(_objectSpread({}, group), {}, {
|
|
24
|
+
components: group.components.filter(function (item) {
|
|
25
|
+
return item.name.toLowerCase().includes(searchTerm) || item.desc.toLowerCase().includes(searchTerm);
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
}).filter(function (group) {
|
|
29
|
+
return group.components.length > 0;
|
|
30
|
+
});
|
|
31
|
+
}, [data]);
|
|
32
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
className: styles['components-search']
|
|
34
|
+
}, /*#__PURE__*/React.createElement(Search, {
|
|
35
|
+
placeholder: formatMessage({
|
|
36
|
+
id: 'luckda.lowcode.painter.components.search',
|
|
37
|
+
label: '搜索组件'
|
|
38
|
+
}),
|
|
39
|
+
onChange: handleSearch
|
|
40
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
41
|
+
className: styles['components-content']
|
|
42
|
+
}, filteredData.map(function (group) {
|
|
43
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
44
|
+
key: group.group,
|
|
45
|
+
className: styles['components-wrapper']
|
|
46
|
+
}, /*#__PURE__*/React.createElement("h3", null, group.groupName), group.components.map(function (item) {
|
|
47
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
key: item.component,
|
|
49
|
+
className: styles['components-item'],
|
|
50
|
+
onClick: function onClick() {
|
|
51
|
+
return onComponentClick(item);
|
|
52
|
+
}
|
|
53
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
54
|
+
className: styles['icon-wrapper']
|
|
55
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
56
|
+
type: item.icon || 'home'
|
|
57
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
className: styles['text-content']
|
|
59
|
+
}, /*#__PURE__*/React.createElement("span", null, item.name)));
|
|
60
|
+
}));
|
|
61
|
+
})));
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 组件清单
|
|
66
|
+
*/
|
|
67
|
+
var Components = function Components(_ref2) {
|
|
68
|
+
var _ref2$dataset = _ref2.dataset,
|
|
69
|
+
dataset = _ref2$dataset === void 0 ? 'test' : _ref2$dataset;
|
|
70
|
+
var context = useLDContext();
|
|
71
|
+
var onComponentClick = useMemoizedFn(function (data) {
|
|
72
|
+
context.$publisher(context.topics.COMPONENT_SETTING_CLICK, {
|
|
73
|
+
data: data
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
if (!dataset) return /*#__PURE__*/React.createElement("div", {
|
|
77
|
+
className: styles['lc-painter-components'],
|
|
78
|
+
style: {
|
|
79
|
+
paddingTop: '16px'
|
|
80
|
+
}
|
|
81
|
+
}, /*#__PURE__*/React.createElement(BaseCom, {
|
|
82
|
+
onComponentClick: onComponentClick
|
|
83
|
+
}));
|
|
84
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
85
|
+
className: styles['lc-painter-components']
|
|
86
|
+
}, /*#__PURE__*/React.createElement(Tabs, {
|
|
87
|
+
defaultActiveKey: "base"
|
|
88
|
+
}, /*#__PURE__*/React.createElement(TabPane, {
|
|
89
|
+
tab: formatMessage({
|
|
90
|
+
id: 'ccm.dev.page.set.components.base',
|
|
91
|
+
label: '基础组件'
|
|
92
|
+
}),
|
|
93
|
+
key: "base"
|
|
94
|
+
}, /*#__PURE__*/React.createElement(BaseCom, {
|
|
95
|
+
onComponentClick: onComponentClick
|
|
96
|
+
})), /*#__PURE__*/React.createElement(TabPane, {
|
|
97
|
+
tab: formatMessage({
|
|
98
|
+
id: 'ccm.dev.page.set.components.dataset',
|
|
99
|
+
label: '数据集字段'
|
|
100
|
+
}),
|
|
101
|
+
key: "dataset"
|
|
102
|
+
})));
|
|
103
|
+
};
|
|
104
|
+
export default Components;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import React, { useRef, useEffect, useState } from 'react';
|
|
4
|
+
import { useEventListener, useSize, useScroll } from 'ahooks';
|
|
5
|
+
import { Select, Button, Icon, Divider, message } from 'luck-design/antd';
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
import { cloneDeep } from 'lodash';
|
|
8
|
+
import { useLDContext } from "../engine/provider/ContextProvider";
|
|
9
|
+
import Page from "../view/Page";
|
|
10
|
+
import { add } from "../engine/tools/dataProcess";
|
|
11
|
+
import generateShortUuid from "../engine/tools/lcid";
|
|
12
|
+
import { CELL_KEY, CELL_CLASS_NAME } from "../constants";
|
|
13
|
+
import styles from "./style/design.less";
|
|
14
|
+
var setRect = function setRect(page, node, cellNode) {
|
|
15
|
+
var _page$getBoundingClie = page.getBoundingClientRect(),
|
|
16
|
+
pageLeft = _page$getBoundingClie.left,
|
|
17
|
+
pageTop = _page$getBoundingClie.top;
|
|
18
|
+
var _cellNode$getBounding = cellNode.getBoundingClientRect(),
|
|
19
|
+
cellNodeLeft = _cellNode$getBounding.left,
|
|
20
|
+
cellNodeTop = _cellNode$getBounding.top;
|
|
21
|
+
node.style.left = "".concat(cellNodeLeft - pageLeft, "px");
|
|
22
|
+
node.style.top = "".concat(cellNodeTop - pageTop, "px");
|
|
23
|
+
node.style.width = "".concat(cellNode.offsetWidth, "px");
|
|
24
|
+
node.style.height = "".concat(cellNode.offsetHeight, "px");
|
|
25
|
+
};
|
|
26
|
+
var Design = function Design() {
|
|
27
|
+
var context = useLDContext();
|
|
28
|
+
var detectorRef = useRef(null);
|
|
29
|
+
var selectorRef = useRef(null);
|
|
30
|
+
var simulatorRef = useRef(null);
|
|
31
|
+
var hoverCellRef = useRef(null);
|
|
32
|
+
var activeCellRef = useRef(null);
|
|
33
|
+
var size = useSize(simulatorRef);
|
|
34
|
+
var scroll = useScroll(simulatorRef);
|
|
35
|
+
var _useState = useState('pc'),
|
|
36
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
37
|
+
activedTarget = _useState2[0],
|
|
38
|
+
setActivedTarget = _useState2[1];
|
|
39
|
+
useEventListener('mousemove', function (event) {
|
|
40
|
+
var elem = event.target;
|
|
41
|
+
var targetCell = elem.closest(".".concat(CELL_CLASS_NAME));
|
|
42
|
+
if (targetCell && !targetCell.isEqualNode(hoverCellRef.current) && !targetCell.isEqualNode(activeCellRef.current)) {
|
|
43
|
+
var _id = targetCell.id;
|
|
44
|
+
hoverCellRef.current = targetCell;
|
|
45
|
+
context.$publisher(context.topics.COMPONENT_HOVER, {
|
|
46
|
+
id: _id,
|
|
47
|
+
cellNode: targetCell
|
|
48
|
+
});
|
|
49
|
+
} else if (!targetCell || targetCell.isEqualNode(activeCellRef.current)) {
|
|
50
|
+
hoverCellRef.current = null;
|
|
51
|
+
context.$publisher(context.topics.COMPONENT_HOVER, null);
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
target: simulatorRef
|
|
55
|
+
});
|
|
56
|
+
useEventListener('mouseleave', function () {
|
|
57
|
+
if (hoverCellRef.current) {
|
|
58
|
+
hoverCellRef.current = null;
|
|
59
|
+
context.$publisher(context.topics.COMPONENT_HOVER, null);
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
target: simulatorRef
|
|
63
|
+
});
|
|
64
|
+
useEventListener('click', function (event) {
|
|
65
|
+
var elem = event.target;
|
|
66
|
+
var targetCell = elem.closest(".".concat(CELL_CLASS_NAME));
|
|
67
|
+
if (!targetCell || targetCell.isEqualNode(activeCellRef.current)) return;
|
|
68
|
+
context.$publisher(context.topics.COMPONENT_HOVER, null);
|
|
69
|
+
context.$publisher(context.topics.COMPONENT_ACTIVE, {
|
|
70
|
+
id: targetCell.id,
|
|
71
|
+
cellNode: targetCell
|
|
72
|
+
});
|
|
73
|
+
}, {
|
|
74
|
+
target: simulatorRef
|
|
75
|
+
});
|
|
76
|
+
useEffect(function () {
|
|
77
|
+
if (selectorRef.current && activeCellRef.current) setRect(simulatorRef.current, selectorRef.current, activeCellRef.current);
|
|
78
|
+
if (detectorRef.current && hoverCellRef.current) setRect(simulatorRef.current, detectorRef.current, hoverCellRef.current);
|
|
79
|
+
}, [size, scroll]);
|
|
80
|
+
useEffect(function () {
|
|
81
|
+
var hcid = context.$subscriber(context.topics.COMPONENT_HOVER).on(function (payload) {
|
|
82
|
+
if (payload.id) {
|
|
83
|
+
detectorRef.current.style.display = 'block';
|
|
84
|
+
setRect(simulatorRef.current, detectorRef.current, payload.cellNode);
|
|
85
|
+
} else {
|
|
86
|
+
detectorRef.current.style.display = 'none';
|
|
87
|
+
}
|
|
88
|
+
}).watch();
|
|
89
|
+
var acid = context.$subscriber(context.topics.COMPONENT_ACTIVE).on(function (payload) {
|
|
90
|
+
if (payload.id) {
|
|
91
|
+
activeCellRef.current = payload.cellNode;
|
|
92
|
+
hoverCellRef.current = null;
|
|
93
|
+
selectorRef.current.style.display = 'block';
|
|
94
|
+
setRect(simulatorRef.current, selectorRef.current, payload.cellNode);
|
|
95
|
+
} else {
|
|
96
|
+
selectorRef.current.style.display = 'none';
|
|
97
|
+
}
|
|
98
|
+
}).watch();
|
|
99
|
+
return function () {
|
|
100
|
+
context.$unsubscriber(context.topics.COMPONENT_HOVER, hcid);
|
|
101
|
+
context.$unsubscriber(context.topics.COMPONENT_ACTIVE, acid);
|
|
102
|
+
};
|
|
103
|
+
}, [scroll]);
|
|
104
|
+
useEffect(function () {
|
|
105
|
+
var moid = context.$subscriber(context.topics.MODAL_OPEN).on(function () {
|
|
106
|
+
simulatorRef.current.style['overflow-y'] = 'hidden';
|
|
107
|
+
}).watch();
|
|
108
|
+
var mcid = context.$subscriber(context.topics.MODAL_CLOSE).on(function () {
|
|
109
|
+
simulatorRef.current.style['overflow-y'] = 'auto';
|
|
110
|
+
}).watch();
|
|
111
|
+
return function () {
|
|
112
|
+
context.$unsubscriber(context.topics.MODAL_OPEN, moid);
|
|
113
|
+
context.$unsubscriber(context.topics.MODAL_CLOSE, mcid);
|
|
114
|
+
};
|
|
115
|
+
}, []);
|
|
116
|
+
useEffect(function () {
|
|
117
|
+
var csid = context.$subscriber(context.topics.COMPONENT_SETTING_CLICK).on(function (_ref) {
|
|
118
|
+
var data = _ref.data;
|
|
119
|
+
if (!activeCellRef.current) {
|
|
120
|
+
message.info('请在右侧画布选择节点');
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (activeCellRef.current.getAttribute('name') !== 'box') {
|
|
124
|
+
message.info('该节点不支持添加子节点');
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
var json = require("../engine/meta/".concat(data.component.toLowerCase(), ".props.default.json"));
|
|
128
|
+
var _id = "".concat(data.component.toLowerCase(), "_").concat(generateShortUuid());
|
|
129
|
+
var cloneData = cloneDeep(context.pageData);
|
|
130
|
+
add(cloneData, activeCellRef.current.id, _id, json);
|
|
131
|
+
context._setPageData(cloneData);
|
|
132
|
+
setTimeout(function () {
|
|
133
|
+
context.$publisher(context.topics.COMPONENT_APPEND, {
|
|
134
|
+
id: _id,
|
|
135
|
+
pageData: cloneDeep(cloneData)
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
}).watch();
|
|
139
|
+
return function () {
|
|
140
|
+
return context.$unsubscriber(context.topics.COMPONENT_SETTING_CLICK, csid);
|
|
141
|
+
};
|
|
142
|
+
}, [context.pageData]);
|
|
143
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
144
|
+
className: styles['lc-painter-design']
|
|
145
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
146
|
+
className: styles['lc-painter-design-toolbar']
|
|
147
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
148
|
+
size: "small",
|
|
149
|
+
defaultValue: "chinese",
|
|
150
|
+
className: styles['i18n-selecter'],
|
|
151
|
+
style: {
|
|
152
|
+
fontSize: 12
|
|
153
|
+
}
|
|
154
|
+
}, /*#__PURE__*/React.createElement(Select.Option, {
|
|
155
|
+
value: "chinese"
|
|
156
|
+
}, "\u7B80\u4F53\u4E2D\u6587"), /*#__PURE__*/React.createElement(Select.Option, {
|
|
157
|
+
value: "endlish"
|
|
158
|
+
}, "English")), /*#__PURE__*/React.createElement("span", {
|
|
159
|
+
className: classNames(styles['toolbar-item'], _defineProperty({}, styles.actived, activedTarget === 'pc')),
|
|
160
|
+
onClick: function onClick() {
|
|
161
|
+
return setActivedTarget('pc');
|
|
162
|
+
}
|
|
163
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
164
|
+
type: "laptop"
|
|
165
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
166
|
+
className: classNames(styles['toolbar-item'], _defineProperty({}, styles.actived, activedTarget === 'mobile')),
|
|
167
|
+
onClick: function onClick() {
|
|
168
|
+
return setActivedTarget('mobile');
|
|
169
|
+
}
|
|
170
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
171
|
+
type: "mobile"
|
|
172
|
+
})), /*#__PURE__*/React.createElement(Divider, {
|
|
173
|
+
type: "vertical"
|
|
174
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
175
|
+
style: {
|
|
176
|
+
width: 'auto',
|
|
177
|
+
fontSize: 12
|
|
178
|
+
},
|
|
179
|
+
className: styles['toolbar-item'],
|
|
180
|
+
onClick: function onClick() {
|
|
181
|
+
context.$publisher(context.topics.COMPONENT_ACTIVE, {
|
|
182
|
+
id: CELL_KEY.PAGE_ROOT,
|
|
183
|
+
cellNode: context.componentMap.get(CELL_KEY.PAGE_ROOT).dom
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}, "\u9875\u9762\u5C5E\u6027"), /*#__PURE__*/React.createElement(Divider, {
|
|
187
|
+
type: "vertical"
|
|
188
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
189
|
+
size: "small",
|
|
190
|
+
type: "primary",
|
|
191
|
+
style: {
|
|
192
|
+
fontSize: 12
|
|
193
|
+
}
|
|
194
|
+
}, "\u4FDD\u5B58")), /*#__PURE__*/React.createElement("div", {
|
|
195
|
+
className: styles['lc-painter-design-workspace']
|
|
196
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
197
|
+
id: "lc-detector",
|
|
198
|
+
ref: detectorRef,
|
|
199
|
+
className: styles['lc-painter-design-detector']
|
|
200
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
201
|
+
id: "lc-selector",
|
|
202
|
+
ref: selectorRef,
|
|
203
|
+
className: styles['lc-painter-design-selector']
|
|
204
|
+
}), /*#__PURE__*/React.createElement(Page, {
|
|
205
|
+
ref: simulatorRef,
|
|
206
|
+
pageCode: "mk2i87qb",
|
|
207
|
+
className: styles['lc-painter-design-simulator']
|
|
208
|
+
})));
|
|
209
|
+
};
|
|
210
|
+
export default Design;
|