@luck-design-biz/luckda 0.0.25-1 → 0.0.25-2
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/locales/zh-CN.js +9 -0
- package/es/lowcode/constants/api-url.js +184 -100
- package/es/lowcode/constants/index.js +2 -1
- package/es/lowcode/engine/meta/box.props.default.json +1 -1
- package/es/lowcode/engine/meta/box.props.json +1 -1
- package/es/lowcode/engine/meta/button.props.json +1 -1
- package/es/lowcode/engine/meta/cardlist.props.json +1 -1
- package/es/lowcode/engine/meta/components-list.json +1 -1
- package/es/lowcode/engine/meta/dialog.props.json +1 -1
- package/es/lowcode/engine/meta/drawer.props.json +1 -1
- package/es/lowcode/engine/meta/form.props.default.json +4 -5
- package/es/lowcode/engine/meta/form.props.json +33 -30
- package/es/lowcode/engine/meta/image.props.json +2 -2
- package/es/lowcode/engine/meta/imex.props.json +1 -1
- package/es/lowcode/engine/meta/link.props.json +1 -1
- package/es/lowcode/engine/meta/section.props.default.json +4 -6
- package/es/lowcode/engine/meta/section.props.json +52 -49
- package/es/lowcode/engine/meta/text.props.json +2 -2
- package/es/lowcode/engine/meta/tree.props.json +2 -2
- package/es/lowcode/engine/provider/ContextProvider/index.js +10 -2
- package/es/lowcode/engine/provider/RemoteSourceProvider.js +28 -15
- package/es/lowcode/engine/tools/helper.js +23 -21
- package/es/lowcode/engine/tools/useCanvasRender.js +5 -7
- package/es/lowcode/engine/tools/usePromiseState.js +23 -14
- package/es/lowcode/painter/Design.js +34 -2
- package/es/lowcode/painter/DesignOperator.js +6 -8
- package/es/lowcode/painter/DesignToolbar.js +258 -21
- package/es/lowcode/painter/Panel.js +8 -9
- package/es/lowcode/painter/components/AttrsPanel.js +6 -6
- package/es/lowcode/painter/components/DragDrop/DragDropWrapper.js +5 -2
- package/es/lowcode/painter/components/ListEditor.js +8 -2
- package/es/lowcode/painter/components/field-setting/BatchSetting.js +13 -3
- package/es/lowcode/painter/components/field-setting/SettingUI.js +26 -7
- package/es/lowcode/painter/components/field-setting/index.js +18 -8
- package/es/lowcode/painter/index.js +1 -28
- package/es/lowcode/painter/panel-section/ActionsColumnWidth.js +25 -0
- package/es/lowcode/painter/panel-section/BlockEditor/index.js +7 -4
- package/es/lowcode/painter/panel-section/BlocksEditor/BlockEditorItem.js +4 -3
- package/es/lowcode/painter/panel-section/BlocksEditor/index.js +48 -15
- package/es/lowcode/painter/panel-section/FieldsSetting.js +48 -27
- package/es/lowcode/painter/panel-section/I18nInput.js +20 -0
- package/es/lowcode/painter/style/design.less +6 -2
- package/es/lowcode/painter/style/list-editor.less +36 -0
- package/es/lowcode/preview/index.js +17 -4
- package/es/lowcode/view/lc-components/Box/meta.json +1 -1
- package/es/lowcode/view/lc-components/Button/meta.json +1 -1
- package/es/lowcode/view/lc-components/CardList/meta.json +1 -1
- package/es/lowcode/view/lc-components/Dialog/FunctionDesign.js +2 -4
- package/es/lowcode/view/lc-components/Dialog/meta.json +1 -1
- package/es/lowcode/view/lc-components/Drawer/meta.json +1 -1
- package/es/lowcode/view/lc-components/Form/FunctionDesign.js +66 -4
- package/es/lowcode/view/lc-components/Form/index.js +232 -61
- package/es/lowcode/view/lc-components/Form/meta.json +33 -30
- package/es/lowcode/view/lc-components/ImEx/meta.json +1 -1
- package/es/lowcode/view/lc-components/Image/meta.json +2 -2
- package/es/lowcode/view/lc-components/Layout/FunctionDesign.js +6 -7
- package/es/lowcode/view/lc-components/Link/meta.json +1 -1
- package/es/lowcode/view/lc-components/Section/FunctionDesign.js +31 -2
- package/es/lowcode/view/lc-components/Section/index.js +114 -24
- package/es/lowcode/view/lc-components/Section/index.less +7 -0
- package/es/lowcode/view/lc-components/Section/meta.json +48 -49
- package/es/lowcode/view/lc-components/Split/FunctionDesign.js +4 -6
- package/es/lowcode/view/lc-components/Split/index.js +4 -4
- package/es/lowcode/view/lc-components/Table/index.js +7 -6
- package/es/lowcode/view/lc-components/Tabs/FunctionDesign.js +2 -4
- package/es/lowcode/view/lc-components/Text/meta.json +2 -2
- package/es/lowcode/view/lc-components/Tree/meta.json +2 -2
- package/es/upload/Form/gridForm.js +7 -3
- package/lib/locales/zh-CN.js +9 -0
- package/lib/lowcode/constants/api-url.js +183 -100
- package/lib/lowcode/constants/index.js +3 -2
- package/lib/lowcode/engine/meta/box.props.default.json +1 -1
- package/lib/lowcode/engine/meta/box.props.json +1 -1
- package/lib/lowcode/engine/meta/button.props.json +1 -1
- package/lib/lowcode/engine/meta/cardlist.props.json +1 -1
- package/lib/lowcode/engine/meta/components-list.json +1 -1
- package/lib/lowcode/engine/meta/dialog.props.json +1 -1
- package/lib/lowcode/engine/meta/drawer.props.json +1 -1
- package/lib/lowcode/engine/meta/form.props.default.json +4 -5
- package/lib/lowcode/engine/meta/form.props.json +33 -30
- package/lib/lowcode/engine/meta/image.props.json +2 -2
- package/lib/lowcode/engine/meta/imex.props.json +1 -1
- package/lib/lowcode/engine/meta/link.props.json +1 -1
- package/lib/lowcode/engine/meta/section.props.default.json +4 -6
- package/lib/lowcode/engine/meta/section.props.json +52 -49
- package/lib/lowcode/engine/meta/text.props.json +2 -2
- package/lib/lowcode/engine/meta/tree.props.json +2 -2
- package/lib/lowcode/engine/provider/ContextProvider/index.js +10 -2
- package/lib/lowcode/engine/provider/RemoteSourceProvider.js +24 -11
- package/lib/lowcode/engine/tools/helper.js +23 -21
- package/lib/lowcode/engine/tools/useCanvasRender.js +3 -5
- package/lib/lowcode/engine/tools/usePromiseState.js +22 -14
- package/lib/lowcode/painter/Design.js +32 -0
- package/lib/lowcode/painter/DesignOperator.js +5 -7
- package/lib/lowcode/painter/DesignToolbar.js +256 -19
- package/lib/lowcode/painter/Panel.js +7 -8
- package/lib/lowcode/painter/components/AttrsPanel.js +6 -6
- package/lib/lowcode/painter/components/DragDrop/DragDropWrapper.js +5 -2
- package/lib/lowcode/painter/components/ListEditor.js +8 -2
- package/lib/lowcode/painter/components/field-setting/BatchSetting.js +13 -3
- package/lib/lowcode/painter/components/field-setting/SettingUI.js +26 -7
- package/lib/lowcode/painter/components/field-setting/index.js +18 -8
- package/lib/lowcode/painter/index.js +1 -30
- package/lib/lowcode/painter/panel-section/ActionsColumnWidth.js +32 -0
- package/lib/lowcode/painter/panel-section/BlockEditor/index.js +7 -4
- package/lib/lowcode/painter/panel-section/BlocksEditor/BlockEditorItem.js +4 -3
- package/lib/lowcode/painter/panel-section/BlocksEditor/index.js +47 -13
- package/lib/lowcode/painter/panel-section/FieldsSetting.js +46 -25
- package/lib/lowcode/painter/panel-section/I18nInput.js +27 -0
- package/lib/lowcode/painter/style/design.less +6 -2
- package/lib/lowcode/painter/style/list-editor.less +36 -0
- package/lib/lowcode/preview/index.js +18 -4
- package/lib/lowcode/view/lc-components/Box/meta.json +1 -1
- package/lib/lowcode/view/lc-components/Button/meta.json +1 -1
- package/lib/lowcode/view/lc-components/CardList/meta.json +1 -1
- package/lib/lowcode/view/lc-components/Dialog/FunctionDesign.js +2 -4
- package/lib/lowcode/view/lc-components/Dialog/meta.json +1 -1
- package/lib/lowcode/view/lc-components/Drawer/meta.json +1 -1
- package/lib/lowcode/view/lc-components/Form/FunctionDesign.js +64 -2
- package/lib/lowcode/view/lc-components/Form/index.js +230 -59
- package/lib/lowcode/view/lc-components/Form/meta.json +33 -30
- package/lib/lowcode/view/lc-components/ImEx/meta.json +1 -1
- package/lib/lowcode/view/lc-components/Image/meta.json +2 -2
- package/lib/lowcode/view/lc-components/Layout/FunctionDesign.js +5 -6
- package/lib/lowcode/view/lc-components/Link/meta.json +1 -1
- package/lib/lowcode/view/lc-components/Section/FunctionDesign.js +31 -2
- package/lib/lowcode/view/lc-components/Section/index.js +113 -23
- package/lib/lowcode/view/lc-components/Section/index.less +7 -0
- package/lib/lowcode/view/lc-components/Section/meta.json +48 -49
- package/lib/lowcode/view/lc-components/Split/FunctionDesign.js +5 -7
- package/lib/lowcode/view/lc-components/Split/index.js +4 -4
- package/lib/lowcode/view/lc-components/Table/index.js +7 -6
- package/lib/lowcode/view/lc-components/Tabs/FunctionDesign.js +4 -6
- package/lib/lowcode/view/lc-components/Text/meta.json +2 -2
- package/lib/lowcode/view/lc-components/Tree/meta.json +2 -2
- package/lib/upload/Form/gridForm.js +7 -3
- package/package.json +1 -1
- package/es/lowcode/painter/services/toolbar.js +0 -25
- package/lib/lowcode/painter/services/toolbar.js +0 -32
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
width: 100%;
|
|
8
8
|
.list-item {
|
|
9
9
|
height: 28px;
|
|
10
|
+
position: relative;
|
|
10
11
|
background: #fff;
|
|
11
12
|
border: 1px solid #e5e6e8;
|
|
12
13
|
border-radius: 6px;
|
|
@@ -37,6 +38,41 @@
|
|
|
37
38
|
cursor: pointer;
|
|
38
39
|
}
|
|
39
40
|
}
|
|
41
|
+
|
|
42
|
+
.list-item-bottom-line {
|
|
43
|
+
width: 100%;
|
|
44
|
+
height: 8px;
|
|
45
|
+
border-bottom: solid 1px var(--ant-primary-color);
|
|
46
|
+
position: absolute;
|
|
47
|
+
left: 0;
|
|
48
|
+
bottom: -6px;
|
|
49
|
+
padding-top: 4px;
|
|
50
|
+
display: none;
|
|
51
|
+
align-items: center;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
z-index: 10;
|
|
55
|
+
}
|
|
56
|
+
.list-item-bottom-line::after {
|
|
57
|
+
content: "+";
|
|
58
|
+
height: 12px;
|
|
59
|
+
margin-top: 4px;
|
|
60
|
+
color: var(--ant-primary-color);
|
|
61
|
+
border: solid 1px var(--ant-primary-color);
|
|
62
|
+
border-radius: 10px;
|
|
63
|
+
font-weight: bold;
|
|
64
|
+
font-size: 14px;
|
|
65
|
+
background-color: white;
|
|
66
|
+
padding: 0 8px;
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
}
|
|
71
|
+
&:hover {
|
|
72
|
+
.list-item-bottom-line {
|
|
73
|
+
display: flex;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
40
76
|
}
|
|
41
77
|
}
|
|
42
78
|
|
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { useUpdateEffect } from 'ahooks';
|
|
2
4
|
import EventBusProvider from "../engine/provider/EventBusProvider";
|
|
3
5
|
import ContextProvider from "../engine/provider/ContextProvider";
|
|
4
6
|
import Page from "../view/Page";
|
|
5
7
|
import { RUNTIME } from "../constants/index";
|
|
6
8
|
var Preview = function Preview(_ref) {
|
|
7
|
-
var code = _ref.code
|
|
8
|
-
|
|
9
|
+
var code = _ref.code,
|
|
10
|
+
userId = _ref.userId;
|
|
11
|
+
var _useState = useState(userId),
|
|
12
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
13
|
+
currentKey = _useState2[0],
|
|
14
|
+
setCurrentKey = _useState2[1];
|
|
15
|
+
useUpdateEffect(function () {
|
|
16
|
+
setCurrentKey(void 0);
|
|
17
|
+
setTimeout(function () {
|
|
18
|
+
setCurrentKey(userId);
|
|
19
|
+
});
|
|
20
|
+
}, [userId]);
|
|
21
|
+
return code && currentKey ? /*#__PURE__*/React.createElement(EventBusProvider, {
|
|
9
22
|
runtime: RUNTIME.PREVIEW
|
|
10
23
|
}, /*#__PURE__*/React.createElement(ContextProvider, {
|
|
11
24
|
code: code
|
|
12
|
-
}, /*#__PURE__*/React.createElement(Page, null)));
|
|
25
|
+
}, /*#__PURE__*/React.createElement(Page, null))) : null;
|
|
13
26
|
};
|
|
14
27
|
export default Preview;
|
|
@@ -6,7 +6,6 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
6
6
|
var _excluded = ["id", "children", "className"];
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { useCreation } from 'ahooks';
|
|
9
|
-
import { cloneDeep } from 'lodash';
|
|
10
9
|
import Index from "./index";
|
|
11
10
|
import { suid } from '@luck-design-biz/base/utils';
|
|
12
11
|
import { useContext, usePageData } from "../../../engine/provider/ContextProvider";
|
|
@@ -29,11 +28,10 @@ var FunctionDesign = function FunctionDesign(_ref) {
|
|
|
29
28
|
var compId = _ref2.id,
|
|
30
29
|
pageData = _ref2.pageData;
|
|
31
30
|
if (compId !== id) return;
|
|
32
|
-
|
|
33
|
-
add(cloneData, id, "box_".concat(suid()), _objectSpread(_objectSpread({}, boxDefaultMeta), {}, {
|
|
31
|
+
add(pageData, id, "box_".concat(suid()), _objectSpread(_objectSpread({}, boxDefaultMeta), {}, {
|
|
34
32
|
buildIn: true
|
|
35
33
|
}));
|
|
36
|
-
setPageData(
|
|
34
|
+
setPageData(pageData);
|
|
37
35
|
}).watch();
|
|
38
36
|
}, []);
|
|
39
37
|
return /*#__PURE__*/React.createElement(Index, _extends({
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
5
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
6
|
var _excluded = ["children", "blocks", "id"];
|
|
5
|
-
import React, { useRef,
|
|
7
|
+
import React, { useRef, useEffect } from 'react';
|
|
6
8
|
import { usePrevious, useUpdateLayoutEffect } from 'ahooks';
|
|
7
|
-
import { isEqual, differenceWith, cloneDeep } from 'lodash';
|
|
9
|
+
import { isEqual, differenceWith, cloneDeep, differenceBy } from 'lodash';
|
|
10
|
+
import { suid } from '@luck-design-biz/base/utils';
|
|
11
|
+
import { useContext, usePageData } from "../../../engine/provider/ContextProvider";
|
|
12
|
+
import { add, findNodeAndParent } from "../../../engine/tools/dataProcess";
|
|
13
|
+
import boxDefaultMeta from "../../../engine/meta/box.props.default.json";
|
|
8
14
|
import Index from "./index";
|
|
9
15
|
var FunctionDesign = function FunctionDesign(_ref) {
|
|
10
16
|
var children = _ref.children,
|
|
@@ -12,19 +18,75 @@ var FunctionDesign = function FunctionDesign(_ref) {
|
|
|
12
18
|
id = _ref.id,
|
|
13
19
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
14
20
|
var ref = useRef(null);
|
|
21
|
+
var ctx = useContext();
|
|
22
|
+
var _usePageData = usePageData(),
|
|
23
|
+
_usePageData2 = _slicedToArray(_usePageData, 2),
|
|
24
|
+
setPageData = _usePageData2[1].setPageData;
|
|
15
25
|
var previousBlocks = usePrevious(cloneDeep(blocks), function (prev, next) {
|
|
16
26
|
return !isEqual(prev, next);
|
|
17
27
|
});
|
|
18
28
|
useUpdateLayoutEffect(function () {
|
|
19
|
-
var
|
|
29
|
+
var diffDataset = differenceWith(blocks, previousBlocks, function (arrVal, othVal) {
|
|
20
30
|
var _arrVal$dataset, _othVal$dataset;
|
|
21
31
|
return arrVal.id === othVal.id && ((_arrVal$dataset = arrVal.dataset) === null || _arrVal$dataset === void 0 ? void 0 : _arrVal$dataset.code) === ((_othVal$dataset = othVal.dataset) === null || _othVal$dataset === void 0 ? void 0 : _othVal$dataset.code);
|
|
22
32
|
});
|
|
23
|
-
|
|
33
|
+
diffDataset.forEach(function (df) {
|
|
24
34
|
var _df$dataset;
|
|
25
35
|
((_df$dataset = df.dataset) === null || _df$dataset === void 0 ? void 0 : _df$dataset.code) && ref.current.doQueryOne(df.id);
|
|
26
36
|
});
|
|
37
|
+
var diffColReset = differenceWith(blocks, previousBlocks, function (arrVal, othVal) {
|
|
38
|
+
return arrVal.id === othVal.id && arrVal.actionsColumnReset === othVal.actionsColumnReset;
|
|
39
|
+
});
|
|
40
|
+
diffColReset.forEach(function (df) {
|
|
41
|
+
var _ctx$componentMap$get2;
|
|
42
|
+
var _ctx$componentMap$get = (_ctx$componentMap$get2 = ctx.componentMap.get(id)) === null || _ctx$componentMap$get2 === void 0 ? void 0 : _ctx$componentMap$get2.api.getForm().getFormRef(df.id).formRef.current,
|
|
43
|
+
gridApi = _ctx$componentMap$get.gridApi;
|
|
44
|
+
gridApi.api.refreshCells({
|
|
45
|
+
columns: ['luck-actions'],
|
|
46
|
+
force: true
|
|
47
|
+
});
|
|
48
|
+
});
|
|
27
49
|
}, [JSON.stringify(blocks)]);
|
|
50
|
+
useEffect(function () {
|
|
51
|
+
var cmid = ctx.$subscriber(ctx.topics.COMPONENT_MODIFY).on(function (_ref2) {
|
|
52
|
+
var compId = _ref2.id,
|
|
53
|
+
pageData = _ref2.pageData,
|
|
54
|
+
newValue = _ref2.newValue,
|
|
55
|
+
oldValue = _ref2.oldValue;
|
|
56
|
+
if (compId !== id || !newValue.hasOwnProperty('blocks')) return;
|
|
57
|
+
if (newValue.blocks.length > oldValue.blocks.length) {
|
|
58
|
+
var _differenceBy = differenceBy(newValue.blocks, oldValue.blocks, 'id'),
|
|
59
|
+
_differenceBy2 = _slicedToArray(_differenceBy, 1),
|
|
60
|
+
newItem = _differenceBy2[0];
|
|
61
|
+
if (newItem.type === 'blank') {
|
|
62
|
+
var boxId = "box_".concat(suid());
|
|
63
|
+
add(pageData, id, boxId, _objectSpread(_objectSpread({}, boxDefaultMeta), {}, {
|
|
64
|
+
buildIn: true,
|
|
65
|
+
formBoxId: newItem.id
|
|
66
|
+
}));
|
|
67
|
+
setPageData(pageData);
|
|
68
|
+
}
|
|
69
|
+
} else if (newValue.blocks.length < oldValue.blocks.length) {
|
|
70
|
+
var _differenceBy3 = differenceBy(oldValue.blocks, newValue.blocks, 'id'),
|
|
71
|
+
_differenceBy4 = _slicedToArray(_differenceBy3, 1),
|
|
72
|
+
removeItem = _differenceBy4[0];
|
|
73
|
+
if (removeItem.type === 'blank') {
|
|
74
|
+
var _findNodeAndParent = findNodeAndParent(id, pageData),
|
|
75
|
+
current = _findNodeAndParent.node;
|
|
76
|
+
var _boxId = current.children.find(function (childId) {
|
|
77
|
+
return current[childId].props.tabId === removeItem.id;
|
|
78
|
+
});
|
|
79
|
+
ctx.$publisher(ctx.topics.COMPONENT_DELETE, {
|
|
80
|
+
id: _boxId,
|
|
81
|
+
pageData: pageData
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}).watch();
|
|
86
|
+
return function () {
|
|
87
|
+
return ctx.$unsubscriber(ctx.topics.COMPONENT_MODIFY, cmid);
|
|
88
|
+
};
|
|
89
|
+
}, []);
|
|
28
90
|
return /*#__PURE__*/React.createElement(Index, _extends({}, props, {
|
|
29
91
|
id: id,
|
|
30
92
|
blocks: blocks,
|
|
@@ -1,30 +1,82 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import React, { useRef, forwardRef } from 'react';
|
|
6
|
-
import { useMemoizedFn } from 'ahooks';
|
|
3
|
+
import React, { useRef, forwardRef, Fragment, useImperativeHandle } from 'react';
|
|
4
|
+
import { useMemoizedFn, useCreation, useMount, useUnmount } from 'ahooks';
|
|
7
5
|
import classNames from 'classnames';
|
|
8
6
|
import { reduce, includes, isNil } from 'lodash';
|
|
7
|
+
import { BasicDivider } from 'luck-design';
|
|
8
|
+
import { Collapse } from '@luck-design-biz/base';
|
|
9
9
|
import Wrapper from "../Wrapper";
|
|
10
10
|
import { LdFormList } from "../../../../index";
|
|
11
11
|
import { omitBadProps, executeCode } from "../../../engine/tools/helper";
|
|
12
|
-
import { useContext } from "../../../engine/provider/ContextProvider";
|
|
12
|
+
import { useContext, useRemoteSource } from "../../../engine/provider/ContextProvider";
|
|
13
|
+
import buildUploadForm from "../../../../upload/Form";
|
|
14
|
+
import LdRuntimeCom from "../../../../components/LdRuntimeCom";
|
|
13
15
|
import defaultMeta from "../../../engine/meta/form.props.default.json";
|
|
14
16
|
import styles from "./index.less";
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
var Header = function Header(_ref) {
|
|
18
|
+
var _ref$header = _ref.header,
|
|
19
|
+
header = _ref$header === void 0 ? 'collapse' : _ref$header,
|
|
20
|
+
title = _ref.title,
|
|
21
|
+
ldId = _ref.ldId,
|
|
22
|
+
children = _ref.children;
|
|
23
|
+
if (header === 'collapse' || header === 'collapseFollow') return /*#__PURE__*/React.createElement(Collapse, {
|
|
24
|
+
title: title || ldId,
|
|
25
|
+
id: ldId,
|
|
26
|
+
key: ldId,
|
|
27
|
+
mode: header === 'collapse' && 'tab'
|
|
28
|
+
}, children);
|
|
29
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
30
|
+
key: ldId
|
|
31
|
+
}, header === 'divider' && /*#__PURE__*/React.createElement(BasicDivider, {
|
|
32
|
+
title: title || ldId,
|
|
33
|
+
id: ldId
|
|
34
|
+
}), children);
|
|
35
|
+
};
|
|
36
|
+
var LCForm = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
37
|
+
var id = _ref2.id,
|
|
38
|
+
parentId = _ref2.parentId,
|
|
39
|
+
width = _ref2.width,
|
|
40
|
+
height = _ref2.height,
|
|
41
|
+
className = _ref2.className,
|
|
42
|
+
blocks = _ref2.blocks,
|
|
43
|
+
advance = _ref2.advance,
|
|
44
|
+
initData = _ref2.initData,
|
|
45
|
+
readOnly = _ref2.readOnly,
|
|
46
|
+
showSave = _ref2.showSave,
|
|
47
|
+
saveTitle = _ref2.saveTitle,
|
|
48
|
+
settingLayout = _ref2.settingLayout,
|
|
49
|
+
renderFormLeft = _ref2.renderFormLeft,
|
|
50
|
+
renderFormRight = _ref2.renderFormRight,
|
|
51
|
+
children = _ref2.children;
|
|
52
|
+
var apiRef = useRef();
|
|
26
53
|
var boxRef = useRef();
|
|
54
|
+
var formRef = useRef();
|
|
27
55
|
var ctx = useContext();
|
|
56
|
+
var remoteSource = useRemoteSource();
|
|
57
|
+
var serials = useCreation(function () {
|
|
58
|
+
var _remoteSource$serials;
|
|
59
|
+
return ((_remoteSource$serials = remoteSource.serials) === null || _remoteSource$serials === void 0 ? void 0 : _remoteSource$serials.map(function (i) {
|
|
60
|
+
return i.serial;
|
|
61
|
+
})) || [];
|
|
62
|
+
}, [remoteSource.serials]);
|
|
63
|
+
useMount(function () {
|
|
64
|
+
ctx.doAction(advance.events.onMount, {
|
|
65
|
+
instance: (ref || formRef).current
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
useUnmount(function () {
|
|
69
|
+
ctx.doAction(advance.events.onUnmount, {
|
|
70
|
+
instance: (ref || formRef).current
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
useImperativeHandle(apiRef, function () {
|
|
74
|
+
return {
|
|
75
|
+
getForm: function getForm() {
|
|
76
|
+
return (ref || formRef).current;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
});
|
|
28
80
|
var getTargetDom = useMemoizedFn(function () {
|
|
29
81
|
return boxRef.current;
|
|
30
82
|
});
|
|
@@ -34,9 +86,9 @@ var LCForm = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
34
86
|
};
|
|
35
87
|
return executeCode(ctx, defaultDataSourceFormat, ['defaultValues'], defaultValues);
|
|
36
88
|
});
|
|
37
|
-
var handleDataSourceFormat = useMemoizedFn(function (dataSourceFormat,
|
|
38
|
-
var values =
|
|
39
|
-
submitData =
|
|
89
|
+
var handleDataSourceFormat = useMemoizedFn(function (dataSourceFormat, _ref3) {
|
|
90
|
+
var values = _ref3.values,
|
|
91
|
+
submitData = _ref3.submitData;
|
|
40
92
|
if (isNil(dataSourceFormat)) return submitData;
|
|
41
93
|
return executeCode(ctx, dataSourceFormat, ['values', 'submitData'], values, submitData);
|
|
42
94
|
});
|
|
@@ -50,61 +102,166 @@ var LCForm = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
50
102
|
var handleGridFormReady = useMemoizedFn(function (onGridFormReady, ref, params, gridForm) {
|
|
51
103
|
if (!isNil(onGridFormReady)) return executeCode(ctx, onGridFormReady, ['ref', 'params', 'gridForm'], ref, params, gridForm);
|
|
52
104
|
});
|
|
105
|
+
var handleResetActions = useMemoizedFn(function (resetActions, data, index, actionList, params) {
|
|
106
|
+
if (isNil(resetActions)) return actionList;
|
|
107
|
+
return executeCode(ctx, resetActions, ['data', 'index', 'actionList', 'params'], data, index, actionList, params);
|
|
108
|
+
});
|
|
109
|
+
var handleForbiddenTypes = useMemoizedFn(function (forbiddenTypes) {
|
|
110
|
+
if (isNil(forbiddenTypes)) return [];
|
|
111
|
+
return executeCode(ctx, forbiddenTypes, []);
|
|
112
|
+
});
|
|
113
|
+
var handleBeforeUpload = useMemoizedFn(function (beforeUpload, file, fileList) {
|
|
114
|
+
if (isNil(beforeUpload)) return true;
|
|
115
|
+
return executeCode(ctx, beforeUpload, ['file', 'fileList'], file, fileList);
|
|
116
|
+
});
|
|
117
|
+
var handleUploadChange = useMemoizedFn(function (onUploadChange, e) {
|
|
118
|
+
if (!isNil(onUploadChange)) return executeCode(ctx, onUploadChange, ['event'], e);
|
|
119
|
+
});
|
|
120
|
+
var renderAffix = useMemoizedFn(function (_render) {
|
|
121
|
+
return _render ? /*#__PURE__*/React.createElement(LdRuntimeCom, null, _render) : null;
|
|
122
|
+
});
|
|
53
123
|
var renderFormList = useMemoizedFn(function (formConfig) {
|
|
54
|
-
|
|
55
|
-
if (includes(['auto', 'grid', 'writer'], item.type)) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
124
|
+
return reduce(blocks, function (result, item) {
|
|
125
|
+
if (includes(['auto', 'grid', 'writer'], item.type) && item.dataset && includes(item.mode, formConfig.formMode)) {
|
|
126
|
+
var data = {
|
|
127
|
+
id: item.id,
|
|
128
|
+
order: item.order,
|
|
129
|
+
type: item.type,
|
|
130
|
+
readOnly: item.readOnly,
|
|
131
|
+
title: item.name,
|
|
132
|
+
header: item.header,
|
|
133
|
+
dataSetKey: item.dataset.code,
|
|
134
|
+
serial: item.serial,
|
|
135
|
+
serialEffect: item.serialEffect,
|
|
136
|
+
defaultDataSourceFormat: function defaultDataSourceFormat(defaultValues) {
|
|
137
|
+
return handleDefaultDataSourceFormat(item.defaultDataSourceFormat, defaultValues);
|
|
138
|
+
},
|
|
139
|
+
onUpdate: {
|
|
140
|
+
post: function post(data) {
|
|
141
|
+
return handleDataSourceFormat(item.dataSourceFormat, data);
|
|
73
142
|
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
if (item.type === 'auto') data = _objectSpread(_objectSpread({}, data), {}, {
|
|
146
|
+
col: item.cols
|
|
147
|
+
});else data = _objectSpread(_objectSpread({}, data), {}, {
|
|
148
|
+
suppressPreset: item.suppressPreset,
|
|
149
|
+
height: item.height,
|
|
150
|
+
bordered: item.bordered,
|
|
151
|
+
draggable: item.draggable,
|
|
152
|
+
orderByAdd: item.orderByAdd,
|
|
153
|
+
hideActionsColumn: item.suppressActions,
|
|
154
|
+
actionsWidth: item.actionsColumnWidth,
|
|
155
|
+
columnsReset: function columnsReset(columns) {
|
|
156
|
+
return handleColumnsReset(item.columnsReset, columns);
|
|
157
|
+
},
|
|
158
|
+
onGridFormReady: function onGridFormReady(ref, params, gridForm) {
|
|
159
|
+
return handleGridFormReady(item.onGridFormReady, ref, params, gridForm);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
if (item.actionsColumnReset) data = _objectSpread(_objectSpread({}, data), {}, {
|
|
163
|
+
resetActionsColumn: function resetActionsColumn(data, index, actions, params) {
|
|
164
|
+
return handleResetActionsColumn(item.actionsColumnReset, data, index, actions, params);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
result.push(data);
|
|
168
|
+
}
|
|
169
|
+
return result;
|
|
170
|
+
}, []);
|
|
171
|
+
});
|
|
172
|
+
var renderFormExtra = useMemoizedFn(function (formConfig) {
|
|
173
|
+
return reduce(blocks, function (result, item) {
|
|
174
|
+
if (includes(item.mode, formConfig.formMode) && !item.serial || item.serialEffect === 'disable' || includes(serials, item.serial)) {
|
|
175
|
+
if (item.type === 'uploadForm') {
|
|
176
|
+
var _remoteSource$pageinf;
|
|
177
|
+
var dom = /*#__PURE__*/React.createElement(Header, {
|
|
178
|
+
ldId: item.id,
|
|
179
|
+
key: item.id,
|
|
180
|
+
header: item.header,
|
|
181
|
+
title: item.name,
|
|
182
|
+
order: item.order
|
|
183
|
+
}, buildUploadForm(_objectSpread(_objectSpread({}, formConfig), {}, {
|
|
184
|
+
formId: item.id,
|
|
185
|
+
moduleCode: remoteSource === null || remoteSource === void 0 || (_remoteSource$pageinf = remoteSource.pageinfo) === null || _remoteSource$pageinf === void 0 || (_remoteSource$pageinf = _remoteSource$pageinf.relationship) === null || _remoteSource$pageinf === void 0 ? void 0 : _remoteSource$pageinf.moduleCode,
|
|
186
|
+
readOnly: item.readOnly || formConfig.readOnly || item.serial && !includes(serials, item.serial),
|
|
78
187
|
suppressPreset: item.suppressPreset,
|
|
79
188
|
height: item.height,
|
|
80
189
|
bordered: item.bordered,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
190
|
+
showNote: item.showNote,
|
|
191
|
+
zipName: "".concat(item.zipName || 'download', ".zip"),
|
|
192
|
+
uploadUrl: item.uploadUrl,
|
|
193
|
+
resetActions: item.useResetActions ? null : function () {
|
|
194
|
+
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
195
|
+
params[_key] = arguments[_key];
|
|
196
|
+
}
|
|
197
|
+
return handleResetActions.apply(void 0, [item.resetActions].concat(params));
|
|
87
198
|
},
|
|
88
|
-
|
|
89
|
-
return
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
199
|
+
forbiddenTypes: function forbiddenTypes() {
|
|
200
|
+
return handleForbiddenTypes(item.forbiddenTypes);
|
|
201
|
+
},
|
|
202
|
+
beforeUpload: function beforeUpload() {
|
|
203
|
+
for (var _len2 = arguments.length, params = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
204
|
+
params[_key2] = arguments[_key2];
|
|
205
|
+
}
|
|
206
|
+
return handleBeforeUpload.apply(void 0, [item.beforeUpload].concat(params));
|
|
207
|
+
},
|
|
208
|
+
onUploadChange: function onUploadChange(e) {
|
|
209
|
+
return handleUploadChange(item.onUploadChange, e);
|
|
95
210
|
}
|
|
96
|
-
});
|
|
97
|
-
result.push(
|
|
211
|
+
})));
|
|
212
|
+
result.push(dom);
|
|
213
|
+
}
|
|
214
|
+
if (item.type === 'blank') {
|
|
215
|
+
var _dom = /*#__PURE__*/React.createElement(Header, {
|
|
216
|
+
ldId: item.id,
|
|
217
|
+
key: item.id,
|
|
218
|
+
header: item.header,
|
|
219
|
+
title: item.name,
|
|
220
|
+
order: item.order
|
|
221
|
+
}, children === null || children === void 0 ? void 0 : children.find(function (child) {
|
|
222
|
+
return child.props.formBoxId === item.id;
|
|
223
|
+
}));
|
|
224
|
+
result.push(_dom);
|
|
98
225
|
}
|
|
99
226
|
}
|
|
100
227
|
return result;
|
|
101
228
|
}, []);
|
|
102
|
-
|
|
229
|
+
});
|
|
230
|
+
var beforeSubmit = useMemoizedFn(function (values, data) {
|
|
231
|
+
return new Promise(function (resolve) {
|
|
232
|
+
if (isNil(advance.events.beforeSave)) resolve(values);else {
|
|
233
|
+
var _data = ctx.doAction(advance.events.beforeSave, {
|
|
234
|
+
values: values,
|
|
235
|
+
data: data
|
|
236
|
+
});
|
|
237
|
+
resolve(_data);
|
|
238
|
+
}
|
|
239
|
+
;
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
var afterSubmit = useMemoizedFn(function (success, mainKey, res) {
|
|
243
|
+
ctx.doAction(advance.events.onSaveCallback, {
|
|
244
|
+
success: success,
|
|
245
|
+
mainKey: mainKey,
|
|
246
|
+
res: res
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
var onValueChange = useMemoizedFn(function (change, data) {
|
|
250
|
+
ctx.doAction(advance.events.onValueChange, {
|
|
251
|
+
change: change,
|
|
252
|
+
data: data
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
var onChildChange = useMemoizedFn(function (instance) {
|
|
256
|
+
ctx.doAction(advance.events.onChildChange, {
|
|
257
|
+
instance: instance
|
|
258
|
+
});
|
|
103
259
|
});
|
|
104
260
|
return /*#__PURE__*/React.createElement(Wrapper, {
|
|
105
261
|
id: id,
|
|
106
262
|
displayName: "Form",
|
|
107
|
-
getTargetDom: getTargetDom
|
|
263
|
+
getTargetDom: getTargetDom,
|
|
264
|
+
api: apiRef
|
|
108
265
|
}, /*#__PURE__*/React.createElement("div", {
|
|
109
266
|
ref: boxRef,
|
|
110
267
|
style: {
|
|
@@ -116,10 +273,24 @@ var LCForm = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
116
273
|
ldId: id,
|
|
117
274
|
className: classNames(styles['lc-component-form'], _defineProperty({}, className, !!className)),
|
|
118
275
|
renderFormList: renderFormList,
|
|
276
|
+
renderFormExtra: renderFormExtra,
|
|
119
277
|
mainFormLdId: "block_main",
|
|
120
278
|
initData: initData,
|
|
121
|
-
ref: ref,
|
|
122
|
-
readOnly: readOnly
|
|
279
|
+
ref: ref || formRef,
|
|
280
|
+
readOnly: readOnly,
|
|
281
|
+
showSaveBtn: showSave,
|
|
282
|
+
saveBtnTitle: saveTitle,
|
|
283
|
+
affixLayout: settingLayout,
|
|
284
|
+
renderAffixLeft: function renderAffixLeft() {
|
|
285
|
+
return renderAffix(renderFormLeft);
|
|
286
|
+
},
|
|
287
|
+
renderAffixRight: function renderAffixRight() {
|
|
288
|
+
return renderAffix(renderFormRight);
|
|
289
|
+
},
|
|
290
|
+
beforeSubmit: beforeSubmit,
|
|
291
|
+
afterSubmit: advance.events.onSaveCallback ? afterSubmit : null,
|
|
292
|
+
onValueChange: onValueChange,
|
|
293
|
+
onChildChange: onChildChange
|
|
123
294
|
})));
|
|
124
295
|
});
|
|
125
296
|
LCForm.defaultProps = omitBadProps(defaultMeta);
|