@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.
- package/dist/component/CustomSchemaForm/components/Form/context.d.ts +2 -0
- package/dist/component/CustomSchemaForm/components/Form/index.d.ts +1 -0
- package/dist/component/CustomSchemaForm/components/SetterSwitcher/index.d.ts +2 -0
- package/dist/component/CustomSchemaForm/index.d.ts +3 -0
- package/dist/component/Workbench/index.d.ts +4 -0
- package/dist/core/pluginManager.d.ts +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +197 -0
- package/dist/index.js.map +1 -0
- package/dist/{index.es.js → index.mjs} +2995 -2944
- package/dist/index.mjs.map +1 -0
- package/dist/plugins/RightPanel/view.d.ts +4 -0
- package/package.json +12 -9
- package/.eslintignore +0 -1
- package/.eslintrc.js +0 -36
- package/.prettierrc.json +0 -7
- package/.storybook/main.js +0 -24
- package/.storybook/preview.js +0 -9
- package/CHANGELOG.md +0 -54
- package/__tests__/demo.test.ts +0 -3
- package/build.config.js +0 -88
- package/dist/index.cjs.js +0 -197
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.es.js.map +0 -1
- package/index.html +0 -16
- package/jest.config.js +0 -196
- package/public/Engine.module.scss.d.ts +0 -5
- package/public/_dev_/render.d.ts +0 -2
- package/public/component/CSSEditor/style.module.scss.d.ts +0 -6
- package/public/component/CSSPropertiesEditor/style.module.scss.d.ts +0 -15
- package/public/component/CSSPropertiesVariableBindEditor/style.module.scss.d.ts +0 -15
- package/public/component/CustomSchemaForm/components/Form/Field/style.module.scss.d.ts +0 -8
- package/public/component/CustomSchemaForm/components/SetterSwitcher/style.module.scss.d.ts +0 -7
- package/public/component/CustomSchemaForm/components/Setters/ArraySetter/style.module.scss.d.ts +0 -7
- package/public/component/CustomSchemaForm/components/Setters/CSSValueSetter/style.module.scss.d.ts +0 -6
- package/public/component/CustomSchemaForm/style.module.scss.d.ts +0 -11
- package/public/component/Workbench/style.module.scss.d.ts +0 -25
- package/public/plugins/AdvancePanel/style.module.scss.d.ts +0 -7
- package/public/plugins/ComponentLibrary/components/DragItem/style.module.scss.d.ts +0 -9
- package/public/plugins/ComponentLibrary/components/ListView/style.module.scss.d.ts +0 -12
- package/public/plugins/ComponentLibrary/style.module.scss.d.ts +0 -11
- package/public/plugins/Designer/components/DefaultSelectToolBar/style.module.scss.d.ts +0 -11
- package/public/plugins/Designer/style.module.scss.d.ts +0 -5
- package/public/plugins/GlobalStatePanel/style.module.scss.d.ts +0 -5
- package/public/plugins/OutlineTree/components/TreeView/style.module.scss.d.ts +0 -16
- package/public/plugins/PropertyPanel/style.module.scss.d.ts +0 -10
- package/public/plugins/RightPanel/style.module.scss.d.ts +0 -10
- package/public/plugins/VisualPanelPlus/style.module.scss.d.ts +0 -10
- package/public/render.umd.js +0 -42
- package/public/render.umd.js.map +0 -1
- package/src/Engine.module.scss +0 -10
- package/src/Engine.module.scss.d.ts +0 -5
- package/src/_dev_/index.css +0 -22
- package/src/_dev_/index.tsx +0 -5
- package/src/_dev_/page/Editor/index.tsx +0 -198
- package/src/_dev_/page/Editor/indexCustom.tsx +0 -274
- package/src/_dev_/page/Preview/index.tsx +0 -56
- package/src/_dev_/render.ts +0 -3
- package/src/_dev_/router.tsx +0 -14
- package/src/assets/react.svg +0 -4
- package/src/assets/styles/mixin.scss +0 -15
- package/src/component/CSSEditor/index.tsx +0 -247
- package/src/component/CSSEditor/style.module.scss +0 -22
- package/src/component/CSSEditor/style.module.scss.d.ts +0 -6
- package/src/component/CSSPropertiesEditor/cssProperties.ts +0 -1062
- package/src/component/CSSPropertiesEditor/index.tsx +0 -389
- package/src/component/CSSPropertiesEditor/style.module.scss +0 -46
- package/src/component/CSSPropertiesEditor/style.module.scss.d.ts +0 -15
- package/src/component/CSSPropertiesEditor/util.ts +0 -19
- package/src/component/CSSPropertiesVariableBindEditor/cssProperties.ts +0 -782
- package/src/component/CSSPropertiesVariableBindEditor/index.tsx +0 -366
- package/src/component/CSSPropertiesVariableBindEditor/style.module.scss +0 -48
- package/src/component/CSSPropertiesVariableBindEditor/style.module.scss.d.ts +0 -15
- package/src/component/CSSPropertiesVariableBindEditor/util.ts +0 -19
- package/src/component/ClassNameEditor/index.tsx +0 -91
- package/src/component/ClassNameEditor/style.module.scss +0 -0
- package/src/component/CustomSchemaForm/components/Form/Field/index.tsx +0 -81
- package/src/component/CustomSchemaForm/components/Form/Field/style.module.scss +0 -32
- package/src/component/CustomSchemaForm/components/Form/Field/style.module.scss.d.ts +0 -8
- package/src/component/CustomSchemaForm/components/Form/context.ts +0 -23
- package/src/component/CustomSchemaForm/components/Form/index.tsx +0 -71
- package/src/component/CustomSchemaForm/components/SetterSwitcher/index.tsx +0 -273
- package/src/component/CustomSchemaForm/components/SetterSwitcher/style.module.scss +0 -16
- package/src/component/CustomSchemaForm/components/SetterSwitcher/style.module.scss.d.ts +0 -7
- package/src/component/CustomSchemaForm/components/Setters/ArraySetter/ArrayItem.tsx +0 -55
- package/src/component/CustomSchemaForm/components/Setters/ArraySetter/SortItemOrderModal.tsx +0 -160
- package/src/component/CustomSchemaForm/components/Setters/ArraySetter/index.tsx +0 -129
- package/src/component/CustomSchemaForm/components/Setters/ArraySetter/style.module.scss +0 -22
- package/src/component/CustomSchemaForm/components/Setters/ArraySetter/style.module.scss.d.ts +0 -7
- package/src/component/CustomSchemaForm/components/Setters/BooleanSetter/index.tsx +0 -32
- package/src/component/CustomSchemaForm/components/Setters/CSSValueSetter/index.tsx +0 -78
- package/src/component/CustomSchemaForm/components/Setters/CSSValueSetter/style.module.scss +0 -7
- package/src/component/CustomSchemaForm/components/Setters/CSSValueSetter/style.module.scss.d.ts +0 -6
- package/src/component/CustomSchemaForm/components/Setters/ExpressionSetter/index.tsx +0 -47
- package/src/component/CustomSchemaForm/components/Setters/FunctionSetter/defaultDts.ts +0 -28
- package/src/component/CustomSchemaForm/components/Setters/FunctionSetter/index.tsx +0 -93
- package/src/component/CustomSchemaForm/components/Setters/JSONSetter/index.tsx +0 -80
- package/src/component/CustomSchemaForm/components/Setters/NumberSetter/index.tsx +0 -34
- package/src/component/CustomSchemaForm/components/Setters/SelectSetter/index.tsx +0 -35
- package/src/component/CustomSchemaForm/components/Setters/ShapeSetter/index.tsx +0 -65
- package/src/component/CustomSchemaForm/components/Setters/StringSetter/index.tsx +0 -30
- package/src/component/CustomSchemaForm/components/Setters/TextAreaSetter/index.tsx +0 -31
- package/src/component/CustomSchemaForm/components/Setters/index.ts +0 -26
- package/src/component/CustomSchemaForm/components/Setters/type.ts +0 -18
- package/src/component/CustomSchemaForm/context.ts +0 -20
- package/src/component/CustomSchemaForm/index.tsx +0 -93
- package/src/component/CustomSchemaForm/style.module.scss +0 -15
- package/src/component/CustomSchemaForm/style.module.scss.d.ts +0 -11
- package/src/component/CustomSchemaForm/utils.ts +0 -13
- package/src/component/MonacoEditor/index.tsx +0 -81
- package/src/component/Workbench/index.tsx +0 -329
- package/src/component/Workbench/style.module.scss +0 -159
- package/src/component/Workbench/style.module.scss.d.ts +0 -25
- package/src/core/pluginManager.ts +0 -151
- package/src/i18n/en_US/index.ts +0 -5
- package/src/i18n/index.ts +0 -39
- package/src/i18n/zh_CN/index.ts +0 -5
- package/src/index.tsx +0 -150
- package/src/material/innerMaterial.ts +0 -343
- package/src/plugins/AdvancePanel/index.tsx +0 -191
- package/src/plugins/AdvancePanel/style.module.scss +0 -8
- package/src/plugins/AdvancePanel/style.module.scss.d.ts +0 -7
- package/src/plugins/ComponentLibrary/components/DragItem/index.tsx +0 -65
- package/src/plugins/ComponentLibrary/components/DragItem/style.module.scss +0 -58
- package/src/plugins/ComponentLibrary/components/DragItem/style.module.scss.d.ts +0 -9
- package/src/plugins/ComponentLibrary/components/ListView/index.tsx +0 -50
- package/src/plugins/ComponentLibrary/components/ListView/style.module.scss +0 -27
- package/src/plugins/ComponentLibrary/components/ListView/style.module.scss.d.ts +0 -12
- package/src/plugins/ComponentLibrary/index.tsx +0 -184
- package/src/plugins/ComponentLibrary/localize/en_US/index.ts +0 -3
- package/src/plugins/ComponentLibrary/localize/index.ts +0 -3
- package/src/plugins/ComponentLibrary/localize/zh_CN/index.ts +0 -3
- package/src/plugins/ComponentLibrary/style.module.scss +0 -31
- package/src/plugins/ComponentLibrary/style.module.scss.d.ts +0 -11
- package/src/plugins/ComponentLibrary/util.ts +0 -14
- package/src/plugins/ComponentStatePanel/index.tsx +0 -59
- package/src/plugins/Designer/components/DefaultSelectToolBar/index.tsx +0 -94
- package/src/plugins/Designer/components/DefaultSelectToolBar/style.module.scss +0 -59
- package/src/plugins/Designer/components/DefaultSelectToolBar/style.module.scss.d.ts +0 -11
- package/src/plugins/Designer/components/GhostView/index.tsx +0 -18
- package/src/plugins/Designer/config.ts +0 -1
- package/src/plugins/Designer/index.tsx +0 -61
- package/src/plugins/Designer/localize/en_US/index.ts +0 -3
- package/src/plugins/Designer/localize/index.ts +0 -3
- package/src/plugins/Designer/localize/zh_CN/index.ts +0 -3
- package/src/plugins/Designer/style.module.scss +0 -10
- package/src/plugins/Designer/style.module.scss.d.ts +0 -5
- package/src/plugins/Designer/util.ts +0 -18
- package/src/plugins/Designer/view.tsx +0 -225
- package/src/plugins/DisplaySourceSchema/index.tsx +0 -76
- package/src/plugins/GlobalStatePanel/index.tsx +0 -96
- package/src/plugins/GlobalStatePanel/localize/en_US/index.ts +0 -3
- package/src/plugins/GlobalStatePanel/localize/index.ts +0 -3
- package/src/plugins/GlobalStatePanel/localize/zh_CN/index.ts +0 -3
- package/src/plugins/GlobalStatePanel/style.module.scss +0 -8
- package/src/plugins/GlobalStatePanel/style.module.scss.d.ts +0 -5
- package/src/plugins/History/index.tsx +0 -110
- package/src/plugins/OutlineTree/components/TreeView/context.ts +0 -43
- package/src/plugins/OutlineTree/components/TreeView/dataStruct.ts +0 -58
- package/src/plugins/OutlineTree/components/TreeView/index.tsx +0 -376
- package/src/plugins/OutlineTree/components/TreeView/style.module.scss +0 -93
- package/src/plugins/OutlineTree/components/TreeView/style.module.scss.d.ts +0 -16
- package/src/plugins/OutlineTree/components/TreeView/treeNode.tsx +0 -271
- package/src/plugins/OutlineTree/index.tsx +0 -39
- package/src/plugins/OutlineTree/localize/en_US/index.ts +0 -3
- package/src/plugins/OutlineTree/localize/index.ts +0 -3
- package/src/plugins/OutlineTree/localize/zh_CN/index.ts +0 -3
- package/src/plugins/OutlineTree/util.tsx +0 -302
- package/src/plugins/PropertyPanel/index.tsx +0 -63
- package/src/plugins/PropertyPanel/style.module.scss +0 -12
- package/src/plugins/PropertyPanel/style.module.scss.d.ts +0 -10
- package/src/plugins/PropertyPanel/utils.ts +0 -13
- package/src/plugins/RightPanel/index.tsx +0 -30
- package/src/plugins/RightPanel/style.module.scss +0 -16
- package/src/plugins/RightPanel/style.module.scss.d.ts +0 -10
- package/src/plugins/RightPanel/view.tsx +0 -177
- package/src/plugins/VisualPanel/index.tsx +0 -185
- package/src/plugins/VisualPanel/style.module.scss +0 -17
- package/src/plugins/VisualPanelPlus/index.tsx +0 -103
- package/src/plugins/VisualPanelPlus/style.module.scss +0 -20
- package/src/plugins/VisualPanelPlus/style.module.scss.d.ts +0 -10
- package/src/plugins/index.tsx +0 -26
- package/src/stories/Button.jsx +0 -50
- package/src/stories/Button.stories.jsx +0 -40
- package/src/stories/Introduction.stories.mdx +0 -194
- package/src/stories/assets/code-brackets.svg +0 -1
- package/src/stories/assets/colors.svg +0 -1
- package/src/stories/assets/comments.svg +0 -1
- package/src/stories/assets/direction.svg +0 -1
- package/src/stories/assets/flow.svg +0 -1
- package/src/stories/assets/plugin.svg +0 -1
- package/src/stories/assets/repo.svg +0 -1
- package/src/stories/assets/stackalt.svg +0 -1
- package/src/stories/button.css +0 -30
- package/src/stories/plugins/CSSEditor.stories.tsx +0 -75
- package/src/stories/plugins/VisualPanelPlus.stories.tsx +0 -74
- package/src/style.d.ts +0 -2
- package/src/typing.d.ts +0 -9
- package/src/utils/css.ts +0 -88
- package/src/utils/defaultEngineConfig.tsx +0 -55
- package/src/utils/index.ts +0 -12
- package/src/utils/logger.ts +0 -4
- package/src/vite-env.d.ts +0 -1
- 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,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
|
-
};
|