@chamn/engine 0.0.10 → 0.0.11

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 (204) hide show
  1. package/dist/component/CustomSchemaForm/components/Form/context.d.ts +2 -0
  2. package/dist/component/CustomSchemaForm/components/Form/index.d.ts +1 -0
  3. package/dist/component/CustomSchemaForm/components/SetterSwitcher/index.d.ts +2 -0
  4. package/dist/component/CustomSchemaForm/index.d.ts +3 -0
  5. package/dist/component/Workbench/index.d.ts +4 -0
  6. package/dist/core/pluginManager.d.ts +5 -0
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.js +197 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/{index.es.js → index.mjs} +2995 -2944
  11. package/dist/index.mjs.map +1 -0
  12. package/dist/plugins/RightPanel/view.d.ts +4 -0
  13. package/package.json +12 -9
  14. package/.eslintignore +0 -1
  15. package/.eslintrc.js +0 -36
  16. package/.prettierrc.json +0 -7
  17. package/.storybook/main.js +0 -24
  18. package/.storybook/preview.js +0 -9
  19. package/CHANGELOG.md +0 -54
  20. package/__tests__/demo.test.ts +0 -3
  21. package/build.config.js +0 -88
  22. package/dist/index.cjs.js +0 -197
  23. package/dist/index.cjs.js.map +0 -1
  24. package/dist/index.es.js.map +0 -1
  25. package/index.html +0 -16
  26. package/jest.config.js +0 -196
  27. package/public/Engine.module.scss.d.ts +0 -5
  28. package/public/_dev_/render.d.ts +0 -2
  29. package/public/component/CSSEditor/style.module.scss.d.ts +0 -6
  30. package/public/component/CSSPropertiesEditor/style.module.scss.d.ts +0 -15
  31. package/public/component/CSSPropertiesVariableBindEditor/style.module.scss.d.ts +0 -15
  32. package/public/component/CustomSchemaForm/components/Form/Field/style.module.scss.d.ts +0 -8
  33. package/public/component/CustomSchemaForm/components/SetterSwitcher/style.module.scss.d.ts +0 -7
  34. package/public/component/CustomSchemaForm/components/Setters/ArraySetter/style.module.scss.d.ts +0 -7
  35. package/public/component/CustomSchemaForm/components/Setters/CSSValueSetter/style.module.scss.d.ts +0 -6
  36. package/public/component/CustomSchemaForm/style.module.scss.d.ts +0 -11
  37. package/public/component/Workbench/style.module.scss.d.ts +0 -25
  38. package/public/plugins/AdvancePanel/style.module.scss.d.ts +0 -7
  39. package/public/plugins/ComponentLibrary/components/DragItem/style.module.scss.d.ts +0 -9
  40. package/public/plugins/ComponentLibrary/components/ListView/style.module.scss.d.ts +0 -12
  41. package/public/plugins/ComponentLibrary/style.module.scss.d.ts +0 -11
  42. package/public/plugins/Designer/components/DefaultSelectToolBar/style.module.scss.d.ts +0 -11
  43. package/public/plugins/Designer/style.module.scss.d.ts +0 -5
  44. package/public/plugins/GlobalStatePanel/style.module.scss.d.ts +0 -5
  45. package/public/plugins/OutlineTree/components/TreeView/style.module.scss.d.ts +0 -16
  46. package/public/plugins/PropertyPanel/style.module.scss.d.ts +0 -10
  47. package/public/plugins/RightPanel/style.module.scss.d.ts +0 -10
  48. package/public/plugins/VisualPanelPlus/style.module.scss.d.ts +0 -10
  49. package/public/render.umd.js +0 -42
  50. package/public/render.umd.js.map +0 -1
  51. package/src/Engine.module.scss +0 -10
  52. package/src/Engine.module.scss.d.ts +0 -5
  53. package/src/_dev_/index.css +0 -22
  54. package/src/_dev_/index.tsx +0 -5
  55. package/src/_dev_/page/Editor/index.tsx +0 -198
  56. package/src/_dev_/page/Editor/indexCustom.tsx +0 -274
  57. package/src/_dev_/page/Preview/index.tsx +0 -56
  58. package/src/_dev_/render.ts +0 -3
  59. package/src/_dev_/router.tsx +0 -14
  60. package/src/assets/react.svg +0 -4
  61. package/src/assets/styles/mixin.scss +0 -15
  62. package/src/component/CSSEditor/index.tsx +0 -247
  63. package/src/component/CSSEditor/style.module.scss +0 -22
  64. package/src/component/CSSEditor/style.module.scss.d.ts +0 -6
  65. package/src/component/CSSPropertiesEditor/cssProperties.ts +0 -1062
  66. package/src/component/CSSPropertiesEditor/index.tsx +0 -389
  67. package/src/component/CSSPropertiesEditor/style.module.scss +0 -46
  68. package/src/component/CSSPropertiesEditor/style.module.scss.d.ts +0 -15
  69. package/src/component/CSSPropertiesEditor/util.ts +0 -19
  70. package/src/component/CSSPropertiesVariableBindEditor/cssProperties.ts +0 -782
  71. package/src/component/CSSPropertiesVariableBindEditor/index.tsx +0 -366
  72. package/src/component/CSSPropertiesVariableBindEditor/style.module.scss +0 -48
  73. package/src/component/CSSPropertiesVariableBindEditor/style.module.scss.d.ts +0 -15
  74. package/src/component/CSSPropertiesVariableBindEditor/util.ts +0 -19
  75. package/src/component/ClassNameEditor/index.tsx +0 -91
  76. package/src/component/ClassNameEditor/style.module.scss +0 -0
  77. package/src/component/CustomSchemaForm/components/Form/Field/index.tsx +0 -81
  78. package/src/component/CustomSchemaForm/components/Form/Field/style.module.scss +0 -32
  79. package/src/component/CustomSchemaForm/components/Form/Field/style.module.scss.d.ts +0 -8
  80. package/src/component/CustomSchemaForm/components/Form/context.ts +0 -23
  81. package/src/component/CustomSchemaForm/components/Form/index.tsx +0 -71
  82. package/src/component/CustomSchemaForm/components/SetterSwitcher/index.tsx +0 -273
  83. package/src/component/CustomSchemaForm/components/SetterSwitcher/style.module.scss +0 -16
  84. package/src/component/CustomSchemaForm/components/SetterSwitcher/style.module.scss.d.ts +0 -7
  85. package/src/component/CustomSchemaForm/components/Setters/ArraySetter/ArrayItem.tsx +0 -55
  86. package/src/component/CustomSchemaForm/components/Setters/ArraySetter/SortItemOrderModal.tsx +0 -160
  87. package/src/component/CustomSchemaForm/components/Setters/ArraySetter/index.tsx +0 -129
  88. package/src/component/CustomSchemaForm/components/Setters/ArraySetter/style.module.scss +0 -22
  89. package/src/component/CustomSchemaForm/components/Setters/ArraySetter/style.module.scss.d.ts +0 -7
  90. package/src/component/CustomSchemaForm/components/Setters/BooleanSetter/index.tsx +0 -32
  91. package/src/component/CustomSchemaForm/components/Setters/CSSValueSetter/index.tsx +0 -78
  92. package/src/component/CustomSchemaForm/components/Setters/CSSValueSetter/style.module.scss +0 -7
  93. package/src/component/CustomSchemaForm/components/Setters/CSSValueSetter/style.module.scss.d.ts +0 -6
  94. package/src/component/CustomSchemaForm/components/Setters/ExpressionSetter/index.tsx +0 -47
  95. package/src/component/CustomSchemaForm/components/Setters/FunctionSetter/defaultDts.ts +0 -28
  96. package/src/component/CustomSchemaForm/components/Setters/FunctionSetter/index.tsx +0 -93
  97. package/src/component/CustomSchemaForm/components/Setters/JSONSetter/index.tsx +0 -80
  98. package/src/component/CustomSchemaForm/components/Setters/NumberSetter/index.tsx +0 -34
  99. package/src/component/CustomSchemaForm/components/Setters/SelectSetter/index.tsx +0 -35
  100. package/src/component/CustomSchemaForm/components/Setters/ShapeSetter/index.tsx +0 -65
  101. package/src/component/CustomSchemaForm/components/Setters/StringSetter/index.tsx +0 -30
  102. package/src/component/CustomSchemaForm/components/Setters/TextAreaSetter/index.tsx +0 -31
  103. package/src/component/CustomSchemaForm/components/Setters/index.ts +0 -26
  104. package/src/component/CustomSchemaForm/components/Setters/type.ts +0 -18
  105. package/src/component/CustomSchemaForm/context.ts +0 -20
  106. package/src/component/CustomSchemaForm/index.tsx +0 -93
  107. package/src/component/CustomSchemaForm/style.module.scss +0 -15
  108. package/src/component/CustomSchemaForm/style.module.scss.d.ts +0 -11
  109. package/src/component/CustomSchemaForm/utils.ts +0 -13
  110. package/src/component/MonacoEditor/index.tsx +0 -81
  111. package/src/component/Workbench/index.tsx +0 -329
  112. package/src/component/Workbench/style.module.scss +0 -159
  113. package/src/component/Workbench/style.module.scss.d.ts +0 -25
  114. package/src/core/pluginManager.ts +0 -151
  115. package/src/i18n/en_US/index.ts +0 -5
  116. package/src/i18n/index.ts +0 -39
  117. package/src/i18n/zh_CN/index.ts +0 -5
  118. package/src/index.tsx +0 -150
  119. package/src/material/innerMaterial.ts +0 -343
  120. package/src/plugins/AdvancePanel/index.tsx +0 -191
  121. package/src/plugins/AdvancePanel/style.module.scss +0 -8
  122. package/src/plugins/AdvancePanel/style.module.scss.d.ts +0 -7
  123. package/src/plugins/ComponentLibrary/components/DragItem/index.tsx +0 -65
  124. package/src/plugins/ComponentLibrary/components/DragItem/style.module.scss +0 -58
  125. package/src/plugins/ComponentLibrary/components/DragItem/style.module.scss.d.ts +0 -9
  126. package/src/plugins/ComponentLibrary/components/ListView/index.tsx +0 -50
  127. package/src/plugins/ComponentLibrary/components/ListView/style.module.scss +0 -27
  128. package/src/plugins/ComponentLibrary/components/ListView/style.module.scss.d.ts +0 -12
  129. package/src/plugins/ComponentLibrary/index.tsx +0 -184
  130. package/src/plugins/ComponentLibrary/localize/en_US/index.ts +0 -3
  131. package/src/plugins/ComponentLibrary/localize/index.ts +0 -3
  132. package/src/plugins/ComponentLibrary/localize/zh_CN/index.ts +0 -3
  133. package/src/plugins/ComponentLibrary/style.module.scss +0 -31
  134. package/src/plugins/ComponentLibrary/style.module.scss.d.ts +0 -11
  135. package/src/plugins/ComponentLibrary/util.ts +0 -14
  136. package/src/plugins/ComponentStatePanel/index.tsx +0 -59
  137. package/src/plugins/Designer/components/DefaultSelectToolBar/index.tsx +0 -94
  138. package/src/plugins/Designer/components/DefaultSelectToolBar/style.module.scss +0 -59
  139. package/src/plugins/Designer/components/DefaultSelectToolBar/style.module.scss.d.ts +0 -11
  140. package/src/plugins/Designer/components/GhostView/index.tsx +0 -18
  141. package/src/plugins/Designer/config.ts +0 -1
  142. package/src/plugins/Designer/index.tsx +0 -61
  143. package/src/plugins/Designer/localize/en_US/index.ts +0 -3
  144. package/src/plugins/Designer/localize/index.ts +0 -3
  145. package/src/plugins/Designer/localize/zh_CN/index.ts +0 -3
  146. package/src/plugins/Designer/style.module.scss +0 -10
  147. package/src/plugins/Designer/style.module.scss.d.ts +0 -5
  148. package/src/plugins/Designer/util.ts +0 -18
  149. package/src/plugins/Designer/view.tsx +0 -225
  150. package/src/plugins/DisplaySourceSchema/index.tsx +0 -76
  151. package/src/plugins/GlobalStatePanel/index.tsx +0 -96
  152. package/src/plugins/GlobalStatePanel/localize/en_US/index.ts +0 -3
  153. package/src/plugins/GlobalStatePanel/localize/index.ts +0 -3
  154. package/src/plugins/GlobalStatePanel/localize/zh_CN/index.ts +0 -3
  155. package/src/plugins/GlobalStatePanel/style.module.scss +0 -8
  156. package/src/plugins/GlobalStatePanel/style.module.scss.d.ts +0 -5
  157. package/src/plugins/History/index.tsx +0 -110
  158. package/src/plugins/OutlineTree/components/TreeView/context.ts +0 -43
  159. package/src/plugins/OutlineTree/components/TreeView/dataStruct.ts +0 -58
  160. package/src/plugins/OutlineTree/components/TreeView/index.tsx +0 -376
  161. package/src/plugins/OutlineTree/components/TreeView/style.module.scss +0 -93
  162. package/src/plugins/OutlineTree/components/TreeView/style.module.scss.d.ts +0 -16
  163. package/src/plugins/OutlineTree/components/TreeView/treeNode.tsx +0 -271
  164. package/src/plugins/OutlineTree/index.tsx +0 -39
  165. package/src/plugins/OutlineTree/localize/en_US/index.ts +0 -3
  166. package/src/plugins/OutlineTree/localize/index.ts +0 -3
  167. package/src/plugins/OutlineTree/localize/zh_CN/index.ts +0 -3
  168. package/src/plugins/OutlineTree/util.tsx +0 -302
  169. package/src/plugins/PropertyPanel/index.tsx +0 -63
  170. package/src/plugins/PropertyPanel/style.module.scss +0 -12
  171. package/src/plugins/PropertyPanel/style.module.scss.d.ts +0 -10
  172. package/src/plugins/PropertyPanel/utils.ts +0 -13
  173. package/src/plugins/RightPanel/index.tsx +0 -30
  174. package/src/plugins/RightPanel/style.module.scss +0 -16
  175. package/src/plugins/RightPanel/style.module.scss.d.ts +0 -10
  176. package/src/plugins/RightPanel/view.tsx +0 -177
  177. package/src/plugins/VisualPanel/index.tsx +0 -185
  178. package/src/plugins/VisualPanel/style.module.scss +0 -17
  179. package/src/plugins/VisualPanelPlus/index.tsx +0 -103
  180. package/src/plugins/VisualPanelPlus/style.module.scss +0 -20
  181. package/src/plugins/VisualPanelPlus/style.module.scss.d.ts +0 -10
  182. package/src/plugins/index.tsx +0 -26
  183. package/src/stories/Button.jsx +0 -50
  184. package/src/stories/Button.stories.jsx +0 -40
  185. package/src/stories/Introduction.stories.mdx +0 -194
  186. package/src/stories/assets/code-brackets.svg +0 -1
  187. package/src/stories/assets/colors.svg +0 -1
  188. package/src/stories/assets/comments.svg +0 -1
  189. package/src/stories/assets/direction.svg +0 -1
  190. package/src/stories/assets/flow.svg +0 -1
  191. package/src/stories/assets/plugin.svg +0 -1
  192. package/src/stories/assets/repo.svg +0 -1
  193. package/src/stories/assets/stackalt.svg +0 -1
  194. package/src/stories/button.css +0 -30
  195. package/src/stories/plugins/CSSEditor.stories.tsx +0 -75
  196. package/src/stories/plugins/VisualPanelPlus.stories.tsx +0 -74
  197. package/src/style.d.ts +0 -2
  198. package/src/typing.d.ts +0 -9
  199. package/src/utils/css.ts +0 -88
  200. package/src/utils/defaultEngineConfig.tsx +0 -55
  201. package/src/utils/index.ts +0 -12
  202. package/src/utils/logger.ts +0 -4
  203. package/src/vite-env.d.ts +0 -1
  204. package/tsconfig.json +0 -32
@@ -1,93 +0,0 @@
1
- import React, { Ref } from 'react';
2
- import { CMaterialPropsType, getMTitleTip } from '@chamn/model';
3
- import { CForm } from './components/Form';
4
- import { isSpecialMaterialPropType } from '@chamn/model';
5
- import { getMTitle } from '@chamn/model/src/types/material';
6
- import { SetterSwitcher } from './components/SetterSwitcher';
7
- import { getSetterList } from './utils';
8
- import styles from './style.module.scss';
9
- import { ConfigProvider } from 'antd';
10
- import { CCustomSchemaFormContext } from './context';
11
- import { CPluginCtx } from '../../core/pluginManager';
12
-
13
- export type CustomSchemaFormInstance = CForm;
14
-
15
- export type CustomSchemaFormProps = {
16
- pluginCtx?: CPluginCtx;
17
- initialValue: Record<string, any>;
18
- properties: CMaterialPropsType<any>;
19
- onValueChange?: (val: any) => void;
20
- onSetterChange: (keyPaths: string[], setterName: string) => void;
21
- defaultSetterConfig: Record<string, { name: string; setter: string }>;
22
- };
23
-
24
- const CustomSchemaFormCore = (props: CustomSchemaFormProps, ref: Ref<CustomSchemaFormInstance | CForm>) => {
25
- const {
26
- properties: originProperties,
27
- initialValue,
28
- onValueChange,
29
- onSetterChange,
30
- defaultSetterConfig,
31
- pluginCtx,
32
- } = props;
33
- const properties: CMaterialPropsType = originProperties;
34
- return (
35
- <CCustomSchemaFormContext.Provider
36
- value={{
37
- defaultSetterConfig,
38
- onSetterChange,
39
- formRef: ref,
40
- pluginCtx: pluginCtx,
41
- }}
42
- >
43
- <ConfigProvider
44
- theme={{
45
- token: {
46
- borderRadius: 4,
47
- },
48
- }}
49
- >
50
- <div
51
- className={styles.CFromRenderBox}
52
- style={{
53
- overflow: 'auto',
54
- height: '100%',
55
- }}
56
- >
57
- <CForm
58
- ref={ref as any}
59
- name="root-form"
60
- initialValue={initialValue}
61
- onValueChange={(val) => {
62
- onValueChange?.(val);
63
- }}
64
- >
65
- {properties.map((property) => {
66
- if (isSpecialMaterialPropType(property)) {
67
- property.content;
68
- } else {
69
- const title = getMTitle(property.title);
70
- const tip = getMTitleTip(property.title);
71
- const setterList = getSetterList(property.setters);
72
- const keyPaths = [property.name];
73
- return (
74
- <SetterSwitcher
75
- key={property.name}
76
- condition={property.condition}
77
- keyPaths={keyPaths}
78
- setters={setterList}
79
- label={title}
80
- name={property.name || ''}
81
- tips={tip}
82
- />
83
- );
84
- }
85
- })}
86
- </CForm>
87
- </div>
88
- </ConfigProvider>
89
- </CCustomSchemaFormContext.Provider>
90
- );
91
- };
92
-
93
- export const CustomSchemaForm = React.forwardRef(CustomSchemaFormCore);
@@ -1,15 +0,0 @@
1
- .CFromRenderBox {
2
- :global {
3
- .ant-collapse .ant-collapse-content > .ant-collapse-content-box {
4
- padding-right: 5px;
5
- }
6
-
7
- .ant-collapse > .ant-collapse-item:last-child > .ant-collapse-header {
8
- padding: 5px 5px 5px 10px;
9
- align-items: center;
10
- .ant-collapse-expand-icon {
11
- padding-inline-end: 4px;
12
- }
13
- }
14
- }
15
- }
@@ -1,11 +0,0 @@
1
- import globalClassNames from '../../style.d';
2
- declare const classNames: typeof globalClassNames & {
3
- readonly CFromRenderBox: 'CFromRenderBox';
4
- readonly 'ant-collapse': 'ant-collapse';
5
- readonly 'ant-collapse-content': 'ant-collapse-content';
6
- readonly 'ant-collapse-content-box': 'ant-collapse-content-box';
7
- readonly 'ant-collapse-item': 'ant-collapse-item';
8
- readonly 'ant-collapse-header': 'ant-collapse-header';
9
- readonly 'ant-collapse-expand-icon': 'ant-collapse-expand-icon';
10
- };
11
- export = classNames;
@@ -1,13 +0,0 @@
1
- import { SetterBasicType, SetterObjType, SetterType } from '@chamn/model';
2
-
3
- export const getSetterList = <T extends SetterBasicType = ''>(setters: SetterType<T>[] = []): SetterObjType<T>[] => {
4
- return setters.map((setter) => {
5
- if (typeof setter === 'string') {
6
- return {
7
- componentName: setter as any,
8
- };
9
- } else {
10
- return setter;
11
- }
12
- });
13
- };
@@ -1,81 +0,0 @@
1
- import { useEffect } from 'react';
2
- import * as monaco from 'monaco-editor';
3
-
4
- import { useRef } from 'react';
5
- import * as monacoEditor from 'monaco-editor/esm/vs/editor/editor.api';
6
-
7
- export type MonacoEditorInstance = monacoEditor.editor.IStandaloneCodeEditor;
8
-
9
- export type MonacoEditorProps = {
10
- beforeMount?: (monaco: typeof monacoEditor) => void;
11
- onDidMount?: (editor: MonacoEditorInstance) => void;
12
- options?: monaco.editor.IStandaloneEditorConstructionOptions;
13
- override?: monaco.editor.IEditorOverrideServices;
14
- onChange?: (val: string, e: monaco.editor.IModelContentChangedEvent) => void;
15
- onDidChangeMarkers?: (markers: monaco.editor.IMarker[]) => void;
16
- initialValue?: string;
17
- language?: 'json' | 'javascript' | 'typescript';
18
- };
19
-
20
- export const MonacoEditor = (props: MonacoEditorProps) => {
21
- const editorDomRef = useRef<HTMLDivElement>(null);
22
- const onChangeRef = useRef<MonacoEditorProps['onChange'] | undefined>();
23
- onChangeRef.current = props.onChange;
24
- const onDidChangeMarkersRef = useRef<MonacoEditorProps['onDidChangeMarkers'] | undefined>();
25
- onDidChangeMarkersRef.current = props.onDidChangeMarkers;
26
- const editorInstance = useRef<MonacoEditorInstance | null>(null);
27
-
28
- useEffect(() => {
29
- if (!editorDomRef.current) {
30
- return;
31
- }
32
- props.beforeMount?.(monaco);
33
- const editor = monaco.editor.create(
34
- editorDomRef.current,
35
- {
36
- ...(props.options || {}),
37
- value: props.initialValue || props.options?.value,
38
- language: props.language || props.options?.language,
39
- },
40
- { ...(props.override || {}) }
41
- );
42
-
43
- editorInstance.current = editor;
44
- props.onDidMount?.(editor);
45
- const subscription = editor?.onDidChangeModelContent((event) => {
46
- if (!event.isFlush) {
47
- onChangeRef.current?.(editor.getValue(), event);
48
- }
49
- });
50
-
51
- monaco.editor.onDidChangeMarkers((uris) => {
52
- const editorModel = editor.getModel();
53
- if (!editorModel) {
54
- return;
55
- }
56
- const editorUri = editorModel.uri;
57
- const changeUri = uris.find((el) => el.path === editorUri.path);
58
- if (changeUri) {
59
- const res = monaco.editor.getModelMarkers({
60
- resource: editorUri,
61
- });
62
- onDidChangeMarkersRef.current?.(res);
63
- }
64
- });
65
-
66
- () => {
67
- editor.dispose();
68
- subscription?.dispose();
69
- };
70
- }, []);
71
-
72
- return (
73
- <div
74
- style={{
75
- width: '100%',
76
- height: '100%',
77
- }}
78
- ref={editorDomRef}
79
- ></div>
80
- );
81
- };
@@ -1,329 +0,0 @@
1
- import React from 'react';
2
- import { Resizable, ResizeCallback } from 're-resizable';
3
- import styles from './style.module.scss';
4
- import { Button } from 'antd';
5
- import { CloseOutlined, DoubleRightOutlined, PushpinOutlined } from '@ant-design/icons';
6
- import clsx from 'clsx';
7
- import mitt, { Emitter } from 'mitt';
8
- import { waitReactUpdate } from '../../utils';
9
-
10
- export interface PluginContext {
11
- openPanel: () => void;
12
- closePanel: () => void;
13
- getPlugin: (pluginName: string) => any;
14
- emitter: Emitter<any>;
15
- }
16
-
17
- type PanelItem = {
18
- name: string;
19
- title: string | React.ReactNode;
20
- icon: React.ReactNode;
21
- render: React.ReactNode;
22
- };
23
-
24
- type WorkbenchStateType = {
25
- leftBoxVisible: boolean;
26
- leftBoxSize: {
27
- width: number;
28
- height: number | string;
29
- };
30
- leftBoxFixed: boolean;
31
- rightBoxSize: {
32
- width: number;
33
- height: number | string;
34
- };
35
- rightBoxVisible: boolean;
36
- currentActiveLeftPanel: string;
37
- leftPanels: PanelItem[];
38
- bodyView: React.ReactNode | null;
39
- rightView: React.ReactNode | null;
40
- topToolBarView: React.ReactNode | null;
41
- };
42
-
43
- export type WorkbenchPropsType = {
44
- emitter: Emitter<any>;
45
- };
46
-
47
- export class Workbench extends React.Component<WorkbenchPropsType, WorkbenchStateType> {
48
- emitter: Emitter<any>;
49
- leftPanelContentRef: React.RefObject<HTMLDivElement>;
50
- constructor(props: WorkbenchPropsType) {
51
- super(props);
52
- this.emitter = props.emitter || mitt();
53
- this.leftPanelContentRef = React.createRef<HTMLDivElement>();
54
- this.state = {
55
- leftBoxVisible: true,
56
- leftBoxSize: {
57
- width: 300,
58
- height: '100%',
59
- },
60
- leftBoxFixed: true,
61
- rightBoxVisible: true,
62
- rightBoxSize: {
63
- width: 350,
64
- height: '100%',
65
- },
66
- currentActiveLeftPanel: 'OutlineTree',
67
- leftPanels: [],
68
- bodyView: null,
69
- rightView: null,
70
- topToolBarView: null,
71
- };
72
- }
73
-
74
- addLeftPanel = (panel: PanelItem) => {
75
- this.state.leftPanels.push(panel);
76
- this.setState({
77
- leftPanels: [...this.state.leftPanels],
78
- });
79
- };
80
-
81
- openLeftPanel = async (currentActiveLeftPanel?: string) => {
82
- const newActive = currentActiveLeftPanel || this.state.currentActiveLeftPanel;
83
- this.setState({
84
- leftBoxVisible: true,
85
- leftBoxSize: {
86
- width: 350,
87
- height: '100%',
88
- },
89
- currentActiveLeftPanel: newActive,
90
- });
91
-
92
- await waitReactUpdate();
93
- this.emitter.emit('leftPanelVisible', {
94
- visible: true,
95
- panelName: newActive,
96
- });
97
- };
98
-
99
- closeLeftPanel = async () => {
100
- this.setState({
101
- leftBoxVisible: false,
102
- leftBoxSize: {
103
- width: 0,
104
- height: '100%',
105
- },
106
- });
107
- await waitReactUpdate();
108
- this.emitter.emit('leftPanelVisible', {
109
- visible: false,
110
- panelName: this.state.currentActiveLeftPanel,
111
- });
112
- };
113
-
114
- toggleLeftPanel = () => {
115
- const { leftBoxVisible } = this.state;
116
- const newVisible = !leftBoxVisible;
117
- if (newVisible) {
118
- this.openLeftPanel();
119
- } else {
120
- this.closeLeftPanel();
121
- }
122
- };
123
-
124
- onPluginIconClick = (panel: PanelItem) => {
125
- const { currentActiveLeftPanel } = this.state;
126
- if (currentActiveLeftPanel === panel.name && this.state.leftBoxVisible) {
127
- this.closeLeftPanel();
128
- } else {
129
- this.openLeftPanel(panel.name);
130
- }
131
- };
132
-
133
- openRightPanel = () => {
134
- const { rightBoxSize } = this.state;
135
- this.setState({
136
- rightBoxVisible: true,
137
- rightBoxSize: {
138
- width: 400,
139
- height: rightBoxSize.height,
140
- },
141
- });
142
- };
143
-
144
- closeRightPanel = () => {
145
- const { rightBoxSize } = this.state;
146
- this.setState({
147
- rightBoxVisible: false,
148
- rightBoxSize: {
149
- width: 0,
150
- height: rightBoxSize.height,
151
- },
152
- });
153
- };
154
-
155
- replaceBodyView = (newView: React.ReactNode) => {
156
- this.setState({
157
- bodyView: newView,
158
- });
159
- };
160
-
161
- replaceRightView = (newView: React.ReactNode) => {
162
- this.setState({
163
- rightView: newView,
164
- });
165
- };
166
-
167
- replaceTopBarView = (newView: React.ReactNode) => {
168
- this.setState({
169
- topToolBarView: newView,
170
- });
171
- };
172
-
173
- toggleRightPanel = () => {
174
- const { rightBoxVisible, rightBoxSize } = this.state;
175
- const newVisible = !rightBoxVisible;
176
- this.setState({
177
- rightBoxVisible: newVisible,
178
- rightBoxSize: {
179
- width: newVisible ? 400 : 0,
180
- height: rightBoxSize.height,
181
- },
182
- });
183
- };
184
-
185
- onLeftBoxResizeStop: ResizeCallback = (_e, _direction, _ref, d) => {
186
- const newW = this.state.leftBoxSize.width + d.width;
187
- this.setState({
188
- leftBoxSize: {
189
- width: newW,
190
- height: this.state.leftBoxSize.height,
191
- },
192
- });
193
- };
194
-
195
- onGlobalClick = (e: MouseEvent) => {
196
- if (e.target && this.leftPanelContentRef.current?.contains(e.target as any)) {
197
- return;
198
- }
199
-
200
- if (!this.state.leftBoxFixed && this.state.leftBoxVisible) {
201
- this.closeLeftPanel();
202
- }
203
- };
204
-
205
- componentDidMount() {
206
- document.addEventListener('click', this.onGlobalClick);
207
- }
208
-
209
- render() {
210
- const {
211
- leftBoxVisible,
212
- leftBoxSize,
213
- leftBoxFixed,
214
- rightBoxSize,
215
- rightBoxVisible,
216
- leftPanels,
217
- currentActiveLeftPanel,
218
- bodyView,
219
- rightView,
220
- topToolBarView,
221
- } = this.state;
222
- const leftBoContentStyle: React.CSSProperties = {};
223
- if (!leftBoxFixed) {
224
- leftBoContentStyle.position = 'absolute';
225
- leftBoContentStyle.left = '50px';
226
- leftBoContentStyle.top = 0;
227
- }
228
-
229
- const currentActivePluginObj = leftPanels.find((el) => el.name === currentActiveLeftPanel);
230
-
231
- const CurrentPluginRenderView = currentActivePluginObj?.render || null;
232
- const { onPluginIconClick, toggleRightPanel, toggleLeftPanel, onLeftBoxResizeStop } = this;
233
- return (
234
- <div className={styles.workbenchContainer}>
235
- <div className={styles.topToolBarBox}>
236
- <div className={styles.topToolBarView}>{topToolBarView}</div>
237
- </div>
238
- <div className={styles.bodyContent}>
239
- <div className={styles.leftBox} ref={this.leftPanelContentRef}>
240
- <div className={styles.pluginIconBar}>
241
- {leftPanels.map((pl) => {
242
- return (
243
- <div
244
- key={pl.name}
245
- onClick={() => onPluginIconClick(pl)}
246
- className={clsx([styles.pluginIconItem, currentActivePluginObj?.name === pl.name && styles.active])}
247
- >
248
- {pl.icon}
249
- </div>
250
- );
251
- })}
252
- </div>
253
- {leftBoxVisible && (
254
- <Resizable
255
- className={styles.pluginPanelBoxResizeBox}
256
- size={leftBoxSize}
257
- style={leftBoContentStyle}
258
- minWidth={300}
259
- maxWidth={600}
260
- enable={{
261
- right: leftBoxVisible,
262
- }}
263
- onResizeStop={onLeftBoxResizeStop}
264
- >
265
- <div className={styles.pluginHeader}>
266
- <span className={styles.pluginNameText}>
267
- {currentActivePluginObj?.title || currentActivePluginObj?.name}
268
- </span>
269
- <Button
270
- className={clsx([styles.fixedBtn])}
271
- type="text"
272
- size="small"
273
- onClick={() => {
274
- this.setState({
275
- leftBoxFixed: !this.state.leftBoxFixed,
276
- });
277
- }}
278
- >
279
- <PushpinOutlined className={clsx([leftBoxFixed && styles.active])} />
280
- </Button>
281
- <Button className={styles.closeBtn} type="text" size="small" onClick={toggleLeftPanel}>
282
- <CloseOutlined />
283
- </Button>
284
- </div>
285
- <div className={styles.pluginPanelBox}>{CurrentPluginRenderView}</div>
286
- </Resizable>
287
- )}
288
- </div>
289
- <div className={styles.centerBox}>
290
- {/* <div className={styles.subTopToolbarBox}></div> */}
291
- <div className={styles.canvasBox}>
292
- <div className={styles.scrollBox}>{bodyView}</div>
293
- </div>
294
- </div>
295
- <div className={styles.rightResizeBox}>
296
- <div className={styles.arrowCursor} onClick={toggleRightPanel}>
297
- <DoubleRightOutlined className={clsx([!rightBoxVisible && styles.active])} />
298
- </div>
299
- <div
300
- style={{
301
- display: rightBoxVisible ? 'block' : 'none',
302
- height: '100%',
303
- }}
304
- >
305
- <Resizable
306
- minWidth={400}
307
- maxWidth={600}
308
- enable={{
309
- left: rightBoxVisible,
310
- }}
311
- size={rightBoxSize}
312
- onResizeStop={(_e, _direction, _ref, d) => {
313
- this.setState({
314
- rightBoxSize: {
315
- width: this.state.rightBoxSize.width + d.width,
316
- height: this.state.rightBoxSize.height,
317
- },
318
- });
319
- }}
320
- >
321
- <div className={styles.rightBox}>{rightView}</div>
322
- </Resizable>
323
- </div>
324
- </div>
325
- </div>
326
- </div>
327
- );
328
- }
329
- }
@@ -1,159 +0,0 @@
1
- .workbenchContainer {
2
- width: 100%;
3
- height: 100%;
4
- display: flex;
5
- flex-direction: column;
6
-
7
- .topToolBarBox {
8
- height: 64px;
9
- width: 100%;
10
- border-bottom: 1px solid $borderColor;
11
- display: flex;
12
-
13
- .topToolBarView {
14
- flex: 1;
15
- }
16
- }
17
-
18
- .bodyContent {
19
- display: flex;
20
- width: 100%;
21
- flex: 1;
22
- overflow: hidden;
23
-
24
- .leftBox {
25
- position: relative;
26
- display: flex;
27
- background-color: #fff;
28
- z-index: 100;
29
- .pluginIconBar {
30
- width: 50px;
31
- height: 100%;
32
- border-right: 1px solid $borderColor;
33
-
34
- .pluginIconItem {
35
- position: relative;
36
- cursor: pointer;
37
- width: 50px;
38
- height: 50px;
39
- display: flex;
40
- align-items: center;
41
- justify-content: center;
42
- transition: all 0.1s;
43
-
44
- &.active ::before,
45
- &:hover ::before {
46
- transition: all 0.1s;
47
- display: block;
48
- content: '';
49
- width: 2px;
50
- height: 100%;
51
- position: absolute;
52
- left: 0;
53
- top: 0;
54
- }
55
-
56
- &.active ::before {
57
- border-left: 4px solid $baseColor !important;
58
- }
59
-
60
- &:hover ::before {
61
- border-left: 4px solid $hoverColor;
62
- }
63
- }
64
- }
65
-
66
- .pluginPanelBoxResizeBox {
67
- display: flex;
68
- flex-direction: column;
69
- background-color: #fff;
70
- z-index: 100;
71
- border-right: 1px solid $borderColor;
72
-
73
- .pluginHeader {
74
- display: flex;
75
- color: $fontColor;
76
- height: 30px;
77
- margin: 10px;
78
- overflow: hidden;
79
- align-items: center;
80
- .pluginNameText {
81
- font-size: 16px;
82
- font-weight: 700;
83
- margin-right: auto;
84
- flex-wrap: nowrap;
85
- word-break: keep-all;
86
- }
87
- .closeBtn,
88
- .fixedBtn {
89
- color: $fontColor;
90
- }
91
-
92
- .fixedBtn {
93
- > * {
94
- transition: all 0.1s;
95
- }
96
- > .active {
97
- transform: rotate(-45deg);
98
- }
99
- }
100
- }
101
- }
102
- .pluginPanelBox {
103
- width: 100%;
104
- flex: 1;
105
- background-color: ghostwhite;
106
- overflow: hidden;
107
- }
108
- }
109
-
110
- .rightResizeBox {
111
- position: relative;
112
- .arrowCursor {
113
- cursor: pointer;
114
- position: absolute;
115
- left: -18px;
116
- top: 50%;
117
- transform: translateY(-50%);
118
- z-index: 2;
119
- background-color: #fff;
120
- padding: 10px 3px;
121
- border-radius: 4px 0 0 4px;
122
- font-size: 12px;
123
- > .active {
124
- transform: rotate(-180deg);
125
- }
126
- }
127
- .rightBox {
128
- position: relative;
129
- width: 100%;
130
- height: 100%;
131
- border-left: 1px $borderColor solid;
132
- }
133
- }
134
-
135
- .centerBox {
136
- display: flex;
137
- flex-direction: column;
138
- flex: 1;
139
- overflow: hidden;
140
- .subTopToolbarBox {
141
- width: 100%;
142
- height: 50px;
143
- background-color: #fff;
144
- }
145
- .canvasBox {
146
- width: 100%;
147
- flex: 1;
148
- overflow: hidden;
149
- padding: 20px 30px;
150
- background-color: $baseBackgroundColor;
151
- .scrollBox {
152
- width: 100%;
153
- height: 100%;
154
- box-shadow: 0 1px 4px 0 rgb(31 50 88 / 13%);
155
- }
156
- }
157
- }
158
- }
159
- }