@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,50 +0,0 @@
1
- import React from 'react';
2
- import { SnippetsType } from '@chamn/model';
3
- import { Collapse } from 'antd';
4
- import { DragComponentItem } from '../DragItem';
5
- import styles from './style.module.scss';
6
- const { Panel } = Collapse;
7
-
8
- export type ListViewProps = {
9
- dataSource: {
10
- name: string;
11
- list: SnippetsType[];
12
- }[];
13
- };
14
- export const ListView = (props: ListViewProps) => {
15
- const { dataSource } = props;
16
- const defaultActiveKey = dataSource.map((el) => el.name || '');
17
- if (!dataSource.length) {
18
- return null;
19
- }
20
- return (
21
- <div className={styles.ListBox}>
22
- <Collapse style={{ width: '100%' }} defaultActiveKey={defaultActiveKey}>
23
- {dataSource.map((el) => {
24
- const category = el.name || '';
25
- const contentView = (
26
- <div className={styles.collapsePanel}>
27
- {el.list.map((it) => {
28
- return (
29
- <DragComponentItem
30
- id={it.id!}
31
- key={it.id!}
32
- name={it.title}
33
- icon={it.snapshot || it.snapshotText}
34
- iconText={it.snapshotText}
35
- description={it.description || ''}
36
- />
37
- );
38
- })}
39
- </div>
40
- );
41
- return (
42
- <Panel header={category} key={category}>
43
- {contentView}
44
- </Panel>
45
- );
46
- })}
47
- </Collapse>
48
- </div>
49
- );
50
- };
@@ -1,27 +0,0 @@
1
- .ListBox {
2
- display: flex;
3
- flex-wrap: wrap;
4
- :global {
5
- .ant-collapse .ant-collapse-content > .ant-collapse-content-box {
6
- padding: 0;
7
- }
8
- .ant-collapse {
9
- border: none;
10
- background-color: white;
11
- }
12
- .ant-collapse-header {
13
- padding: 10px 16px !important;
14
- }
15
- .ant-collapse-expand-icon {
16
- padding-inline-end: 0 !important;
17
- }
18
- .ant-collapse-item {
19
- border-color: $borderColor;
20
- }
21
- }
22
- }
23
-
24
- .collapsePanel {
25
- display: flex;
26
- flex-wrap: wrap;
27
- }
@@ -1,12 +0,0 @@
1
- import globalClassNames from '../../../../style.d';
2
- declare const classNames: typeof globalClassNames & {
3
- readonly ListBox: 'ListBox';
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-header': 'ant-collapse-header';
8
- readonly 'ant-collapse-expand-icon': 'ant-collapse-expand-icon';
9
- readonly 'ant-collapse-item': 'ant-collapse-item';
10
- readonly collapsePanel: 'collapsePanel';
11
- };
12
- export = classNames;
@@ -1,184 +0,0 @@
1
- import React from 'react';
2
- import { AppstoreAddOutlined } from '@ant-design/icons';
3
- import { LayoutDragAndDropExtraDataType, Sensor, SensorEventObjType } from '@chamn/layout';
4
- import { Tabs } from 'antd';
5
- import { CPlugin, CPluginCtx } from '../../core/pluginManager';
6
- import { DesignerExports } from '../Designer';
7
- import localize from './localize';
8
- import styles from './style.module.scss';
9
- import { withTranslation, WithTranslation } from 'react-i18next';
10
- import { ListView } from './components/ListView';
11
- import { getTargetMNodeKeyVal } from './util';
12
- import { DRAG_ITEM_KEY } from './components/DragItem';
13
- import { SnippetsCollection } from '@chamn/model';
14
- import { capitalize } from 'lodash-es';
15
-
16
- interface ComponentLibViewProps extends WithTranslation {
17
- pluginCtx: CPluginCtx;
18
- }
19
-
20
- export const PLUGIN_NAME = 'ComponentLib';
21
- const i18nNamespace = `plugin:${PLUGIN_NAME}`;
22
-
23
- const TabTitle = ({ children }: { children: any }) => {
24
- return <div className={styles.tabTitle}>{children}</div>;
25
- };
26
-
27
- type ComponentLibViewState = {
28
- componentsList: SnippetsCollection;
29
- };
30
- class ComponentLibView extends React.Component<ComponentLibViewProps, ComponentLibViewState> {
31
- containerRef: React.RefObject<HTMLDivElement>;
32
- disposeList: (() => void)[] = [];
33
- constructor(props: ComponentLibViewProps) {
34
- super(props);
35
- this.containerRef = React.createRef<HTMLDivElement>();
36
- this.state = {
37
- componentsList: [],
38
- };
39
- }
40
-
41
- leftPanelVisibleCb = async ({ visible, panelName }: { visible: boolean; panelName: string }) => {
42
- await this.props.pluginCtx.pluginManager.onPluginReadyOk('Designer');
43
- if (panelName === PLUGIN_NAME && visible) {
44
- this.registerDragEvent();
45
- }
46
- };
47
-
48
- async componentDidMount() {
49
- const { pluginCtx } = this.props;
50
- const { pageModel, i18n } = pluginCtx;
51
- const { materialsModel } = pageModel;
52
- await this.props.pluginCtx.pluginManager.onPluginReadyOk('Designer');
53
- this.registerDragEvent();
54
-
55
- Object.keys(localize).forEach((lng) => {
56
- i18n.addResourceBundle(lng, i18nNamespace, localize[lng], true, true);
57
- });
58
-
59
- i18n.update();
60
- const allSnippets = materialsModel.getAllSnippets();
61
- this.setState({
62
- componentsList: allSnippets,
63
- });
64
- }
65
-
66
- componentWillUnmount(): void {
67
- this.disposeList.map((el) => el());
68
- }
69
-
70
- registerDragEvent = async () => {
71
- const { containerRef } = this;
72
- const { pluginCtx } = this.props;
73
- const designerHandle = await pluginCtx.pluginManager.get('Designer');
74
-
75
- if (!designerHandle) {
76
- return;
77
- }
78
- if (!containerRef.current) {
79
- return;
80
- }
81
- const pageModel = pluginCtx.pageModel;
82
- const designerExports: DesignerExports = designerHandle.exports;
83
- const dnd = designerExports.getDnd();
84
- const boxSensor = new Sensor({
85
- name: 'ComponentListBox',
86
- container: containerRef.current,
87
- });
88
-
89
- boxSensor.setCanDrag((eventObj: SensorEventObjType) => {
90
- const targetDom = eventObj.event.target;
91
- if (!targetDom) {
92
- return;
93
- }
94
- const targetNodeId = getTargetMNodeKeyVal(targetDom as HTMLElement, DRAG_ITEM_KEY);
95
-
96
- if (!targetNodeId) {
97
- return;
98
- }
99
-
100
- const meta = pageModel.materialsModel.findSnippetById(targetNodeId);
101
- if (!meta) {
102
- return;
103
- }
104
- const newNode = pageModel?.createNode(meta.schema);
105
-
106
- this.props.pluginCtx.pluginManager.get('Designer').then((designerHandle) => {
107
- const designerExports: DesignerExports = designerHandle?.exports;
108
- designerExports.selectNode('');
109
- });
110
-
111
- return {
112
- ...eventObj,
113
- extraData: {
114
- type: 'NEW_ADD',
115
- startNode: newNode,
116
- } as LayoutDragAndDropExtraDataType,
117
- };
118
- });
119
- dnd.registerSensor(boxSensor);
120
-
121
- const dragStart = () => {
122
- const { getWorkbench } = this.props.pluginCtx;
123
- const workbench = getWorkbench();
124
- if (!workbench.state.leftBoxFixed) {
125
- workbench.closeLeftPanel();
126
- }
127
- };
128
-
129
- this.disposeList.push(() => {
130
- dnd.emitter.off('dragStart', dragStart);
131
- });
132
- dnd.emitter.on('dragStart', dragStart);
133
- };
134
-
135
- render(): React.ReactNode {
136
- const { componentsList } = this.state;
137
- const items = componentsList.map((el) => {
138
- return {
139
- label: <TabTitle>{capitalize(el.name)}</TabTitle>,
140
- key: el.name,
141
- children: <ListView dataSource={el.list} />,
142
- };
143
- });
144
- return (
145
- <div ref={this.containerRef} className={styles.container}>
146
- <Tabs
147
- defaultActiveKey="BaseComponent"
148
- items={items}
149
- style={{
150
- flex: 1,
151
- }}
152
- />
153
- </div>
154
- );
155
- }
156
- }
157
-
158
- export const ComponentLibPlugin: CPlugin = {
159
- name: PLUGIN_NAME,
160
- async init(ctx) {
161
- const ComponentLibViewWithLocalize = withTranslation(i18nNamespace)(ComponentLibView);
162
- const Title = withTranslation(i18nNamespace)(({ t }) => {
163
- return <>{t('pluginName')}</>;
164
- });
165
- const workbench = ctx.getWorkbench();
166
- workbench.addLeftPanel({
167
- title: <Title />,
168
- name: 'ComponentLib',
169
- icon: <AppstoreAddOutlined />,
170
- render: <ComponentLibViewWithLocalize pluginCtx={ctx} />,
171
- });
172
- },
173
- async destroy(ctx) {
174
- console.log('destroy', ctx);
175
- },
176
- exports: (ctx) => {
177
- return {};
178
- },
179
- meta: {
180
- engine: {
181
- version: '1.0.0',
182
- },
183
- },
184
- };
@@ -1,3 +0,0 @@
1
- export const en_US: Record<string, any> = {
2
- pluginName: 'Component Store',
3
- };
@@ -1,3 +0,0 @@
1
- import { zh_CN } from './zh_CN';
2
- import { en_US } from './en_US';
3
- export default { zh_CN, en_US } as Record<string, any>;
@@ -1,3 +0,0 @@
1
- export const zh_CN: Record<string, any> = {
2
- pluginName: '组件库',
3
- };
@@ -1,31 +0,0 @@
1
- .container {
2
- width: 100%;
3
- height: 100%;
4
- overflow: hidden;
5
- background-color: white;
6
- display: flex;
7
-
8
- :global {
9
- .ant-tabs .ant-tabs-tab + .ant-tabs-tab {
10
- margin-left: 12px;
11
- }
12
-
13
- .ant-tabs-content.ant-tabs-content-top {
14
- height: 100%;
15
- overflow: auto;
16
- }
17
- .ant-tabs-tab {
18
- padding: 6px 0;
19
- }
20
- .ant-tabs-nav {
21
- margin-bottom: 0;
22
- }
23
- }
24
- }
25
-
26
- .tabTitle {
27
- padding: 0 10px;
28
- font-size: 12px;
29
- font-weight: 400;
30
- text-rendering: optimizeLegibility;
31
- }
@@ -1,11 +0,0 @@
1
- import globalClassNames from '../../style.d';
2
- declare const classNames: typeof globalClassNames & {
3
- readonly container: 'container';
4
- readonly 'ant-tabs': 'ant-tabs';
5
- readonly 'ant-tabs-tab': 'ant-tabs-tab';
6
- readonly 'ant-tabs-content': 'ant-tabs-content';
7
- readonly 'ant-tabs-content-top': 'ant-tabs-content-top';
8
- readonly 'ant-tabs-nav': 'ant-tabs-nav';
9
- readonly tabTitle: 'tabTitle';
10
- };
11
- export = classNames;
@@ -1,14 +0,0 @@
1
- export const getTargetMNodeKeyVal = (
2
- dom: HTMLElement | null,
3
- key: string
4
- ): null | string => {
5
- if (!dom) {
6
- return null;
7
- }
8
- const val = dom.getAttribute(key);
9
- if (!val) {
10
- return getTargetMNodeKeyVal(dom.parentElement, key);
11
- } else {
12
- return val;
13
- }
14
- };
@@ -1,59 +0,0 @@
1
- import { useEffect, useRef } from 'react';
2
- import { CNode, CRootNode } from '@chamn/model';
3
- import { CPluginCtx } from '../../core/pluginManager';
4
- import { CRightPanelItem } from '../RightPanel/view';
5
- import { MonacoEditor, MonacoEditorInstance } from '../../component/MonacoEditor';
6
-
7
- export type ComponentStatePanelProps = {
8
- node: CNode | CRootNode;
9
- pluginCtx: CPluginCtx;
10
- };
11
-
12
- export const ComponentStatePanel = (props: ComponentStatePanelProps) => {
13
- const { node } = props;
14
- const nodeState = node.value.state || {};
15
- const editorRef = useRef<MonacoEditorInstance | null>(null);
16
- useEffect(() => {
17
- const currentState = node.value.state || {};
18
- editorRef?.current?.setValue(JSON.stringify(currentState, null, 2));
19
- }, [node]);
20
-
21
- const onValueChange = (newValStr: string) => {
22
- try {
23
- const newVal = JSON.parse(newValStr);
24
- node.value.state = newVal;
25
- node.updateValue();
26
- } catch (e) {
27
- console.warn(e);
28
- }
29
- };
30
-
31
- return (
32
- <>
33
- <MonacoEditor
34
- initialValue={JSON.stringify(nodeState, null, 2)}
35
- language={'json'}
36
- options={{
37
- automaticLayout: true,
38
- // lineDecorationsWidth: 0,
39
- tabSize: 2,
40
- minimap: { enabled: false },
41
- quickSuggestions: false,
42
- // lineNumbers: 'off',
43
- suggestOnTriggerCharacters: false,
44
- folding: false,
45
- }}
46
- onDidMount={(editor) => {
47
- editorRef.current = editor;
48
- }}
49
- onChange={onValueChange}
50
- />
51
- </>
52
- );
53
- };
54
-
55
- export const ComponentStatePanelConfig: CRightPanelItem = {
56
- key: 'State',
57
- name: 'State',
58
- view: ({ node, pluginCtx }) => <ComponentStatePanel node={node} pluginCtx={pluginCtx} />,
59
- };
@@ -1,94 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { CopyOutlined, DeleteOutlined, EyeInvisibleOutlined } from '@ant-design/icons';
3
- import styles from './style.module.scss';
4
- import { CNode } from '@chamn/model';
5
- import clsx from 'clsx';
6
-
7
- export type DefaultSelectToolBarProps = {
8
- nodeList: CNode[];
9
- toSelectNode: (id: string) => void;
10
- toDelete: (id: string) => void;
11
- toCopy: (idd: string) => void;
12
- toHidden: (idd: string) => void;
13
- };
14
-
15
- const LayoutSelect = ({
16
- dataSource,
17
- children,
18
- onSelect,
19
- }: {
20
- dataSource: { key: string; label: string }[];
21
- children: React.ReactNode;
22
- onSelect: (key: string) => void;
23
- }) => {
24
- const [hover, setHover] = useState(false);
25
- return (
26
- <div className={styles.layoutSelectBox}>
27
- <div className={clsx([styles.hoverBox, hover && styles.hoverBoxActive])}>
28
- {dataSource.map((el) => {
29
- return (
30
- <div className={styles.hoverItem} key={el.key} onClick={() => onSelect(el.key)}>
31
- {el.label}
32
- </div>
33
- );
34
- })}
35
- </div>
36
- <div className={styles.placeholder} onMouseOver={() => setHover(true)} onMouseOut={() => setHover(false)}>
37
- {children}
38
- </div>
39
- </div>
40
- );
41
- };
42
-
43
- export const DefaultSelectToolBar = ({
44
- nodeList,
45
- toSelectNode,
46
- toDelete,
47
- toCopy,
48
- toHidden,
49
- }: DefaultSelectToolBarProps) => {
50
- const tempList = [...nodeList];
51
- const currentNode = tempList.shift();
52
- const parentNodeItems = tempList.map((el) => {
53
- const node = el;
54
- const nodeMeta = node.materialsModel.findByComponentName(node.value.componentName)?.value.title;
55
- const label = node.value.title || nodeMeta || node.value.componentName || '';
56
- return {
57
- key: el.id,
58
- label: label || 'Empty',
59
- };
60
- });
61
-
62
- const copyItem = (
63
- <div className={styles.item} onClick={() => toCopy(currentNode?.id || '')}>
64
- <CopyOutlined />
65
- </div>
66
- );
67
-
68
- const deleteItem = (
69
- <div className={styles.item} onClick={() => toDelete(currentNode?.id || '')}>
70
- <DeleteOutlined />
71
- </div>
72
- );
73
-
74
- const visibleItem = (
75
- <div className={styles.item} onClick={() => toHidden(currentNode?.id || '')}>
76
- <EyeInvisibleOutlined />
77
- </div>
78
- );
79
-
80
- const nodeLayout = (
81
- <LayoutSelect dataSource={parentNodeItems.reverse()} onSelect={toSelectNode}>
82
- <div>{currentNode?.value.title || currentNode?.material?.value.title || 'Empty'}</div>
83
- </LayoutSelect>
84
- );
85
-
86
- return (
87
- <div className={styles.toolBarBox}>
88
- {nodeLayout}
89
- {visibleItem}
90
- {copyItem}
91
- {deleteItem}
92
- </div>
93
- );
94
- };
@@ -1,59 +0,0 @@
1
- .toolBarBox {
2
- display: flex;
3
- margin-bottom: 3px;
4
- margin-right: -2px;
5
- pointer-events: all;
6
- float: right;
7
- }
8
-
9
- .item {
10
- background-color: $baseColor;
11
- color: white;
12
- padding: 2px 3px;
13
- font-size: 12px;
14
- overflow: hidden;
15
- margin-left: 1px;
16
- cursor: pointer;
17
- }
18
-
19
- .layoutSelectBox {
20
- position: relative;
21
- margin-right: 1px;
22
- height: 21px;
23
-
24
- .hoverBox {
25
- transition: all 0.3s;
26
- position: absolute;
27
- left: 0;
28
- top: 0;
29
- white-space: nowrap;
30
- opacity: 0;
31
- transform: translateY(-100%);
32
- pointer-events: none;
33
-
34
- &:hover,
35
- &.hoverBoxActive {
36
- opacity: 1;
37
- pointer-events: all;
38
- }
39
-
40
- .hoverItem {
41
- background-color: $baseColor;
42
- padding: 2px 3px;
43
- color: white;
44
- font-size: 12px;
45
- margin-bottom: 1px;
46
- cursor: pointer;
47
- }
48
- }
49
- .placeholder {
50
- overflow: hidden;
51
- text-overflow: ellipsis;
52
- white-space: nowrap;
53
- background-color: $baseColor;
54
- color: white;
55
- padding: 2px 5px;
56
- font-size: 12px;
57
- max-width: 100px;
58
- }
59
- }
@@ -1,11 +0,0 @@
1
- import globalClassNames from '../../../../style.d';
2
- declare const classNames: typeof globalClassNames & {
3
- readonly toolBarBox: 'toolBarBox';
4
- readonly item: 'item';
5
- readonly layoutSelectBox: 'layoutSelectBox';
6
- readonly hoverBox: 'hoverBox';
7
- readonly hoverBoxActive: 'hoverBoxActive';
8
- readonly hoverItem: 'hoverItem';
9
- readonly placeholder: 'placeholder';
10
- };
11
- export = classNames;
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import { CNode, CRootNode } from '@chamn/model';
3
-
4
- export const GhostView = ({ node }: { node: CNode | CRootNode }) => {
5
- return (
6
- <div
7
- style={{
8
- backgroundColor: 'rgba(100,100,100)',
9
- padding: '3px 10px 3px 15px',
10
- borderRadius: '2px',
11
- opacity: 0.9,
12
- color: 'rgba(220,220,220)',
13
- }}
14
- >
15
- {node.value.componentName}
16
- </div>
17
- );
18
- };
@@ -1 +0,0 @@
1
- export const PLUGIN_NAME = 'Designer';
@@ -1,61 +0,0 @@
1
- import React from 'react';
2
- import { DragAndDrop } from '@chamn/layout';
3
- import '@chamn/layout/dist/style.css';
4
- import { CPlugin } from '../../core/pluginManager';
5
- import { PLUGIN_NAME } from './config';
6
- import { Designer } from './view';
7
- import { AssetPackage, CPage, CPageDataType } from '@chamn/model';
8
- import { RenderInstance } from '@chamn/render';
9
-
10
- export const DesignerPlugin: CPlugin = (ctx) => {
11
- const designerRef = React.createRef<Designer>();
12
- return {
13
- name: PLUGIN_NAME,
14
- async init(ctx) {
15
- const workbench = ctx.getWorkbench();
16
- workbench.replaceBodyView(<Designer ref={designerRef} pluginCtx={ctx} />);
17
- },
18
- async destroy(ctx) {
19
- console.log('destroy', ctx);
20
- },
21
- exports: () => {
22
- return {
23
- getDnd: () => {
24
- return designerRef.current?.layoutRef.current?.dnd;
25
- },
26
- selectNode: (nodeId) => {
27
- designerRef.current?.layoutRef.current?.selectNode(nodeId);
28
- },
29
- updatePage: (page: CPageDataType | CPage) => {
30
- designerRef.current?.layoutRef.current?.designRenderRef?.current?.rerender(page);
31
- },
32
- reload: ({ assets } = {}) => {
33
- designerRef.current?.reloadRender({ assets });
34
- },
35
- getComponentInstances: (id: string) => {
36
- return designerRef.current?.layoutRef.current?.designRenderRef.current?.getInstancesById(id) || [];
37
- },
38
- getDynamicComponentInstances: (id: string) => {
39
- const map =
40
- designerRef.current?.layoutRef.current?.designRenderRef.current?.renderRef.current
41
- ?.dynamicComponentInstanceMap;
42
- return map?.get(id) || [];
43
- },
44
- } as DesignerExports;
45
- },
46
- meta: {
47
- engine: {
48
- version: '1.0.0',
49
- },
50
- },
51
- };
52
- };
53
-
54
- export type DesignerExports = {
55
- reload: (params?: { assets?: AssetPackage[] }) => void;
56
- getDnd: () => DragAndDrop;
57
- selectNode: (nodeId: string) => void;
58
- updatePage: (page: CPageDataType) => void;
59
- getComponentInstances: (id: string) => RenderInstance[];
60
- getDynamicComponentInstances: (id: string) => RenderInstance;
61
- };
@@ -1,3 +0,0 @@
1
- export const en_US: Record<string, any> = {
2
- pluginName: 'Component Store',
3
- };
@@ -1,3 +0,0 @@
1
- import { zh_CN } from './zh_CN';
2
- import { en_US } from './en_US';
3
- export default { zh_CN, en_US } as Record<string, any>;
@@ -1,3 +0,0 @@
1
- export const zh_CN: Record<string, any> = {
2
- pluginName: '组件库',
3
- };
@@ -1,10 +0,0 @@
1
- .hoverTips {
2
- display: inline-block;
3
- color: $baseColor;
4
- opacity: 0.9;
5
- font-size: 12px;
6
- margin-bottom: 2px;
7
- background-color: white;
8
- padding: 1px 3px;
9
- border-radius: 2px;
10
- }