@luck-design-biz/luckda 0.0.22 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +40 -49
- package/es/components/Builder/index.js +4 -4
- package/es/components/LdAutoForm/index.js +7 -9
- package/es/components/LdCard/index.js +5 -6
- package/es/components/LdCard/model.js +1 -1
- package/es/components/LdCom/index.js +2 -2
- package/es/components/LdFormList/index.js +19 -17
- package/es/components/LdGrid/index.js +11 -12
- package/es/components/LdGrid/model.js +1 -1
- package/es/components/LdGridForm/index.js +10 -10
- package/es/components/LdGridForm/index.less +7 -7
- package/es/components/LdInfoPanel/index.js +2 -2
- package/es/components/LdRuntimeCom/index.js +42 -0
- package/es/components/LdTree/index.js +3 -4
- package/es/components/LdTree/index.less +36 -36
- package/es/helper/FromItems.js +1 -1
- package/es/helper/action.js +8 -8
- package/es/helper/form.js +16 -16
- package/es/helper/index.less +7 -7
- package/es/helper/ldBuilder.js +1 -1
- package/es/helper/ldComBuild.js +4 -4
- package/es/index.js +10 -9
- package/es/lowcode/constants/api-url.js +2 -0
- package/es/lowcode/constants/event-topics.js +23 -0
- package/es/lowcode/constants/index.js +12 -0
- package/es/lowcode/engine/factory/DataFactory.js +1 -0
- package/es/lowcode/engine/meta/button.props.default.json +8 -0
- package/es/lowcode/engine/meta/cardlist.props.default.json +10 -0
- package/es/lowcode/engine/meta/components/button.json +104 -0
- package/es/lowcode/engine/meta/components/card-list.json +143 -0
- package/es/lowcode/engine/meta/components/drawer.json +143 -0
- package/es/lowcode/engine/meta/components/form.json +116 -0
- package/es/lowcode/engine/meta/components/iframe.json +31 -0
- package/es/lowcode/engine/meta/components/image.json +113 -0
- package/es/lowcode/engine/meta/components/imex.json +81 -0
- package/es/lowcode/engine/meta/components/jsx.json +24 -0
- package/es/lowcode/engine/meta/components/layout.json +107 -0
- package/es/lowcode/engine/meta/components/link.json +111 -0
- package/es/lowcode/engine/meta/components/modal.json +120 -0
- package/es/lowcode/engine/meta/components/section.json +107 -0
- package/es/lowcode/engine/meta/components/split.json +71 -0
- package/es/lowcode/engine/meta/components/table.json +161 -0
- package/es/lowcode/engine/meta/components/tabs.json +140 -0
- package/es/lowcode/engine/meta/components/text.json +65 -0
- package/es/lowcode/engine/meta/components/tree.json +156 -0
- package/es/lowcode/engine/meta/components-list.json +122 -0
- package/es/lowcode/engine/meta/drawer.props.default.json +10 -0
- package/es/lowcode/engine/meta/form.props.default.json +5 -0
- package/es/lowcode/engine/meta/iframe.props.default.json +3 -0
- package/es/lowcode/engine/meta/image.props.default.json +8 -0
- package/es/lowcode/engine/meta/imex.props.default.json +4 -0
- package/es/lowcode/engine/meta/jsx.props.default.json +1 -0
- package/es/lowcode/engine/meta/layout.props.default.json +5 -0
- package/es/lowcode/engine/meta/link.props.default.json +6 -0
- package/es/lowcode/engine/meta/modal.props.default.json +11 -0
- package/es/lowcode/engine/meta/section.props.default.json +9 -0
- package/es/lowcode/engine/meta/split.props.default.json +5 -0
- package/es/lowcode/engine/meta/table.props.default.json +10 -0
- package/es/lowcode/engine/meta/tabs.props.default.json +10 -0
- package/es/lowcode/engine/meta/text.props.default.json +4 -0
- package/es/lowcode/engine/meta/tree.props.default.json +9 -0
- package/es/lowcode/engine/provider/ContextProvider.js +164 -0
- package/es/lowcode/engine/provider/EventBusProvider.js +120 -0
- package/es/lowcode/engine/tools/dataProcess.js +188 -0
- package/es/lowcode/engine/tools/helper.js +4 -0
- package/es/lowcode/engine/tools/lcid.js +16 -0
- package/es/lowcode/index.js +3 -0
- package/es/lowcode/painter/Components.js +104 -0
- package/es/lowcode/painter/Design.js +97 -0
- package/es/lowcode/painter/I18n.js +5 -0
- package/es/lowcode/painter/Outline.js +202 -0
- package/es/lowcode/painter/Panel.js +8 -0
- package/es/lowcode/painter/Ribbon.js +136 -0
- package/es/lowcode/painter/components/PanelItem.js +20 -0
- package/es/lowcode/painter/components/RuleInput.js +105 -0
- package/es/lowcode/painter/index.js +19 -0
- package/es/lowcode/painter/panel-section/LayoutRatio.js +123 -0
- package/es/lowcode/painter/panel-section/Radio.js +58 -0
- package/es/lowcode/painter/style/components.less +90 -0
- package/es/lowcode/painter/style/design.less +38 -0
- package/es/lowcode/painter/style/index.less +7 -0
- package/es/lowcode/painter/style/layout-ratio.less +51 -0
- package/es/lowcode/painter/style/outline.less +26 -0
- package/es/lowcode/painter/style/panel-item.less +21 -0
- package/es/lowcode/painter/style/panel.less +5 -0
- package/es/lowcode/painter/style/radio.less +24 -0
- package/es/lowcode/painter/style/ribbon.less +4 -0
- package/es/lowcode/painter/style/rule-input.less +13 -0
- package/es/lowcode/view/Canvas.js +135 -0
- package/es/lowcode/view/Loading.js +23 -0
- package/es/lowcode/view/Page.js +55 -0
- package/es/lowcode/view/index.js +18 -0
- package/es/lowcode/view/lc-components/Box/index.js +21 -0
- package/es/lowcode/view/lc-components/Button/index.js +37 -0
- package/es/lowcode/view/lc-components/CardList/index.js +20 -0
- package/es/lowcode/view/lc-components/Dialog/index.js +50 -0
- package/es/lowcode/view/lc-components/Dialog/index.less +3 -0
- package/es/lowcode/view/lc-components/Drawer/index.js +46 -0
- package/es/lowcode/view/lc-components/Form/index.js +20 -0
- package/es/lowcode/view/lc-components/Iframe/index.js +20 -0
- package/es/lowcode/view/lc-components/ImEx/index.js +20 -0
- package/es/lowcode/view/lc-components/Image/index.js +20 -0
- package/es/lowcode/view/lc-components/JSX/index.js +20 -0
- package/es/lowcode/view/lc-components/Layout/index.js +24 -0
- package/es/lowcode/view/lc-components/Link/index.js +20 -0
- package/es/lowcode/view/lc-components/Section/index.js +34 -0
- package/es/lowcode/view/lc-components/Split/index.js +21 -0
- package/es/lowcode/view/lc-components/Table/index.js +23 -0
- package/es/lowcode/view/lc-components/Tabs/index.js +21 -0
- package/es/lowcode/view/lc-components/Text/index.js +23 -0
- package/es/lowcode/view/lc-components/Tree/index.js +20 -0
- package/es/lowcode/view/lc-components/Wrapper.js +45 -0
- package/es/lowcode/view/style/canvas.less +5 -0
- package/es/lowcode/view/style/loading.less +84 -0
- package/es/lowcode/view/style/page.less +6 -0
- package/es/services.js +1 -1
- package/es/upload/Form/gridForm.js +29 -7
- package/es/upload/Form/index.js +1 -1
- package/es/upload/Form/index.less +7 -7
- package/es/upload/FormItem/index.js +30 -18
- package/es/upload/index.js +3 -3
- package/es/utils/action.js +1 -1
- package/es/utils/form.js +26 -26
- package/es/utils/grid.js +22 -26
- package/es/utils/index.js +3 -3
- package/lib/components/Builder/index.js +3 -5
- package/lib/components/LdAutoForm/index.js +5 -8
- package/lib/components/LdCard/index.js +5 -7
- package/lib/components/LdCom/index.js +6 -11
- package/lib/components/LdFormList/index.js +15 -13
- package/lib/components/LdGrid/index.js +10 -12
- package/lib/components/LdGridForm/index.js +6 -7
- package/lib/components/LdGridForm/index.less +7 -7
- package/lib/components/LdInfoPanel/index.js +2 -3
- package/lib/components/LdPop/index.js +2 -4
- package/lib/components/LdRuntimeCom/index.js +49 -0
- package/lib/components/LdTree/index.js +2 -4
- package/lib/components/LdTree/index.less +36 -36
- package/lib/helper/FromItems.js +15 -29
- package/lib/helper/action.js +9 -11
- package/lib/helper/form.js +18 -20
- package/lib/helper/index.less +7 -7
- package/lib/helper/ldBuilder.js +1 -2
- package/lib/helper/ldComBuild.js +7 -11
- package/lib/index.js +9 -1
- package/lib/lowcode/constants/api-url.js +8 -0
- package/lib/lowcode/constants/event-topics.js +29 -0
- package/lib/lowcode/constants/index.js +18 -0
- package/lib/lowcode/engine/factory/DataFactory.js +3 -0
- package/lib/lowcode/engine/meta/button.props.default.json +8 -0
- package/lib/lowcode/engine/meta/cardlist.props.default.json +10 -0
- package/lib/lowcode/engine/meta/components/button.json +104 -0
- package/lib/lowcode/engine/meta/components/card-list.json +143 -0
- package/lib/lowcode/engine/meta/components/drawer.json +143 -0
- package/lib/lowcode/engine/meta/components/form.json +116 -0
- package/lib/lowcode/engine/meta/components/iframe.json +31 -0
- package/lib/lowcode/engine/meta/components/image.json +113 -0
- package/lib/lowcode/engine/meta/components/imex.json +81 -0
- package/lib/lowcode/engine/meta/components/jsx.json +24 -0
- package/lib/lowcode/engine/meta/components/layout.json +107 -0
- package/lib/lowcode/engine/meta/components/link.json +111 -0
- package/lib/lowcode/engine/meta/components/modal.json +120 -0
- package/lib/lowcode/engine/meta/components/section.json +107 -0
- package/lib/lowcode/engine/meta/components/split.json +71 -0
- package/lib/lowcode/engine/meta/components/table.json +161 -0
- package/lib/lowcode/engine/meta/components/tabs.json +140 -0
- package/lib/lowcode/engine/meta/components/text.json +65 -0
- package/lib/lowcode/engine/meta/components/tree.json +156 -0
- package/lib/lowcode/engine/meta/components-list.json +122 -0
- package/lib/lowcode/engine/meta/drawer.props.default.json +10 -0
- package/lib/lowcode/engine/meta/form.props.default.json +5 -0
- package/lib/lowcode/engine/meta/iframe.props.default.json +3 -0
- package/lib/lowcode/engine/meta/image.props.default.json +8 -0
- package/lib/lowcode/engine/meta/imex.props.default.json +4 -0
- package/lib/lowcode/engine/meta/jsx.props.default.json +1 -0
- package/lib/lowcode/engine/meta/layout.props.default.json +5 -0
- package/lib/lowcode/engine/meta/link.props.default.json +6 -0
- package/lib/lowcode/engine/meta/modal.props.default.json +11 -0
- package/lib/lowcode/engine/meta/section.props.default.json +9 -0
- package/lib/lowcode/engine/meta/split.props.default.json +5 -0
- package/lib/lowcode/engine/meta/table.props.default.json +10 -0
- package/lib/lowcode/engine/meta/tabs.props.default.json +10 -0
- package/lib/lowcode/engine/meta/text.props.default.json +4 -0
- package/lib/lowcode/engine/meta/tree.props.default.json +9 -0
- package/lib/lowcode/engine/provider/ContextProvider.js +172 -0
- package/lib/lowcode/engine/provider/EventBusProvider.js +128 -0
- package/lib/lowcode/engine/tools/dataProcess.js +201 -0
- package/lib/lowcode/engine/tools/helper.js +11 -0
- package/lib/lowcode/engine/tools/lcid.js +22 -0
- package/lib/lowcode/index.js +20 -0
- package/lib/lowcode/painter/Components.js +112 -0
- package/lib/lowcode/painter/Design.js +105 -0
- package/lib/lowcode/painter/I18n.js +12 -0
- package/lib/lowcode/painter/Outline.js +210 -0
- package/lib/lowcode/painter/Panel.js +16 -0
- package/lib/lowcode/painter/Ribbon.js +151 -0
- package/lib/lowcode/painter/components/PanelItem.js +26 -0
- package/lib/lowcode/painter/components/RuleInput.js +112 -0
- package/lib/lowcode/painter/index.js +26 -0
- package/lib/lowcode/painter/panel-section/LayoutRatio.js +131 -0
- package/lib/lowcode/painter/panel-section/Radio.js +65 -0
- package/lib/lowcode/painter/style/components.less +90 -0
- package/lib/lowcode/painter/style/design.less +38 -0
- package/lib/lowcode/painter/style/index.less +7 -0
- package/lib/lowcode/painter/style/layout-ratio.less +51 -0
- package/lib/lowcode/painter/style/outline.less +26 -0
- package/lib/lowcode/painter/style/panel-item.less +21 -0
- package/lib/lowcode/painter/style/panel.less +5 -0
- package/lib/lowcode/painter/style/radio.less +24 -0
- package/lib/lowcode/painter/style/ribbon.less +4 -0
- package/lib/lowcode/painter/style/rule-input.less +13 -0
- package/lib/lowcode/view/Canvas.js +150 -0
- package/lib/lowcode/view/Loading.js +30 -0
- package/lib/lowcode/view/Page.js +63 -0
- package/lib/lowcode/view/index.js +25 -0
- package/lib/lowcode/view/lc-components/Box/index.js +29 -0
- package/lib/lowcode/view/lc-components/Button/index.js +45 -0
- package/lib/lowcode/view/lc-components/CardList/index.js +28 -0
- package/lib/lowcode/view/lc-components/Dialog/index.js +58 -0
- package/lib/lowcode/view/lc-components/Dialog/index.less +3 -0
- package/lib/lowcode/view/lc-components/Drawer/index.js +54 -0
- package/lib/lowcode/view/lc-components/Form/index.js +28 -0
- package/lib/lowcode/view/lc-components/Iframe/index.js +28 -0
- package/lib/lowcode/view/lc-components/ImEx/index.js +28 -0
- package/lib/lowcode/view/lc-components/Image/index.js +28 -0
- package/lib/lowcode/view/lc-components/JSX/index.js +28 -0
- package/lib/lowcode/view/lc-components/Layout/index.js +32 -0
- package/lib/lowcode/view/lc-components/Link/index.js +28 -0
- package/lib/lowcode/view/lc-components/Section/index.js +42 -0
- package/lib/lowcode/view/lc-components/Split/index.js +29 -0
- package/lib/lowcode/view/lc-components/Table/index.js +31 -0
- package/lib/lowcode/view/lc-components/Tabs/index.js +29 -0
- package/lib/lowcode/view/lc-components/Text/index.js +31 -0
- package/lib/lowcode/view/lc-components/Tree/index.js +28 -0
- package/lib/lowcode/view/lc-components/Wrapper.js +52 -0
- package/lib/lowcode/view/style/canvas.less +5 -0
- package/lib/lowcode/view/style/loading.less +84 -0
- package/lib/lowcode/view/style/page.less +6 -0
- package/lib/upload/Form/gridForm.js +27 -6
- package/lib/upload/Form/index.js +1 -2
- package/lib/upload/Form/index.less +7 -7
- package/lib/upload/FormItem/index.js +30 -19
- package/lib/upload/GridCell/index.js +1 -2
- package/lib/utils/form.js +26 -29
- package/lib/utils/grid.js +23 -28
- package/lowcode.js +1 -0
- package/package.json +157 -78
- package/upload.js +1 -1
- package/utils.js +1 -1
- package/README.zh-CN.md +0 -51
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
|
+
var _excluded = ["props", "children"];
|
|
6
|
+
import React, { useRef, useState, useEffect } from 'react';
|
|
7
|
+
import { useMemoizedFn, useDeepCompareLayoutEffect } from 'ahooks';
|
|
8
|
+
import { uniq, split, reduce } from 'lodash';
|
|
9
|
+
import classNames from 'classnames';
|
|
10
|
+
import { Card, Tree, Icon } from 'luck-design/antd';
|
|
11
|
+
import { formatMessage } from '@luck-design-biz/base/utils';
|
|
12
|
+
import { useLDContext } from "../engine/provider/ContextProvider";
|
|
13
|
+
import { CELL_KEY } from "../constants";
|
|
14
|
+
import { getPathById } from "../engine/tools/dataProcess";
|
|
15
|
+
import styles from "./style/outline.less";
|
|
16
|
+
var TreeNode = Tree.TreeNode;
|
|
17
|
+
var PAGE_CELL = [CELL_KEY.PAGE_HEADER, CELL_KEY.PAGE_CONTENT, CELL_KEY.PAGE_FOOTER];
|
|
18
|
+
var Outline = function Outline() {
|
|
19
|
+
var modalTreeRef = useRef();
|
|
20
|
+
var pageTreeRef = useRef();
|
|
21
|
+
var openModal = useRef(void 0);
|
|
22
|
+
var clickBySelf = useRef(false);
|
|
23
|
+
var context = useLDContext();
|
|
24
|
+
var _useState = useState(null),
|
|
25
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
26
|
+
pageAndModal = _useState2[0],
|
|
27
|
+
setPageAndModal = _useState2[1];
|
|
28
|
+
var _useState3 = useState(null),
|
|
29
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
30
|
+
selectedKey = _useState4[0],
|
|
31
|
+
setSelectedKey = _useState4[1];
|
|
32
|
+
var _useState5 = useState([]),
|
|
33
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
34
|
+
modalExpandedKeys = _useState6[0],
|
|
35
|
+
setModalExpandedKeys = _useState6[1];
|
|
36
|
+
var _useState7 = useState([]),
|
|
37
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
38
|
+
pageExpandedKeys = _useState8[0],
|
|
39
|
+
setPageExpandedKeys = _useState8[1];
|
|
40
|
+
useEffect(function () {
|
|
41
|
+
var _id = context.$subscriber(context.topics.COMPONENT_ACTIVE).on(function (payload) {
|
|
42
|
+
setSelectedKey(payload.id);
|
|
43
|
+
if (clickBySelf.current) {
|
|
44
|
+
clickBySelf.current = false;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
setModalExpandedKeys(uniq([].concat(_toConsumableArray((openModal.current ? modalTreeRef : pageTreeRef).current.props.expandedKeys), _toConsumableArray(split(getPathById(context.pageData, payload.id), '/')))));
|
|
48
|
+
}).watch();
|
|
49
|
+
return function () {
|
|
50
|
+
context.$unsubscriber(context.topics.COMPONENT_ACTIVE, _id);
|
|
51
|
+
};
|
|
52
|
+
}, []);
|
|
53
|
+
var handleSelect = function handleSelect(_key) {
|
|
54
|
+
clickBySelf.current = true;
|
|
55
|
+
context.$publisher(context.topics.COMPONENT_ACTIVE, _key ? {
|
|
56
|
+
id: _key,
|
|
57
|
+
cellNode: context.componentMap.get(_key).dom
|
|
58
|
+
} : null);
|
|
59
|
+
};
|
|
60
|
+
var handleOpenModal = useMemoizedFn(function (_key) {
|
|
61
|
+
var _comp = context.componentMap.get(_key);
|
|
62
|
+
var _prevComp = openModal.current ? context.componentMap.get(openModal.current) : null;
|
|
63
|
+
_prevComp === null || _prevComp === void 0 || _prevComp.api.doClose();
|
|
64
|
+
_comp.api.doOpen();
|
|
65
|
+
openModal.current = _key;
|
|
66
|
+
});
|
|
67
|
+
var render = useMemoizedFn(function (_ref) {
|
|
68
|
+
var props = _ref.props,
|
|
69
|
+
children = _ref.children,
|
|
70
|
+
childrenMap = _objectWithoutProperties(_ref, _excluded);
|
|
71
|
+
if (props) {
|
|
72
|
+
return /*#__PURE__*/React.createElement(TreeNode, {
|
|
73
|
+
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
74
|
+
type: "layout"
|
|
75
|
+
}),
|
|
76
|
+
title: props.label,
|
|
77
|
+
key: props.id
|
|
78
|
+
}, (children === null || children === void 0 ? void 0 : children.length) && children.map(function (_id) {
|
|
79
|
+
return render(childrenMap[_id]);
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
return (children || []).map(function (_id) {
|
|
83
|
+
return render(childrenMap[_id]);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
useDeepCompareLayoutEffect(function () {
|
|
87
|
+
var _reduce = reduce(context.pageData.children, function (result, _id) {
|
|
88
|
+
var resultKey = PAGE_CELL.includes(_id) ? 'page' : 'modal';
|
|
89
|
+
result[resultKey][_id] = context.pageData[_id];
|
|
90
|
+
if (!result[resultKey].children) {
|
|
91
|
+
result[resultKey].children = [];
|
|
92
|
+
}
|
|
93
|
+
result[resultKey].children.push(_id);
|
|
94
|
+
return result;
|
|
95
|
+
}, {
|
|
96
|
+
page: {},
|
|
97
|
+
modal: {}
|
|
98
|
+
}),
|
|
99
|
+
page = _reduce.page,
|
|
100
|
+
modal = _reduce.modal;
|
|
101
|
+
setPageAndModal({
|
|
102
|
+
page: render(page),
|
|
103
|
+
modal: render(modal)
|
|
104
|
+
});
|
|
105
|
+
}, [context.pageData]);
|
|
106
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
107
|
+
className: styles['lc-painter-outline']
|
|
108
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
109
|
+
className: classNames(styles['page-node'], _defineProperty({}, styles['page-node-active'], selectedKey === CELL_KEY.PAGE_ROOT)),
|
|
110
|
+
onClick: function onClick() {
|
|
111
|
+
return handleSelect(CELL_KEY.PAGE_ROOT);
|
|
112
|
+
}
|
|
113
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
114
|
+
type: "layout"
|
|
115
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
116
|
+
style: {
|
|
117
|
+
marginLeft: 5
|
|
118
|
+
}
|
|
119
|
+
}, formatMessage({
|
|
120
|
+
id: 'luckda.lowcode.page',
|
|
121
|
+
label: '页面'
|
|
122
|
+
}))), /*#__PURE__*/React.createElement(Card, {
|
|
123
|
+
size: "small",
|
|
124
|
+
type: "inner",
|
|
125
|
+
hoverable: true,
|
|
126
|
+
title: formatMessage({
|
|
127
|
+
id: 'luckda.lowcode.model',
|
|
128
|
+
label: '模态视图层'
|
|
129
|
+
}),
|
|
130
|
+
style: {
|
|
131
|
+
margin: 5
|
|
132
|
+
},
|
|
133
|
+
bodyStyle: {
|
|
134
|
+
padding: 0
|
|
135
|
+
}
|
|
136
|
+
}, /*#__PURE__*/React.createElement(Tree, {
|
|
137
|
+
ref: modalTreeRef,
|
|
138
|
+
showLine: true,
|
|
139
|
+
showIcon: true,
|
|
140
|
+
blockNode: true,
|
|
141
|
+
switcherIcon: /*#__PURE__*/React.createElement(Icon, {
|
|
142
|
+
type: "down"
|
|
143
|
+
}),
|
|
144
|
+
selectedKeys: [selectedKey],
|
|
145
|
+
onSelect: function onSelect(_ref2, _ref3) {
|
|
146
|
+
var _ref4 = _slicedToArray(_ref2, 1),
|
|
147
|
+
_key = _ref4[0];
|
|
148
|
+
var selected = _ref3.selected,
|
|
149
|
+
node = _ref3.node;
|
|
150
|
+
if (selected && node.props.pos.split('-').length === 2) {
|
|
151
|
+
handleOpenModal(_key);
|
|
152
|
+
handleSelect(_key);
|
|
153
|
+
} else if (!selected && node.props.pos.split('-').length === 2) {
|
|
154
|
+
var _comp = context.componentMap.get(openModal.current);
|
|
155
|
+
_comp.api.doClose();
|
|
156
|
+
openModal.current = void 0;
|
|
157
|
+
handleSelect(null);
|
|
158
|
+
} else {
|
|
159
|
+
handleSelect(node.props.eventKey);
|
|
160
|
+
var _split = split(getPathById(context.pageData, node.props.eventKey), '/'),
|
|
161
|
+
_split2 = _slicedToArray(_split, 1),
|
|
162
|
+
parentModal = _split2[0];
|
|
163
|
+
if (!openModal.current || openModal.current !== parentModal) {
|
|
164
|
+
handleOpenModal(parentModal);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
expandedKeys: modalExpandedKeys,
|
|
169
|
+
onExpand: function onExpand(_keys, _ref5) {
|
|
170
|
+
var expanded = _ref5.expanded,
|
|
171
|
+
node = _ref5.node;
|
|
172
|
+
if (expanded && node.props.pos.split('-').length === 2) {
|
|
173
|
+
handleSelect(null);
|
|
174
|
+
handleOpenModal(node.props.eventKey);
|
|
175
|
+
}
|
|
176
|
+
setModalExpandedKeys(_keys);
|
|
177
|
+
}
|
|
178
|
+
}, pageAndModal === null || pageAndModal === void 0 ? void 0 : pageAndModal.modal)), /*#__PURE__*/React.createElement(Tree, {
|
|
179
|
+
ref: pageTreeRef,
|
|
180
|
+
showLine: true,
|
|
181
|
+
showIcon: true,
|
|
182
|
+
blockNode: true,
|
|
183
|
+
switcherIcon: /*#__PURE__*/React.createElement(Icon, {
|
|
184
|
+
type: "down"
|
|
185
|
+
}),
|
|
186
|
+
selectedKeys: [selectedKey],
|
|
187
|
+
onSelect: function onSelect(_ref6, _ref7) {
|
|
188
|
+
var _ref8 = _slicedToArray(_ref6, 1),
|
|
189
|
+
_key = _ref8[0];
|
|
190
|
+
var node = _ref7.node;
|
|
191
|
+
if (openModal.current) {
|
|
192
|
+
var _prevComp = context.componentMap.get(openModal.current);
|
|
193
|
+
_prevComp.api.doClose();
|
|
194
|
+
openModal.current = void 0;
|
|
195
|
+
}
|
|
196
|
+
handleSelect(node.props.eventKey);
|
|
197
|
+
},
|
|
198
|
+
expandedKeys: pageExpandedKeys,
|
|
199
|
+
onExpand: setPageExpandedKeys
|
|
200
|
+
}, pageAndModal === null || pageAndModal === void 0 ? void 0 : pageAndModal.page));
|
|
201
|
+
};
|
|
202
|
+
export default Outline;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import styles from "./style/panel.less";
|
|
3
|
+
var Panel = function Panel() {
|
|
4
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
5
|
+
className: styles['lc-painter-panel']
|
|
6
|
+
}, "Panel");
|
|
7
|
+
};
|
|
8
|
+
export default Panel;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import { useCreation } from 'ahooks';
|
|
6
|
+
import { dynamic } from 'umi';
|
|
7
|
+
import { Box } from 'luck-design';
|
|
8
|
+
import { Icon, Tooltip, Drawer } from 'luck-design/antd';
|
|
9
|
+
import { formatMessage } from '@luck-design-biz/base/utils';
|
|
10
|
+
import { upperFirst } from 'lodash';
|
|
11
|
+
import styles from "./style/ribbon.less";
|
|
12
|
+
var _WIDTH_ = 48;
|
|
13
|
+
var _DRAWER_OUTLINE_ = {
|
|
14
|
+
width: 300,
|
|
15
|
+
key: 'outline',
|
|
16
|
+
title: '大纲树',
|
|
17
|
+
fix: true
|
|
18
|
+
};
|
|
19
|
+
var _DRAWER_COMPONENTS_ = {
|
|
20
|
+
width: 310,
|
|
21
|
+
key: 'components',
|
|
22
|
+
title: '组件',
|
|
23
|
+
fix: false
|
|
24
|
+
};
|
|
25
|
+
var _DRAWER_I18N_ = {
|
|
26
|
+
width: 450,
|
|
27
|
+
key: 'i18n',
|
|
28
|
+
title: '多语言文案管理',
|
|
29
|
+
fix: false
|
|
30
|
+
};
|
|
31
|
+
var Ribbon = function Ribbon() {
|
|
32
|
+
var _useState = useState(null),
|
|
33
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
34
|
+
drawer = _useState2[0],
|
|
35
|
+
setDrawer = _useState2[1];
|
|
36
|
+
var Detail = useCreation(function () {
|
|
37
|
+
return dynamic({
|
|
38
|
+
loader: function () {
|
|
39
|
+
var _loader = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
40
|
+
var name, _yield$import, Comp;
|
|
41
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
42
|
+
while (1) switch (_context.prev = _context.next) {
|
|
43
|
+
case 0:
|
|
44
|
+
if (!drawer) {
|
|
45
|
+
_context.next = 7;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
name = upperFirst(drawer.key);
|
|
49
|
+
_context.next = 4;
|
|
50
|
+
return import("./".concat(name));
|
|
51
|
+
case 4:
|
|
52
|
+
_yield$import = _context.sent;
|
|
53
|
+
Comp = _yield$import.default;
|
|
54
|
+
return _context.abrupt("return", Comp);
|
|
55
|
+
case 7:
|
|
56
|
+
return _context.abrupt("return", null);
|
|
57
|
+
case 8:
|
|
58
|
+
case "end":
|
|
59
|
+
return _context.stop();
|
|
60
|
+
}
|
|
61
|
+
}, _callee);
|
|
62
|
+
}));
|
|
63
|
+
function loader() {
|
|
64
|
+
return _loader.apply(this, arguments);
|
|
65
|
+
}
|
|
66
|
+
return loader;
|
|
67
|
+
}()
|
|
68
|
+
});
|
|
69
|
+
}, [drawer]);
|
|
70
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Box, {
|
|
71
|
+
className: styles['lc-painter-ribbon'],
|
|
72
|
+
width: _WIDTH_,
|
|
73
|
+
heitht: "100%",
|
|
74
|
+
direction: "column",
|
|
75
|
+
align: "center",
|
|
76
|
+
style: {
|
|
77
|
+
marginRight: drawer !== null && drawer !== void 0 && drawer.fix ? drawer.width : 0
|
|
78
|
+
}
|
|
79
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
80
|
+
placement: "right",
|
|
81
|
+
title: formatMessage({
|
|
82
|
+
id: 'luckda.lowcode.outline',
|
|
83
|
+
label: _DRAWER_OUTLINE_.title
|
|
84
|
+
})
|
|
85
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
86
|
+
type: "apartment",
|
|
87
|
+
onClick: function onClick() {
|
|
88
|
+
return setDrawer((drawer === null || drawer === void 0 ? void 0 : drawer.key) === _DRAWER_OUTLINE_.key ? null : _DRAWER_OUTLINE_);
|
|
89
|
+
}
|
|
90
|
+
})), /*#__PURE__*/React.createElement(Tooltip, {
|
|
91
|
+
placement: "right",
|
|
92
|
+
title: formatMessage({
|
|
93
|
+
id: 'luckda.lowcode.components',
|
|
94
|
+
label: _DRAWER_COMPONENTS_.title
|
|
95
|
+
})
|
|
96
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
97
|
+
type: "appstore",
|
|
98
|
+
onClick: function onClick() {
|
|
99
|
+
return setDrawer((drawer === null || drawer === void 0 ? void 0 : drawer.key) === _DRAWER_COMPONENTS_.key ? null : _DRAWER_COMPONENTS_);
|
|
100
|
+
}
|
|
101
|
+
})), /*#__PURE__*/React.createElement(Tooltip, {
|
|
102
|
+
placement: "right",
|
|
103
|
+
title: formatMessage({
|
|
104
|
+
id: 'luckda.lowcode.i18n',
|
|
105
|
+
label: _DRAWER_I18N_.title
|
|
106
|
+
})
|
|
107
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
108
|
+
type: "global",
|
|
109
|
+
onClick: function onClick() {
|
|
110
|
+
return setDrawer((drawer === null || drawer === void 0 ? void 0 : drawer.key) === _DRAWER_I18N_.key ? null : _DRAWER_I18N_);
|
|
111
|
+
}
|
|
112
|
+
}))), /*#__PURE__*/React.createElement(Drawer, {
|
|
113
|
+
title: drawer ? formatMessage({
|
|
114
|
+
id: "luckda.lowcode.".concat(drawer.key),
|
|
115
|
+
label: drawer.title
|
|
116
|
+
}) : '',
|
|
117
|
+
placement: "left",
|
|
118
|
+
width: (drawer === null || drawer === void 0 ? void 0 : drawer.width) || 0,
|
|
119
|
+
visible: !!drawer,
|
|
120
|
+
mask: false,
|
|
121
|
+
getContainer: false,
|
|
122
|
+
onClose: function onClose() {
|
|
123
|
+
return setDrawer(null);
|
|
124
|
+
},
|
|
125
|
+
style: {
|
|
126
|
+
position: 'absolute',
|
|
127
|
+
left: _WIDTH_
|
|
128
|
+
},
|
|
129
|
+
bodyStyle: {
|
|
130
|
+
overflowY: 'auto',
|
|
131
|
+
height: 'calc(100% - 55px)',
|
|
132
|
+
padding: 0
|
|
133
|
+
}
|
|
134
|
+
}, Detail && /*#__PURE__*/React.createElement(Detail, null)));
|
|
135
|
+
};
|
|
136
|
+
export default Ribbon;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styles from "../style/panel-item.less";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 属性面板属性行组件
|
|
6
|
+
* @param {string} label 属性名
|
|
7
|
+
* @param {React.ReactNode} component 属性组件
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export default function (_ref) {
|
|
11
|
+
var label = _ref.label,
|
|
12
|
+
component = _ref.component;
|
|
13
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
14
|
+
className: styles['lc-painter-components-panelitem']
|
|
15
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
16
|
+
className: styles['item-label']
|
|
17
|
+
}, label), /*#__PURE__*/React.createElement("span", {
|
|
18
|
+
className: styles['item-component']
|
|
19
|
+
}, component));
|
|
20
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
var _excluded = ["onValueChange", "rules", "value"];
|
|
6
|
+
import React, { forwardRef, useState, useEffect } from 'react';
|
|
7
|
+
import { Input, Tooltip } from 'luck-design/antd';
|
|
8
|
+
import styles from "../style/rule-input.less";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 带校验功能的输入组件。
|
|
12
|
+
*
|
|
13
|
+
* 此组件封装了antd的Input组件,并增加了输入值的校验功能。它允许开发者定义一组校验规则,
|
|
14
|
+
* 以确保用户输入符合特定要求。每条规则由一个校验函数和一个错误信息组成。如果用户的输入
|
|
15
|
+
* 不满足任何一条规则,将展示相应的错误信息提示。
|
|
16
|
+
*
|
|
17
|
+
* @component
|
|
18
|
+
* @example
|
|
19
|
+
* <RuleInput
|
|
20
|
+
* value="示例值"
|
|
21
|
+
* onValueChange={(e, newValue) => console.log('新值:', newValue)}
|
|
22
|
+
* rules={[
|
|
23
|
+
* { func: value => !!value, err: '输入不能为空' },
|
|
24
|
+
* { func: value => /^\d+$/.test(value), err: '只允许输入数字' }
|
|
25
|
+
* ]}
|
|
26
|
+
* />
|
|
27
|
+
*
|
|
28
|
+
* @param {Object} props 组件接收的props
|
|
29
|
+
* @param {string} props.value 输入框当前的值,可以由外部控制以实现受控组件。
|
|
30
|
+
* @param {Function} props.onValueChange 当输入值改变并通过所有校验时,触发的回调函数。
|
|
31
|
+
* 该函数接收原生的事件对象和新的输入值作为参数。
|
|
32
|
+
* @param {Array<{func: (value: string) => boolean, err: string}>} props.rules
|
|
33
|
+
* 定义输入校验规则的数组。每个元素是一个对象,其中`func`属性是一个函数,用于执行校验逻辑,
|
|
34
|
+
* 接收当前输入值作为参数,返回一个布尔值表示校验是否通过;`err`属性是一个字符串,指定当
|
|
35
|
+
* 校验失败时要显示的错误信息。
|
|
36
|
+
* @param {Object} rest 传递给内部Input组件的其他props,如`placeholder`、`disabled`等。
|
|
37
|
+
* @param {React.Ref} ref React ref对象,用于将ref传递给内部的Input DOM元素。
|
|
38
|
+
*
|
|
39
|
+
* @returns React元素,渲染一个带有校验功能的输入框和校验失败时的错误信息提示。
|
|
40
|
+
*/
|
|
41
|
+
export default /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
42
|
+
var onValueChange = _ref.onValueChange,
|
|
43
|
+
rules = _ref.rules,
|
|
44
|
+
value = _ref.value,
|
|
45
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
46
|
+
var _useState = useState(value),
|
|
47
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
48
|
+
inputValue = _useState2[0],
|
|
49
|
+
setInputValue = _useState2[1]; // 托管输入值的状态
|
|
50
|
+
var _useState3 = useState(null),
|
|
51
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
52
|
+
err = _useState4[0],
|
|
53
|
+
setErr = _useState4[1];
|
|
54
|
+
|
|
55
|
+
// 使用useEffect钩子监听value的变化
|
|
56
|
+
useEffect(function () {
|
|
57
|
+
setInputValue(value);
|
|
58
|
+
setErr(null);
|
|
59
|
+
}, [value]);
|
|
60
|
+
var handleInputChange = function handleInputChange(e) {
|
|
61
|
+
var value = e.target.value;
|
|
62
|
+
setInputValue(value); // 更新托管的输入值
|
|
63
|
+
|
|
64
|
+
if (value == '') onValueChange(e, value);
|
|
65
|
+
var error = null;
|
|
66
|
+
|
|
67
|
+
// 遍历rules,检查输入值是否满足条件
|
|
68
|
+
var _iterator = _createForOfIteratorHelper(rules),
|
|
69
|
+
_step;
|
|
70
|
+
try {
|
|
71
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
72
|
+
var rule = _step.value;
|
|
73
|
+
if (!rule.func(value)) {
|
|
74
|
+
error = rule.err;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
} catch (err) {
|
|
79
|
+
_iterator.e(err);
|
|
80
|
+
} finally {
|
|
81
|
+
_iterator.f();
|
|
82
|
+
}
|
|
83
|
+
if (!error) {
|
|
84
|
+
setErr(null);
|
|
85
|
+
onValueChange(e, value);
|
|
86
|
+
} else {
|
|
87
|
+
setErr(error);
|
|
88
|
+
console.log('err', error);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
var className = styles['lc-painter-components-ruleinput'];
|
|
92
|
+
if (err) className += ' ' + styles['err'];
|
|
93
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tooltip, {
|
|
94
|
+
title: err,
|
|
95
|
+
visible: err
|
|
96
|
+
}, /*#__PURE__*/React.createElement(Input, _extends({
|
|
97
|
+
className: className,
|
|
98
|
+
size: "small",
|
|
99
|
+
value: inputValue // 绑定输入值
|
|
100
|
+
,
|
|
101
|
+
onChange: handleInputChange
|
|
102
|
+
}, rest, {
|
|
103
|
+
ref: ref
|
|
104
|
+
}))));
|
|
105
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import EventBusProvider from "../engine/provider/EventBusProvider";
|
|
5
|
+
import ContextProvider from "../engine/provider/ContextProvider";
|
|
6
|
+
import Ribbon from "./Ribbon";
|
|
7
|
+
import Design from "./Design";
|
|
8
|
+
import Panel from "./Panel";
|
|
9
|
+
import { RUNTIME } from "../constants/index";
|
|
10
|
+
import styles from "./style/index.less";
|
|
11
|
+
var Painter = function Painter(_ref) {
|
|
12
|
+
var className = _ref.className;
|
|
13
|
+
return /*#__PURE__*/React.createElement(EventBusProvider, {
|
|
14
|
+
runtime: RUNTIME.DESIGN
|
|
15
|
+
}, /*#__PURE__*/React.createElement(ContextProvider, null, /*#__PURE__*/React.createElement("div", {
|
|
16
|
+
className: classNames(styles['lc-painter'], _defineProperty({}, className, !!className))
|
|
17
|
+
}, /*#__PURE__*/React.createElement(Ribbon, null), /*#__PURE__*/React.createElement(Design, null), /*#__PURE__*/React.createElement(Panel, null))));
|
|
18
|
+
};
|
|
19
|
+
export default Painter;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useState, useImperativeHandle, forwardRef } from 'react';
|
|
3
|
+
import styles from "../style/layout-ratio.less";
|
|
4
|
+
import { formatMessage } from '@luck-design-biz/base/utils';
|
|
5
|
+
import RuleInput from "../components/RuleInput";
|
|
6
|
+
import PanelItem from "../components/PanelItem";
|
|
7
|
+
var ratios = ['12', '6:6', '3:9', '9:3', '4:4:4', '3:6:3', '3:3:3:3', '2:2:2:2:2:2'];
|
|
8
|
+
var defaultRatio = '12';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 布局比例组件
|
|
12
|
+
*
|
|
13
|
+
* @param {string} value 默认值
|
|
14
|
+
* @param {Function} onChange 当合法数据变化时触发
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
var LayoutRatio = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
18
|
+
var value = _ref.value,
|
|
19
|
+
onChange = _ref.onChange;
|
|
20
|
+
var _useState = useState(value || defaultRatio),
|
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
+
currentRatio = _useState2[0],
|
|
23
|
+
setCurrentRatio = _useState2[1];
|
|
24
|
+
var handleInputChange = function handleInputChange(_, value) {
|
|
25
|
+
console.log('value', value);
|
|
26
|
+
if (!value) value = defaultRatio;
|
|
27
|
+
setCurrentRatio(value);
|
|
28
|
+
};
|
|
29
|
+
var handGridClick = function handGridClick(selectedRadio) {
|
|
30
|
+
// console.log('selectedRadio', selectedRadio);
|
|
31
|
+
setCurrentRatio(selectedRadio);
|
|
32
|
+
if (onChange) onChange(selectedRadio);
|
|
33
|
+
};
|
|
34
|
+
useImperativeHandle(ref, function () {
|
|
35
|
+
return {
|
|
36
|
+
getValue: function getValue() {
|
|
37
|
+
return currentRatio;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// 定义验证规则
|
|
43
|
+
var rules = [{
|
|
44
|
+
func: function func(value) {
|
|
45
|
+
// 首先,检查value是否为字符串
|
|
46
|
+
if (typeof value !== 'string') return false;
|
|
47
|
+
|
|
48
|
+
// 使用正则表达式检查字符串是否只包含数字和冒号,并且不以冒号开始或结束
|
|
49
|
+
if (!/^[0-9]+(:[0-9]+)*$/.test(value)) return false;
|
|
50
|
+
|
|
51
|
+
// 使用冒号分割字符串,并将分割后的每个元素转换为数字
|
|
52
|
+
var numbers = value.split(':').map(Number);
|
|
53
|
+
|
|
54
|
+
// 计算所有数字的总和
|
|
55
|
+
var sum = numbers.reduce(function (acc, cur) {
|
|
56
|
+
return acc + cur;
|
|
57
|
+
}, 0);
|
|
58
|
+
|
|
59
|
+
// 判断总和是否等于12
|
|
60
|
+
return sum === 12;
|
|
61
|
+
},
|
|
62
|
+
err: formatMessage({
|
|
63
|
+
id: 'luckda.lowcode.painter.panel-section.Layoutratio.err',
|
|
64
|
+
label: '必须是数字或者数字加:号的组合,且数字之和必须等于12'
|
|
65
|
+
})
|
|
66
|
+
}];
|
|
67
|
+
var isCurrentInRatios = ratios.includes(currentRatio);
|
|
68
|
+
var currentItemRatios = currentRatio.split(':');
|
|
69
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
className: styles['lc-painter-panel-section-layoutratio']
|
|
71
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
72
|
+
className: styles['ratio-view']
|
|
73
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
74
|
+
className: styles['gridbox-container']
|
|
75
|
+
}, ratios.map(function (ratio) {
|
|
76
|
+
var itemRatios = ratio.split(':');
|
|
77
|
+
var isCurrent = ratio == currentRatio;
|
|
78
|
+
var className = styles['gridbox'];
|
|
79
|
+
if (isCurrent) className = className + ' ' + styles['current'];
|
|
80
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
81
|
+
className: className,
|
|
82
|
+
onClick: function onClick() {
|
|
83
|
+
return handGridClick(ratio);
|
|
84
|
+
}
|
|
85
|
+
}, itemRatios.map(function (itemRatio) {
|
|
86
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
87
|
+
className: styles['girditem'],
|
|
88
|
+
style: {
|
|
89
|
+
gridColumn: 'span ' + itemRatio
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}));
|
|
93
|
+
}), !isCurrentInRatios && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
94
|
+
className: "".concat(styles['gridbox'], " ").concat(styles['current']),
|
|
95
|
+
onClick: function onClick() {
|
|
96
|
+
return handGridClick(ratio);
|
|
97
|
+
}
|
|
98
|
+
}, currentItemRatios.map(function (itemRatio) {
|
|
99
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
100
|
+
className: styles['girditem'],
|
|
101
|
+
style: {
|
|
102
|
+
gridColumn: 'span ' + itemRatio
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}))))), /*#__PURE__*/React.createElement("div", {
|
|
106
|
+
className: styles['ratio-input']
|
|
107
|
+
}, /*#__PURE__*/React.createElement(PanelItem, {
|
|
108
|
+
label: formatMessage({
|
|
109
|
+
id: 'luckda.lowcode.painter.panel-section.Layoutratio.label',
|
|
110
|
+
label: '列比例'
|
|
111
|
+
}),
|
|
112
|
+
component: /*#__PURE__*/React.createElement(RuleInput, {
|
|
113
|
+
placeholder: formatMessage({
|
|
114
|
+
id: 'luckda.lowcode.painter.panel-section.Layoutratio.placeholder',
|
|
115
|
+
label: '请输入列比例'
|
|
116
|
+
}),
|
|
117
|
+
rules: rules,
|
|
118
|
+
onValueChange: handleInputChange,
|
|
119
|
+
value: currentRatio
|
|
120
|
+
})
|
|
121
|
+
})));
|
|
122
|
+
});
|
|
123
|
+
export default LayoutRatio;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import styles from "../style/radio.less";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Radio组件允许用户从一组选项中选择一个。它接收一个`options`数组来渲染选项,以及一个可选的`onChange`回调函数,
|
|
7
|
+
* 当用户选择不同的选项时,`onChange`会被调用并传递当前选中的选项对象。
|
|
8
|
+
*
|
|
9
|
+
* @component
|
|
10
|
+
* @example
|
|
11
|
+
* const options = [
|
|
12
|
+
* { label: '小', value: 'small' },
|
|
13
|
+
* { label: '中', value: 'middle' },
|
|
14
|
+
* { label: '大', value: 'large' }
|
|
15
|
+
* ];
|
|
16
|
+
*
|
|
17
|
+
* function handleChange(option) {
|
|
18
|
+
* console.log(option);
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* <Radio options={options} onChange={handleChange} />
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} props - 组件的props。
|
|
24
|
+
* @param {Object[]} props.options - 选项数组,每个对象都应包含`label`和`value`。
|
|
25
|
+
* @param {string} props.options[].label - 选项的显示文本。
|
|
26
|
+
* @param {string} props.options[].value - 选项的值,应唯一。
|
|
27
|
+
* @param {Function} [props.onChange] - 可选,当选项变化时调用的回调函数。传递当前选中的选项对象。
|
|
28
|
+
*/
|
|
29
|
+
var Radio = function Radio(_ref) {
|
|
30
|
+
var _options$;
|
|
31
|
+
var options = _ref.options,
|
|
32
|
+
onChange = _ref.onChange;
|
|
33
|
+
var _useState = useState((_options$ = options[0]) === null || _options$ === void 0 ? void 0 : _options$.value),
|
|
34
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
+
activeValue = _useState2[0],
|
|
36
|
+
setActiveValue = _useState2[1];
|
|
37
|
+
|
|
38
|
+
// 点击事件处理函数
|
|
39
|
+
var handleClick = function handleClick(option) {
|
|
40
|
+
// 设置当前激活的选项
|
|
41
|
+
setActiveValue(option.value);
|
|
42
|
+
if (onChange) {
|
|
43
|
+
onChange(option);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
className: styles['lc-painter-panel-section-radio']
|
|
48
|
+
}, options.map(function (option) {
|
|
49
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
50
|
+
key: option.value,
|
|
51
|
+
className: "".concat(styles['radio-item'], " ").concat(activeValue === option.value ? 'active' : ''),
|
|
52
|
+
onClick: function onClick() {
|
|
53
|
+
return handleClick(option);
|
|
54
|
+
}
|
|
55
|
+
}, option.label);
|
|
56
|
+
}));
|
|
57
|
+
};
|
|
58
|
+
export default Radio;
|