@chamn/engine 0.0.10 → 0.0.12

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 (205) 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} +3849 -3814
  11. package/dist/index.mjs.map +1 -0
  12. package/dist/material/innerMaterial.d.ts +1 -1
  13. package/dist/plugins/RightPanel/view.d.ts +4 -0
  14. package/package.json +12 -9
  15. package/.eslintignore +0 -1
  16. package/.eslintrc.js +0 -36
  17. package/.prettierrc.json +0 -7
  18. package/.storybook/main.js +0 -24
  19. package/.storybook/preview.js +0 -9
  20. package/CHANGELOG.md +0 -54
  21. package/__tests__/demo.test.ts +0 -3
  22. package/build.config.js +0 -88
  23. package/dist/index.cjs.js +0 -197
  24. package/dist/index.cjs.js.map +0 -1
  25. package/dist/index.es.js.map +0 -1
  26. package/index.html +0 -16
  27. package/jest.config.js +0 -196
  28. package/public/Engine.module.scss.d.ts +0 -5
  29. package/public/_dev_/render.d.ts +0 -2
  30. package/public/component/CSSEditor/style.module.scss.d.ts +0 -6
  31. package/public/component/CSSPropertiesEditor/style.module.scss.d.ts +0 -15
  32. package/public/component/CSSPropertiesVariableBindEditor/style.module.scss.d.ts +0 -15
  33. package/public/component/CustomSchemaForm/components/Form/Field/style.module.scss.d.ts +0 -8
  34. package/public/component/CustomSchemaForm/components/SetterSwitcher/style.module.scss.d.ts +0 -7
  35. package/public/component/CustomSchemaForm/components/Setters/ArraySetter/style.module.scss.d.ts +0 -7
  36. package/public/component/CustomSchemaForm/components/Setters/CSSValueSetter/style.module.scss.d.ts +0 -6
  37. package/public/component/CustomSchemaForm/style.module.scss.d.ts +0 -11
  38. package/public/component/Workbench/style.module.scss.d.ts +0 -25
  39. package/public/plugins/AdvancePanel/style.module.scss.d.ts +0 -7
  40. package/public/plugins/ComponentLibrary/components/DragItem/style.module.scss.d.ts +0 -9
  41. package/public/plugins/ComponentLibrary/components/ListView/style.module.scss.d.ts +0 -12
  42. package/public/plugins/ComponentLibrary/style.module.scss.d.ts +0 -11
  43. package/public/plugins/Designer/components/DefaultSelectToolBar/style.module.scss.d.ts +0 -11
  44. package/public/plugins/Designer/style.module.scss.d.ts +0 -5
  45. package/public/plugins/GlobalStatePanel/style.module.scss.d.ts +0 -5
  46. package/public/plugins/OutlineTree/components/TreeView/style.module.scss.d.ts +0 -16
  47. package/public/plugins/PropertyPanel/style.module.scss.d.ts +0 -10
  48. package/public/plugins/RightPanel/style.module.scss.d.ts +0 -10
  49. package/public/plugins/VisualPanelPlus/style.module.scss.d.ts +0 -10
  50. package/public/render.umd.js +0 -42
  51. package/public/render.umd.js.map +0 -1
  52. package/src/Engine.module.scss +0 -10
  53. package/src/Engine.module.scss.d.ts +0 -5
  54. package/src/_dev_/index.css +0 -22
  55. package/src/_dev_/index.tsx +0 -5
  56. package/src/_dev_/page/Editor/index.tsx +0 -198
  57. package/src/_dev_/page/Editor/indexCustom.tsx +0 -274
  58. package/src/_dev_/page/Preview/index.tsx +0 -56
  59. package/src/_dev_/render.ts +0 -3
  60. package/src/_dev_/router.tsx +0 -14
  61. package/src/assets/react.svg +0 -4
  62. package/src/assets/styles/mixin.scss +0 -15
  63. package/src/component/CSSEditor/index.tsx +0 -247
  64. package/src/component/CSSEditor/style.module.scss +0 -22
  65. package/src/component/CSSEditor/style.module.scss.d.ts +0 -6
  66. package/src/component/CSSPropertiesEditor/cssProperties.ts +0 -1062
  67. package/src/component/CSSPropertiesEditor/index.tsx +0 -389
  68. package/src/component/CSSPropertiesEditor/style.module.scss +0 -46
  69. package/src/component/CSSPropertiesEditor/style.module.scss.d.ts +0 -15
  70. package/src/component/CSSPropertiesEditor/util.ts +0 -19
  71. package/src/component/CSSPropertiesVariableBindEditor/cssProperties.ts +0 -782
  72. package/src/component/CSSPropertiesVariableBindEditor/index.tsx +0 -366
  73. package/src/component/CSSPropertiesVariableBindEditor/style.module.scss +0 -48
  74. package/src/component/CSSPropertiesVariableBindEditor/style.module.scss.d.ts +0 -15
  75. package/src/component/CSSPropertiesVariableBindEditor/util.ts +0 -19
  76. package/src/component/ClassNameEditor/index.tsx +0 -91
  77. package/src/component/ClassNameEditor/style.module.scss +0 -0
  78. package/src/component/CustomSchemaForm/components/Form/Field/index.tsx +0 -81
  79. package/src/component/CustomSchemaForm/components/Form/Field/style.module.scss +0 -32
  80. package/src/component/CustomSchemaForm/components/Form/Field/style.module.scss.d.ts +0 -8
  81. package/src/component/CustomSchemaForm/components/Form/context.ts +0 -23
  82. package/src/component/CustomSchemaForm/components/Form/index.tsx +0 -71
  83. package/src/component/CustomSchemaForm/components/SetterSwitcher/index.tsx +0 -273
  84. package/src/component/CustomSchemaForm/components/SetterSwitcher/style.module.scss +0 -16
  85. package/src/component/CustomSchemaForm/components/SetterSwitcher/style.module.scss.d.ts +0 -7
  86. package/src/component/CustomSchemaForm/components/Setters/ArraySetter/ArrayItem.tsx +0 -55
  87. package/src/component/CustomSchemaForm/components/Setters/ArraySetter/SortItemOrderModal.tsx +0 -160
  88. package/src/component/CustomSchemaForm/components/Setters/ArraySetter/index.tsx +0 -129
  89. package/src/component/CustomSchemaForm/components/Setters/ArraySetter/style.module.scss +0 -22
  90. package/src/component/CustomSchemaForm/components/Setters/ArraySetter/style.module.scss.d.ts +0 -7
  91. package/src/component/CustomSchemaForm/components/Setters/BooleanSetter/index.tsx +0 -32
  92. package/src/component/CustomSchemaForm/components/Setters/CSSValueSetter/index.tsx +0 -78
  93. package/src/component/CustomSchemaForm/components/Setters/CSSValueSetter/style.module.scss +0 -7
  94. package/src/component/CustomSchemaForm/components/Setters/CSSValueSetter/style.module.scss.d.ts +0 -6
  95. package/src/component/CustomSchemaForm/components/Setters/ExpressionSetter/index.tsx +0 -47
  96. package/src/component/CustomSchemaForm/components/Setters/FunctionSetter/defaultDts.ts +0 -28
  97. package/src/component/CustomSchemaForm/components/Setters/FunctionSetter/index.tsx +0 -93
  98. package/src/component/CustomSchemaForm/components/Setters/JSONSetter/index.tsx +0 -80
  99. package/src/component/CustomSchemaForm/components/Setters/NumberSetter/index.tsx +0 -34
  100. package/src/component/CustomSchemaForm/components/Setters/SelectSetter/index.tsx +0 -35
  101. package/src/component/CustomSchemaForm/components/Setters/ShapeSetter/index.tsx +0 -65
  102. package/src/component/CustomSchemaForm/components/Setters/StringSetter/index.tsx +0 -30
  103. package/src/component/CustomSchemaForm/components/Setters/TextAreaSetter/index.tsx +0 -31
  104. package/src/component/CustomSchemaForm/components/Setters/index.ts +0 -26
  105. package/src/component/CustomSchemaForm/components/Setters/type.ts +0 -18
  106. package/src/component/CustomSchemaForm/context.ts +0 -20
  107. package/src/component/CustomSchemaForm/index.tsx +0 -93
  108. package/src/component/CustomSchemaForm/style.module.scss +0 -15
  109. package/src/component/CustomSchemaForm/style.module.scss.d.ts +0 -11
  110. package/src/component/CustomSchemaForm/utils.ts +0 -13
  111. package/src/component/MonacoEditor/index.tsx +0 -81
  112. package/src/component/Workbench/index.tsx +0 -329
  113. package/src/component/Workbench/style.module.scss +0 -159
  114. package/src/component/Workbench/style.module.scss.d.ts +0 -25
  115. package/src/core/pluginManager.ts +0 -151
  116. package/src/i18n/en_US/index.ts +0 -5
  117. package/src/i18n/index.ts +0 -39
  118. package/src/i18n/zh_CN/index.ts +0 -5
  119. package/src/index.tsx +0 -150
  120. package/src/material/innerMaterial.ts +0 -343
  121. package/src/plugins/AdvancePanel/index.tsx +0 -191
  122. package/src/plugins/AdvancePanel/style.module.scss +0 -8
  123. package/src/plugins/AdvancePanel/style.module.scss.d.ts +0 -7
  124. package/src/plugins/ComponentLibrary/components/DragItem/index.tsx +0 -65
  125. package/src/plugins/ComponentLibrary/components/DragItem/style.module.scss +0 -58
  126. package/src/plugins/ComponentLibrary/components/DragItem/style.module.scss.d.ts +0 -9
  127. package/src/plugins/ComponentLibrary/components/ListView/index.tsx +0 -50
  128. package/src/plugins/ComponentLibrary/components/ListView/style.module.scss +0 -27
  129. package/src/plugins/ComponentLibrary/components/ListView/style.module.scss.d.ts +0 -12
  130. package/src/plugins/ComponentLibrary/index.tsx +0 -184
  131. package/src/plugins/ComponentLibrary/localize/en_US/index.ts +0 -3
  132. package/src/plugins/ComponentLibrary/localize/index.ts +0 -3
  133. package/src/plugins/ComponentLibrary/localize/zh_CN/index.ts +0 -3
  134. package/src/plugins/ComponentLibrary/style.module.scss +0 -31
  135. package/src/plugins/ComponentLibrary/style.module.scss.d.ts +0 -11
  136. package/src/plugins/ComponentLibrary/util.ts +0 -14
  137. package/src/plugins/ComponentStatePanel/index.tsx +0 -59
  138. package/src/plugins/Designer/components/DefaultSelectToolBar/index.tsx +0 -94
  139. package/src/plugins/Designer/components/DefaultSelectToolBar/style.module.scss +0 -59
  140. package/src/plugins/Designer/components/DefaultSelectToolBar/style.module.scss.d.ts +0 -11
  141. package/src/plugins/Designer/components/GhostView/index.tsx +0 -18
  142. package/src/plugins/Designer/config.ts +0 -1
  143. package/src/plugins/Designer/index.tsx +0 -61
  144. package/src/plugins/Designer/localize/en_US/index.ts +0 -3
  145. package/src/plugins/Designer/localize/index.ts +0 -3
  146. package/src/plugins/Designer/localize/zh_CN/index.ts +0 -3
  147. package/src/plugins/Designer/style.module.scss +0 -10
  148. package/src/plugins/Designer/style.module.scss.d.ts +0 -5
  149. package/src/plugins/Designer/util.ts +0 -18
  150. package/src/plugins/Designer/view.tsx +0 -225
  151. package/src/plugins/DisplaySourceSchema/index.tsx +0 -76
  152. package/src/plugins/GlobalStatePanel/index.tsx +0 -96
  153. package/src/plugins/GlobalStatePanel/localize/en_US/index.ts +0 -3
  154. package/src/plugins/GlobalStatePanel/localize/index.ts +0 -3
  155. package/src/plugins/GlobalStatePanel/localize/zh_CN/index.ts +0 -3
  156. package/src/plugins/GlobalStatePanel/style.module.scss +0 -8
  157. package/src/plugins/GlobalStatePanel/style.module.scss.d.ts +0 -5
  158. package/src/plugins/History/index.tsx +0 -110
  159. package/src/plugins/OutlineTree/components/TreeView/context.ts +0 -43
  160. package/src/plugins/OutlineTree/components/TreeView/dataStruct.ts +0 -58
  161. package/src/plugins/OutlineTree/components/TreeView/index.tsx +0 -376
  162. package/src/plugins/OutlineTree/components/TreeView/style.module.scss +0 -93
  163. package/src/plugins/OutlineTree/components/TreeView/style.module.scss.d.ts +0 -16
  164. package/src/plugins/OutlineTree/components/TreeView/treeNode.tsx +0 -271
  165. package/src/plugins/OutlineTree/index.tsx +0 -39
  166. package/src/plugins/OutlineTree/localize/en_US/index.ts +0 -3
  167. package/src/plugins/OutlineTree/localize/index.ts +0 -3
  168. package/src/plugins/OutlineTree/localize/zh_CN/index.ts +0 -3
  169. package/src/plugins/OutlineTree/util.tsx +0 -302
  170. package/src/plugins/PropertyPanel/index.tsx +0 -63
  171. package/src/plugins/PropertyPanel/style.module.scss +0 -12
  172. package/src/plugins/PropertyPanel/style.module.scss.d.ts +0 -10
  173. package/src/plugins/PropertyPanel/utils.ts +0 -13
  174. package/src/plugins/RightPanel/index.tsx +0 -30
  175. package/src/plugins/RightPanel/style.module.scss +0 -16
  176. package/src/plugins/RightPanel/style.module.scss.d.ts +0 -10
  177. package/src/plugins/RightPanel/view.tsx +0 -177
  178. package/src/plugins/VisualPanel/index.tsx +0 -185
  179. package/src/plugins/VisualPanel/style.module.scss +0 -17
  180. package/src/plugins/VisualPanelPlus/index.tsx +0 -103
  181. package/src/plugins/VisualPanelPlus/style.module.scss +0 -20
  182. package/src/plugins/VisualPanelPlus/style.module.scss.d.ts +0 -10
  183. package/src/plugins/index.tsx +0 -26
  184. package/src/stories/Button.jsx +0 -50
  185. package/src/stories/Button.stories.jsx +0 -40
  186. package/src/stories/Introduction.stories.mdx +0 -194
  187. package/src/stories/assets/code-brackets.svg +0 -1
  188. package/src/stories/assets/colors.svg +0 -1
  189. package/src/stories/assets/comments.svg +0 -1
  190. package/src/stories/assets/direction.svg +0 -1
  191. package/src/stories/assets/flow.svg +0 -1
  192. package/src/stories/assets/plugin.svg +0 -1
  193. package/src/stories/assets/repo.svg +0 -1
  194. package/src/stories/assets/stackalt.svg +0 -1
  195. package/src/stories/button.css +0 -30
  196. package/src/stories/plugins/CSSEditor.stories.tsx +0 -75
  197. package/src/stories/plugins/VisualPanelPlus.stories.tsx +0 -74
  198. package/src/style.d.ts +0 -2
  199. package/src/typing.d.ts +0 -9
  200. package/src/utils/css.ts +0 -88
  201. package/src/utils/defaultEngineConfig.tsx +0 -55
  202. package/src/utils/index.ts +0 -12
  203. package/src/utils/logger.ts +0 -4
  204. package/src/vite-env.d.ts +0 -1
  205. 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,7 +0,0 @@
1
- import globalClassNames from '../../../../../style.d';
2
- declare const classNames: typeof globalClassNames & {
3
- readonly dragItem: 'dragItem';
4
- readonly sortModalBox: 'sortModalBox';
5
- readonly addOneBtn: 'addOneBtn';
6
- };
7
- export = classNames;
@@ -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,7 +0,0 @@
1
- .inputAuto {
2
- border-bottom: 1px solid rgba(128, 128, 128, 0.23);
3
- }
4
-
5
- .active {
6
- border-bottom: 1px solid rgb(128, 177, 255);
7
- }
@@ -1,6 +0,0 @@
1
- import globalClassNames from '../../../../../style.d';
2
- declare const classNames: typeof globalClassNames & {
3
- readonly inputAuto: 'inputAuto';
4
- readonly active: 'active';
5
- };
6
- export = classNames;
@@ -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
- });