@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.
Files changed (170) hide show
  1. package/package.json +4 -4
  2. package/copy.ts +0 -6
  3. package/dist/designable.react.umd.production.css +0 -1
  4. package/dist/designable.react.umd.production.js +0 -6
  5. package/dist/designable.react.umd.production.min.css +0 -1
  6. package/dist/designable.react.umd.production.min.js +0 -3769
  7. package/rollup.config.js +0 -3
  8. package/src/containers/Designer.tsx +0 -50
  9. package/src/containers/Layout.tsx +0 -50
  10. package/src/containers/Simulator.tsx +0 -30
  11. package/src/containers/Viewport.tsx +0 -69
  12. package/src/containers/Workbench.tsx +0 -15
  13. package/src/containers/Workspace.tsx +0 -41
  14. package/src/containers/index.ts +0 -7
  15. package/src/containers/styles.less +0 -19
  16. package/src/context.ts +0 -17
  17. package/src/hooks/index.ts +0 -25
  18. package/src/hooks/useComponents.ts +0 -3
  19. package/src/hooks/useCursor.ts +0 -6
  20. package/src/hooks/useDesigner.ts +0 -19
  21. package/src/hooks/useHistory.ts +0 -6
  22. package/src/hooks/useHover.ts +0 -6
  23. package/src/hooks/useLayout.ts +0 -11
  24. package/src/hooks/useMoveHelper.ts +0 -6
  25. package/src/hooks/useNodeIdProps.ts +0 -11
  26. package/src/hooks/useOperation.ts +0 -6
  27. package/src/hooks/useOutline.ts +0 -6
  28. package/src/hooks/usePosition.ts +0 -5
  29. package/src/hooks/usePrefix.ts +0 -5
  30. package/src/hooks/useRegistry.ts +0 -6
  31. package/src/hooks/useScreen.ts +0 -5
  32. package/src/hooks/useSelected.ts +0 -6
  33. package/src/hooks/useSelectedNode.ts +0 -14
  34. package/src/hooks/useSelection.ts +0 -6
  35. package/src/hooks/useTheme.ts +0 -5
  36. package/src/hooks/useTransformHelper.ts +0 -6
  37. package/src/hooks/useTree.ts +0 -6
  38. package/src/hooks/useTreeNode.ts +0 -6
  39. package/src/hooks/useValidNodeOffsetRect.ts +0 -48
  40. package/src/hooks/useViewport.ts +0 -6
  41. package/src/hooks/useWorkbench.ts +0 -6
  42. package/src/hooks/useWorkspace.ts +0 -16
  43. package/src/icons/actions.tsx +0 -138
  44. package/src/icons/add.tsx +0 -8
  45. package/src/icons/animations.tsx +0 -325
  46. package/src/icons/boolean.tsx +0 -7
  47. package/src/icons/clone.tsx +0 -9
  48. package/src/icons/close.tsx +0 -7
  49. package/src/icons/code.tsx +0 -5
  50. package/src/icons/command.tsx +0 -8
  51. package/src/icons/component.tsx +0 -5
  52. package/src/icons/container.tsx +0 -8
  53. package/src/icons/corner.tsx +0 -26
  54. package/src/icons/delete.tsx +0 -9
  55. package/src/icons/design.tsx +0 -7
  56. package/src/icons/display.tsx +0 -17
  57. package/src/icons/dragmove.tsx +0 -10
  58. package/src/icons/expand.tsx +0 -5
  59. package/src/icons/expression.tsx +0 -5
  60. package/src/icons/eyes.tsx +0 -15
  61. package/src/icons/flex.tsx +0 -85
  62. package/src/icons/flip.tsx +0 -5
  63. package/src/icons/focus.tsx +0 -5
  64. package/src/icons/font.tsx +0 -61
  65. package/src/icons/formula.tsx +0 -5
  66. package/src/icons/freemove.tsx +0 -10
  67. package/src/icons/help.tsx +0 -8
  68. package/src/icons/hidden.tsx +0 -5
  69. package/src/icons/history.tsx +0 -7
  70. package/src/icons/image.tsx +0 -9
  71. package/src/icons/index.ts +0 -53
  72. package/src/icons/json.tsx +0 -5
  73. package/src/icons/logo.tsx +0 -5
  74. package/src/icons/menu.tsx +0 -7
  75. package/src/icons/mobile.tsx +0 -8
  76. package/src/icons/move.tsx +0 -5
  77. package/src/icons/number.tsx +0 -7
  78. package/src/icons/outline.tsx +0 -5
  79. package/src/icons/page.tsx +0 -9
  80. package/src/icons/pc.tsx +0 -7
  81. package/src/icons/play.tsx +0 -8
  82. package/src/icons/position.tsx +0 -30
  83. package/src/icons/pushpin.tsx +0 -29
  84. package/src/icons/recover.tsx +0 -5
  85. package/src/icons/redo.tsx +0 -5
  86. package/src/icons/remove.tsx +0 -5
  87. package/src/icons/responsive.tsx +0 -9
  88. package/src/icons/return.tsx +0 -5
  89. package/src/icons/selection.tsx +0 -5
  90. package/src/icons/setting.tsx +0 -5
  91. package/src/icons/shadow.tsx +0 -20
  92. package/src/icons/shift.tsx +0 -5
  93. package/src/icons/sources.tsx +0 -3377
  94. package/src/icons/text.tsx +0 -13
  95. package/src/icons/undo.tsx +0 -7
  96. package/src/icons/upload.tsx +0 -8
  97. package/src/index.ts +0 -9
  98. package/src/locales/global.ts +0 -16
  99. package/src/locales/icons.ts +0 -132
  100. package/src/locales/index.ts +0 -7
  101. package/src/locales/operations.ts +0 -50
  102. package/src/locales/panels.ts +0 -26
  103. package/src/panels/CompositePanel.tsx +0 -195
  104. package/src/panels/SettingsPanel.tsx +0 -85
  105. package/src/panels/StudioPanel.tsx +0 -54
  106. package/src/panels/ToolbarPanel.tsx +0 -19
  107. package/src/panels/ViewPanel.tsx +0 -62
  108. package/src/panels/ViewportPanel.tsx +0 -10
  109. package/src/panels/WorkspacePanel.tsx +0 -31
  110. package/src/panels/index.ts +0 -8
  111. package/src/panels/styles.less +0 -331
  112. package/src/simulators/MobileSimulator/body.tsx +0 -78
  113. package/src/simulators/MobileSimulator/index.tsx +0 -21
  114. package/src/simulators/MobileSimulator/styles.less +0 -29
  115. package/src/simulators/PCSimulator/index.tsx +0 -17
  116. package/src/simulators/PCSimulator/styles.less +0 -11
  117. package/src/simulators/ResponsiveSimulator/handle.tsx +0 -29
  118. package/src/simulators/ResponsiveSimulator/index.tsx +0 -193
  119. package/src/simulators/ResponsiveSimulator/styles.less +0 -56
  120. package/src/simulators/index.tsx +0 -3
  121. package/src/theme.less +0 -224
  122. package/src/types.ts +0 -41
  123. package/src/variables.less +0 -1
  124. package/src/widgets/AuxToolWidget/Copy.tsx +0 -28
  125. package/src/widgets/AuxToolWidget/Cover.tsx +0 -76
  126. package/src/widgets/AuxToolWidget/DashedBox.tsx +0 -55
  127. package/src/widgets/AuxToolWidget/Delete.tsx +0 -29
  128. package/src/widgets/AuxToolWidget/DragHandler.tsx +0 -29
  129. package/src/widgets/AuxToolWidget/FreeSelection.tsx +0 -53
  130. package/src/widgets/AuxToolWidget/Helpers.tsx +0 -116
  131. package/src/widgets/AuxToolWidget/Insertion.tsx +0 -80
  132. package/src/widgets/AuxToolWidget/ResizeHandler.tsx +0 -35
  133. package/src/widgets/AuxToolWidget/Selection.tsx +0 -85
  134. package/src/widgets/AuxToolWidget/Selector.tsx +0 -125
  135. package/src/widgets/AuxToolWidget/SnapLine.tsx +0 -40
  136. package/src/widgets/AuxToolWidget/SpaceBlock.tsx +0 -112
  137. package/src/widgets/AuxToolWidget/TranslateHandler.tsx +0 -29
  138. package/src/widgets/AuxToolWidget/index.tsx +0 -40
  139. package/src/widgets/AuxToolWidget/styles.less +0 -383
  140. package/src/widgets/ComponentTreeWidget/index.tsx +0 -99
  141. package/src/widgets/ComponentTreeWidget/styles.less +0 -6
  142. package/src/widgets/DesignerToolsWidget/index.tsx +0 -206
  143. package/src/widgets/DesignerToolsWidget/styles.less +0 -29
  144. package/src/widgets/DroppableWidget/index.tsx +0 -63
  145. package/src/widgets/DroppableWidget/styles.less +0 -11
  146. package/src/widgets/EmptyWidget/index.tsx +0 -58
  147. package/src/widgets/EmptyWidget/styles.less +0 -27
  148. package/src/widgets/GhostWidget/index.tsx +0 -47
  149. package/src/widgets/GhostWidget/styles.less +0 -20
  150. package/src/widgets/HistoryWidget/index.tsx +0 -42
  151. package/src/widgets/HistoryWidget/styles.less +0 -23
  152. package/src/widgets/IconWidget/index.tsx +0 -152
  153. package/src/widgets/IconWidget/styles.less +0 -17
  154. package/src/widgets/NodeActionsWidget/index.tsx +0 -56
  155. package/src/widgets/NodeActionsWidget/styles.less +0 -51
  156. package/src/widgets/NodePathWidget/index.tsx +0 -57
  157. package/src/widgets/NodePathWidget/styles.less +0 -16
  158. package/src/widgets/NodeTitleWidget/index.tsx +0 -20
  159. package/src/widgets/OutlineWidget/Insertion.tsx +0 -63
  160. package/src/widgets/OutlineWidget/OutlineNode.tsx +0 -198
  161. package/src/widgets/OutlineWidget/context.ts +0 -9
  162. package/src/widgets/OutlineWidget/index.tsx +0 -66
  163. package/src/widgets/OutlineWidget/styles.less +0 -195
  164. package/src/widgets/ResourceWidget/index.tsx +0 -110
  165. package/src/widgets/ResourceWidget/styles.less +0 -87
  166. package/src/widgets/TextWidget/index.tsx +0 -43
  167. package/src/widgets/ViewToolsWidget/index.tsx +0 -72
  168. package/src/widgets/index.ts +0 -15
  169. package/tsconfig.build.json +0 -10
  170. package/tsconfig.json +0 -5
@@ -1,206 +0,0 @@
1
- import React, { Fragment, useRef } from 'react'
2
- import { Button, InputNumber } from 'antd'
3
- import { observer } from '@formily/reactive-react'
4
- import { CursorType, ScreenType } from '@formily-design/core'
5
- import {
6
- useCursor,
7
- useHistory,
8
- useScreen,
9
- usePrefix,
10
- useWorkbench,
11
- } from '../../hooks'
12
- import { IconWidget } from '../IconWidget'
13
- import cls from 'classnames'
14
- import './styles.less'
15
-
16
- type DesignerToolsType = 'HISTORY' | 'CURSOR' | 'SCREEN_TYPE'
17
-
18
- export type IDesignerToolsWidgetProps = {
19
- className?: string
20
- style?: React.CSSProperties
21
- use?: DesignerToolsType[]
22
- }
23
-
24
- export const DesignerToolsWidget: React.FC<IDesignerToolsWidgetProps> =
25
- observer((props) => {
26
- const screen = useScreen()
27
- const cursor = useCursor()
28
- const workbench = useWorkbench()
29
- const history = useHistory()
30
- const sizeRef = useRef<{ width?: any; height?: any }>({})
31
- const prefix = usePrefix('designer-tools')
32
- const renderHistoryController = () => {
33
- if (!props.use.includes('HISTORY')) return null
34
- return (
35
- <Button.Group size="small" style={{ marginRight: 20 }}>
36
- <Button
37
- size="small"
38
- disabled={!history?.allowUndo}
39
- onClick={() => {
40
- history.undo()
41
- }}
42
- >
43
- <IconWidget infer="Undo" />
44
- </Button>
45
- <Button
46
- size="small"
47
- disabled={!history?.allowRedo}
48
- onClick={() => {
49
- history.redo()
50
- }}
51
- >
52
- <IconWidget infer="Redo" />
53
- </Button>
54
- </Button.Group>
55
- )
56
- }
57
-
58
- const renderCursorController = () => {
59
- if (workbench.type !== 'DESIGNABLE') return null
60
- if (!props.use.includes('CURSOR')) return null
61
- return (
62
- <Button.Group size="small" style={{ marginRight: 20 }}>
63
- <Button
64
- size="small"
65
- disabled={cursor.type === CursorType.Normal}
66
- onClick={() => {
67
- cursor.setType(CursorType.Normal)
68
- }}
69
- >
70
- <IconWidget infer="Move" />
71
- </Button>
72
- <Button
73
- size="small"
74
- disabled={cursor.type === CursorType.Selection}
75
- onClick={() => {
76
- cursor.setType(CursorType.Selection)
77
- }}
78
- >
79
- <IconWidget infer="Selection" />
80
- </Button>
81
- </Button.Group>
82
- )
83
- }
84
-
85
- const renderResponsiveController = () => {
86
- if (!props.use.includes('SCREEN_TYPE')) return null
87
- if (screen.type !== ScreenType.Responsive) return null
88
- return (
89
- <Fragment>
90
- <InputNumber
91
- size="small"
92
- value={screen.width}
93
- style={{ width: 70, textAlign: 'center' }}
94
- onChange={(value) => {
95
- sizeRef.current.width = value
96
- }}
97
- onPressEnter={() => {
98
- screen.setSize(sizeRef.current.width, screen.height)
99
- }}
100
- />
101
- <IconWidget
102
- size={10}
103
- infer="Close"
104
- style={{ padding: '0 3px', color: '#999' }}
105
- />
106
- <InputNumber
107
- value={screen.height}
108
- size="small"
109
- style={{
110
- width: 70,
111
- textAlign: 'center',
112
- marginRight: 10,
113
- }}
114
- onChange={(value) => {
115
- sizeRef.current.height = value
116
- }}
117
- onPressEnter={() => {
118
- screen.setSize(screen.width, sizeRef.current.height)
119
- }}
120
- />
121
- {(screen.width !== '100%' || screen.height !== '100%') && (
122
- <Button
123
- size="small"
124
- style={{ marginRight: 20 }}
125
- onClick={() => {
126
- screen.resetSize()
127
- }}
128
- >
129
- <IconWidget infer="Recover" />
130
- </Button>
131
- )}
132
- </Fragment>
133
- )
134
- }
135
-
136
- const renderScreenTypeController = () => {
137
- if (!props.use.includes('SCREEN_TYPE')) return null
138
- return (
139
- <Button.Group size="small" style={{ marginRight: 20 }}>
140
- <Button
141
- size="small"
142
- disabled={screen.type === ScreenType.PC}
143
- onClick={() => {
144
- screen.setType(ScreenType.PC)
145
- }}
146
- >
147
- <IconWidget infer="PC" />
148
- </Button>
149
- <Button
150
- size="small"
151
- disabled={screen.type === ScreenType.Mobile}
152
- onClick={() => {
153
- screen.setType(ScreenType.Mobile)
154
- }}
155
- >
156
- <IconWidget infer="Mobile" />
157
- </Button>
158
- <Button
159
- size="small"
160
- disabled={screen.type === ScreenType.Responsive}
161
- onClick={() => {
162
- screen.setType(ScreenType.Responsive)
163
- }}
164
- >
165
- <IconWidget infer="Responsive" />
166
- </Button>
167
- </Button.Group>
168
- )
169
- }
170
-
171
- const renderMobileController = () => {
172
- if (!props.use.includes('SCREEN_TYPE')) return null
173
- if (screen.type !== ScreenType.Mobile) return
174
- return (
175
- <Button
176
- size="small"
177
- style={{ marginRight: 20 }}
178
- onClick={() => {
179
- screen.setFlip(!screen.flip)
180
- }}
181
- >
182
- <IconWidget
183
- infer="Flip"
184
- style={{
185
- transition: 'all .15s ease-in',
186
- transform: screen.flip ? 'rotate(-90deg)' : '',
187
- }}
188
- />
189
- </Button>
190
- )
191
- }
192
-
193
- return (
194
- <div style={props.style} className={cls(prefix, props.className)}>
195
- {renderHistoryController()}
196
- {renderCursorController()}
197
- {renderScreenTypeController()}
198
- {renderMobileController()}
199
- {renderResponsiveController()}
200
- </div>
201
- )
202
- })
203
-
204
- DesignerToolsWidget.defaultProps = {
205
- use: ['HISTORY', 'CURSOR', 'SCREEN_TYPE'],
206
- }
@@ -1,29 +0,0 @@
1
- @import '../../variables.less';
2
-
3
- .@{prefix-cls}-designer-tools {
4
- display: flex;
5
- align-items: center;
6
-
7
- .ant-input-number {
8
- font-size: 12px !important;
9
- background: var(--dn-toolbar-input-bg-color) !important;
10
- border-color: var(--dn-toolbar-input-border-color) !important;
11
- color: var(--dn-toolbar-input-color) !important;
12
-
13
- .ant-input-number-handler-wrap,
14
- .ant-input-number-handler {
15
- background: var(--dn-toolbar-input-handler-bg-color) !important;
16
- border-color: var(--dn-toolbar-input-border-color) !important;
17
- color: var(--dn-toolbar-input-color) !important;
18
- }
19
-
20
- .ant-input-number-handler-down-inner,
21
- .ant-input-number-handler-up-inner {
22
- color: var(--dn-toolbar-input-color) !important;
23
- }
24
-
25
- &:hover {
26
- border-color: var(--dn-toolbar-input-hover-border-color) !important;
27
- }
28
- }
29
- }
@@ -1,63 +0,0 @@
1
- import React from 'react'
2
- import { TreeNode } from '@formily-design/core'
3
- import { observer } from '@formily/reactive-react'
4
- import { useTreeNode, useNodeIdProps } from '../../hooks'
5
- import { NodeTitleWidget } from '../NodeTitleWidget'
6
- import {
7
- NodeActionsWidget,
8
- INodeActionsWidgetActionProps,
9
- } from '../NodeActionsWidget'
10
- import './styles.less'
11
-
12
- export interface IDroppableWidgetProps {
13
- children?: React.ReactNode
14
- node?: TreeNode
15
- actions?: INodeActionsWidgetActionProps[]
16
- placeholder?: boolean
17
- height?: number
18
- style?: React.CSSProperties
19
- className?: string
20
- hasChildren?: boolean
21
- }
22
-
23
- export const DroppableWidget: React.FC<IDroppableWidgetProps> = observer(
24
- ({
25
- node,
26
- actions,
27
- height,
28
- placeholder,
29
- style,
30
- className,
31
- hasChildren: hasChildrenProp,
32
- ...props
33
- }) => {
34
- const currentNode = useTreeNode()
35
- const nodeId = useNodeIdProps(node)
36
- const target = node ?? currentNode
37
- const hasChildren = hasChildrenProp ?? target.children?.length > 0
38
- return (
39
- <div {...nodeId} {...props} className={className} style={style}>
40
- {hasChildren ? (
41
- props.children
42
- ) : placeholder ? (
43
- <div style={{ height }} className="dn-droppable-placeholder">
44
- <NodeTitleWidget node={target} />
45
- </div>
46
- ) : (
47
- props.children
48
- )}
49
- {actions?.length ? (
50
- <NodeActionsWidget>
51
- {actions.map((action, key) => (
52
- <NodeActionsWidget.Action {...action} key={key} />
53
- ))}
54
- </NodeActionsWidget>
55
- ) : null}
56
- </div>
57
- )
58
- }
59
- )
60
-
61
- DroppableWidget.defaultProps = {
62
- placeholder: true,
63
- }
@@ -1,11 +0,0 @@
1
- .dn-droppable-placeholder {
2
- height: 60px;
3
- background-color: var(--dn-droppable-bg-color);
4
- border: 1px dashed var(--dn-droppable-border-color);
5
- display: flex;
6
- align-items: center;
7
- justify-content: center;
8
- color: var(--dn-droppable-color);
9
- font-weight: lighter;
10
- font-size: 13px;
11
- }
@@ -1,58 +0,0 @@
1
- import React from 'react'
2
- import { useTree, usePrefix } from '../../hooks'
3
- import { observer } from '@formily/reactive-react'
4
- import { IconWidget } from '../IconWidget'
5
- import './styles.less'
6
-
7
- export interface IEmptyWidgetProps {
8
- children?: React.ReactNode
9
- dragTipsDirection?: 'left' | 'right'
10
- }
11
-
12
- export const EmptyWidget: React.FC<IEmptyWidgetProps> = observer((props) => {
13
- const tree = useTree()
14
- const prefix = usePrefix('empty')
15
- const renderEmpty = () => {
16
- return (
17
- <div style={{ display: 'flex', flexDirection: 'column' }}>
18
- <div className="animations">
19
- <IconWidget
20
- infer={
21
- props.dragTipsDirection === 'left'
22
- ? 'DragLeftSourceAnimation'
23
- : 'DragRightSourceAnimation'
24
- }
25
- size={240}
26
- />
27
- <IconWidget infer="BatchDragAnimation" size={240} />
28
- </div>
29
- <div className="hotkeys-list">
30
- <div>
31
- Selection <IconWidget infer="Command" /> + Click /{' '}
32
- <IconWidget infer="Shift" /> + Click /{' '}
33
- <IconWidget infer="Command" /> + A
34
- </div>
35
- <div>
36
- Copy <IconWidget infer="Command" /> + C / Paste{' '}
37
- <IconWidget infer="Command" /> + V
38
- </div>
39
- <div>
40
- Delete <IconWidget infer="Delete" />
41
- </div>
42
- </div>
43
- </div>
44
- )
45
- }
46
- if (!tree?.children?.length) {
47
- return (
48
- <div className={prefix}>
49
- {props.children ? props.children : renderEmpty()}
50
- </div>
51
- )
52
- }
53
- return null
54
- })
55
-
56
- EmptyWidget.defaultProps = {
57
- dragTipsDirection: 'left',
58
- }
@@ -1,27 +0,0 @@
1
- @import '../../variables.less';
2
-
3
- .@{prefix-cls}-empty {
4
- transform: perspective(1px) translate3d(0, 0, 0);
5
- position: absolute;
6
- top: 0;
7
- left: 0;
8
- right: 0;
9
- bottom: 0;
10
- height: 100%;
11
- width: 100%;
12
- pointer-events: none;
13
- display: flex;
14
- align-items: center;
15
- justify-content: center;
16
- background: var(--dn-empty-bg-color);
17
- .animations {
18
- display: flex;
19
- flex-wrap: wrap;
20
- justify-content: center;
21
- }
22
- .hotkeys-list {
23
- text-align: center;
24
- line-height: 30px;
25
- color: #888;
26
- }
27
- }
@@ -1,47 +0,0 @@
1
- import React, { useRef, useEffect } from 'react'
2
- import { useCursor, usePrefix, useDesigner } from '../../hooks'
3
- import { CursorStatus } from '@formily-design/core'
4
- import { autorun } from '@formily/reactive'
5
- import { observer } from '@formily/reactive-react'
6
- import { NodeTitleWidget } from '../NodeTitleWidget'
7
- import './styles.less'
8
-
9
- export const GhostWidget = observer(() => {
10
- const designer = useDesigner()
11
- const cursor = useCursor()
12
- const ref = useRef<HTMLDivElement>()
13
- const prefix = usePrefix('ghost')
14
- const movingNodes = designer.findMovingNodes()
15
- const firstNode = movingNodes[0]
16
- useEffect(
17
- () =>
18
- autorun(() => {
19
- const transform = `perspective(1px) translate3d(${
20
- cursor.position?.topClientX - 18
21
- }px,${cursor.position?.topClientY - 12}px,0) scale(0.8)`
22
- if (!ref.current) return
23
- ref.current.style.transform = transform
24
- }),
25
- [designer, cursor]
26
- )
27
- const renderNodes = () => {
28
- return (
29
- <span
30
- style={{
31
- whiteSpace: 'nowrap',
32
- }}
33
- >
34
- <NodeTitleWidget node={firstNode} />
35
- {movingNodes.length > 1 ? '...' : ''}
36
- </span>
37
- )
38
- }
39
- if (!firstNode) return null
40
- return cursor.status === CursorStatus.Dragging ? (
41
- <div ref={ref} className={prefix}>
42
- {renderNodes()}
43
- </div>
44
- ) : null
45
- })
46
-
47
- GhostWidget.displayName = 'GhostWidget'
@@ -1,20 +0,0 @@
1
- @import '../../variables.less';
2
-
3
- .@{prefix-cls}-ghost {
4
- padding-left: 25px;
5
- padding-right: 15px;
6
- height: 30px;
7
- display: flex;
8
- justify-content: center;
9
- align-items: center;
10
- position: fixed;
11
- color: var(--dn-ghost-color);
12
- font-size: 12px;
13
- z-index: 9999;
14
- border-radius: 50px;
15
- background-color: var(--dn-ghost-bg-color);
16
- pointer-events: none;
17
- left: 0;
18
- top: 0;
19
- transform: translate3d(0, 0, 0);
20
- }
@@ -1,42 +0,0 @@
1
- import React from 'react'
2
- import format from 'dateformat'
3
- import { observer } from '@formily/reactive-react'
4
- import { usePrefix, useWorkbench } from '../../hooks'
5
- import { TextWidget } from '../TextWidget'
6
- import cls from 'classnames'
7
- import './styles.less'
8
-
9
- export const HistoryWidget: React.FC = observer(() => {
10
- const workbench = useWorkbench()
11
- const currentWorkspace =
12
- workbench?.activeWorkspace || workbench?.currentWorkspace
13
- const prefix = usePrefix('history')
14
- if (!currentWorkspace) return null
15
- return (
16
- <div className={prefix}>
17
- {currentWorkspace.history.list().map((item, index) => {
18
- const type = item.type || 'default_state'
19
- const token = type.replace(/\:/g, '_')
20
- return (
21
- <div
22
- className={cls(prefix + '-item', {
23
- active: currentWorkspace.history.current === index,
24
- })}
25
- key={item.timestamp}
26
- onClick={() => {
27
- currentWorkspace.history.goTo(index)
28
- }}
29
- >
30
- <span className={prefix + '-item-title'}>
31
- <TextWidget token={`operations.${token}`} />
32
- </span>
33
- <span className={prefix + '-item-timestamp'}>
34
- {' '}
35
- {format(item.timestamp, 'yy/mm/dd HH:MM:ss')}
36
- </span>
37
- </div>
38
- )
39
- })}
40
- </div>
41
- )
42
- })
@@ -1,23 +0,0 @@
1
- @import '../../variables.less';
2
-
3
- .@{prefix-cls}-history {
4
- &-item {
5
- display: flex;
6
- justify-content: space-between;
7
- min-height: 32px;
8
- padding: 0 10px;
9
- align-items: center;
10
- cursor: pointer;
11
- color: var(--dn-outline-tree-node-header-color);
12
- &-timestamp {
13
- font-size: 10px;
14
- }
15
- &:hover {
16
- background-color: var(--dn-panel-active-bg-color);
17
- }
18
-
19
- &.active {
20
- background-color: var(--dn-panel-active-bg-color);
21
- }
22
- }
23
- }
@@ -1,152 +0,0 @@
1
- import React, { createContext, useContext, useEffect, useRef } from 'react'
2
- import { isStr, isFn, isObj, isPlainObj } from '@formily-design/shared'
3
- import { observer } from '@formily/reactive-react'
4
- import { Tooltip, TooltipProps } from 'antd'
5
- import { usePrefix, useRegistry, useTheme } from '../../hooks'
6
- import cls from 'classnames'
7
- import './styles.less'
8
-
9
- const IconContext = createContext<IconProviderProps>(null)
10
-
11
- const isNumSize = (val: any) => /^[\d.]+$/.test(val)
12
- export interface IconProviderProps {
13
- children?: React.ReactNode
14
- tooltip?: boolean
15
- }
16
-
17
- export interface IShadowSVGProps {
18
- content?: string
19
- width?: number | string
20
- height?: number | string
21
- }
22
- export interface IIconWidgetProps extends React.HTMLAttributes<HTMLElement> {
23
- tooltip?: React.ReactNode | TooltipProps
24
- infer: React.ReactNode | { shadow: string }
25
- size?: number | string
26
- }
27
-
28
- export const IconWidget: React.FC<IIconWidgetProps> & {
29
- Provider?: React.FC<IconProviderProps>
30
- ShadowSVG?: React.FC<IShadowSVGProps>
31
- } = observer((props: React.PropsWithChildren<IIconWidgetProps>) => {
32
- const theme = useTheme()
33
- const context = useContext(IconContext)
34
- const registry = useRegistry()
35
- const prefix = usePrefix('icon')
36
- const size = props.size || '1em'
37
- const height = props.style?.height || size
38
- const width = props.style?.width || size
39
- const takeIcon = (infer: IIconWidgetProps['infer']) => {
40
- if (isStr(infer)) {
41
- const finded = registry.getDesignerIcon(infer)
42
- if (finded) {
43
- return takeIcon(finded)
44
- }
45
- return <img src={infer} height={height} width={width} />
46
- } else if (isFn(infer)) {
47
- return React.createElement(infer, {
48
- height,
49
- width,
50
- fill: 'currentColor',
51
- })
52
- } else if (React.isValidElement(infer)) {
53
- if (infer.type === 'svg') {
54
- const svgProps: any = {
55
- height,
56
- width,
57
- fill: 'currentColor',
58
- viewBox: infer.props.viewBox || '0 0 1024 1024',
59
- focusable: 'false',
60
- 'aria-hidden': 'true',
61
- }
62
- return React.cloneElement(infer, svgProps)
63
- } else if (infer.type === 'path' || infer.type === 'g') {
64
- return (
65
- <svg
66
- viewBox="0 0 1024 1024"
67
- height={height}
68
- width={width}
69
- fill="currentColor"
70
- focusable="false"
71
- aria-hidden="true"
72
- >
73
- {infer}
74
- </svg>
75
- )
76
- }
77
- return infer
78
- } else if (isPlainObj(infer)) {
79
- if (infer[theme]) {
80
- return takeIcon(infer[theme])
81
- } else if (infer['shadow']) {
82
- return (
83
- <IconWidget.ShadowSVG
84
- width={width}
85
- height={height}
86
- content={infer['shadow']}
87
- />
88
- )
89
- }
90
- return null
91
- }
92
- }
93
- const renderTooltips = (children: React.ReactElement): React.ReactElement => {
94
- if (!isStr(props.infer) && context?.tooltip) return children as any
95
- const tooltip =
96
- props.tooltip || registry.getDesignerMessage(`icons.${props.infer}`)
97
- if (tooltip) {
98
- const title =
99
- React.isValidElement(tooltip) || isStr(tooltip)
100
- ? tooltip
101
- : tooltip.title
102
- const props =
103
- React.isValidElement(tooltip) || isStr(tooltip)
104
- ? {}
105
- : isObj(tooltip)
106
- ? tooltip
107
- : {}
108
- return (
109
- <Tooltip {...props} title={title}>
110
- {children}
111
- </Tooltip>
112
- )
113
- }
114
- return children
115
- }
116
- if (!props.infer) return null
117
- return renderTooltips(
118
- <span
119
- {...props}
120
- className={cls(prefix, props.className)}
121
- style={{
122
- ...props.style,
123
- cursor: props.onClick ? 'pointer' : props.style?.cursor,
124
- }}
125
- >
126
- {takeIcon(props.infer)}
127
- </span>
128
- )
129
- })
130
-
131
- IconWidget.ShadowSVG = (props) => {
132
- const ref = useRef<HTMLDivElement>()
133
- const width = isNumSize(props.width) ? `${props.width}px` : props.width
134
- const height = isNumSize(props.height) ? `${props.height}px` : props.height
135
- useEffect(() => {
136
- if (ref.current) {
137
- const root =
138
- ref.current.shadowRoot ||
139
- ref.current.attachShadow({
140
- mode: 'open',
141
- })
142
- root.innerHTML = `<svg viewBox="0 0 1024 1024" style="width:${width};height:${height}">${props.content}</svg>`
143
- }
144
- }, [])
145
- return <div ref={ref}></div>
146
- }
147
-
148
- IconWidget.Provider = (props) => {
149
- return (
150
- <IconContext.Provider value={props}>{props.children}</IconContext.Provider>
151
- )
152
- }