@luck-design-biz/luckda 0.0.25-15 → 0.0.25-16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/lowcode/engine/tools/usePageDataStore.js +15 -1
- package/es/lowcode/painter/components/PreviewIframe.js +8 -44
- package/es/lowcode/view/lc-components/PageLayout/FunctionDesign.js +18 -13
- package/es/lowcode/view/lc-components/PageLayout/index.js +1 -1
- package/lib/lowcode/engine/tools/usePageDataStore.js +15 -1
- package/lib/lowcode/painter/components/PreviewIframe.js +8 -45
- package/lib/lowcode/view/lc-components/PageLayout/FunctionDesign.js +17 -12
- package/lib/lowcode/view/lc-components/PageLayout/index.js +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import { create, createStore, useStore } from 'zustand';
|
|
|
5
5
|
import { immer } from 'zustand/middleware/immer';
|
|
6
6
|
import { subscribeWithSelector } from 'zustand/middleware';
|
|
7
7
|
import { useShallow } from 'zustand/react/shallow';
|
|
8
|
-
import { isObject, isArray, isNil, isFunction, isString, get, set as _set, unset, assign, forOwn, omit, debounce } from 'lodash';
|
|
8
|
+
import { isObject, isArray, isNil, isFunction, isString, get, set as _set, unset, assign, forOwn, forEach, omit, debounce } from 'lodash';
|
|
9
9
|
import isDeepEqual from 'fast-deep-equal';
|
|
10
10
|
import { getPathNodesById, findNodeAndParent } from "./dataProcess";
|
|
11
11
|
import { LC_BUILDIN_UNIT_KEY } from "../../constants";
|
|
@@ -245,6 +245,20 @@ export var modifyNode = function modifyNode(id, data) {
|
|
|
245
245
|
});
|
|
246
246
|
});
|
|
247
247
|
};
|
|
248
|
+
export var clearChildren = function clearChildren(id) {
|
|
249
|
+
usePageDataStore.setState(function (state) {
|
|
250
|
+
if (id === LC_BUILDIN_UNIT_KEY.PAGE_ROOT) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
var _ref4 = findNode(state.pageData, id) || {},
|
|
254
|
+
target = _ref4.target;
|
|
255
|
+
if (!target) return;
|
|
256
|
+
forEach(target.children, function (c) {
|
|
257
|
+
delete target[c];
|
|
258
|
+
});
|
|
259
|
+
delete target['children'];
|
|
260
|
+
});
|
|
261
|
+
};
|
|
248
262
|
export var useTask = function useTask(type) {
|
|
249
263
|
var promiseRef = useRef(null);
|
|
250
264
|
var task = useCallback(function () {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { createPortal } from 'react-dom';
|
|
4
|
-
import { useBoolean } from 'ahooks';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { getCreateHistoryOptions } from 'umi';
|
|
5
3
|
import styled from 'styled-components';
|
|
6
|
-
import
|
|
4
|
+
import { useCreation } from 'ahooks';
|
|
7
5
|
var Iframe = styled.iframe.withConfig({
|
|
8
6
|
displayName: "Iframe",
|
|
9
7
|
componentId: "luckda-6530__sc-cyloc5-0"
|
|
@@ -11,45 +9,11 @@ var Iframe = styled.iframe.withConfig({
|
|
|
11
9
|
var PreviewIframe = function PreviewIframe(_ref) {
|
|
12
10
|
var code = _ref.code,
|
|
13
11
|
userId = _ref.userId;
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
isMount = _useBoolean2[0],
|
|
18
|
-
setTrue = _useBoolean2[1].setTrue;
|
|
19
|
-
useEffect(function () {
|
|
20
|
-
var styles = Array.from(document.styleSheets).map(function (styleSheet) {
|
|
21
|
-
if (styleSheet.href) {
|
|
22
|
-
var link = document.createElement('link');
|
|
23
|
-
link.rel = 'stylesheet';
|
|
24
|
-
link.href = styleSheet.href;
|
|
25
|
-
return link;
|
|
26
|
-
} else {
|
|
27
|
-
try {
|
|
28
|
-
var style = document.createElement('style');
|
|
29
|
-
style.textContent = Array.from(styleSheet.cssRules).map(function (rule) {
|
|
30
|
-
return rule.cssText;
|
|
31
|
-
}).join('\n');
|
|
32
|
-
return style;
|
|
33
|
-
} catch (e) {
|
|
34
|
-
console.error(e);
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}).filter(Boolean);
|
|
39
|
-
styles.forEach(function (style) {
|
|
40
|
-
return ref.current.contentDocument.head.appendChild(style);
|
|
41
|
-
});
|
|
42
|
-
ref.current.contentDocument.body.setAttribute('luck-theme', 'base');
|
|
43
|
-
setTrue();
|
|
44
|
-
}, []);
|
|
12
|
+
var basename = useCreation(function () {
|
|
13
|
+
return getCreateHistoryOptions().basename;
|
|
14
|
+
});
|
|
45
15
|
return /*#__PURE__*/React.createElement(Iframe, {
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
id: "root"
|
|
49
|
-
}, /*#__PURE__*/React.createElement(Preview, {
|
|
50
|
-
code: code,
|
|
51
|
-
userId: userId,
|
|
52
|
-
debug: true
|
|
53
|
-
})), ref.current.contentDocument.body));
|
|
16
|
+
src: "".concat(basename === '/' ? '' : basename, "/byteman/preview?code=").concat(code, "&user=").concat(userId)
|
|
17
|
+
});
|
|
54
18
|
};
|
|
55
19
|
export default PreviewIframe;
|
|
@@ -5,8 +5,7 @@ var _excluded = ["children", "id", "display"];
|
|
|
5
5
|
import React, { useEffect } from 'react';
|
|
6
6
|
import { useCreation, useMemoizedFn } from 'ahooks';
|
|
7
7
|
import { suid } from '@luck-design-biz/base/utils';
|
|
8
|
-
import {
|
|
9
|
-
import { useContext, useGet, addNode, deleteNode } from "../../../engine/provider/ContextProvider";
|
|
8
|
+
import { useContext, useGet, addNode, clearChildren } from "../../../engine/provider/ContextProvider";
|
|
10
9
|
import Index from "./index";
|
|
11
10
|
import boxDefaultMeta from "../../../engine/meta/box.props.default.json";
|
|
12
11
|
var FunctionDesign = function FunctionDesign(_ref) {
|
|
@@ -19,18 +18,24 @@ var FunctionDesign = function FunctionDesign(_ref) {
|
|
|
19
18
|
id: id
|
|
20
19
|
});
|
|
21
20
|
var refreshChild = useMemoizedFn(function () {
|
|
22
|
-
var _current$children;
|
|
23
21
|
var ratioArr = display.split('');
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
var prevChildren = [];
|
|
23
|
+
for (var i in current.children) {
|
|
24
|
+
var _box$children;
|
|
25
|
+
var _box = current[current.children[i]];
|
|
26
|
+
if (_box !== null && _box !== void 0 && (_box$children = _box.children) !== null && _box$children !== void 0 && _box$children[0]) {
|
|
27
|
+
prevChildren.push([_box.children[0], _box[_box.children[0]].props]);
|
|
28
|
+
}
|
|
29
|
+
if (i === ratioArr.length - 1) break;
|
|
30
|
+
}
|
|
31
|
+
clearChildren(id);
|
|
32
|
+
ratioArr.forEach(function (_, i) {
|
|
33
|
+
var _boxId = "box_".concat(suid());
|
|
34
|
+
addNode(id, _boxId, _objectSpread(_objectSpread({}, boxDefaultMeta), {}, {
|
|
35
|
+
buildIn: true
|
|
36
|
+
}));
|
|
37
|
+
if (prevChildren[i]) {
|
|
38
|
+
addNode(_boxId, prevChildren[i][0], prevChildren[i][1]);
|
|
34
39
|
}
|
|
35
40
|
});
|
|
36
41
|
});
|
|
@@ -29,7 +29,7 @@ var LCPageLayout = function LCPageLayout(_ref) {
|
|
|
29
29
|
$css: css
|
|
30
30
|
}, display === 'tb' ? /*#__PURE__*/React.createElement(Layout.Main, null, (children === null || children === void 0 ? void 0 : children.length) === display.split('').length ? /*#__PURE__*/React.createElement(MemorySplit, {
|
|
31
31
|
split: "horizontal"
|
|
32
|
-
}, children
|
|
32
|
+
}, children) : null) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Layout.Sider, null, children === null || children === void 0 ? void 0 : children[0]), /*#__PURE__*/React.createElement(Layout.Main, null, (children === null || children === void 0 ? void 0 : children.length) === display.split('').length ? /*#__PURE__*/React.createElement(React.Fragment, null, display === 'lr' ? children === null || children === void 0 ? void 0 : children[1] : /*#__PURE__*/React.createElement(MemorySplit, {
|
|
33
33
|
split: display === 'ltb' ? 'horizontal' : 'vertical'
|
|
34
34
|
}, children === null || children === void 0 ? void 0 : children[1], children === null || children === void 0 ? void 0 : children[2])) : null))));
|
|
35
35
|
};
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.useTemporalStore = exports.useTask = exports.useGet = exports.resetPageData = exports.modifyNode = exports.getSelfAndParent = exports.getLevelNodes = exports.getCanUndoAndRedo = exports.deleteNode = exports.default = exports.addNode = void 0;
|
|
7
|
+
exports.useTemporalStore = exports.useTask = exports.useGet = exports.resetPageData = exports.modifyNode = exports.getSelfAndParent = exports.getLevelNodes = exports.getCanUndoAndRedo = exports.deleteNode = exports.default = exports.clearChildren = exports.addNode = void 0;
|
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
9
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
10
10
|
var _react = require("react");
|
|
@@ -252,6 +252,20 @@ var modifyNode = exports.modifyNode = function modifyNode(id, data) {
|
|
|
252
252
|
});
|
|
253
253
|
});
|
|
254
254
|
};
|
|
255
|
+
var clearChildren = exports.clearChildren = function clearChildren(id) {
|
|
256
|
+
usePageDataStore.setState(function (state) {
|
|
257
|
+
if (id === _constants.LC_BUILDIN_UNIT_KEY.PAGE_ROOT) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
var _ref4 = findNode(state.pageData, id) || {},
|
|
261
|
+
target = _ref4.target;
|
|
262
|
+
if (!target) return;
|
|
263
|
+
(0, _lodash.forEach)(target.children, function (c) {
|
|
264
|
+
delete target[c];
|
|
265
|
+
});
|
|
266
|
+
delete target['children'];
|
|
267
|
+
});
|
|
268
|
+
};
|
|
255
269
|
var useTask = exports.useTask = function useTask(type) {
|
|
256
270
|
var promiseRef = (0, _react.useRef)(null);
|
|
257
271
|
var task = (0, _react.useCallback)(function () {
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var _reactDom = require("react-dom");
|
|
12
|
-
var _ahooks = require("ahooks");
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _umi = require("umi");
|
|
13
10
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
14
|
-
var
|
|
11
|
+
var _ahooks = require("ahooks");
|
|
15
12
|
var Iframe = _styledComponents.default.iframe.withConfig({
|
|
16
13
|
displayName: "Iframe",
|
|
17
14
|
componentId: "luckda-6530__sc-cyloc5-0"
|
|
@@ -19,45 +16,11 @@ var Iframe = _styledComponents.default.iframe.withConfig({
|
|
|
19
16
|
var PreviewIframe = function PreviewIframe(_ref) {
|
|
20
17
|
var code = _ref.code,
|
|
21
18
|
userId = _ref.userId;
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
isMount = _useBoolean2[0],
|
|
26
|
-
setTrue = _useBoolean2[1].setTrue;
|
|
27
|
-
(0, _react.useEffect)(function () {
|
|
28
|
-
var styles = Array.from(document.styleSheets).map(function (styleSheet) {
|
|
29
|
-
if (styleSheet.href) {
|
|
30
|
-
var link = document.createElement('link');
|
|
31
|
-
link.rel = 'stylesheet';
|
|
32
|
-
link.href = styleSheet.href;
|
|
33
|
-
return link;
|
|
34
|
-
} else {
|
|
35
|
-
try {
|
|
36
|
-
var style = document.createElement('style');
|
|
37
|
-
style.textContent = Array.from(styleSheet.cssRules).map(function (rule) {
|
|
38
|
-
return rule.cssText;
|
|
39
|
-
}).join('\n');
|
|
40
|
-
return style;
|
|
41
|
-
} catch (e) {
|
|
42
|
-
console.error(e);
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}).filter(Boolean);
|
|
47
|
-
styles.forEach(function (style) {
|
|
48
|
-
return ref.current.contentDocument.head.appendChild(style);
|
|
49
|
-
});
|
|
50
|
-
ref.current.contentDocument.body.setAttribute('luck-theme', 'base');
|
|
51
|
-
setTrue();
|
|
52
|
-
}, []);
|
|
19
|
+
var basename = (0, _ahooks.useCreation)(function () {
|
|
20
|
+
return (0, _umi.getCreateHistoryOptions)().basename;
|
|
21
|
+
});
|
|
53
22
|
return /*#__PURE__*/_react.default.createElement(Iframe, {
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
id: "root"
|
|
57
|
-
}, /*#__PURE__*/_react.default.createElement(_preview.default, {
|
|
58
|
-
code: code,
|
|
59
|
-
userId: userId,
|
|
60
|
-
debug: true
|
|
61
|
-
})), ref.current.contentDocument.body));
|
|
23
|
+
src: "".concat(basename === '/' ? '' : basename, "/byteman/preview?code=").concat(code, "&user=").concat(userId)
|
|
24
|
+
});
|
|
62
25
|
};
|
|
63
26
|
var _default = exports.default = PreviewIframe;
|
|
@@ -12,7 +12,6 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _ahooks = require("ahooks");
|
|
14
14
|
var _utils = require("@luck-design-biz/base/utils");
|
|
15
|
-
var _lodash = require("lodash");
|
|
16
15
|
var _ContextProvider = require("../../../engine/provider/ContextProvider");
|
|
17
16
|
var _index = _interopRequireDefault(require("./index"));
|
|
18
17
|
var _boxPropsDefault = _interopRequireDefault(require("../../../engine/meta/box.props.default.json"));
|
|
@@ -27,18 +26,24 @@ var FunctionDesign = function FunctionDesign(_ref) {
|
|
|
27
26
|
id: id
|
|
28
27
|
});
|
|
29
28
|
var refreshChild = (0, _ahooks.useMemoizedFn)(function () {
|
|
30
|
-
var _current$children;
|
|
31
29
|
var ratioArr = display.split('');
|
|
32
|
-
|
|
33
|
-
(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
var prevChildren = [];
|
|
31
|
+
for (var i in current.children) {
|
|
32
|
+
var _box$children;
|
|
33
|
+
var _box = current[current.children[i]];
|
|
34
|
+
if (_box !== null && _box !== void 0 && (_box$children = _box.children) !== null && _box$children !== void 0 && _box$children[0]) {
|
|
35
|
+
prevChildren.push([_box.children[0], _box[_box.children[0]].props]);
|
|
36
|
+
}
|
|
37
|
+
if (i === ratioArr.length - 1) break;
|
|
38
|
+
}
|
|
39
|
+
(0, _ContextProvider.clearChildren)(id);
|
|
40
|
+
ratioArr.forEach(function (_, i) {
|
|
41
|
+
var _boxId = "box_".concat((0, _utils.suid)());
|
|
42
|
+
(0, _ContextProvider.addNode)(id, _boxId, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _boxPropsDefault.default), {}, {
|
|
43
|
+
buildIn: true
|
|
44
|
+
}));
|
|
45
|
+
if (prevChildren[i]) {
|
|
46
|
+
(0, _ContextProvider.addNode)(_boxId, prevChildren[i][0], prevChildren[i][1]);
|
|
42
47
|
}
|
|
43
48
|
});
|
|
44
49
|
});
|
|
@@ -37,7 +37,7 @@ var LCPageLayout = function LCPageLayout(_ref) {
|
|
|
37
37
|
$css: css
|
|
38
38
|
}, display === 'tb' ? /*#__PURE__*/_react.default.createElement(_base.Layout.Main, null, (children === null || children === void 0 ? void 0 : children.length) === display.split('').length ? /*#__PURE__*/_react.default.createElement(_base.MemorySplit, {
|
|
39
39
|
split: "horizontal"
|
|
40
|
-
}, children
|
|
40
|
+
}, children) : null) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_base.Layout.Sider, null, children === null || children === void 0 ? void 0 : children[0]), /*#__PURE__*/_react.default.createElement(_base.Layout.Main, null, (children === null || children === void 0 ? void 0 : children.length) === display.split('').length ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, display === 'lr' ? children === null || children === void 0 ? void 0 : children[1] : /*#__PURE__*/_react.default.createElement(_base.MemorySplit, {
|
|
41
41
|
split: display === 'ltb' ? 'horizontal' : 'vertical'
|
|
42
42
|
}, children === null || children === void 0 ? void 0 : children[1], children === null || children === void 0 ? void 0 : children[2])) : null))));
|
|
43
43
|
};
|
package/package.json
CHANGED