@aloudata/aloudata-design 2.13.11 → 2.13.12
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/dist/Icon/components/DragLightLine.js +3 -3
- package/dist/Icon/components/TrashLightLine.d.ts +11 -0
- package/dist/Icon/components/TrashLightLine.js +38 -0
- package/dist/Icon/index.d.ts +1 -0
- package/dist/Icon/index.js +1 -0
- package/dist/Icon/svg/Trash-light-line.svg +8 -0
- package/dist/Icon/svg/drag-light-line.svg +2 -2
- package/dist/LogicTree/components/LogicItem/index.d.ts +3 -3
- package/dist/LogicTree/components/LogicItem/index.js +121 -37
- package/dist/LogicTree/helper.d.ts +1 -0
- package/dist/LogicTree/helper.js +8 -0
- package/dist/LogicTree/index.d.ts +4 -0
- package/dist/LogicTree/index.js +17 -10
- package/dist/LogicTree/style/LoginItem.less +71 -15
- package/dist/ald.min.css +1 -1
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ var DragLightLine = function DragLightLine(_ref, ref) {
|
|
|
15
15
|
width: props.width || props.size || 16,
|
|
16
16
|
height: props.height || props.size || 16,
|
|
17
17
|
fill: "none",
|
|
18
|
-
viewBox: "0 0
|
|
18
|
+
viewBox: "0 0 24 24",
|
|
19
19
|
ref: ref,
|
|
20
20
|
"aria-labelledby": titleId,
|
|
21
21
|
"aria-describedby": descId
|
|
@@ -24,9 +24,9 @@ var DragLightLine = function DragLightLine(_ref, ref) {
|
|
|
24
24
|
}, desc) : null, title ? /*#__PURE__*/React.createElement("title", {
|
|
25
25
|
id: titleId
|
|
26
26
|
}, title) : null, /*#__PURE__*/React.createElement("path", {
|
|
27
|
-
fill:
|
|
27
|
+
fill: props.color || 'currentColor',
|
|
28
28
|
fillRule: "evenodd",
|
|
29
|
-
d: "
|
|
29
|
+
d: "M9 6a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm0 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm1 6a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm5-13a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm0 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm1 6a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",
|
|
30
30
|
clipRule: "evenodd"
|
|
31
31
|
}));
|
|
32
32
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SVGProps } from 'react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
interface SVGRProps {
|
|
4
|
+
size?: number | string;
|
|
5
|
+
title?: string;
|
|
6
|
+
titleId?: string;
|
|
7
|
+
desc?: string;
|
|
8
|
+
descId?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const Memo: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<SVGProps<SVGSVGElement> & SVGRProps, "ref"> & React.RefAttributes<SVGSVGElement>>>;
|
|
11
|
+
export default Memo;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var _excluded = ["title", "titleId", "desc", "descId"];
|
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { forwardRef, memo } from 'react';
|
|
7
|
+
var TrashLightLine = function TrashLightLine(_ref, ref) {
|
|
8
|
+
var title = _ref.title,
|
|
9
|
+
titleId = _ref.titleId,
|
|
10
|
+
desc = _ref.desc,
|
|
11
|
+
descId = _ref.descId,
|
|
12
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
13
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
14
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15
|
+
width: props.width || props.size || 16,
|
|
16
|
+
height: props.height || props.size || 16,
|
|
17
|
+
fill: "none",
|
|
18
|
+
viewBox: "0 0 24 24",
|
|
19
|
+
ref: ref,
|
|
20
|
+
"aria-labelledby": titleId,
|
|
21
|
+
"aria-describedby": descId
|
|
22
|
+
}, props), desc ? /*#__PURE__*/React.createElement("desc", {
|
|
23
|
+
id: descId
|
|
24
|
+
}, desc) : null, title ? /*#__PURE__*/React.createElement("title", {
|
|
25
|
+
id: titleId
|
|
26
|
+
}, title) : null, /*#__PURE__*/React.createElement("g", {
|
|
27
|
+
fill: props.color || 'currentColor'
|
|
28
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
29
|
+
d: "M8.75 3.25a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z"
|
|
30
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
31
|
+
fillRule: "evenodd",
|
|
32
|
+
d: "M4 6.25a.75.75 0 0 0 0 1.5h1.25V18A2.75 2.75 0 0 0 8 20.75h8A2.75 2.75 0 0 0 18.75 18V7.75H20a.75.75 0 0 0 0-1.5H4ZM6.75 18V7.75h10.5V18c0 .69-.56 1.25-1.25 1.25H8c-.69 0-1.25-.56-1.25-1.25Z",
|
|
33
|
+
clipRule: "evenodd"
|
|
34
|
+
})));
|
|
35
|
+
};
|
|
36
|
+
var ForwardRef = /*#__PURE__*/forwardRef(TrashLightLine);
|
|
37
|
+
var Memo = /*#__PURE__*/memo(ForwardRef);
|
|
38
|
+
export default Memo;
|
package/dist/Icon/index.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export { default as SortAscendingOrderColor } from './components/SortAscendingOr
|
|
|
44
44
|
export { default as SortColor } from './components/SortColor';
|
|
45
45
|
export { default as SortDescendingOrderColor } from './components/SortDescendingOrderColor';
|
|
46
46
|
export { default as TimesLightLine } from './components/TimesLightLine';
|
|
47
|
+
export { default as TrashLightLine } from './components/TrashLightLine';
|
|
47
48
|
export { default as TriangleLightLine } from './components/TriangleLightLine';
|
|
48
49
|
export { default as User } from './components/User';
|
|
49
50
|
export { default as UserGroup } from './components/UserGroup';
|
package/dist/Icon/index.js
CHANGED
|
@@ -44,6 +44,7 @@ export { default as SortAscendingOrderColor } from "./components/SortAscendingOr
|
|
|
44
44
|
export { default as SortColor } from "./components/SortColor";
|
|
45
45
|
export { default as SortDescendingOrderColor } from "./components/SortDescendingOrderColor";
|
|
46
46
|
export { default as TimesLightLine } from "./components/TimesLightLine";
|
|
47
|
+
export { default as TrashLightLine } from "./components/TrashLightLine";
|
|
47
48
|
export { default as TriangleLightLine } from "./components/TriangleLightLine";
|
|
48
49
|
export { default as User } from "./components/User";
|
|
49
50
|
export { default as UserGroup } from "./components/UserGroup";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g id=" Icon / Light / General / Trash-light-line">
|
|
3
|
+
<g id="Icon">
|
|
4
|
+
<path d="M8.75 3.25C8.33579 3.25 8 3.58579 8 4C8 4.41421 8.33579 4.75 8.75 4.75H15.25C15.6642 4.75 16 4.41421 16 4C16 3.58579 15.6642 3.25 15.25 3.25H8.75Z" fill="black"/>
|
|
5
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M4 6.25C3.58579 6.25 3.25 6.58579 3.25 7C3.25 7.41421 3.58579 7.75 4 7.75H5.25V18C5.25 19.5188 6.48122 20.75 8 20.75H16C17.5188 20.75 18.75 19.5188 18.75 18V7.75H20C20.4142 7.75 20.75 7.41421 20.75 7C20.75 6.58579 20.4142 6.25 20 6.25H4ZM6.75 18V7.75H17.25V18C17.25 18.6904 16.6904 19.25 16 19.25H8C7.30964 19.25 6.75 18.6904 6.75 18Z" fill="black"/>
|
|
6
|
+
</g>
|
|
7
|
+
</g>
|
|
8
|
+
</svg>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<svg width="
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
2
|
<g id=" Icon / Light / Interface / drag-light-line">
|
|
3
|
-
<path id="Icon" fill-rule="evenodd" clip-rule="evenodd" d="
|
|
3
|
+
<path id="Icon" fill-rule="evenodd" clip-rule="evenodd" d="M9 6C9.55229 6 10 5.55228 10 5C10 4.44772 9.55229 4 9 4C8.44771 4 8 4.44772 8 5C8 5.55228 8.44771 6 9 6ZM9 13C9.55229 13 10 12.5523 10 12C10 11.4477 9.55229 11 9 11C8.44771 11 8 11.4477 8 12C8 12.5523 8.44771 13 9 13ZM10 19C10 19.5523 9.55229 20 9 20C8.44771 20 8 19.5523 8 19C8 18.4477 8.44771 18 9 18C9.55229 18 10 18.4477 10 19ZM15 6C15.5523 6 16 5.55228 16 5C16 4.44772 15.5523 4 15 4C14.4477 4 14 4.44772 14 5C14 5.55228 14.4477 6 15 6ZM15 13C15.5523 13 16 12.5523 16 12C16 11.4477 15.5523 11 15 11C14.4477 11 14 11.4477 14 12C14 12.5523 14.4477 13 15 13ZM16 19C16 19.5523 15.5523 20 15 20C14.4477 20 14 19.5523 14 19C14 18.4477 14.4477 18 15 18C15.5523 18 16 18.4477 16 19Z" fill="black"/>
|
|
4
4
|
</g>
|
|
5
5
|
</svg>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TRenderCondition } from '../..';
|
|
2
|
+
import { EPutPosition, TRenderCondition } from '../..';
|
|
3
3
|
import { ELogicType, TNode } from '../../type';
|
|
4
4
|
interface IProps<T> {
|
|
5
5
|
value: TNode<T>;
|
|
@@ -9,10 +9,10 @@ interface IProps<T> {
|
|
|
9
9
|
changeRecordData: (id: string, data: T) => void;
|
|
10
10
|
changeRelation: (id: string, logicType: ELogicType) => void;
|
|
11
11
|
renderCondition: TRenderCondition<T>;
|
|
12
|
-
onDragEnd: (dragId: string, hoverId: string) => void;
|
|
12
|
+
onDragEnd: (dragId: string, hoverId: string, dropPosition: EPutPosition) => void;
|
|
13
13
|
hoverId: string;
|
|
14
14
|
setHoverId: (id: string) => void;
|
|
15
15
|
isRoot?: boolean;
|
|
16
16
|
}
|
|
17
|
-
export default function LogicItem<T>({ value, addCondition, addRelation, changeRecordData, remove, changeRelation, renderCondition, onDragEnd,
|
|
17
|
+
export default function LogicItem<T>({ value, addCondition, addRelation, changeRecordData, remove, changeRelation, renderCondition, onDragEnd, hoverId, setHoverId, isRoot, }: IProps<T>): React.JSX.Element;
|
|
18
18
|
export {};
|
|
@@ -7,15 +7,17 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
7
7
|
import classNames from 'classnames';
|
|
8
8
|
import _ from 'lodash';
|
|
9
9
|
import React, { useContext, useRef, useState } from 'react';
|
|
10
|
-
import { useDrag, useDrop } from 'react-dnd';
|
|
10
|
+
import { DragPreviewImage, useDrag, useDrop } from 'react-dnd';
|
|
11
|
+
import { EPutPosition } from "../..";
|
|
11
12
|
import DragLightLine from "../../../Icon/components/DragLightLine";
|
|
12
13
|
import PlusIcon from "../../../Icon/components/SignLightLine";
|
|
13
|
-
import
|
|
14
|
+
import TrashLightLine from "../../../Icon/components/TrashLightLine";
|
|
14
15
|
import IconButton from "../../../IconButton";
|
|
15
16
|
import Select from "../../../Select";
|
|
16
17
|
import TextLink from "../../../TextLink";
|
|
17
18
|
import { LocaleContext, getTranslator } from "../../../locale/default";
|
|
18
19
|
import { ELogicType, ENodeType } from "../../type";
|
|
20
|
+
var dargPreviewImg = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAYSURBVHgB7cAxAQAAAMKg9U9tCU8oAPgYBlQAAX19SpgAAAAASUVORK5CYII=';
|
|
19
21
|
var TWO = 2;
|
|
20
22
|
export default function LogicItem(_ref) {
|
|
21
23
|
var value = _ref.value,
|
|
@@ -26,18 +28,26 @@ export default function LogicItem(_ref) {
|
|
|
26
28
|
changeRelation = _ref.changeRelation,
|
|
27
29
|
renderCondition = _ref.renderCondition,
|
|
28
30
|
onDragEnd = _ref.onDragEnd,
|
|
29
|
-
_ref$isRoot = _ref.isRoot,
|
|
30
|
-
isRoot = _ref$isRoot === void 0 ? false : _ref$isRoot,
|
|
31
31
|
hoverId = _ref.hoverId,
|
|
32
|
-
setHoverId = _ref.setHoverId
|
|
33
|
-
|
|
32
|
+
setHoverId = _ref.setHoverId,
|
|
33
|
+
_ref$isRoot = _ref.isRoot,
|
|
34
|
+
isRoot = _ref$isRoot === void 0 ? false : _ref$isRoot;
|
|
35
|
+
var _useState = useState(false),
|
|
34
36
|
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
isHoverDragBox = _useState2[0],
|
|
38
|
+
setIsHoverDragBox = _useState2[1];
|
|
37
39
|
var _useState3 = useState(0),
|
|
38
40
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
firstNodeHight = _useState4[0],
|
|
42
|
+
setFirstNodeHight = _useState4[1];
|
|
43
|
+
var _useState5 = useState(0),
|
|
44
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
45
|
+
lastNodeHight = _useState6[0],
|
|
46
|
+
setLastNodeHight = _useState6[1];
|
|
47
|
+
var _useState7 = useState(),
|
|
48
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
49
|
+
dropPosition = _useState8[0],
|
|
50
|
+
setDropPosition = _useState8[1];
|
|
41
51
|
var _useContext = useContext(LocaleContext),
|
|
42
52
|
locale = _useContext.locale;
|
|
43
53
|
var t = getTranslator(locale);
|
|
@@ -60,13 +70,38 @@ export default function LogicItem(_ref) {
|
|
|
60
70
|
isDragging: monitor.isDragging()
|
|
61
71
|
};
|
|
62
72
|
},
|
|
63
|
-
canDrag: !isRoot
|
|
73
|
+
canDrag: !isRoot && isHoverDragBox
|
|
64
74
|
}),
|
|
65
|
-
_useDrag2 = _slicedToArray(_useDrag,
|
|
75
|
+
_useDrag2 = _slicedToArray(_useDrag, 3),
|
|
66
76
|
isDragging = _useDrag2[0].isDragging,
|
|
67
|
-
drag = _useDrag2[1]
|
|
77
|
+
drag = _useDrag2[1],
|
|
78
|
+
preview = _useDrag2[2];
|
|
68
79
|
var _useDrop = useDrop({
|
|
69
80
|
accept: 'LOGIC_ITEM',
|
|
81
|
+
hover: function hover(item, monitor) {
|
|
82
|
+
if (!ref.current) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
var dragId = item.id;
|
|
86
|
+
var hoverId = value.id;
|
|
87
|
+
if (dragId === hoverId) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// 检查是否为最顶层的放置目标
|
|
91
|
+
if (monitor.didDrop()) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 获取鼠标位置和目标元素位置
|
|
96
|
+
var hoverBoundingRect = ref.current.getBoundingClientRect();
|
|
97
|
+
var hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;
|
|
98
|
+
var clientOffset = monitor.getClientOffset();
|
|
99
|
+
if (clientOffset) {
|
|
100
|
+
var hoverClientY = clientOffset.y - hoverBoundingRect.top;
|
|
101
|
+
var _dropPosition = hoverClientY < hoverMiddleY ? EPutPosition.TOP : EPutPosition.BOTTOM;
|
|
102
|
+
setDropPosition(_dropPosition);
|
|
103
|
+
} else setDropPosition(undefined);
|
|
104
|
+
},
|
|
70
105
|
drop: function drop(item, monitor) {
|
|
71
106
|
if (!ref.current) {
|
|
72
107
|
return;
|
|
@@ -80,7 +115,18 @@ export default function LogicItem(_ref) {
|
|
|
80
115
|
if (monitor.didDrop()) {
|
|
81
116
|
return;
|
|
82
117
|
}
|
|
83
|
-
|
|
118
|
+
|
|
119
|
+
// 获取鼠标位置和目标元素位置
|
|
120
|
+
var hoverBoundingRect = ref.current.getBoundingClientRect();
|
|
121
|
+
var hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;
|
|
122
|
+
var clientOffset = monitor.getClientOffset();
|
|
123
|
+
if (clientOffset) {
|
|
124
|
+
var hoverClientY = clientOffset.y - hoverBoundingRect.top;
|
|
125
|
+
|
|
126
|
+
// 确定放置位置
|
|
127
|
+
var _dropPosition2 = hoverClientY < hoverMiddleY ? EPutPosition.TOP : EPutPosition.BOTTOM;
|
|
128
|
+
onDragEnd(dragId, hoverId, _dropPosition2);
|
|
129
|
+
}
|
|
84
130
|
},
|
|
85
131
|
collect: function collect(monitor) {
|
|
86
132
|
return {
|
|
@@ -134,22 +180,20 @@ export default function LogicItem(_ref) {
|
|
|
134
180
|
var verticalLineHeight = nodes.length > 1 ? "calc(100% - ".concat(firstNodeHight / TWO, "px - ").concat(lastNodeHight / TWO, "px - 42px)") : "30px";
|
|
135
181
|
return /*#__PURE__*/React.createElement("div", {
|
|
136
182
|
className: classNames('ald-logic-tree-logic-node', {
|
|
137
|
-
'is-
|
|
138
|
-
'is-
|
|
139
|
-
'is-
|
|
183
|
+
'is-hover-drag-box': isHoverDragBox,
|
|
184
|
+
'is-dragging': isDragging,
|
|
185
|
+
'is-hover-top': isDragOver && dropPosition === EPutPosition.TOP,
|
|
186
|
+
'is-hover-bottom': isDragOver && dropPosition === EPutPosition.BOTTOM
|
|
140
187
|
}),
|
|
141
|
-
ref: ref,
|
|
142
188
|
onMouseMove: function onMouseMove(e) {
|
|
143
189
|
e.stopPropagation();
|
|
144
190
|
setHoverId(value.id);
|
|
145
191
|
},
|
|
146
192
|
onMouseOut: function onMouseOut(e) {
|
|
147
193
|
e.stopPropagation();
|
|
148
|
-
setHoverId(
|
|
194
|
+
setHoverId('');
|
|
149
195
|
},
|
|
150
|
-
|
|
151
|
-
opacity: isDragging ? 0.5 : 1
|
|
152
|
-
}
|
|
196
|
+
ref: ref
|
|
153
197
|
}, _.map(nodes, function (node, index) {
|
|
154
198
|
var ref = null;
|
|
155
199
|
if (index === 0) {
|
|
@@ -196,24 +240,47 @@ export default function LogicItem(_ref) {
|
|
|
196
240
|
height: verticalLineHeight,
|
|
197
241
|
top: "".concat(firstNodeHight / TWO + 4, "px")
|
|
198
242
|
}
|
|
199
|
-
}), !isRoot && (hoverId === value.id || isDragging) && /*#__PURE__*/React.createElement(
|
|
243
|
+
}), !isRoot && (hoverId === value.id || isDragging) && /*#__PURE__*/React.createElement("div", {
|
|
244
|
+
className: "ald-logic-tree-node-drag-icon-wrapper",
|
|
245
|
+
onMouseMove: function onMouseMove(e) {
|
|
246
|
+
e.stopPropagation();
|
|
247
|
+
setIsHoverDragBox(true);
|
|
248
|
+
setHoverId(value.id);
|
|
249
|
+
},
|
|
250
|
+
onMouseOut: function onMouseOut(e) {
|
|
251
|
+
e.stopPropagation();
|
|
252
|
+
setIsHoverDragBox(false);
|
|
253
|
+
}
|
|
254
|
+
}, /*#__PURE__*/React.createElement(DragLightLine, {
|
|
255
|
+
onMouseMove: function onMouseMove(e) {
|
|
256
|
+
e.stopPropagation();
|
|
257
|
+
setIsHoverDragBox(true);
|
|
258
|
+
setHoverId(value.id);
|
|
259
|
+
},
|
|
200
260
|
size: 16,
|
|
201
|
-
color: "#
|
|
261
|
+
color: "#374151",
|
|
202
262
|
className: "ald-logic-tree-node-drag-icon"
|
|
203
|
-
}), /*#__PURE__*/React.createElement(Select, {
|
|
263
|
+
})), /*#__PURE__*/React.createElement(Select, {
|
|
204
264
|
options: logicOptions,
|
|
205
265
|
className: "ald-logic-tree-select-relation",
|
|
206
266
|
size: "small",
|
|
207
267
|
value: _logicType,
|
|
208
268
|
onChange: onChangeRelation,
|
|
209
269
|
disabled: nodes.length <= 1
|
|
270
|
+
}), /*#__PURE__*/React.createElement(DragPreviewImage, {
|
|
271
|
+
connect: preview,
|
|
272
|
+
src: dargPreviewImg
|
|
210
273
|
}));
|
|
211
274
|
}
|
|
212
|
-
return /*#__PURE__*/React.createElement(
|
|
275
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DragPreviewImage, {
|
|
276
|
+
connect: preview,
|
|
277
|
+
src: dargPreviewImg
|
|
278
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
213
279
|
className: classNames('ald-logic-tree-record-node', {
|
|
214
|
-
'is-
|
|
215
|
-
'is-
|
|
216
|
-
'is-
|
|
280
|
+
'is-hover-drag-box': isHoverDragBox,
|
|
281
|
+
'is-dragging': isDragging,
|
|
282
|
+
'is-hover-top': isDragOver && dropPosition === EPutPosition.TOP,
|
|
283
|
+
'is-hover-bottom': isDragOver && dropPosition === EPutPosition.BOTTOM
|
|
217
284
|
}),
|
|
218
285
|
ref: ref,
|
|
219
286
|
onMouseMove: function onMouseMove(e) {
|
|
@@ -222,23 +289,40 @@ export default function LogicItem(_ref) {
|
|
|
222
289
|
},
|
|
223
290
|
onMouseOut: function onMouseOut(e) {
|
|
224
291
|
e.stopPropagation();
|
|
292
|
+
setHoverId('');
|
|
293
|
+
}
|
|
294
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
295
|
+
className: "ald-logic-tree-node-drag-icon-preview",
|
|
296
|
+
ref: preview
|
|
297
|
+
}), (hoverId === value.id || isDragging) && /*#__PURE__*/React.createElement("div", {
|
|
298
|
+
className: "ald-logic-tree-record-node-drag-icon-wrapper",
|
|
299
|
+
onMouseMove: function onMouseMove(e) {
|
|
300
|
+
e.stopPropagation();
|
|
301
|
+
setIsHoverDragBox(true);
|
|
225
302
|
setHoverId(value.id);
|
|
226
303
|
},
|
|
227
|
-
|
|
228
|
-
|
|
304
|
+
onMouseOut: function onMouseOut(e) {
|
|
305
|
+
e.stopPropagation();
|
|
306
|
+
setIsHoverDragBox(false);
|
|
229
307
|
}
|
|
230
|
-
},
|
|
308
|
+
}, /*#__PURE__*/React.createElement(DragLightLine, {
|
|
309
|
+
onMouseMove: function onMouseMove(e) {
|
|
310
|
+
e.stopPropagation();
|
|
311
|
+
setIsHoverDragBox(true);
|
|
312
|
+
setHoverId(value.id);
|
|
313
|
+
},
|
|
231
314
|
size: 16,
|
|
232
|
-
color: "#
|
|
315
|
+
color: "#374151",
|
|
233
316
|
className: "ald-logic-tree-record-node-drag-icon"
|
|
234
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
317
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
235
318
|
className: "ald-logic-tree-render-condition-wrap"
|
|
236
319
|
}, renderCondition(value.data, {
|
|
237
320
|
changeData: onChangeRecordData
|
|
238
321
|
})), /*#__PURE__*/React.createElement(IconButton, {
|
|
239
|
-
icon: /*#__PURE__*/React.createElement(
|
|
240
|
-
size:
|
|
322
|
+
icon: /*#__PURE__*/React.createElement(TrashLightLine, {
|
|
323
|
+
size: 16
|
|
241
324
|
}),
|
|
325
|
+
size: 'small',
|
|
242
326
|
onClick: onRemove
|
|
243
|
-
}));
|
|
327
|
+
})));
|
|
244
328
|
}
|
|
@@ -8,3 +8,4 @@ export declare function changeRelation<T>(id: string, logicType: ELogicType, roo
|
|
|
8
8
|
export declare function changeRecordData<T>(id: string, newData: T, rootNode: TNode<T>): TNode<T>;
|
|
9
9
|
export declare function getInitialLogicNode<T>(initialData: T[]): TNode<T>;
|
|
10
10
|
export declare function logicTreeIterator<T, U>(rootNode: TNode<T>, callback: (node: TNode<T>, acc: U[]) => U): U;
|
|
11
|
+
export declare function isDescendant<T>(hoverId: string, dragNode: TNode<T>): boolean;
|
package/dist/LogicTree/helper.js
CHANGED
|
@@ -180,4 +180,12 @@ export function logicTreeIterator(rootNode, callback) {
|
|
|
180
180
|
return callback(rootNode, []);
|
|
181
181
|
}
|
|
182
182
|
return callback(rootNode, []);
|
|
183
|
+
}
|
|
184
|
+
export function isDescendant(hoverId, dragNode) {
|
|
185
|
+
if (!dragNode || dragNode.type === ENodeType.RECORD) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
return dragNode.nodes.some(function (childNode) {
|
|
189
|
+
return childNode.id === hoverId || isDescendant(hoverId, childNode);
|
|
190
|
+
});
|
|
183
191
|
}
|
|
@@ -3,6 +3,10 @@ import DisplayLogicTree from './DisplayLogicTree';
|
|
|
3
3
|
import { ELogicType, ENodeType, TNode } from './type';
|
|
4
4
|
export type { TNode };
|
|
5
5
|
export { DisplayLogicTree, ELogicType, ENodeType };
|
|
6
|
+
export declare enum EPutPosition {
|
|
7
|
+
TOP = "TOP",
|
|
8
|
+
BOTTOM = "BOTTOM"
|
|
9
|
+
}
|
|
6
10
|
export type TRenderCondition<T> = (data: T, { changeData }: {
|
|
7
11
|
changeData: (data: T) => void;
|
|
8
12
|
}) => React.ReactNode;
|
package/dist/LogicTree/index.js
CHANGED
|
@@ -13,9 +13,14 @@ import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
|
13
13
|
import { getUniqId } from "../_utils/getUniqId";
|
|
14
14
|
import DisplayLogicTree from "./DisplayLogicTree";
|
|
15
15
|
import LogicItem from "./components/LogicItem";
|
|
16
|
-
import { addLogicNode, addRecordNode, changeRecordData, changeRelation, findNodeById, findParentNodeById, removeNode } from "./helper";
|
|
16
|
+
import { addLogicNode, addRecordNode, changeRecordData, changeRelation, findNodeById, findParentNodeById, isDescendant, removeNode } from "./helper";
|
|
17
17
|
import { ELogicType, ENodeType } from "./type";
|
|
18
18
|
export { DisplayLogicTree, ELogicType, ENodeType };
|
|
19
|
+
export var EPutPosition = /*#__PURE__*/function (EPutPosition) {
|
|
20
|
+
EPutPosition["TOP"] = "TOP";
|
|
21
|
+
EPutPosition["BOTTOM"] = "BOTTOM";
|
|
22
|
+
return EPutPosition;
|
|
23
|
+
}({});
|
|
19
24
|
export default function LogicTree(props) {
|
|
20
25
|
var newInitializationData = props.newInitializationData,
|
|
21
26
|
propsOnChange = props.onChange,
|
|
@@ -70,40 +75,42 @@ export default function LogicTree(props) {
|
|
|
70
75
|
var newRootNode = changeRecordData(id, data, innerValue);
|
|
71
76
|
changeInnerValue(newRootNode);
|
|
72
77
|
};
|
|
73
|
-
var moveNode = useCallback(function (dragId, hoverId) {
|
|
78
|
+
var moveNode = useCallback(function (dragId, hoverId, dropPosition) {
|
|
74
79
|
var newRootNode = _.cloneDeep(innerValue);
|
|
75
80
|
var dragNode = findNodeById(dragId, newRootNode);
|
|
76
81
|
var hoverNode = findNodeById(hoverId, newRootNode);
|
|
77
82
|
if (dragNode && hoverNode) {
|
|
83
|
+
if (isDescendant(hoverId, dragNode)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
78
86
|
var dragParent = findParentNodeById(dragId, newRootNode);
|
|
79
87
|
var hoverParent = findParentNodeById(hoverId, newRootNode);
|
|
80
88
|
if (dragParent && hoverParent) {
|
|
81
|
-
|
|
89
|
+
// 从原位置移除节点
|
|
90
|
+
dragParent.nodes = dragParent.nodes.filter(function (node) {
|
|
82
91
|
return node.id !== dragId;
|
|
83
92
|
});
|
|
84
93
|
|
|
85
|
-
//
|
|
86
|
-
if (
|
|
94
|
+
// 如果拖拽父节点为空,处理删除逻辑
|
|
95
|
+
if (dragParent.nodes.length === 0) {
|
|
87
96
|
var grandParent = findParentNodeById(dragParent.id, newRootNode);
|
|
88
97
|
if (grandParent) {
|
|
89
98
|
grandParent.nodes = grandParent.nodes.filter(function (node) {
|
|
90
99
|
return node.id !== dragParent.id;
|
|
91
100
|
});
|
|
92
101
|
} else {
|
|
93
|
-
// 如果 dragParent 是根节点,则不删除,只清空其 nodes
|
|
94
102
|
dragParent.nodes = [];
|
|
95
103
|
}
|
|
96
|
-
} else {
|
|
97
|
-
dragParent.nodes = tempDragParentNodes;
|
|
98
104
|
}
|
|
99
105
|
|
|
100
106
|
// 插入到新位置
|
|
101
107
|
var hoverIndex = hoverParent.nodes.findIndex(function (node) {
|
|
102
108
|
return node.id === hoverId;
|
|
103
109
|
});
|
|
104
|
-
|
|
110
|
+
var newIndex = dropPosition === EPutPosition.TOP ? hoverIndex : hoverIndex + 1;
|
|
111
|
+
hoverParent.nodes.splice(newIndex, 0, dragNode);
|
|
105
112
|
|
|
106
|
-
//
|
|
113
|
+
// 更新状态
|
|
107
114
|
changeInnerValue(newRootNode);
|
|
108
115
|
}
|
|
109
116
|
}
|
|
@@ -13,24 +13,45 @@
|
|
|
13
13
|
flex-direction: column;
|
|
14
14
|
padding-left: calc(@recordLineWidth + @selectWidth / 2 + @dragIConWidth);
|
|
15
15
|
position: relative;
|
|
16
|
-
cursor: pointer;
|
|
17
16
|
border-radius: 6px;
|
|
18
17
|
margin-left: -16px;
|
|
18
|
+
z-index: 10;
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
&:hover {
|
|
21
|
+
.ald-logic-tree-node-drag-icon,
|
|
22
|
+
.ald-logic-tree-record-node-drag-icon {
|
|
23
|
+
background: #fff !important;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&.is-hover-drag-box {
|
|
21
28
|
background: rgba(244, 244, 245);
|
|
22
|
-
|
|
29
|
+
|
|
30
|
+
.ald-logic-tree-node-drag-icon,
|
|
31
|
+
.ald-logic-tree-record-node-drag-icon {
|
|
32
|
+
background: rgba(244, 244, 245) !important;
|
|
33
|
+
}
|
|
23
34
|
}
|
|
24
35
|
|
|
25
36
|
&.is-dragging {
|
|
26
37
|
background: var(--alias-colors-bg-selected-default, #e8f2fe);
|
|
38
|
+
|
|
39
|
+
.ald-logic-tree-node-drag-icon,
|
|
40
|
+
.ald-logic-tree-record-node-drag-icon {
|
|
41
|
+
background: var(--alias-colors-bg-selected-default, #e8f2fe) !important;
|
|
42
|
+
}
|
|
27
43
|
}
|
|
28
44
|
|
|
29
|
-
.ald-logic-tree-node-drag-icon {
|
|
45
|
+
.ald-logic-tree-node-drag-icon-wrapper {
|
|
30
46
|
position: absolute;
|
|
31
|
-
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
top: 0;
|
|
32
49
|
left: 0;
|
|
33
|
-
|
|
50
|
+
height: 100%;
|
|
51
|
+
z-index: 10px;
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: center;
|
|
34
55
|
}
|
|
35
56
|
|
|
36
57
|
.ald-logic-tree-node-wrap {
|
|
@@ -58,7 +79,7 @@
|
|
|
58
79
|
border-left: 1px dashed #d1d5db;
|
|
59
80
|
height: calc(50% - 16px);
|
|
60
81
|
width: @recordLineWidth;
|
|
61
|
-
top: 50
|
|
82
|
+
top: calc(50% - 4px);
|
|
62
83
|
left: calc(@selectWidth / 2 + @dragIConWidth);
|
|
63
84
|
}
|
|
64
85
|
}
|
|
@@ -71,7 +92,7 @@
|
|
|
71
92
|
|
|
72
93
|
.ald-logic-tree-select-relation {
|
|
73
94
|
position: absolute !important;
|
|
74
|
-
top: calc(50% -
|
|
95
|
+
top: calc(50% - 12px);
|
|
75
96
|
left: 16px;
|
|
76
97
|
z-index: 1;
|
|
77
98
|
width: @selectWidth !important;
|
|
@@ -96,16 +117,20 @@
|
|
|
96
117
|
display: flex;
|
|
97
118
|
align-items: center;
|
|
98
119
|
gap: 6px;
|
|
99
|
-
cursor: pointer;
|
|
100
120
|
padding-left: 16px;
|
|
101
121
|
margin-left: -16px;
|
|
122
|
+
position: relative;
|
|
123
|
+
z-index: 10;
|
|
124
|
+
border-radius: 6px;
|
|
102
125
|
|
|
103
|
-
&.is-hover {
|
|
126
|
+
&.is-hover-drag-box {
|
|
104
127
|
display: flex;
|
|
105
128
|
align-items: center;
|
|
106
|
-
border-radius: 6px;
|
|
107
129
|
background: rgba(244, 244, 245);
|
|
108
|
-
|
|
130
|
+
|
|
131
|
+
.ald-logic-tree-record-node-drag-icon {
|
|
132
|
+
background: rgba(244, 244, 245) !important;
|
|
133
|
+
}
|
|
109
134
|
}
|
|
110
135
|
|
|
111
136
|
&.is-dragging {
|
|
@@ -113,13 +138,29 @@
|
|
|
113
138
|
align-items: center;
|
|
114
139
|
border-radius: 6px;
|
|
115
140
|
background: var(--alias-colors-bg-selected-default, #e8f2fe);
|
|
141
|
+
|
|
142
|
+
.ald-logic-tree-record-node-drag-icon {
|
|
143
|
+
background: var(--alias-colors-bg-selected-default, #e8f2fe) !important;
|
|
144
|
+
}
|
|
116
145
|
}
|
|
117
146
|
|
|
118
|
-
.ald-logic-tree-record-node-drag-icon {
|
|
147
|
+
.ald-logic-tree-record-node-drag-icon-wrapper {
|
|
119
148
|
position: absolute;
|
|
149
|
+
cursor: pointer;
|
|
120
150
|
top: calc(50%);
|
|
121
151
|
left: 0;
|
|
122
152
|
transform: translateY(-50%);
|
|
153
|
+
height: 100%;
|
|
154
|
+
width: 16px;
|
|
155
|
+
border-radius: 6px;
|
|
156
|
+
display: flex;
|
|
157
|
+
justify-content: center;
|
|
158
|
+
align-items: center;
|
|
159
|
+
z-index: 10;
|
|
160
|
+
|
|
161
|
+
.ald-logic-tree-record-node-drag-icon {
|
|
162
|
+
background-color: #fff;
|
|
163
|
+
}
|
|
123
164
|
}
|
|
124
165
|
|
|
125
166
|
.ald-logic-tree-render-condition-wrap {
|
|
@@ -136,8 +177,8 @@
|
|
|
136
177
|
padding-bottom: 4px;
|
|
137
178
|
}
|
|
138
179
|
|
|
139
|
-
.ald-logic-tree-logic-node.is-
|
|
140
|
-
.ald-logic-tree-record-node.is-
|
|
180
|
+
.ald-logic-tree-logic-node.is-hover-bottom:last-child::after,
|
|
181
|
+
.ald-logic-tree-record-node.is-hover-bottom:last-child::after {
|
|
141
182
|
content: '';
|
|
142
183
|
position: absolute;
|
|
143
184
|
bottom: -1px;
|
|
@@ -146,3 +187,18 @@
|
|
|
146
187
|
height: 2px;
|
|
147
188
|
background-color: #126fdd;
|
|
148
189
|
}
|
|
190
|
+
|
|
191
|
+
.ald-logic-tree-logic-node.is-hover-top:last-child::after,
|
|
192
|
+
.ald-logic-tree-record-node.is-hover-top:last-child::after {
|
|
193
|
+
content: '';
|
|
194
|
+
position: absolute;
|
|
195
|
+
top: -1px;
|
|
196
|
+
left: 16px;
|
|
197
|
+
width: calc(100% - 16px);
|
|
198
|
+
height: 2px;
|
|
199
|
+
background-color: #126fdd;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.ald-logic-tree-node-drag-icon-preview {
|
|
203
|
+
display: none;
|
|
204
|
+
}
|