@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,13 +0,0 @@
1
- import React from 'react'
2
-
3
- export const Text = (
4
- <svg>
5
- <path d="M812,190 C834.09139,190 852,207.90861 852,230 L852,280 C852,302.09139 834.09139,320 812,320 C789.90861,320 772,302.09139 772,280 L772,270 L552,270 L552,754 L672,754 C694.09139,754 712,771.90861 712,794 C712,816.09139 694.09139,834 672,834 L352,834 C329.90861,834 312,816.09139 312,794 C312,771.90861 329.90861,754 352,754 L472,754 L472,269.999 L252,269.999 L252,290 C252,312.09139 234.09139,330 212,330 C189.90861,330 172,312.09139 172,290 L172,230 C172,207.90861 189.90861,190 212,190 L812,190 L812,190 Z"></path>
6
- </svg>
7
- )
8
-
9
- export const RichText = (
10
- <svg>
11
- <path d="M100,189.5 C102.155215,189.5 104.27062,189.67045 106.333468,189.998605 L580,190 L580,190 C602.09139,190 620,207.90861 620,230 L620,280 C620,302.09139 602.09139,320 580,320 C557.90861,320 540,302.09139 540,280 L540,270 L380,270 L380,753 L500,753 C522.09139,753 540,770.90861 540,793 C540,815.09139 522.09139,833 500,833 L180,833 C157.90861,833 140,815.09139 140,793 C140,770.90861 157.90861,753 180,753 L300,753 L300,269.999 L140,269.999 L140,279.5 C140,301.59139 122.09139,319.5 100,319.5 C77.90861,319.5 60,301.59139 60,279.5 L60,229.5 C60,207.40861 77.90861,189.5 100,189.5 Z M652,833 C629.90861,833 612,815.09139 612,793 C612,770.90861 629.90861,753 652,753 L712,753 L712,541 L620,541 L620,551 C620,573.09139 602.09139,591 580,591 C557.90861,591 540,573.09139 540,551 L540,501 C540,478.90861 557.90861,461 580,461 L924,461 L924,461 C946.09139,461 964,478.90861 964,501 L964,551 C964,573.09139 946.09139,591 924,591 C901.90861,591 884,573.09139 884,551 L884,541 L792,541 L792,753 L852,753 C874.09139,753 892,770.90861 892,793 C892,815.09139 874.09139,833 852,833 L652,833 Z"></path>
12
- </svg>
13
- )
@@ -1,7 +0,0 @@
1
- import React from 'react'
2
-
3
- export const Undo = (
4
- <svg viewBox="0 0 1024 1024">
5
- <path d="M629.44 291.712V0S0 394.56 0 458.24c0 63.744 629.44 416.64 629.44 416.64V625.088s289.344 4.672 370.304 374.976c84.48-279.104-54.912-693.824-370.304-708.352z m176.768 337.92c-91.392-52.544-172.736-54.464-176.064-54.592l-47.232-0.704V792.192c-229.76-131.2-461.568-275.584-525.44-334.72 62.848-62.912 294.656-222.848 525.44-369.984v252.096l44.544 2.048c132.352 6.144 214.144 90.944 259.52 161.024 55.488 85.952 86.912 195.52 90.432 303.232-51.584-91.328-116.8-144.96-171.2-176.256z"></path>
6
- </svg>
7
- )
@@ -1,8 +0,0 @@
1
- import React from 'react'
2
-
3
- export const CloudUpload = (
4
- <svg viewBox="64 64 896 896">
5
- <path d="M518.3 459a8 8 0 00-12.6 0l-112 141.7a7.98 7.98 0 006.3 12.9h73.9V856c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V613.7H624c6.7 0 10.4-7.7 6.3-12.9L518.3 459z"></path>
6
- <path d="M811.4 366.7C765.6 245.9 648.9 160 512.2 160S258.8 245.8 213 366.6C127.3 389.1 64 467.2 64 560c0 110.5 89.5 200 199.9 200H304c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8h-40.1c-33.7 0-65.4-13.4-89-37.7-23.5-24.2-36-56.8-34.9-90.6.9-26.4 9.9-51.2 26.2-72.1 16.7-21.3 40.1-36.8 66.1-43.7l37.9-9.9 13.9-36.6c8.6-22.8 20.6-44.1 35.7-63.4a245.6 245.6 0 0152.4-49.9c41.1-28.9 89.5-44.2 140-44.2s98.9 15.3 140 44.2c19.9 14 37.5 30.8 52.4 49.9 15.1 19.3 27.1 40.7 35.7 63.4l13.8 36.5 37.8 10C846.1 454.5 884 503.8 884 560c0 33.1-12.9 64.3-36.3 87.7a123.07 123.07 0 01-87.6 36.3H720c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h40.1C870.5 760 960 670.5 960 560c0-92.7-63.1-170.7-148.6-193.3z"></path>
7
- </svg>
8
- )
package/src/index.ts DELETED
@@ -1,9 +0,0 @@
1
- import './locales'
2
- import './theme.less'
3
- export * from './panels'
4
- export * from './widgets'
5
- export * from './context'
6
- export * from './hooks'
7
- export * from './containers'
8
- export * from './simulators'
9
- export * from './types'
@@ -1,16 +0,0 @@
1
- export default {
2
- 'zh-CN': {
3
- save: '保存',
4
- submit: '提交',
5
- cancel: '取消',
6
- reset: '重置',
7
- publish: '发布',
8
- },
9
- 'en-US': {
10
- save: 'Save',
11
- submit: 'Submit',
12
- cancel: 'Cancel',
13
- reset: 'Reset',
14
- publish: 'Publish',
15
- },
16
- }
@@ -1,132 +0,0 @@
1
- export default {
2
- 'zh-CN': {
3
- icons: {
4
- Image: '图片',
5
- ImageSize: '图片尺寸',
6
- Position: '位置',
7
- Number: '数字',
8
- Text: '文本',
9
- Expression: '表达式',
10
- RichText: '富文本',
11
- Boolean: '布尔',
12
- Repeat: '重复',
13
- Top: '上',
14
- Left: '左',
15
- Right: '右',
16
- Bottom: '下',
17
- TopLeft: '左上',
18
- TopRight: '右上',
19
- BottomRight: '右下',
20
- BottomLeft: '左下',
21
- DisplayBlock: '区块',
22
- DisplayInlineBlock: '内联区块',
23
- DisplayInline: '文本内联',
24
- DisplayFlex: '弹性盒子',
25
- FlexDirectionRow: '横向',
26
- FlexDirectionColumn: '纵向',
27
- FlexAlignContentCenter: '居中',
28
- FlexAlignContentStart: '头部',
29
- FlexAlignContentEnd: '尾部',
30
- FlexAlignContentSpaceAround: 'Space Around',
31
- FlexAlignContentSpaceBetween: 'Space Between',
32
- FlexAlignContentStretch: 'Stretch',
33
- FlexJustifyCenter: '居中',
34
- FlexJustifyStart: '头部',
35
- FlexJustifyEnd: '尾部',
36
- FlexJustifySpaceBetween: 'Space Between',
37
- FlexJustifySpaceAround: 'Space Around',
38
- FlexJustifySpaceEvenly: 'Space Evenly',
39
- FlexAlignItemsCenter: '居中',
40
- FlexAlignItemsStart: '头部',
41
- FlexAlignItemsEnd: '尾部',
42
- FlexAlignItemsStretch: 'Stretch',
43
- FlexAlignItemsBaseline: 'Baseline',
44
- FlexNoWrap: '不换行',
45
- FlexWrap: '换行',
46
- AxisX: 'X轴',
47
- AxisY: 'Y轴',
48
- Blur: '模糊度',
49
- Shadow: '阴影扩展',
50
- FontWeight: '字重',
51
- FontStyle: '风格',
52
- NormalFontStyle: '标准',
53
- ItalicFontStyle: '斜体',
54
- FontColor: '颜色',
55
- FontSize: '大小',
56
- LineHeight: '行高',
57
- TextDecoration: '修饰',
58
- TextUnderline: '下划线',
59
- TextLineThrough: '中横线',
60
- TextAlign: '对齐',
61
- TextAlignLeft: '左对齐',
62
- TextAlignCenter: '居中',
63
- TextAlignRight: '右对齐',
64
- TextAlignJustify: '自适应',
65
- },
66
- },
67
- 'en-US': {
68
- icons: {
69
- Image: 'Image',
70
- ImageSize: 'Image Size',
71
- Boolean: 'Boolean',
72
- Number: 'Number',
73
- Text: 'Text',
74
- Expression: 'Expression',
75
- RichText: 'Rich Text',
76
- Position: 'Position',
77
- Repeat: 'Repeat',
78
- Top: 'Top',
79
- Left: 'Left',
80
- Right: 'Right',
81
- Bottom: 'Bottom',
82
- TopLeft: 'Top Left',
83
- TopRight: 'Top Right',
84
- BottomRight: 'Bottom Right',
85
- BottomLeft: 'Bottom Left',
86
- DisplayBlock: 'Block',
87
- DisplayInlineBlock: 'Inline Block',
88
- DisplayInline: 'Inline',
89
- DisplayFlex: 'Flex',
90
- FlexDirectionRow: 'Horizontal',
91
- FlexDirectionColumn: 'Vertical',
92
- FlexAlignContentCenter: 'Center',
93
- FlexAlignContentStart: 'Start',
94
- FlexAlignContentEnd: 'End',
95
- FlexAlignContentSpaceAround: 'Space Around',
96
- FlexAlignContentSpaceBetween: 'Space Between',
97
- FlexAlignContentStretch: 'Stretch',
98
- FlexJustifyCenter: 'Center',
99
- FlexJustifyStart: 'Start',
100
- FlexJustifyEnd: 'End',
101
- FlexJustifySpaceBetween: 'Space Between',
102
- FlexJustifySpaceAround: 'Space Around',
103
- FlexJustifySpaceEvenly: 'Space Evenly',
104
- FlexAlignItemsCenter: 'Center',
105
- FlexAlignItemsStart: 'Start',
106
- FlexAlignItemsEnd: 'End',
107
- FlexAlignItemsStretch: 'Stretch',
108
- FlexAlignItemsBaseline: 'Baseline',
109
- FlexNoWrap: 'No Wrap',
110
- FlexWrap: 'Wrap',
111
- AxisX: 'X Axis',
112
- AxisY: 'Y Axis',
113
- Blur: 'Blur',
114
- Shadow: 'Shadow Spread',
115
- FontWeight: 'Font Weight',
116
- FontStyle: 'Font Style',
117
- NormalFontStyle: 'Normal',
118
- ItalicFontStyle: 'Italic',
119
- FontColor: 'Color',
120
- FontSize: 'Font Size',
121
- LineHeight: 'Line Height',
122
- TextDecoration: 'Decoration',
123
- TextUnderline: 'Underline',
124
- TextLineThrough: 'Line Through',
125
- TextAlign: 'Align',
126
- TextAlignLeft: 'Left',
127
- TextAlignCenter: 'Center',
128
- TextAlignRight: 'Right',
129
- TextAlignJustify: 'Justify',
130
- },
131
- },
132
- }
@@ -1,7 +0,0 @@
1
- import { GlobalRegistry } from '@formily-design/core'
2
- import icons from './icons'
3
- import panels from './panels'
4
- import global from './global'
5
- import operations from './operations'
6
-
7
- GlobalRegistry.registerDesignerLocales(icons, panels, global, operations)
@@ -1,50 +0,0 @@
1
- export default {
2
- 'zh-CN': {
3
- operations: {
4
- default_state: '缺省态',
5
- append_node: '追加节点',
6
- prepend_node: '头部追加',
7
- clone_node: '复制节点',
8
- update_node_props: '属性更改',
9
- insert_after: '后置插入',
10
- insert_before: '前置插入',
11
- insert_children: '插入子节点',
12
- update_children: '覆盖子节点',
13
- remove_node: '删除节点',
14
- wrap_node: '包装节点',
15
- from_node: '子树更新',
16
- },
17
- },
18
- 'en-US': {
19
- operations: {
20
- default_state: 'Default State',
21
- append_node: 'Append Node',
22
- prepend_node: 'Prepend Node',
23
- clone_node: 'Clone Node',
24
- update_node_props: 'Update Node Props',
25
- insert_after: 'Insert Node After',
26
- insert_before: 'Insert Node Before',
27
- insert_children: 'Insert Node Children',
28
- update_children: 'Update Children',
29
- remove_node: 'Remove Node',
30
- wrap_node: 'Wrap Node',
31
- from_node: 'Update Child Tree',
32
- },
33
- },
34
- 'ko-KR': {
35
- operations: {
36
- default_state: '초기 상태',
37
- append_node: '노드 추가',
38
- prepend_node: '노드 삽입',
39
- clone_node: '노드 복제',
40
- update_node_props: '노드 속성 수정',
41
- insert_after: '뒤쪽 노드 삽입',
42
- insert_before: '앞쪽 노드 삽입',
43
- insert_children: '자식 노드 삽입',
44
- update_children: '자식 노드 수정',
45
- remove_node: '노드 삭제',
46
- wrap_node: '노드 랩핑',
47
- from_node: '자식 노드 트리 수정',
48
- },
49
- },
50
- }
@@ -1,26 +0,0 @@
1
- export default {
2
- 'zh-CN': {
3
- panels: {
4
- Component: '组件',
5
- OutlinedTree: '大纲树',
6
- PropertySettings: '属性配置',
7
- History: '历史记录',
8
- },
9
- },
10
- 'en-US': {
11
- panels: {
12
- Component: 'Component',
13
- OutlinedTree: 'Outlined Tree',
14
- PropertySettings: 'Property Settings',
15
- History: 'History',
16
- },
17
- },
18
- 'ko-KR': {
19
- panels: {
20
- Component: '컴포넌트',
21
- OutlinedTree: '트리 노드',
22
- PropertySettings: '속성 설정',
23
- History: '기록',
24
- },
25
- },
26
- }
@@ -1,195 +0,0 @@
1
- import React, { useEffect, useRef, useState } from 'react'
2
- import { isValid } from '@formily-design/shared'
3
- import cls from 'classnames'
4
- import { IconWidget, TextWidget } from '../widgets'
5
- import { usePrefix } from '../hooks'
6
-
7
- export interface ICompositePanelProps {
8
- children?: React.ReactNode
9
- direction?: 'left' | 'right'
10
- showNavTitle?: boolean
11
- defaultOpen?: boolean
12
- defaultPinning?: boolean
13
- defaultActiveKey?: number
14
- activeKey?: number | string
15
- onChange?: (activeKey: number | string) => void
16
- }
17
- export interface ICompositePanelItemProps {
18
- children?: React.ReactNode
19
- shape?: 'tab' | 'button' | 'link'
20
- title?: React.ReactNode
21
- icon?: React.ReactNode
22
- key?: number | string
23
- href?: string
24
- onClick?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void
25
- extra?: React.ReactNode
26
- }
27
-
28
- const parseItems = (
29
- children: React.ReactNode
30
- ): React.PropsWithChildren<ICompositePanelItemProps>[] => {
31
- const items = []
32
- React.Children.forEach(children, (child, index) => {
33
- if (child?.['type'] === CompositePanel.Item) {
34
- items.push({ key: child['key'] ?? index, ...child['props'] })
35
- }
36
- })
37
- return items
38
- }
39
-
40
- const findItem = (
41
- items: React.PropsWithChildren<ICompositePanelItemProps>[],
42
- key: string | number
43
- ) => {
44
- for (let index = 0; index < items.length; index++) {
45
- const item = items[index]
46
- if (key === index) return item
47
- if (key === item.key) return item
48
- }
49
- }
50
-
51
- const getDefaultKey = (children: React.ReactNode) => {
52
- const items = parseItems(children)
53
- return items?.[0].key
54
- }
55
-
56
- export const CompositePanel: React.FC<ICompositePanelProps> & {
57
- Item: React.FC<ICompositePanelItemProps>
58
- } = (props) => {
59
- const prefix = usePrefix('composite-panel')
60
- const [activeKey, setActiveKey] = useState<string | number>(
61
- props.defaultActiveKey ?? getDefaultKey(props.children)
62
- )
63
- const activeKeyRef = useRef(null)
64
- const [pinning, setPinning] = useState(props.defaultPinning ?? false)
65
- const [visible, setVisible] = useState(props.defaultOpen ?? true)
66
- const items = parseItems(props.children)
67
- const currentItem = findItem(items, activeKey)
68
- const content = currentItem?.children
69
-
70
- activeKeyRef.current = activeKey
71
-
72
- useEffect(() => {
73
- if (isValid(props.activeKey)) {
74
- if (props.activeKey !== activeKeyRef.current) {
75
- setActiveKey(props.activeKey)
76
- }
77
- }
78
- }, [props.activeKey])
79
-
80
- const renderContent = () => {
81
- if (!content || !visible) return
82
- return (
83
- <div
84
- className={cls(prefix + '-tabs-content', {
85
- pinning,
86
- })}
87
- >
88
- <div className={prefix + '-tabs-header'}>
89
- <div className={prefix + '-tabs-header-title'}>
90
- <TextWidget>{currentItem.title}</TextWidget>
91
- </div>
92
- <div className={prefix + '-tabs-header-actions'}>
93
- <div className={prefix + '-tabs-header-extra'}>
94
- {currentItem.extra}
95
- </div>
96
- {!pinning && (
97
- <IconWidget
98
- infer="PushPinOutlined"
99
- className={prefix + '-tabs-header-pin'}
100
- onClick={() => {
101
- setPinning(!pinning)
102
- }}
103
- />
104
- )}
105
- {pinning && (
106
- <IconWidget
107
- infer="PushPinFilled"
108
- className={prefix + '-tabs-header-pin-filled'}
109
- onClick={() => {
110
- setPinning(!pinning)
111
- }}
112
- />
113
- )}
114
- <IconWidget
115
- infer="Close"
116
- className={prefix + '-tabs-header-close'}
117
- onClick={() => {
118
- setVisible(false)
119
- }}
120
- />
121
- </div>
122
- </div>
123
- <div className={prefix + '-tabs-body'}>{content}</div>
124
- </div>
125
- )
126
- }
127
-
128
- return (
129
- <div
130
- className={cls(prefix, {
131
- [`direction-${props.direction}`]: !!props.direction,
132
- })}
133
- >
134
- <div className={prefix + '-tabs'}>
135
- {items.map((item, index) => {
136
- const takeTab = () => {
137
- if (item.href) {
138
- return <a href={item.href}>{item.icon}</a>
139
- }
140
- return (
141
- <IconWidget
142
- tooltip={
143
- props.showNavTitle
144
- ? null
145
- : {
146
- title: <TextWidget>{item.title}</TextWidget>,
147
- placement:
148
- props.direction === 'right' ? 'left' : 'right',
149
- }
150
- }
151
- infer={item.icon}
152
- />
153
- )
154
- }
155
- const shape = item.shape ?? 'tab'
156
- const Comp = shape === 'link' ? 'a' : 'div'
157
- return (
158
- <Comp
159
- className={cls(prefix + '-tabs-pane', {
160
- active: activeKey === item.key,
161
- })}
162
- key={index}
163
- href={item.href}
164
- onClick={(e: any) => {
165
- if (shape === 'tab') {
166
- if (activeKey === item.key) {
167
- setVisible(!visible)
168
- } else {
169
- setVisible(true)
170
- }
171
- if (!props?.activeKey || !props?.onChange)
172
- setActiveKey(item.key)
173
- }
174
- item.onClick?.(e)
175
- props.onChange?.(item.key)
176
- }}
177
- >
178
- {takeTab()}
179
- {props.showNavTitle && item.title ? (
180
- <div className={prefix + '-tabs-pane-title'}>
181
- <TextWidget>{item.title}</TextWidget>
182
- </div>
183
- ) : null}
184
- </Comp>
185
- )
186
- })}
187
- </div>
188
- {renderContent()}
189
- </div>
190
- )
191
- }
192
-
193
- CompositePanel.Item = () => {
194
- return <React.Fragment />
195
- }
@@ -1,85 +0,0 @@
1
- import React, { useEffect, useState } from 'react'
2
- import { requestIdle } from '@formily-design/shared'
3
- import { observer } from '@formily/reactive-react'
4
- import { TextWidget, IconWidget } from '../widgets'
5
- import { usePrefix, useWorkbench } from '../hooks'
6
- import cls from 'classnames'
7
- export interface ISettingPanelProps {
8
- children?: React.ReactNode
9
- title?: React.ReactNode
10
- extra?: React.ReactNode
11
- }
12
-
13
- export const SettingsPanel: React.FC<ISettingPanelProps> = observer((props) => {
14
- const prefix = usePrefix('settings-panel')
15
- const workbench = useWorkbench()
16
- const [innerVisible, setInnerVisible] = useState(true)
17
- const [pinning, setPinning] = useState(false)
18
- const [visible, setVisible] = useState(true)
19
- useEffect(() => {
20
- if (visible || workbench.type === 'DESIGNABLE') {
21
- if (!innerVisible) {
22
- requestIdle(() => {
23
- requestAnimationFrame(() => {
24
- setInnerVisible(true)
25
- })
26
- })
27
- }
28
- }
29
- }, [visible, workbench.type])
30
- if (workbench.type !== 'DESIGNABLE') {
31
- if (innerVisible) setInnerVisible(false)
32
- return null
33
- }
34
- if (!visible) {
35
- if (innerVisible) setInnerVisible(false)
36
- return (
37
- <div
38
- className={prefix + '-opener'}
39
- onClick={() => {
40
- setVisible(true)
41
- }}
42
- >
43
- <IconWidget infer="Setting" size={20} />
44
- </div>
45
- )
46
- }
47
- return (
48
- <div className={cls(prefix, { pinning })}>
49
- <div className={prefix + '-header'}>
50
- <div className={prefix + '-header-title'}>
51
- <TextWidget>{props.title}</TextWidget>
52
- </div>
53
- <div className={prefix + '-header-actions'}>
54
- <div className={prefix + '-header-extra'}>{props.extra}</div>
55
- {!pinning && (
56
- <IconWidget
57
- infer="PushPinOutlined"
58
- className={prefix + '-header-pin'}
59
- onClick={() => {
60
- setPinning(!pinning)
61
- }}
62
- />
63
- )}
64
- {pinning && (
65
- <IconWidget
66
- infer="PushPinFilled"
67
- className={prefix + '-pin-filled'}
68
- onClick={() => {
69
- setPinning(!pinning)
70
- }}
71
- />
72
- )}
73
- <IconWidget
74
- infer="Close"
75
- className={prefix + '-header-close'}
76
- onClick={() => {
77
- setVisible(false)
78
- }}
79
- />
80
- </div>
81
- </div>
82
- <div className={prefix + '-body'}>{innerVisible && props.children}</div>
83
- </div>
84
- )
85
- })
@@ -1,54 +0,0 @@
1
- import React from 'react'
2
- import { usePrefix, usePosition } from '../hooks'
3
- import { Layout } from '../containers'
4
- import cls from 'classnames'
5
- export interface IStudioPanelProps {
6
- children?: React.ReactNode
7
- style?: React.CSSProperties
8
- className?: string
9
- logo?: React.ReactNode
10
- actions?: React.ReactNode
11
- prefixCls?: string
12
- theme?: string
13
- position?: React.ComponentProps<typeof Layout>['position']
14
- }
15
-
16
- const StudioPanelInternal: React.FC<IStudioPanelProps> = ({
17
- logo,
18
- actions,
19
- ...props
20
- }) => {
21
- const prefix = usePrefix('main-panel')
22
- const position = usePosition()
23
- const classNameBase = cls('root', position, props.className)
24
- if (logo || actions) {
25
- return (
26
- <div {...props} className={cls(`${prefix}-container`, classNameBase)}>
27
- <div className={prefix + '-header'}>
28
- <div className={prefix + '-header-logo'}>{logo}</div>
29
- <div className={prefix + '-header-actions'}>{actions}</div>
30
- </div>
31
- <div className={prefix}>{props.children}</div>
32
- </div>
33
- )
34
- }
35
- return (
36
- <div {...props} className={cls(prefix, classNameBase)}>
37
- {props.children}
38
- </div>
39
- )
40
- }
41
-
42
- export const StudioPanel: React.FC<IStudioPanelProps> = (props) => {
43
- return (
44
- <Layout
45
- theme={props.theme}
46
- prefixCls={props.prefixCls}
47
- position={props.position}
48
- className={props.className}
49
- style={props.style}
50
- >
51
- <StudioPanelInternal {...props} />
52
- </Layout>
53
- )
54
- }
@@ -1,19 +0,0 @@
1
- import React from 'react'
2
- import { WorkspacePanel, IWorkspaceItemProps } from './WorkspacePanel'
3
-
4
- export const ToolbarPanel: React.FC<IWorkspaceItemProps> = (props) => {
5
- return (
6
- <WorkspacePanel.Item
7
- {...props}
8
- style={{
9
- display: 'flex',
10
- justifyContent: 'space-between',
11
- marginBottom: 4,
12
- padding: '0 4px',
13
- ...props.style,
14
- }}
15
- >
16
- {props.children}
17
- </WorkspacePanel.Item>
18
- )
19
- }