@coding-flow/flow-design 0.0.45 → 0.0.47

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.
@@ -0,0 +1,2 @@
1
+ export declare const save: (body: any) => Promise<import("@coding-flow/flow-core").Response>;
2
+ export declare const getScript: (key: string) => Promise<import("@coding-flow/flow-core").Response>;
@@ -0,0 +1,6 @@
1
+ import { httpClient } from "./index.js";
2
+ const save = (body)=>httpClient.post('/api/cmd/node-view/save', body);
3
+ const getScript = (key)=>httpClient.get('/api/cmd/node-view/getScript', {
4
+ key
5
+ });
6
+ export { getScript, save };
@@ -1,30 +1,62 @@
1
- import { Fragment, jsx } from "react/jsx-runtime";
2
- import "react";
3
- import { Form, Input } from "antd";
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import react from "react";
3
+ import { Button, Form, Input, Space } from "antd";
4
4
  import { Field } from "@flowgram.ai/fixed-layout-editor";
5
+ import { BugOutlined } from "@ant-design/icons";
6
+ import { ViewCodeDrawer } from "../../../../script-components/components/view-code-drawer.js";
5
7
  const View = ()=>{
6
8
  const [form] = Form.useForm();
7
- return /*#__PURE__*/ jsx(Form, {
9
+ const [visible, setVisible] = react.useState(false);
10
+ return /*#__PURE__*/ jsxs(Form, {
8
11
  form: form,
9
12
  style: {
10
13
  width: '100%'
11
14
  },
12
15
  layout: "vertical",
13
- children: /*#__PURE__*/ jsx(Form.Item, {
14
- label: "视图名称",
15
- name: [
16
- "view"
17
- ],
18
- children: /*#__PURE__*/ jsx(Field, {
19
- name: "view",
16
+ children: [
17
+ /*#__PURE__*/ jsx(Form.Item, {
18
+ label: "视图名称",
19
+ name: [
20
+ "view"
21
+ ],
22
+ children: /*#__PURE__*/ jsx(Field, {
23
+ name: "view",
24
+ render: ({ field: { value, onChange } })=>/*#__PURE__*/ jsx(Fragment, {
25
+ children: /*#__PURE__*/ jsxs(Space.Compact, {
26
+ style: {
27
+ width: '100%'
28
+ },
29
+ children: [
30
+ /*#__PURE__*/ jsx(Input, {
31
+ value: value,
32
+ onChange: onChange
33
+ }),
34
+ /*#__PURE__*/ jsx(Button, {
35
+ icon: /*#__PURE__*/ jsx(BugOutlined, {}),
36
+ onClick: ()=>{
37
+ setVisible(true);
38
+ },
39
+ style: {
40
+ borderRadius: '0 6px 6px 0'
41
+ },
42
+ children: "代码"
43
+ })
44
+ ]
45
+ })
46
+ })
47
+ })
48
+ }),
49
+ /*#__PURE__*/ jsx(Field, {
50
+ name: "code",
20
51
  render: ({ field: { value, onChange } })=>/*#__PURE__*/ jsx(Fragment, {
21
- children: /*#__PURE__*/ jsx(Input, {
22
- value: value,
23
- onChange: onChange
52
+ children: /*#__PURE__*/ jsx(ViewCodeDrawer, {
53
+ code: value,
54
+ visible: visible,
55
+ onClose: ()=>setVisible(false)
24
56
  })
25
57
  })
26
58
  })
27
- })
59
+ ]
28
60
  });
29
61
  };
30
62
  export { View };
@@ -14,6 +14,7 @@ class NodeConvertorManager {
14
14
  order: node.order,
15
15
  actions: node.actions,
16
16
  script: node.script,
17
+ code: node.code,
17
18
  view: node.view,
18
19
  display: node.display,
19
20
  ...this.toStrategyRender(node)
@@ -33,6 +34,7 @@ class NodeConvertorManager {
33
34
  name: data?.title,
34
35
  order: data?.order ? data?.order + '' : '0',
35
36
  view: data?.view,
37
+ code: data?.code,
36
38
  actions: data?.actions || [],
37
39
  strategies: this.toStrategyData(data),
38
40
  script: data?.script,
@@ -26,6 +26,7 @@ export interface FlowNode {
26
26
  strategies: any[];
27
27
  blocks?: FlowNode[];
28
28
  script?: string;
29
+ code?: string;
29
30
  view?: string;
30
31
  display?: boolean;
31
32
  }
@@ -17,6 +17,7 @@ const GroovyCodeEditor = (props)=>{
17
17
  ]);
18
18
  return /*#__PURE__*/ jsx(ScriptCodeEditor, {
19
19
  title: title,
20
+ language: "groovy",
20
21
  toolbar: props.toolbar,
21
22
  value: props.value,
22
23
  onChange: props.onChange,
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { ToolbarItem } from '@coding-script/script-engine';
3
+ interface JavaScriptCodeEditorProps {
4
+ title?: string;
5
+ value?: string;
6
+ toolbar?: ToolbarItem[];
7
+ scriptKey?: string;
8
+ readonly?: boolean;
9
+ onChange?: (value: string) => void;
10
+ onCompile?: (code: string) => void;
11
+ resetScript?: () => string;
12
+ placeholder?: string;
13
+ theme?: 'dark' | 'light';
14
+ options?: {
15
+ fontSize?: number;
16
+ minHeight?: number;
17
+ maxHeight?: number;
18
+ };
19
+ }
20
+ export declare const JavaScriptCodeEditor: React.FC<JavaScriptCodeEditorProps>;
21
+ export {};
@@ -0,0 +1,25 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import "react";
3
+ import { ScriptCodeEditor } from "@coding-script/script-engine";
4
+ const JavaScriptCodeEditor = (props)=>{
5
+ const title = props.title || "javscript脚本编辑器";
6
+ return /*#__PURE__*/ jsx(ScriptCodeEditor, {
7
+ title: title,
8
+ language: "javascript",
9
+ toolbar: props.toolbar,
10
+ value: props.value,
11
+ onChange: props.onChange,
12
+ placeholder: props.placeholder,
13
+ readonly: props.readonly,
14
+ options: props.options,
15
+ defaultTheme: props.theme || 'light',
16
+ enableCompile: false,
17
+ enableFormat: false,
18
+ enableFullscreen: true,
19
+ enableThemeToggle: true,
20
+ onCompile: (code)=>{
21
+ props.onCompile?.(code);
22
+ }
23
+ });
24
+ };
25
+ export { JavaScriptCodeEditor };
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ interface ViewCodeDrawerProps {
3
+ visible: boolean;
4
+ onClose: () => void;
5
+ code: string;
6
+ }
7
+ export declare const ViewCodeDrawer: React.FC<ViewCodeDrawerProps>;
8
+ export {};
@@ -0,0 +1,62 @@
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ import { getScript, save } from "../../api/node-view.js";
3
+ import { JavaScriptCodeEditor } from "../../components/js-code/index.js";
4
+ import { Button, Drawer, message } from "antd";
5
+ import react from "react";
6
+ const JavaScriptCodeContent = ({ code })=>{
7
+ const [script, setScript] = react.useState('');
8
+ react.useEffect(()=>{
9
+ if (code) getScript(code).then((res)=>{
10
+ setScript(res.data);
11
+ });
12
+ return ()=>{
13
+ setScript('');
14
+ };
15
+ }, [
16
+ code
17
+ ]);
18
+ const handleSave = ()=>{
19
+ save({
20
+ code,
21
+ script: script
22
+ }).then((res)=>{
23
+ message.success('保存成功');
24
+ });
25
+ };
26
+ return /*#__PURE__*/ jsx(Fragment, {
27
+ children: /*#__PURE__*/ jsx(JavaScriptCodeEditor, {
28
+ value: script,
29
+ onChange: setScript,
30
+ toolbar: [
31
+ {
32
+ key: 'save',
33
+ title: '保存',
34
+ label: '保存代码',
35
+ backgroundColor: '#1890ff',
36
+ hoverBackgroundColor: '#40a9ff',
37
+ textColor: '#fff',
38
+ borderColor: '#1890ff',
39
+ onClick: ()=>{
40
+ handleSave();
41
+ }
42
+ }
43
+ ]
44
+ })
45
+ });
46
+ };
47
+ const ViewCodeDrawer = (props)=>/*#__PURE__*/ jsx(Drawer, {
48
+ closeIcon: false,
49
+ title: "视图代码",
50
+ open: props.visible,
51
+ onClose: props.onClose,
52
+ destroyOnHidden: true,
53
+ size: '100%',
54
+ extra: /*#__PURE__*/ jsx(Button, {
55
+ onClick: props.onClose,
56
+ children: "关闭"
57
+ }),
58
+ children: /*#__PURE__*/ jsx(JavaScriptCodeContent, {
59
+ code: props.code
60
+ })
61
+ });
62
+ export { ViewCodeDrawer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coding-flow/flow-design",
3
- "version": "0.0.45",
3
+ "version": "0.0.47",
4
4
  "description": "flow-engine design components ",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@ant-design/icons": "~6.1.0",
36
- "@coding-script/script-engine": "^0.0.7",
36
+ "@coding-script/script-engine": "^0.0.8",
37
37
  "@flowgram.ai/export-plugin": "1.0.8",
38
38
  "@flowgram.ai/fixed-layout-editor": "1.0.8",
39
39
  "@flowgram.ai/fixed-semi-materials": "1.0.8",
@@ -49,16 +49,16 @@
49
49
  "nanoid": "^5.1.6",
50
50
  "react-redux": "^9.2.0",
51
51
  "styled-components": "^5.3.11",
52
- "@coding-flow/flow-core": "0.0.45",
53
- "@coding-flow/flow-icons": "0.0.45",
54
- "@coding-flow/flow-types": "0.0.45",
55
- "@coding-flow/flow-pc-ui": "0.0.45"
52
+ "@coding-flow/flow-core": "0.0.47",
53
+ "@coding-flow/flow-types": "0.0.47",
54
+ "@coding-flow/flow-pc-ui": "0.0.47",
55
+ "@coding-flow/flow-icons": "0.0.47"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/lodash-es": "^4.17.12",
59
59
  "@types/styled-components": "^5.1.36",
60
- "@coding-flow/flow-core": "0.0.45",
61
- "@coding-flow/flow-types": "0.0.45"
60
+ "@coding-flow/flow-core": "0.0.47",
61
+ "@coding-flow/flow-types": "0.0.47"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "rslib build",