Skip to content

Commit b7981fb

Browse files
committed
fix node-title.tsx
1 parent 592c0a5 commit b7981fb

30 files changed

Lines changed: 896 additions & 2292 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import React from 'react';
2+
import {Modal} from 'antd';
3+
import {ScriptType,GroovyVariableMapping} from '@/components/design-editor/typings/script';
4+
5+
6+
export interface GroovyScriptModalProps {
7+
open: boolean;
8+
/** 脚本类型 */
9+
scriptType: ScriptType;
10+
/** 当前脚本 */
11+
script: string;
12+
/** 变量映射列表 */
13+
variables: GroovyVariableMapping[];
14+
/** 确认回调 */
15+
onConfirm: (script: string) => void;
16+
/** 取消回调 */
17+
onCancel: () => void;
18+
/** 弹框标题 */
19+
title?: string;
20+
/** 自定义内容组件(可选) */
21+
content:React.ComponentType<GroovyScriptContent>;
22+
}
23+
24+
25+
export interface GroovyScriptContent {
26+
/** 脚本类型 */
27+
type: ScriptType;
28+
/** 当前脚本 */
29+
content: string;
30+
/** 变量映射列表 */
31+
variables: GroovyVariableMapping[];
32+
/** 确认回调 */
33+
onChange: (script: string) => void;
34+
}
35+
36+
interface GroovyScriptContentComponentAction{
37+
handleConfirm: () => void;
38+
}
39+
40+
interface GroovyScriptContentComponentProps extends GroovyScriptModalProps{
41+
actionRef:React.Ref<GroovyScriptContentComponentAction>;
42+
}
43+
44+
const GroovyScriptContentComponent: React.FC<GroovyScriptContentComponentProps> = (props) => {
45+
const [content, setContent] = React.useState(props.script);
46+
const GroovyContent = props.content;
47+
48+
React.useImperativeHandle(props.actionRef,()=>{
49+
return {
50+
handleConfirm:() => {
51+
props.onConfirm(content);
52+
props.onCancel();
53+
}
54+
}
55+
},[content]);
56+
57+
return (
58+
<GroovyContent
59+
type={props.scriptType}
60+
content={content}
61+
variables={props.variables}
62+
onChange={setContent}
63+
/>
64+
)
65+
}
66+
67+
/**
68+
* 通用脚本配置弹框
69+
* 支持普通模式和高级模式切换
70+
*/
71+
export const GroovyScriptModal: React.FC<GroovyScriptModalProps> = (props) => {
72+
73+
const actionRef = React.useRef<GroovyScriptContentComponentAction>(null);
74+
75+
const handleOk = () => {
76+
if (actionRef.current) {
77+
actionRef.current.handleConfirm();
78+
}
79+
}
80+
81+
return (
82+
<Modal
83+
title={props.title}
84+
open={props.open}
85+
onCancel={props.onCancel}
86+
onOk={handleOk}
87+
width={800}
88+
okText="确认"
89+
cancelText="取消"
90+
destroyOnHidden={true}
91+
>
92+
<GroovyScriptContentComponent
93+
{...props}
94+
actionRef={actionRef}
95+
/>
96+
</Modal>
97+
);
98+
};
99+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React from "react";
2+
3+
interface GroovyScriptPreviewProps {
4+
value: string;
5+
// 多行
6+
multiline?: boolean;
7+
}
8+
9+
export const GroovyScriptPreview: React.FC<GroovyScriptPreviewProps> = (props) => {
10+
const value = props.value;
11+
12+
const multiline = props.multiline || false;
13+
14+
return (
15+
<>
16+
{multiline && (
17+
<div
18+
style={{
19+
minHeight: '45px',
20+
padding: '4px 11px',
21+
border: '1px solid #d9d9d9',
22+
borderRadius: '6px 0 0 6px',
23+
backgroundColor: value ? '#fff' : '#fafafa',
24+
color: value ? 'rgba(0,0,0,0.88)' : 'rgba(0,0,0,0.25)',
25+
}}
26+
>
27+
{value}
28+
</div>
29+
)}
30+
31+
{!multiline && (
32+
<div
33+
style={{
34+
flex: 1,
35+
padding: '4px 11px',
36+
backgroundColor: value ? '#fff' : '#fafafa',
37+
border: '1px solid #d9d9d9',
38+
borderRadius: '6px 0 0 6px',
39+
color: value ? 'rgba(0,0,0,0.88)' : 'rgba(0,0,0,0.25)',
40+
whiteSpace: 'nowrap',
41+
overflow: 'hidden',
42+
textOverflow: 'ellipsis',
43+
}}
44+
>
45+
{value}
46+
</div>
47+
)}
48+
</>
49+
50+
)
51+
}

0 commit comments

Comments
 (0)