@formily-design/react 1.0.0 → 1.0.1
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/package.json +4 -4
- package/copy.ts +0 -6
- package/dist/designable.react.umd.production.css +0 -1
- package/dist/designable.react.umd.production.js +0 -6
- package/dist/designable.react.umd.production.min.css +0 -1
- package/dist/designable.react.umd.production.min.js +0 -3769
- package/rollup.config.js +0 -3
- package/src/containers/Designer.tsx +0 -50
- package/src/containers/Layout.tsx +0 -50
- package/src/containers/Simulator.tsx +0 -30
- package/src/containers/Viewport.tsx +0 -69
- package/src/containers/Workbench.tsx +0 -15
- package/src/containers/Workspace.tsx +0 -41
- package/src/containers/index.ts +0 -7
- package/src/containers/styles.less +0 -19
- package/src/context.ts +0 -17
- package/src/hooks/index.ts +0 -25
- package/src/hooks/useComponents.ts +0 -3
- package/src/hooks/useCursor.ts +0 -6
- package/src/hooks/useDesigner.ts +0 -19
- package/src/hooks/useHistory.ts +0 -6
- package/src/hooks/useHover.ts +0 -6
- package/src/hooks/useLayout.ts +0 -11
- package/src/hooks/useMoveHelper.ts +0 -6
- package/src/hooks/useNodeIdProps.ts +0 -11
- package/src/hooks/useOperation.ts +0 -6
- package/src/hooks/useOutline.ts +0 -6
- package/src/hooks/usePosition.ts +0 -5
- package/src/hooks/usePrefix.ts +0 -5
- package/src/hooks/useRegistry.ts +0 -6
- package/src/hooks/useScreen.ts +0 -5
- package/src/hooks/useSelected.ts +0 -6
- package/src/hooks/useSelectedNode.ts +0 -14
- package/src/hooks/useSelection.ts +0 -6
- package/src/hooks/useTheme.ts +0 -5
- package/src/hooks/useTransformHelper.ts +0 -6
- package/src/hooks/useTree.ts +0 -6
- package/src/hooks/useTreeNode.ts +0 -6
- package/src/hooks/useValidNodeOffsetRect.ts +0 -48
- package/src/hooks/useViewport.ts +0 -6
- package/src/hooks/useWorkbench.ts +0 -6
- package/src/hooks/useWorkspace.ts +0 -16
- package/src/icons/actions.tsx +0 -138
- package/src/icons/add.tsx +0 -8
- package/src/icons/animations.tsx +0 -325
- package/src/icons/boolean.tsx +0 -7
- package/src/icons/clone.tsx +0 -9
- package/src/icons/close.tsx +0 -7
- package/src/icons/code.tsx +0 -5
- package/src/icons/command.tsx +0 -8
- package/src/icons/component.tsx +0 -5
- package/src/icons/container.tsx +0 -8
- package/src/icons/corner.tsx +0 -26
- package/src/icons/delete.tsx +0 -9
- package/src/icons/design.tsx +0 -7
- package/src/icons/display.tsx +0 -17
- package/src/icons/dragmove.tsx +0 -10
- package/src/icons/expand.tsx +0 -5
- package/src/icons/expression.tsx +0 -5
- package/src/icons/eyes.tsx +0 -15
- package/src/icons/flex.tsx +0 -85
- package/src/icons/flip.tsx +0 -5
- package/src/icons/focus.tsx +0 -5
- package/src/icons/font.tsx +0 -61
- package/src/icons/formula.tsx +0 -5
- package/src/icons/freemove.tsx +0 -10
- package/src/icons/help.tsx +0 -8
- package/src/icons/hidden.tsx +0 -5
- package/src/icons/history.tsx +0 -7
- package/src/icons/image.tsx +0 -9
- package/src/icons/index.ts +0 -53
- package/src/icons/json.tsx +0 -5
- package/src/icons/logo.tsx +0 -5
- package/src/icons/menu.tsx +0 -7
- package/src/icons/mobile.tsx +0 -8
- package/src/icons/move.tsx +0 -5
- package/src/icons/number.tsx +0 -7
- package/src/icons/outline.tsx +0 -5
- package/src/icons/page.tsx +0 -9
- package/src/icons/pc.tsx +0 -7
- package/src/icons/play.tsx +0 -8
- package/src/icons/position.tsx +0 -30
- package/src/icons/pushpin.tsx +0 -29
- package/src/icons/recover.tsx +0 -5
- package/src/icons/redo.tsx +0 -5
- package/src/icons/remove.tsx +0 -5
- package/src/icons/responsive.tsx +0 -9
- package/src/icons/return.tsx +0 -5
- package/src/icons/selection.tsx +0 -5
- package/src/icons/setting.tsx +0 -5
- package/src/icons/shadow.tsx +0 -20
- package/src/icons/shift.tsx +0 -5
- package/src/icons/sources.tsx +0 -3377
- package/src/icons/text.tsx +0 -13
- package/src/icons/undo.tsx +0 -7
- package/src/icons/upload.tsx +0 -8
- package/src/index.ts +0 -9
- package/src/locales/global.ts +0 -16
- package/src/locales/icons.ts +0 -132
- package/src/locales/index.ts +0 -7
- package/src/locales/operations.ts +0 -50
- package/src/locales/panels.ts +0 -26
- package/src/panels/CompositePanel.tsx +0 -195
- package/src/panels/SettingsPanel.tsx +0 -85
- package/src/panels/StudioPanel.tsx +0 -54
- package/src/panels/ToolbarPanel.tsx +0 -19
- package/src/panels/ViewPanel.tsx +0 -62
- package/src/panels/ViewportPanel.tsx +0 -10
- package/src/panels/WorkspacePanel.tsx +0 -31
- package/src/panels/index.ts +0 -8
- package/src/panels/styles.less +0 -331
- package/src/simulators/MobileSimulator/body.tsx +0 -78
- package/src/simulators/MobileSimulator/index.tsx +0 -21
- package/src/simulators/MobileSimulator/styles.less +0 -29
- package/src/simulators/PCSimulator/index.tsx +0 -17
- package/src/simulators/PCSimulator/styles.less +0 -11
- package/src/simulators/ResponsiveSimulator/handle.tsx +0 -29
- package/src/simulators/ResponsiveSimulator/index.tsx +0 -193
- package/src/simulators/ResponsiveSimulator/styles.less +0 -56
- package/src/simulators/index.tsx +0 -3
- package/src/theme.less +0 -224
- package/src/types.ts +0 -41
- package/src/variables.less +0 -1
- package/src/widgets/AuxToolWidget/Copy.tsx +0 -28
- package/src/widgets/AuxToolWidget/Cover.tsx +0 -76
- package/src/widgets/AuxToolWidget/DashedBox.tsx +0 -55
- package/src/widgets/AuxToolWidget/Delete.tsx +0 -29
- package/src/widgets/AuxToolWidget/DragHandler.tsx +0 -29
- package/src/widgets/AuxToolWidget/FreeSelection.tsx +0 -53
- package/src/widgets/AuxToolWidget/Helpers.tsx +0 -116
- package/src/widgets/AuxToolWidget/Insertion.tsx +0 -80
- package/src/widgets/AuxToolWidget/ResizeHandler.tsx +0 -35
- package/src/widgets/AuxToolWidget/Selection.tsx +0 -85
- package/src/widgets/AuxToolWidget/Selector.tsx +0 -125
- package/src/widgets/AuxToolWidget/SnapLine.tsx +0 -40
- package/src/widgets/AuxToolWidget/SpaceBlock.tsx +0 -112
- package/src/widgets/AuxToolWidget/TranslateHandler.tsx +0 -29
- package/src/widgets/AuxToolWidget/index.tsx +0 -40
- package/src/widgets/AuxToolWidget/styles.less +0 -383
- package/src/widgets/ComponentTreeWidget/index.tsx +0 -99
- package/src/widgets/ComponentTreeWidget/styles.less +0 -6
- package/src/widgets/DesignerToolsWidget/index.tsx +0 -206
- package/src/widgets/DesignerToolsWidget/styles.less +0 -29
- package/src/widgets/DroppableWidget/index.tsx +0 -63
- package/src/widgets/DroppableWidget/styles.less +0 -11
- package/src/widgets/EmptyWidget/index.tsx +0 -58
- package/src/widgets/EmptyWidget/styles.less +0 -27
- package/src/widgets/GhostWidget/index.tsx +0 -47
- package/src/widgets/GhostWidget/styles.less +0 -20
- package/src/widgets/HistoryWidget/index.tsx +0 -42
- package/src/widgets/HistoryWidget/styles.less +0 -23
- package/src/widgets/IconWidget/index.tsx +0 -152
- package/src/widgets/IconWidget/styles.less +0 -17
- package/src/widgets/NodeActionsWidget/index.tsx +0 -56
- package/src/widgets/NodeActionsWidget/styles.less +0 -51
- package/src/widgets/NodePathWidget/index.tsx +0 -57
- package/src/widgets/NodePathWidget/styles.less +0 -16
- package/src/widgets/NodeTitleWidget/index.tsx +0 -20
- package/src/widgets/OutlineWidget/Insertion.tsx +0 -63
- package/src/widgets/OutlineWidget/OutlineNode.tsx +0 -198
- package/src/widgets/OutlineWidget/context.ts +0 -9
- package/src/widgets/OutlineWidget/index.tsx +0 -66
- package/src/widgets/OutlineWidget/styles.less +0 -195
- package/src/widgets/ResourceWidget/index.tsx +0 -110
- package/src/widgets/ResourceWidget/styles.less +0 -87
- package/src/widgets/TextWidget/index.tsx +0 -43
- package/src/widgets/ViewToolsWidget/index.tsx +0 -72
- package/src/widgets/index.ts +0 -15
- package/tsconfig.build.json +0 -10
- package/tsconfig.json +0 -5
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import React, { Fragment } from 'react'
|
|
2
|
-
import { useTransformHelper, useCursor, usePrefix } from '../../hooks'
|
|
3
|
-
import { observer } from '@formily/reactive-react'
|
|
4
|
-
import { CursorStatus } from '@formily-design/core'
|
|
5
|
-
import { ILineSegment, calcRectOfAxisLineSegment } from '@formily-design/shared'
|
|
6
|
-
|
|
7
|
-
export const SpaceBlock = observer(() => {
|
|
8
|
-
const cursor = useCursor()
|
|
9
|
-
const transformHelper = useTransformHelper()
|
|
10
|
-
const prefix = usePrefix('aux-space-block')
|
|
11
|
-
|
|
12
|
-
if (cursor.status !== CursorStatus.Dragging) return null
|
|
13
|
-
|
|
14
|
-
const renderRulerBox = (distance: number, type: string) => {
|
|
15
|
-
if (type === 'top' || type === 'bottom') {
|
|
16
|
-
return (
|
|
17
|
-
<div className={prefix + '-ruler-v'}>
|
|
18
|
-
<div className={prefix + '-ruler-indicator'}>
|
|
19
|
-
<span>{distance?.toFixed(0)}</span>
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
)
|
|
23
|
-
} else if (type === 'left' || type === 'right') {
|
|
24
|
-
return (
|
|
25
|
-
<div className={prefix + '-ruler-h'}>
|
|
26
|
-
<div className={prefix + '-ruler-indicator'}>
|
|
27
|
-
<span>{distance?.toFixed(0)}</span>
|
|
28
|
-
</div>
|
|
29
|
-
</div>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const renderDashedLine = (line: ILineSegment) => {
|
|
35
|
-
const rect = calcRectOfAxisLineSegment(line)
|
|
36
|
-
if (!rect) return null
|
|
37
|
-
const width = rect.width || 2
|
|
38
|
-
const height = rect.height || 2
|
|
39
|
-
return (
|
|
40
|
-
<svg
|
|
41
|
-
width={width + 'px'}
|
|
42
|
-
height={height + 'px'}
|
|
43
|
-
viewBox={`0 0 ${width} ${height}`}
|
|
44
|
-
style={{
|
|
45
|
-
top: 0,
|
|
46
|
-
left: 0,
|
|
47
|
-
transform: `perspective(1px) translate3d(${line.start.x}px,${line.start.y}px,0)`,
|
|
48
|
-
position: 'absolute',
|
|
49
|
-
zIndex: 3,
|
|
50
|
-
}}
|
|
51
|
-
>
|
|
52
|
-
<line
|
|
53
|
-
x1={line.start.x - rect.x}
|
|
54
|
-
y1={line.start.y - rect.y}
|
|
55
|
-
x2={line.end.x - rect.x}
|
|
56
|
-
y2={line.end.y - rect.y}
|
|
57
|
-
strokeDasharray={4}
|
|
58
|
-
stroke="#745BFF"
|
|
59
|
-
strokeWidth={2}
|
|
60
|
-
></line>
|
|
61
|
-
</svg>
|
|
62
|
-
)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<>
|
|
67
|
-
{transformHelper.measurerSpaceBlocks.map(
|
|
68
|
-
({ type, crossDragNodesRect, distance, extendsLine }, key) => {
|
|
69
|
-
return (
|
|
70
|
-
<Fragment>
|
|
71
|
-
{renderDashedLine(extendsLine)}
|
|
72
|
-
<div
|
|
73
|
-
key={key}
|
|
74
|
-
style={{
|
|
75
|
-
top: 0,
|
|
76
|
-
left: 0,
|
|
77
|
-
height: crossDragNodesRect.height,
|
|
78
|
-
width: crossDragNodesRect.width,
|
|
79
|
-
transform: `perspective(1px) translate3d(${crossDragNodesRect.x}px,${crossDragNodesRect.y}px,0)`,
|
|
80
|
-
position: 'absolute',
|
|
81
|
-
zIndex: 3,
|
|
82
|
-
}}
|
|
83
|
-
>
|
|
84
|
-
{renderRulerBox(distance, type)}
|
|
85
|
-
</div>
|
|
86
|
-
</Fragment>
|
|
87
|
-
)
|
|
88
|
-
}
|
|
89
|
-
)}
|
|
90
|
-
{transformHelper.thresholdSpaceBlocks.map(({ rect }, key) => {
|
|
91
|
-
return (
|
|
92
|
-
<div
|
|
93
|
-
key={key}
|
|
94
|
-
className={prefix}
|
|
95
|
-
style={{
|
|
96
|
-
top: 0,
|
|
97
|
-
left: 0,
|
|
98
|
-
height: rect.height,
|
|
99
|
-
width: rect.width,
|
|
100
|
-
transform: `perspective(1px) translate3d(${rect.x}px,${rect.y}px,0)`,
|
|
101
|
-
position: 'absolute',
|
|
102
|
-
background: 'rgba(255, 0, 0, 0.2)',
|
|
103
|
-
zIndex: 1,
|
|
104
|
-
}}
|
|
105
|
-
></div>
|
|
106
|
-
)
|
|
107
|
-
})}
|
|
108
|
-
</>
|
|
109
|
-
)
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
SpaceBlock.displayName = 'SpaceBlock'
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import cls from 'classnames'
|
|
3
|
-
import { useDesigner, usePrefix } from '../../hooks'
|
|
4
|
-
import { TreeNode } from '@formily-design/core'
|
|
5
|
-
import { IconWidget } from '../IconWidget'
|
|
6
|
-
|
|
7
|
-
export interface ITranslateHandlerProps {
|
|
8
|
-
node: TreeNode
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const TranslateHandler: React.FC<ITranslateHandlerProps> = (props) => {
|
|
12
|
-
const designer = useDesigner()
|
|
13
|
-
const prefix = usePrefix('aux-node-translate-handler')
|
|
14
|
-
const createHandler = (value: string) => {
|
|
15
|
-
return {
|
|
16
|
-
[designer.props.nodeTranslateAttrName]: value,
|
|
17
|
-
className: cls(prefix, value),
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const allowTranslate = props.node.allowTranslate()
|
|
21
|
-
if (!allowTranslate) return null
|
|
22
|
-
return (
|
|
23
|
-
<>
|
|
24
|
-
<div {...createHandler('translate')}>
|
|
25
|
-
<IconWidget infer="FreeMove" />
|
|
26
|
-
</div>
|
|
27
|
-
</>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from 'react'
|
|
2
|
-
import { useViewport, useDesigner, usePrefix } from '../../hooks'
|
|
3
|
-
import { Insertion } from './Insertion'
|
|
4
|
-
import { Selection } from './Selection'
|
|
5
|
-
import { FreeSelection } from './FreeSelection'
|
|
6
|
-
import { Cover } from './Cover'
|
|
7
|
-
import { DashedBox } from './DashedBox'
|
|
8
|
-
import { SpaceBlock } from './SpaceBlock'
|
|
9
|
-
import { SnapLine } from './SnapLine'
|
|
10
|
-
import './styles.less'
|
|
11
|
-
|
|
12
|
-
export const AuxToolWidget = () => {
|
|
13
|
-
const engine = useDesigner()
|
|
14
|
-
const viewport = useViewport()
|
|
15
|
-
const prefix = usePrefix('auxtool')
|
|
16
|
-
const ref = useRef<HTMLDivElement>()
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
return engine.subscribeWith('viewport:scroll', () => {
|
|
19
|
-
if (viewport.isIframe && ref.current) {
|
|
20
|
-
ref.current.style.transform = `perspective(1px) translate3d(${-viewport.scrollX}px,${-viewport.scrollY}px,0)`
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
}, [engine, viewport])
|
|
24
|
-
|
|
25
|
-
if (!viewport) return null
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<div ref={ref} className={prefix}>
|
|
29
|
-
<Insertion />
|
|
30
|
-
<SpaceBlock />
|
|
31
|
-
<SnapLine />
|
|
32
|
-
<DashedBox />
|
|
33
|
-
<Selection />
|
|
34
|
-
<Cover />
|
|
35
|
-
<FreeSelection />
|
|
36
|
-
</div>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
AuxToolWidget.displayName = 'AuxToolWidget'
|
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
@import '../../variables.less';
|
|
2
|
-
|
|
3
|
-
@keyframes dn-animate-slide-to-top {
|
|
4
|
-
from {
|
|
5
|
-
transform: translateY(-10%);
|
|
6
|
-
opacity: 0;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
to {
|
|
10
|
-
transform: translateY(0);
|
|
11
|
-
opacity: 0.8;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.@{prefix-cls}-auxtool {
|
|
16
|
-
transform: perspective(1px) translate3d(0, 0, 0);
|
|
17
|
-
position: absolute;
|
|
18
|
-
width: 100%;
|
|
19
|
-
height: 100%;
|
|
20
|
-
top: 0;
|
|
21
|
-
left: 0;
|
|
22
|
-
pointer-events: none;
|
|
23
|
-
|
|
24
|
-
z-index: 9998;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.dn-aux-button {
|
|
28
|
-
button {
|
|
29
|
-
font-size: 12px !important;
|
|
30
|
-
display: flex;
|
|
31
|
-
align-items: center;
|
|
32
|
-
padding: 0 3px;
|
|
33
|
-
height: 20px;
|
|
34
|
-
color: var(--dn-aux-selector-btn-color); //#fff
|
|
35
|
-
background: var(--dn-aux-selector-btn-bg-color); //#1890ff
|
|
36
|
-
border-color: var(--dn-aux-selector-btn-border-color); //#1890ff
|
|
37
|
-
|
|
38
|
-
&:hover,
|
|
39
|
-
&:focus {
|
|
40
|
-
color: var(--dn-aux-selector-btn-hover-color); //#fff
|
|
41
|
-
background: var(--dn-aux-selector-btn-hover-bg-color); //#40a9ff
|
|
42
|
-
border-color: var(--dn-aux-selector-btn-hover-border-color); //#40a9ff
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
&:active {
|
|
46
|
-
color: var(--dn-aux-selector-btn-active-color); //#fff
|
|
47
|
-
background: var(--dn-aux-selector-btn-active-bg-color); //#096dd9
|
|
48
|
-
border-color: var(--dn-aux-selector-btn-active-border-color); //#096dd9
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.@{prefix-cls}-aux-cover-rect {
|
|
54
|
-
&.dragging {
|
|
55
|
-
background-color: var(--dn-aux-cover-rect-dragging-color);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
&.dropping {
|
|
59
|
-
background-color: var(--dn-aux-cover-rect-dropping-color);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.@{prefix-cls}-aux-free-selection {
|
|
64
|
-
background-color: var(--dn-aux-free-selection-background-color);
|
|
65
|
-
border-color: var(--dn-aux-free-selection-border-color);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.@{prefix-cls}-aux-helpers {
|
|
69
|
-
position: absolute;
|
|
70
|
-
pointer-events: all;
|
|
71
|
-
z-index: 10;
|
|
72
|
-
user-select: none;
|
|
73
|
-
|
|
74
|
-
.dn-aux-button();
|
|
75
|
-
|
|
76
|
-
&.bottom-right {
|
|
77
|
-
top: 100%;
|
|
78
|
-
right: 0;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
&.bottom-left {
|
|
82
|
-
top: 100%;
|
|
83
|
-
left: 0;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
&.bottom-center {
|
|
87
|
-
top: 100%;
|
|
88
|
-
left: 50%;
|
|
89
|
-
transform: translateX(-50%);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
&.inner-top-right {
|
|
93
|
-
top: -2px;
|
|
94
|
-
right: 2px;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
&.inner-top-left {
|
|
98
|
-
top: -2px;
|
|
99
|
-
left: 2px;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
&.inner-top-center {
|
|
103
|
-
top: -2px;
|
|
104
|
-
right: 2px;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
&.inner-bottom-right {
|
|
108
|
-
bottom: -2px;
|
|
109
|
-
right: 2px;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
&.inner-bottom-left {
|
|
113
|
-
bottom: -2px;
|
|
114
|
-
left: 2px;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
&.inner-bottom-center {
|
|
118
|
-
bottom: -2px;
|
|
119
|
-
right: 2px;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
&.top-right {
|
|
123
|
-
bottom: 100%;
|
|
124
|
-
right: 0;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
&.top-left {
|
|
128
|
-
bottom: 100%;
|
|
129
|
-
left: 0;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
&.top-center {
|
|
133
|
-
bottom: 100%;
|
|
134
|
-
left: 50%;
|
|
135
|
-
transform: translateX(-50%);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
button {
|
|
139
|
-
span {
|
|
140
|
-
transform: scale(0.9);
|
|
141
|
-
margin-left: 2px;
|
|
142
|
-
|
|
143
|
-
&.@{prefix-cls}-icon {
|
|
144
|
-
transform: scale(1);
|
|
145
|
-
margin-left: 0;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
&-content {
|
|
151
|
-
display: flex;
|
|
152
|
-
flex-wrap: nowrap;
|
|
153
|
-
white-space: nowrap;
|
|
154
|
-
|
|
155
|
-
button {
|
|
156
|
-
font-size: 12px !important;
|
|
157
|
-
display: flex;
|
|
158
|
-
align-items: center;
|
|
159
|
-
padding: 0 3px;
|
|
160
|
-
height: 20px;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
& > * {
|
|
164
|
-
margin-top: 4px;
|
|
165
|
-
margin-bottom: 4px;
|
|
166
|
-
margin-left: 2px;
|
|
167
|
-
|
|
168
|
-
&:first-child {
|
|
169
|
-
margin-left: 0;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
.@{prefix-cls}-aux-insertion {
|
|
176
|
-
background-color: var(--dn-aux-insertion-color);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
.@{prefix-cls}-aux-dashed-box {
|
|
180
|
-
border: 1px dashed var(--dn-aux-dashed-box-color);
|
|
181
|
-
|
|
182
|
-
&-title {
|
|
183
|
-
color: var(--dn-aux-dashed-box-title-color);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
.@{prefix-cls}-aux-selection-box {
|
|
188
|
-
border: 2px solid var(--dn-aux-selection-box-border-color);
|
|
189
|
-
position: relative;
|
|
190
|
-
pointer-events: none;
|
|
191
|
-
|
|
192
|
-
&-inner {
|
|
193
|
-
position: absolute;
|
|
194
|
-
top: 0;
|
|
195
|
-
left: 0;
|
|
196
|
-
right: 0;
|
|
197
|
-
bottom: 0;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
&-title {
|
|
201
|
-
color: var(--dn-aux-selection-box-color);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
.@{prefix-cls}-aux-selector {
|
|
206
|
-
.dn-aux-button();
|
|
207
|
-
|
|
208
|
-
&-menu {
|
|
209
|
-
margin-top: -4px;
|
|
210
|
-
animation: dn-animate-slide-to-top 0.2s;
|
|
211
|
-
opacity: 0.8;
|
|
212
|
-
|
|
213
|
-
button {
|
|
214
|
-
font-size: 12px !important;
|
|
215
|
-
display: flex;
|
|
216
|
-
align-items: center;
|
|
217
|
-
padding: 0 3px;
|
|
218
|
-
height: 20px;
|
|
219
|
-
margin-top: 2px;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
.@{prefix-cls}-aux-drag-handler {
|
|
225
|
-
cursor: move;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
.@{prefix-cls}-aux-node-resize-handler {
|
|
229
|
-
position: absolute;
|
|
230
|
-
width: 10px;
|
|
231
|
-
height: 10px;
|
|
232
|
-
pointer-events: all;
|
|
233
|
-
border-radius: 10px;
|
|
234
|
-
background-color: #fff;
|
|
235
|
-
border: 1px solid var(--dn-brand-color);
|
|
236
|
-
|
|
237
|
-
&.left-center {
|
|
238
|
-
left: 0;
|
|
239
|
-
top: 50%;
|
|
240
|
-
transform: translate(calc(-50% - 1px), -50%);
|
|
241
|
-
cursor: ew-resize;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
&.right-center {
|
|
245
|
-
left: 100%;
|
|
246
|
-
top: 50%;
|
|
247
|
-
transform: translate(calc(-50% + 1px), -50%);
|
|
248
|
-
cursor: ew-resize;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
&.center-top {
|
|
252
|
-
left: 50%;
|
|
253
|
-
top: 0;
|
|
254
|
-
transform: translate(-50%, calc(-50% - 1px));
|
|
255
|
-
cursor: ns-resize;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
&.center-bottom {
|
|
259
|
-
left: 50%;
|
|
260
|
-
top: 100%;
|
|
261
|
-
transform: translate(-50%, calc(-50% + 1px));
|
|
262
|
-
cursor: ns-resize;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
&.left-top {
|
|
266
|
-
left: 0;
|
|
267
|
-
top: 0;
|
|
268
|
-
transform: translate(calc(-50% + 1px), calc(-50% + 1px));
|
|
269
|
-
cursor: nwse-resize;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
&.left-bottom {
|
|
273
|
-
left: 0;
|
|
274
|
-
top: 100%;
|
|
275
|
-
transform: translate(-50%, -50%);
|
|
276
|
-
cursor: nesw-resize;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
&.right-bottom {
|
|
280
|
-
left: 100%;
|
|
281
|
-
top: 100%;
|
|
282
|
-
transform: translate(-50%, -50%);
|
|
283
|
-
cursor: nwse-resize;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
&.right-top {
|
|
287
|
-
left: 100%;
|
|
288
|
-
top: 0;
|
|
289
|
-
transform: translate(-50%, -50%);
|
|
290
|
-
cursor: nesw-resize;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
.@{prefix-cls}-aux-node-translate-handler {
|
|
295
|
-
position: absolute;
|
|
296
|
-
display: flex;
|
|
297
|
-
align-items: center;
|
|
298
|
-
justify-content: center;
|
|
299
|
-
border-radius: 2px;
|
|
300
|
-
width: 40px;
|
|
301
|
-
height: 20px;
|
|
302
|
-
background: #1890ff;
|
|
303
|
-
opacity: 0.5;
|
|
304
|
-
pointer-events: all;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
.@{prefix-cls}-aux-space-block-ruler-indicator {
|
|
308
|
-
position: absolute;
|
|
309
|
-
background-color: var(--dn-brand-color);
|
|
310
|
-
color: var(--dn-white);
|
|
311
|
-
border-radius: 8px;
|
|
312
|
-
z-index: 2;
|
|
313
|
-
display: flex;
|
|
314
|
-
align-items: center;
|
|
315
|
-
justify-content: center;
|
|
316
|
-
|
|
317
|
-
span {
|
|
318
|
-
margin: 0 6px;
|
|
319
|
-
display: inline-block;
|
|
320
|
-
font-size: 12px;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
.@{prefix-cls}-aux-space-block-ruler-h {
|
|
325
|
-
position: absolute;
|
|
326
|
-
top: 50%;
|
|
327
|
-
left: 0;
|
|
328
|
-
transform: translate(0, -50%);
|
|
329
|
-
width: 100%;
|
|
330
|
-
height: 12px;
|
|
331
|
-
border-left: 1px solid var(--dn-brand-color);
|
|
332
|
-
border-right: 1px solid var(--dn-brand-color);
|
|
333
|
-
|
|
334
|
-
&::after {
|
|
335
|
-
content: '';
|
|
336
|
-
display: block;
|
|
337
|
-
position: absolute;
|
|
338
|
-
top: 50%;
|
|
339
|
-
left: 0;
|
|
340
|
-
right: 0;
|
|
341
|
-
transform: translate(0, -50%);
|
|
342
|
-
width: 100%;
|
|
343
|
-
height: 1px;
|
|
344
|
-
background-color: var(--dn-brand-color);
|
|
345
|
-
z-index: 1;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
.@{prefix-cls}-aux-space-block-ruler-indicator {
|
|
349
|
-
left: 50%;
|
|
350
|
-
top: 50%;
|
|
351
|
-
transform: translate(-50%, -50%) scale(0.7);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
.@{prefix-cls}-aux-space-block-ruler-v {
|
|
356
|
-
position: absolute;
|
|
357
|
-
top: 0;
|
|
358
|
-
left: 50%;
|
|
359
|
-
transform: translate(-50%, 0);
|
|
360
|
-
height: 100%;
|
|
361
|
-
width: 12px;
|
|
362
|
-
border-top: 1px solid var(--dn-brand-color);
|
|
363
|
-
border-bottom: 1px solid var(--dn-brand-color);
|
|
364
|
-
|
|
365
|
-
&::after {
|
|
366
|
-
content: '';
|
|
367
|
-
display: block;
|
|
368
|
-
position: absolute;
|
|
369
|
-
top: 0;
|
|
370
|
-
left: 50%;
|
|
371
|
-
transform: translate(-50%, 0);
|
|
372
|
-
height: 100%;
|
|
373
|
-
width: 1px;
|
|
374
|
-
background-color: var(--dn-brand-color);
|
|
375
|
-
z-index: 1;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
.@{prefix-cls}-aux-space-block-ruler-indicator {
|
|
379
|
-
left: 50%;
|
|
380
|
-
top: 50%;
|
|
381
|
-
transform: translate(-50%, -50%) scale(0.7);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import React, { Fragment, useEffect } from 'react'
|
|
2
|
-
import { useTree, usePrefix, useDesigner, useComponents } from '../../hooks'
|
|
3
|
-
import { TreeNodeContext, DesignerComponentsContext } from '../../context'
|
|
4
|
-
import { IDesignerComponents } from '../../types'
|
|
5
|
-
import { TreeNode, GlobalRegistry } from '@formily-design/core'
|
|
6
|
-
import { observer } from '@formily/reactive-react'
|
|
7
|
-
import cls from 'classnames'
|
|
8
|
-
import './styles.less'
|
|
9
|
-
|
|
10
|
-
export interface IComponentTreeWidgetProps {
|
|
11
|
-
style?: React.CSSProperties
|
|
12
|
-
className?: string
|
|
13
|
-
components: IDesignerComponents
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface ITreeNodeWidgetProps {
|
|
17
|
-
node: TreeNode
|
|
18
|
-
children?: React.ReactChild
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const TreeNodeWidget: React.FC<ITreeNodeWidgetProps> = observer(
|
|
22
|
-
(props: ITreeNodeWidgetProps) => {
|
|
23
|
-
const designer = useDesigner(props.node?.designerProps?.effects)
|
|
24
|
-
const components = useComponents()
|
|
25
|
-
const node = props.node
|
|
26
|
-
const renderChildren = () => {
|
|
27
|
-
if (node?.designerProps?.selfRenderChildren) return []
|
|
28
|
-
return node?.children?.map((child) => {
|
|
29
|
-
return <TreeNodeWidget key={child.id} node={child} />
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
const renderProps = (extendsProps: any = {}) => {
|
|
33
|
-
const props = {
|
|
34
|
-
...node.designerProps?.defaultProps,
|
|
35
|
-
...extendsProps,
|
|
36
|
-
...node.props,
|
|
37
|
-
...node.designerProps?.getComponentProps?.(node),
|
|
38
|
-
}
|
|
39
|
-
if (node.depth === 0) {
|
|
40
|
-
delete props.style
|
|
41
|
-
}
|
|
42
|
-
return props
|
|
43
|
-
}
|
|
44
|
-
const renderComponent = () => {
|
|
45
|
-
const componentName = node.componentName
|
|
46
|
-
const Component = components[componentName]
|
|
47
|
-
const dataId = {}
|
|
48
|
-
if (Component) {
|
|
49
|
-
if (designer) {
|
|
50
|
-
dataId[designer?.props?.nodeIdAttrName] = node.id
|
|
51
|
-
}
|
|
52
|
-
return React.createElement(
|
|
53
|
-
Component,
|
|
54
|
-
renderProps(dataId),
|
|
55
|
-
...renderChildren()
|
|
56
|
-
)
|
|
57
|
-
} else {
|
|
58
|
-
if (node?.children?.length) {
|
|
59
|
-
return <Fragment>{renderChildren()}</Fragment>
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (!node) return null
|
|
65
|
-
if (node.hidden) return null
|
|
66
|
-
return React.createElement(
|
|
67
|
-
TreeNodeContext.Provider,
|
|
68
|
-
{ value: node },
|
|
69
|
-
renderComponent()
|
|
70
|
-
)
|
|
71
|
-
}
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
export const ComponentTreeWidget: React.FC<IComponentTreeWidgetProps> =
|
|
75
|
-
observer((props: IComponentTreeWidgetProps) => {
|
|
76
|
-
const tree = useTree()
|
|
77
|
-
const prefix = usePrefix('component-tree')
|
|
78
|
-
const designer = useDesigner()
|
|
79
|
-
const dataId = {}
|
|
80
|
-
if (designer && tree) {
|
|
81
|
-
dataId[designer?.props?.nodeIdAttrName] = tree.id
|
|
82
|
-
}
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
GlobalRegistry.registerDesignerBehaviors(props.components)
|
|
85
|
-
}, [])
|
|
86
|
-
return (
|
|
87
|
-
<div
|
|
88
|
-
style={{ ...props.style, ...tree?.props?.style }}
|
|
89
|
-
className={cls(prefix, props.className)}
|
|
90
|
-
{...dataId}
|
|
91
|
-
>
|
|
92
|
-
<DesignerComponentsContext.Provider value={props.components}>
|
|
93
|
-
<TreeNodeWidget node={tree} />
|
|
94
|
-
</DesignerComponentsContext.Provider>
|
|
95
|
-
</div>
|
|
96
|
-
)
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
ComponentTreeWidget.displayName = 'ComponentTreeWidget'
|