@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,22 +0,0 @@
|
|
|
1
|
-
.dragItem {
|
|
2
|
-
cursor: grab;
|
|
3
|
-
border: 1px solid $borderColor;
|
|
4
|
-
background-color: white;
|
|
5
|
-
padding: 10px;
|
|
6
|
-
text-align: center;
|
|
7
|
-
margin-bottom: 10px;
|
|
8
|
-
font-size: $fontSizeSmall;
|
|
9
|
-
border-radius: $borderRadius;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.sortModalBox {
|
|
13
|
-
padding: 20px 10px 10px;
|
|
14
|
-
overflow: auto;
|
|
15
|
-
max-height: 500px;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.addOneBtn {
|
|
19
|
-
width: 100%;
|
|
20
|
-
font-size: $fontSizeSmall !important;
|
|
21
|
-
color: $fontColor;
|
|
22
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ConfigProvider, Switch, SwitchProps } from 'antd';
|
|
3
|
-
import { CSetter, CSetterProps } from '../type';
|
|
4
|
-
|
|
5
|
-
type BooleanSetterProps = SwitchProps;
|
|
6
|
-
|
|
7
|
-
export const BooleanSetter: CSetter<BooleanSetterProps> = ({
|
|
8
|
-
onValueChange,
|
|
9
|
-
setterContext,
|
|
10
|
-
...props
|
|
11
|
-
}: CSetterProps<BooleanSetterProps>) => {
|
|
12
|
-
return (
|
|
13
|
-
<ConfigProvider
|
|
14
|
-
theme={{
|
|
15
|
-
token: {
|
|
16
|
-
borderRadius: 4,
|
|
17
|
-
},
|
|
18
|
-
}}
|
|
19
|
-
>
|
|
20
|
-
<Switch
|
|
21
|
-
{...props}
|
|
22
|
-
checked={props.value as boolean}
|
|
23
|
-
onChange={(open, e) => {
|
|
24
|
-
props.onChange?.(open, e);
|
|
25
|
-
onValueChange?.(open);
|
|
26
|
-
}}
|
|
27
|
-
/>
|
|
28
|
-
</ConfigProvider>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
BooleanSetter.setterName = 'Bool 设置器';
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import { AutoComplete, ConfigProvider, Input, InputProps } from 'antd';
|
|
3
|
-
import { CSetter, CSetterProps } from '../type';
|
|
4
|
-
import { BaseSelectRef } from 'rc-select';
|
|
5
|
-
import { useDebounceFn } from 'ahooks';
|
|
6
|
-
import clsx from 'clsx';
|
|
7
|
-
import styles from './style.module.scss';
|
|
8
|
-
import { CSSProperties, CSSPropertiesKey } from '../../../../CSSPropertiesEditor/cssProperties';
|
|
9
|
-
|
|
10
|
-
type CSSValueSetterProps = {
|
|
11
|
-
propertyKey: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const CSSValueSetter: CSetter<CSSValueSetterProps> = ({
|
|
15
|
-
onValueChange,
|
|
16
|
-
setterContext,
|
|
17
|
-
propertyKey = '',
|
|
18
|
-
value,
|
|
19
|
-
...props
|
|
20
|
-
}: CSetterProps<CSSValueSetterProps>) => {
|
|
21
|
-
const { keyPaths, onSetterChange } = setterContext;
|
|
22
|
-
const propertyValueRef = useRef<BaseSelectRef | null>(null);
|
|
23
|
-
const [innerValue, setInnerVal] = useState<any>(value || '');
|
|
24
|
-
const [focusState, setFocusState] = useState(false);
|
|
25
|
-
const updateOuterValue = () => {
|
|
26
|
-
onValueChange?.(innerValue);
|
|
27
|
-
};
|
|
28
|
-
useLayoutEffect(() => {
|
|
29
|
-
setInnerVal(value);
|
|
30
|
-
}, [value]);
|
|
31
|
-
const { run: updateOuterValueDebounce } = useDebounceFn(updateOuterValue, {
|
|
32
|
-
wait: 10,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const optionsValue = useMemo(() => {
|
|
36
|
-
const list = CSSProperties[propertyKey as unknown as CSSPropertiesKey]?.values || [];
|
|
37
|
-
return list.map((el) => {
|
|
38
|
-
return {
|
|
39
|
-
value: el,
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
}, [propertyKey]);
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<ConfigProvider
|
|
46
|
-
theme={{
|
|
47
|
-
token: {
|
|
48
|
-
borderRadius: 4,
|
|
49
|
-
},
|
|
50
|
-
}}
|
|
51
|
-
>
|
|
52
|
-
<AutoComplete
|
|
53
|
-
ref={propertyValueRef}
|
|
54
|
-
dropdownMatchSelectWidth={200}
|
|
55
|
-
bordered={false}
|
|
56
|
-
value={innerValue}
|
|
57
|
-
onChange={(val) => {
|
|
58
|
-
setInnerVal(val);
|
|
59
|
-
updateOuterValueDebounce();
|
|
60
|
-
}}
|
|
61
|
-
style={{
|
|
62
|
-
flex: 1,
|
|
63
|
-
}}
|
|
64
|
-
onFocus={() => {
|
|
65
|
-
setFocusState(true);
|
|
66
|
-
}}
|
|
67
|
-
onBlur={() => {
|
|
68
|
-
setFocusState(false);
|
|
69
|
-
}}
|
|
70
|
-
className={clsx([styles.inputAuto, focusState && styles.active])}
|
|
71
|
-
placeholder="value"
|
|
72
|
-
options={optionsValue}
|
|
73
|
-
></AutoComplete>
|
|
74
|
-
</ConfigProvider>
|
|
75
|
-
);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
CSSValueSetter.setterName = 'CSS值设置器';
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ConfigProvider, Input, InputProps } from 'antd';
|
|
2
|
-
import { CSetter, CSetterProps } from '../type';
|
|
3
|
-
import { CNodePropsTypeEnum } from '@chamn/model';
|
|
4
|
-
|
|
5
|
-
export const ExpressionSetter: CSetter<
|
|
6
|
-
InputProps & {
|
|
7
|
-
value: {
|
|
8
|
-
type: string;
|
|
9
|
-
value: string;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
> = ({
|
|
13
|
-
onValueChange,
|
|
14
|
-
setterContext,
|
|
15
|
-
...props
|
|
16
|
-
}: CSetterProps<
|
|
17
|
-
InputProps & {
|
|
18
|
-
value: {
|
|
19
|
-
type: string;
|
|
20
|
-
value: string;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
>) => {
|
|
24
|
-
return (
|
|
25
|
-
<ConfigProvider
|
|
26
|
-
theme={{
|
|
27
|
-
token: {
|
|
28
|
-
borderRadius: 4,
|
|
29
|
-
},
|
|
30
|
-
}}
|
|
31
|
-
>
|
|
32
|
-
<Input
|
|
33
|
-
{...props}
|
|
34
|
-
value={props.value?.value || ''}
|
|
35
|
-
onChange={(e) => {
|
|
36
|
-
props.onChange?.(e);
|
|
37
|
-
onValueChange?.({
|
|
38
|
-
type: CNodePropsTypeEnum.EXPRESSION,
|
|
39
|
-
value: e.target.value,
|
|
40
|
-
});
|
|
41
|
-
}}
|
|
42
|
-
/>
|
|
43
|
-
</ConfigProvider>
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
ExpressionSetter.setterName = '表达式设置器';
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export const DefaultTslibSource = `
|
|
2
|
-
type ContextType = {
|
|
3
|
-
/** 渲染函数的入口参数 */
|
|
4
|
-
params?: Record<any, any>;
|
|
5
|
-
/** 全局状态 */
|
|
6
|
-
globalState?: Record<any, any>;
|
|
7
|
-
/** 更新全局状态 */
|
|
8
|
-
updateGlobalState?: (newState: any) => void;
|
|
9
|
-
/** 当前节点状态 **/
|
|
10
|
-
state?: Record<any, any>;
|
|
11
|
-
/** 存储当前节点的数据,不具有响应性 **/
|
|
12
|
-
staticState?: Record<any, any>;
|
|
13
|
-
/** 更新当前节点状态 */
|
|
14
|
-
updateState?: (newState: any) => void;
|
|
15
|
-
/** 所有节点的索引 */
|
|
16
|
-
refs?: RefManager;
|
|
17
|
-
/** 循环渲染中的单个循环数据 */
|
|
18
|
-
loopData?: Record<any, any>;
|
|
19
|
-
/** 用于访访问和管理页面被注册为全局的局部 state */
|
|
20
|
-
stateManager?: Record<string, {
|
|
21
|
-
state: any,
|
|
22
|
-
updateState: (newState: Record<string, any>) => void
|
|
23
|
-
}>;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/** 渲染上下文 */
|
|
27
|
-
declare var $$context: ContextType;
|
|
28
|
-
`;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useState } from 'react';
|
|
2
|
-
import { Button, ConfigProvider, Modal } from 'antd';
|
|
3
|
-
import { CSetter, CSetterProps } from '../type';
|
|
4
|
-
import { MonacoEditor, MonacoEditorInstance } from '../../../../MonacoEditor';
|
|
5
|
-
import { DefaultTslibSource } from './defaultDts';
|
|
6
|
-
import { CNodePropsTypeEnum } from '@chamn/model';
|
|
7
|
-
|
|
8
|
-
export const FunctionSetter: CSetter<any> = ({ onValueChange, setterContext, ...props }: CSetterProps<any>) => {
|
|
9
|
-
const editorRef = useRef<MonacoEditorInstance | null>(null);
|
|
10
|
-
const [open, setOpen] = useState(false);
|
|
11
|
-
const onInnerValueChange = () => {
|
|
12
|
-
const newValStr = editorRef.current?.getValue() || '';
|
|
13
|
-
onValueChange({
|
|
14
|
-
type: CNodePropsTypeEnum.FUNCTION,
|
|
15
|
-
value: newValStr,
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
return (
|
|
19
|
-
<ConfigProvider
|
|
20
|
-
theme={{
|
|
21
|
-
token: {
|
|
22
|
-
borderRadius: 4,
|
|
23
|
-
},
|
|
24
|
-
}}
|
|
25
|
-
>
|
|
26
|
-
<Button
|
|
27
|
-
size="small"
|
|
28
|
-
style={{
|
|
29
|
-
marginTop: '5px',
|
|
30
|
-
width: '100%',
|
|
31
|
-
color: '#676767',
|
|
32
|
-
fontSize: '12px',
|
|
33
|
-
}}
|
|
34
|
-
onClick={() => {
|
|
35
|
-
setOpen(true);
|
|
36
|
-
}}
|
|
37
|
-
>
|
|
38
|
-
Edit
|
|
39
|
-
</Button>
|
|
40
|
-
<Modal
|
|
41
|
-
destroyOnClose
|
|
42
|
-
open={open}
|
|
43
|
-
title="Function Editor"
|
|
44
|
-
width="800px"
|
|
45
|
-
onCancel={() => setOpen(false)}
|
|
46
|
-
onOk={() => {
|
|
47
|
-
onInnerValueChange();
|
|
48
|
-
setOpen(false);
|
|
49
|
-
}}
|
|
50
|
-
style={{}}
|
|
51
|
-
>
|
|
52
|
-
<div style={{ height: '500px' }}>
|
|
53
|
-
{open && (
|
|
54
|
-
<MonacoEditor
|
|
55
|
-
beforeMount={(monaco) => {
|
|
56
|
-
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
|
|
57
|
-
noSemanticValidation: true,
|
|
58
|
-
noSyntaxValidation: false,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// compiler options
|
|
62
|
-
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
|
|
63
|
-
target: monaco.languages.typescript.ScriptTarget.ES5,
|
|
64
|
-
allowNonTsExtensions: true,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const libUri = 'ts:filename/chameleon.default.variable.d.ts';
|
|
68
|
-
monaco.languages.typescript.javascriptDefaults.addExtraLib(DefaultTslibSource, libUri);
|
|
69
|
-
// When resolving definitions and references, the editor will try to use created models.
|
|
70
|
-
// Creating a model for the library allows "peek definition/references" commands to work with the library.
|
|
71
|
-
const model = monaco.editor.getModel(monaco.Uri.parse(libUri));
|
|
72
|
-
if (!model) {
|
|
73
|
-
monaco.editor.createModel(DefaultTslibSource, 'typescript', monaco.Uri.parse(libUri));
|
|
74
|
-
}
|
|
75
|
-
}}
|
|
76
|
-
onDidMount={(editor) => {
|
|
77
|
-
editorRef.current = editor;
|
|
78
|
-
}}
|
|
79
|
-
initialValue={props.value?.value || ''}
|
|
80
|
-
language={'javascript'}
|
|
81
|
-
options={{
|
|
82
|
-
automaticLayout: true,
|
|
83
|
-
tabSize: 2,
|
|
84
|
-
}}
|
|
85
|
-
/>
|
|
86
|
-
)}
|
|
87
|
-
</div>
|
|
88
|
-
</Modal>
|
|
89
|
-
</ConfigProvider>
|
|
90
|
-
);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
FunctionSetter.setterName = '函数 设置器';
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useState } from 'react';
|
|
2
|
-
import { Button, ConfigProvider, Modal } from 'antd';
|
|
3
|
-
import { CSetter, CSetterProps } from '../type';
|
|
4
|
-
import { MonacoEditor, MonacoEditorInstance } from '../../../../MonacoEditor';
|
|
5
|
-
|
|
6
|
-
export const JSONSetter: CSetter<any> = ({
|
|
7
|
-
onValueChange,
|
|
8
|
-
setterContext,
|
|
9
|
-
...props
|
|
10
|
-
}: CSetterProps<any>) => {
|
|
11
|
-
const { keyPaths, onSetterChange } = setterContext;
|
|
12
|
-
|
|
13
|
-
const editorRef = useRef<MonacoEditorInstance | null>(null);
|
|
14
|
-
|
|
15
|
-
const [open, setOpen] = useState(false);
|
|
16
|
-
const onInnerValueChange = () => {
|
|
17
|
-
const newValStr = editorRef.current?.getValue() || '';
|
|
18
|
-
try {
|
|
19
|
-
const newVal = JSON.parse(newValStr);
|
|
20
|
-
onValueChange(newVal);
|
|
21
|
-
} catch (e) {
|
|
22
|
-
console.warn(e);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
return (
|
|
26
|
-
<ConfigProvider
|
|
27
|
-
theme={{
|
|
28
|
-
token: {
|
|
29
|
-
borderRadius: 4,
|
|
30
|
-
},
|
|
31
|
-
}}
|
|
32
|
-
>
|
|
33
|
-
<Button
|
|
34
|
-
size="small"
|
|
35
|
-
style={{
|
|
36
|
-
marginTop: '5px',
|
|
37
|
-
width: '100%',
|
|
38
|
-
color: '#676767',
|
|
39
|
-
fontSize: '12px',
|
|
40
|
-
}}
|
|
41
|
-
onClick={() => {
|
|
42
|
-
setOpen(true);
|
|
43
|
-
}}
|
|
44
|
-
>
|
|
45
|
-
Edit
|
|
46
|
-
</Button>
|
|
47
|
-
<Modal
|
|
48
|
-
destroyOnClose
|
|
49
|
-
open={open}
|
|
50
|
-
title="JSON Editor"
|
|
51
|
-
width="800px"
|
|
52
|
-
onCancel={() => setOpen(false)}
|
|
53
|
-
onOk={() => {
|
|
54
|
-
onInnerValueChange();
|
|
55
|
-
setOpen(false);
|
|
56
|
-
}}
|
|
57
|
-
style={{}}
|
|
58
|
-
>
|
|
59
|
-
<div style={{ height: '500px' }}>
|
|
60
|
-
{open && (
|
|
61
|
-
<MonacoEditor
|
|
62
|
-
onDidMount={(editor) => {
|
|
63
|
-
editorRef.current = editor;
|
|
64
|
-
}}
|
|
65
|
-
initialValue={JSON.stringify(props.value || {}, null, 2)}
|
|
66
|
-
language={'json'}
|
|
67
|
-
options={{
|
|
68
|
-
automaticLayout: true,
|
|
69
|
-
tabSize: 2,
|
|
70
|
-
suggestOnTriggerCharacters: false,
|
|
71
|
-
}}
|
|
72
|
-
/>
|
|
73
|
-
)}
|
|
74
|
-
</div>
|
|
75
|
-
</Modal>
|
|
76
|
-
</ConfigProvider>
|
|
77
|
-
);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
JSONSetter.setterName = 'JSON 设置器';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ConfigProvider, InputNumber, InputNumberProps } from 'antd';
|
|
3
|
-
import { CSetter, CSetterProps } from '../type';
|
|
4
|
-
|
|
5
|
-
export const NumberSetter: CSetter<InputNumberProps> = ({
|
|
6
|
-
onValueChange,
|
|
7
|
-
setterContext,
|
|
8
|
-
...props
|
|
9
|
-
}: CSetterProps<InputNumberProps>) => {
|
|
10
|
-
const { keyPaths, onSetterChange } = setterContext;
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<ConfigProvider
|
|
14
|
-
theme={{
|
|
15
|
-
token: {
|
|
16
|
-
borderRadius: 4,
|
|
17
|
-
},
|
|
18
|
-
}}
|
|
19
|
-
>
|
|
20
|
-
<InputNumber
|
|
21
|
-
style={{
|
|
22
|
-
width: '100%',
|
|
23
|
-
}}
|
|
24
|
-
{...props}
|
|
25
|
-
onChange={(value) => {
|
|
26
|
-
props.onChange?.(value);
|
|
27
|
-
onValueChange?.(value);
|
|
28
|
-
}}
|
|
29
|
-
/>
|
|
30
|
-
</ConfigProvider>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
NumberSetter.setterName = '数字设置器';
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ConfigProvider, Select, SelectProps } from 'antd';
|
|
3
|
-
import { CSetter, CSetterProps } from '../type';
|
|
4
|
-
|
|
5
|
-
export const SelectSetter: CSetter<SelectProps> = ({
|
|
6
|
-
onValueChange,
|
|
7
|
-
setterContext,
|
|
8
|
-
...props
|
|
9
|
-
}: CSetterProps<SelectProps>) => {
|
|
10
|
-
const { keyPaths, onSetterChange } = setterContext;
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<ConfigProvider
|
|
14
|
-
theme={{
|
|
15
|
-
token: {
|
|
16
|
-
borderRadius: 4,
|
|
17
|
-
},
|
|
18
|
-
}}
|
|
19
|
-
>
|
|
20
|
-
<Select
|
|
21
|
-
showSearch
|
|
22
|
-
style={{
|
|
23
|
-
width: '100%',
|
|
24
|
-
}}
|
|
25
|
-
{...props}
|
|
26
|
-
onChange={(val, option) => {
|
|
27
|
-
props.onChange?.(val, option);
|
|
28
|
-
onValueChange?.(val);
|
|
29
|
-
}}
|
|
30
|
-
/>
|
|
31
|
-
</ConfigProvider>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
SelectSetter.setterName = '选择设置器';
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useRef } from 'react';
|
|
2
|
-
import { ConfigProvider } from 'antd';
|
|
3
|
-
import { CSetter, CSetterProps } from '../type';
|
|
4
|
-
import { CForm } from '../../Form';
|
|
5
|
-
import { SetterSwitcher } from '../../SetterSwitcher';
|
|
6
|
-
import { getSetterList } from '../../../utils';
|
|
7
|
-
import { getMTitle, getMTitleTip, MaterialPropType } from '@chamn/model';
|
|
8
|
-
|
|
9
|
-
export type CShapeSetterProps = {
|
|
10
|
-
elements: MaterialPropType[];
|
|
11
|
-
initialValue?: Record<string, any>;
|
|
12
|
-
value: Record<string, any>;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const ShapeSetter: CSetter<CShapeSetterProps> = ({
|
|
16
|
-
onValueChange,
|
|
17
|
-
elements,
|
|
18
|
-
value,
|
|
19
|
-
setterContext,
|
|
20
|
-
}: CSetterProps<CShapeSetterProps>) => {
|
|
21
|
-
const { keyPaths } = setterContext;
|
|
22
|
-
const formRef = useRef<CForm>(null);
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
formRef.current?.setFields(value || {});
|
|
25
|
-
}, [value]);
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<ConfigProvider
|
|
29
|
-
theme={{
|
|
30
|
-
token: {
|
|
31
|
-
borderRadius: 4,
|
|
32
|
-
},
|
|
33
|
-
}}
|
|
34
|
-
>
|
|
35
|
-
<CForm
|
|
36
|
-
ref={formRef}
|
|
37
|
-
name={keyPaths.join('.')}
|
|
38
|
-
initialValue={value || {}}
|
|
39
|
-
onValueChange={(val) => {
|
|
40
|
-
onValueChange?.(val);
|
|
41
|
-
}}
|
|
42
|
-
>
|
|
43
|
-
{elements.map((el, index) => {
|
|
44
|
-
const setters = getSetterList(el.setters);
|
|
45
|
-
const title = getMTitle(el.title);
|
|
46
|
-
const tip = getMTitleTip(el.title);
|
|
47
|
-
return (
|
|
48
|
-
<div key={index}>
|
|
49
|
-
<SetterSwitcher
|
|
50
|
-
name={el.name}
|
|
51
|
-
label={title}
|
|
52
|
-
tips={tip}
|
|
53
|
-
condition={el.condition}
|
|
54
|
-
keyPaths={[...keyPaths, el.name]}
|
|
55
|
-
setters={setters}
|
|
56
|
-
/>
|
|
57
|
-
</div>
|
|
58
|
-
);
|
|
59
|
-
})}
|
|
60
|
-
</CForm>
|
|
61
|
-
</ConfigProvider>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
ShapeSetter.setterName = '对象设置器';
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ConfigProvider, Input, InputProps } from 'antd';
|
|
3
|
-
import { CSetter, CSetterProps } from '../type';
|
|
4
|
-
|
|
5
|
-
export const StringSetter: CSetter<InputProps> = ({
|
|
6
|
-
onValueChange,
|
|
7
|
-
setterContext,
|
|
8
|
-
...props
|
|
9
|
-
}: CSetterProps<InputProps>) => {
|
|
10
|
-
const { keyPaths, onSetterChange } = setterContext;
|
|
11
|
-
return (
|
|
12
|
-
<ConfigProvider
|
|
13
|
-
theme={{
|
|
14
|
-
token: {
|
|
15
|
-
borderRadius: 4,
|
|
16
|
-
},
|
|
17
|
-
}}
|
|
18
|
-
>
|
|
19
|
-
<Input
|
|
20
|
-
{...props}
|
|
21
|
-
onChange={(e) => {
|
|
22
|
-
props.onChange?.(e);
|
|
23
|
-
onValueChange?.(e.target.value);
|
|
24
|
-
}}
|
|
25
|
-
/>
|
|
26
|
-
</ConfigProvider>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
StringSetter.setterName = '字符设置器';
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ConfigProvider, Input } from 'antd';
|
|
3
|
-
import { CSetter, CSetterProps } from '../type';
|
|
4
|
-
import { TextAreaProps } from 'antd/es/input';
|
|
5
|
-
|
|
6
|
-
export const TextAreaSetter: CSetter<TextAreaProps> = ({
|
|
7
|
-
onValueChange,
|
|
8
|
-
setterContext,
|
|
9
|
-
...props
|
|
10
|
-
}: CSetterProps<TextAreaProps>) => {
|
|
11
|
-
const { keyPaths, onSetterChange } = setterContext;
|
|
12
|
-
return (
|
|
13
|
-
<ConfigProvider
|
|
14
|
-
theme={{
|
|
15
|
-
token: {
|
|
16
|
-
borderRadius: 4,
|
|
17
|
-
},
|
|
18
|
-
}}
|
|
19
|
-
>
|
|
20
|
-
<Input.TextArea
|
|
21
|
-
{...props}
|
|
22
|
-
onChange={(e) => {
|
|
23
|
-
props.onChange?.(e);
|
|
24
|
-
onValueChange?.(e.target.value);
|
|
25
|
-
}}
|
|
26
|
-
/>
|
|
27
|
-
</ConfigProvider>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
TextAreaSetter.setterName = '长文本设置器';
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { CSetter } from './type';
|
|
2
|
-
import { StringSetter } from './StringSetter';
|
|
3
|
-
import { NumberSetter } from './NumberSetter';
|
|
4
|
-
import { ArraySetter } from './ArraySetter';
|
|
5
|
-
import { ShapeSetter } from './ShapeSetter';
|
|
6
|
-
import { ExpressionSetter } from './ExpressionSetter';
|
|
7
|
-
import { BooleanSetter } from './BooleanSetter';
|
|
8
|
-
import { SelectSetter } from './SelectSetter';
|
|
9
|
-
import { JSONSetter } from './JSONSetter';
|
|
10
|
-
import { FunctionSetter } from './FunctionSetter';
|
|
11
|
-
import { TextAreaSetter } from './TextAreaSetter';
|
|
12
|
-
import { CSSValueSetter } from './CSSValueSetter';
|
|
13
|
-
|
|
14
|
-
export default {
|
|
15
|
-
StringSetter,
|
|
16
|
-
ArraySetter,
|
|
17
|
-
ShapeSetter,
|
|
18
|
-
NumberSetter,
|
|
19
|
-
ExpressionSetter,
|
|
20
|
-
BooleanSetter,
|
|
21
|
-
SelectSetter,
|
|
22
|
-
JSONSetter,
|
|
23
|
-
FunctionSetter,
|
|
24
|
-
TextAreaSetter,
|
|
25
|
-
CSSValueSetter,
|
|
26
|
-
} as Record<string, CSetter>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CPluginCtx } from '../../../../core/pluginManager';
|
|
2
|
-
|
|
3
|
-
export type CSetter<T = any> = {
|
|
4
|
-
(props: CSetterProps<T>): JSX.Element;
|
|
5
|
-
setterName: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type CSetterProps<T = { _: any }> = {
|
|
9
|
-
onValueChange?: ((val: any) => void) | undefined;
|
|
10
|
-
value?: unknown;
|
|
11
|
-
setterContext: {
|
|
12
|
-
pluginCtx: CPluginCtx;
|
|
13
|
-
setCollapseHeaderExt?: (el: React.ReactNode) => void;
|
|
14
|
-
onSetterChange: (keyPaths: string[], setterName: string) => void;
|
|
15
|
-
keyPaths: string[];
|
|
16
|
-
label: string;
|
|
17
|
-
};
|
|
18
|
-
} & T;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
2
|
-
import React, { Ref } from 'react';
|
|
3
|
-
import { CustomSchemaFormInstance } from '.';
|
|
4
|
-
import { CPluginCtx } from '../../core/pluginManager';
|
|
5
|
-
import { CForm } from './components/Form';
|
|
6
|
-
|
|
7
|
-
export type ContextState = Record<string, any>;
|
|
8
|
-
|
|
9
|
-
export type CCustomSchemaFormContextData = {
|
|
10
|
-
onSetterChange: (keyPaths: string[], setterName: string) => void;
|
|
11
|
-
defaultSetterConfig: Record<string, { name: string; setter: string }>;
|
|
12
|
-
formRef?: Ref<CustomSchemaFormInstance | CForm>;
|
|
13
|
-
pluginCtx?: CPluginCtx;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const CCustomSchemaFormContext =
|
|
17
|
-
React.createContext<CCustomSchemaFormContextData>({
|
|
18
|
-
defaultSetterConfig: {},
|
|
19
|
-
onSetterChange: () => {},
|
|
20
|
-
});
|