-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: optimize code of flow (#1817)
- Loading branch information
Showing
9 changed files
with
173 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export * from "./select"; | ||
export * from "./cascader"; | ||
export * from "./textarea"; | ||
export * from "./slider"; | ||
export * from "./timePicker"; | ||
export * from "./treeSelect"; | ||
export * from './select'; | ||
export * from './cascader'; | ||
export * from './textarea'; | ||
export * from './slider'; | ||
export * from './timePicker'; | ||
export * from './treeSelect'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
import { IFlowNodeParameter } from "@/types/flow"; | ||
import { Select } from "antd"; | ||
import { IFlowNodeParameter } from '@/types/flow'; | ||
import { Select } from 'antd'; | ||
|
||
type SelectProps = { | ||
data: IFlowNodeParameter; | ||
defaultValue: any; | ||
onChange: (value: any) => void; | ||
} | ||
}; | ||
|
||
export const RenderSelect = (params: SelectProps) => { | ||
const { data, defaultValue, onChange } = params; | ||
|
||
return data.options?.length > 0 && ( | ||
<Select | ||
className="w-full nodrag" | ||
defaultValue={defaultValue} | ||
options={data.options.map((item: any) => ({ label: item.label, value: item.value }))} | ||
onChange={onChange} | ||
/> | ||
) | ||
} | ||
return ( | ||
data.options?.length > 0 && ( | ||
<Select | ||
className="w-full nodrag" | ||
defaultValue={defaultValue} | ||
options={data.options.map((item: any) => ({ label: item.label, value: item.value }))} | ||
onChange={onChange} | ||
/> | ||
) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,38 @@ | ||
import { IFlowNodeParameter } from "@/types/flow"; | ||
import { IFlowNodeParameter } from '@/types/flow'; | ||
import { Col, InputNumber, Row, Slider, Space } from 'antd'; | ||
import { uiAtrrtUnderlineToHump } from '@/utils/flow' | ||
import type { InputNumberProps } from 'antd'; | ||
import React, { useState } from 'react'; | ||
|
||
|
||
type TextAreaProps = { | ||
data: IFlowNodeParameter; | ||
defaultValue: any; | ||
onChange: (value: any) => void; | ||
} | ||
|
||
|
||
|
||
}; | ||
|
||
export const RenderSlider = (params: TextAreaProps) => { | ||
const { data, defaultValue, onChange } = params; | ||
const { data, defaultValue, onChange } = params; | ||
|
||
const [inputValue, setInputValue] = useState(defaultValue); | ||
|
||
const [inputValue, setInputValue] = useState(defaultValue); | ||
const onChangeSlider: InputNumberProps['onChange'] = (newValue) => { | ||
setInputValue(newValue as number); | ||
onChange(newValue as number); | ||
}; | ||
|
||
const onChangeSlider: InputNumberProps['onChange'] = (newValue) => { | ||
setInputValue(newValue as number); | ||
onChange(newValue as number) | ||
}; | ||
return ( | ||
<> | ||
{data?.ui?.show_input ? <Row> | ||
<Col span={12}> | ||
<Slider | ||
{...data.ui.attr} | ||
onChange={onChangeSlider} | ||
value={typeof inputValue === 'number' ? inputValue : 0} | ||
/> | ||
</Col> | ||
<Col span={4}> | ||
<InputNumber | ||
{...data.ui.attr} | ||
style={{ margin: '0 16px' }} | ||
value={inputValue} | ||
onChange={onChangeSlider} | ||
/> | ||
</Col> | ||
</Row>: | ||
<Slider | ||
{...data.ui.attr} | ||
onChange={onChangeSlider} | ||
value={typeof inputValue === 'number' ? inputValue : 0} | ||
/> | ||
} | ||
{data?.ui?.show_input ? ( | ||
<Row> | ||
<Col span={12}> | ||
<Slider {...data.ui.attr} onChange={onChangeSlider} value={typeof inputValue === 'number' ? inputValue : 0} /> | ||
</Col> | ||
<Col span={4}> | ||
<InputNumber {...data.ui.attr} style={{ margin: '0 16px' }} value={inputValue} onChange={onChangeSlider} /> | ||
</Col> | ||
</Row> | ||
) : ( | ||
<Slider {...data.ui.attr} onChange={onChangeSlider} value={typeof inputValue === 'number' ? inputValue : 0} /> | ||
)} | ||
</> | ||
) | ||
} | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,36 @@ | ||
import { IFlowNodeParameter } from "@/types/flow"; | ||
import { IFlowNodeParameter } from '@/types/flow'; | ||
import { Col, InputNumber, Row, Slider, Space } from 'antd'; | ||
import { uiAtrrtUnderlineToHump } from '@/utils/flow' | ||
import type { InputNumberProps } from 'antd'; | ||
import React, { useState } from 'react'; | ||
|
||
|
||
type TextAreaProps = { | ||
data: IFlowNodeParameter; | ||
defaultValue: any; | ||
onChange: (value: any) => void; | ||
} | ||
|
||
|
||
|
||
}; | ||
|
||
export const RenderSlider = (params: TextAreaProps) => { | ||
const { data, defaultValue, onChange } = params; | ||
|
||
const [inputValue, setInputValue] = useState(defaultValue); | ||
const { data, defaultValue, onChange } = params; | ||
const [inputValue, setInputValue] = useState(defaultValue); | ||
|
||
const onChangeSlider: InputNumberProps['onChange'] = (newValue) => { | ||
setInputValue(newValue as number); | ||
onChange(newValue as number) | ||
}; | ||
const onChangeSlider: InputNumberProps['onChange'] = (newValue) => { | ||
setInputValue(newValue as number); | ||
onChange(newValue as number); | ||
}; | ||
return ( | ||
<> | ||
{data?.ui?.show_input ? <Row> | ||
<Col span={12}> | ||
<Slider | ||
{...data.ui.attr} | ||
onChange={onChangeSlider} | ||
value={typeof inputValue === 'number' ? inputValue : 0} | ||
/> | ||
</Col> | ||
<Col span={4}> | ||
<InputNumber | ||
{...data.ui.attr} | ||
style={{ margin: '0 16px' }} | ||
value={inputValue} | ||
onChange={onChangeSlider} | ||
/> | ||
</Col> | ||
</Row>: | ||
<Slider | ||
{...data.ui.attr} | ||
onChange={onChangeSlider} | ||
value={typeof inputValue === 'number' ? inputValue : 0} | ||
/> | ||
} | ||
{data?.ui?.show_input ? ( | ||
<Row> | ||
<Col span={12}> | ||
<Slider {...data.ui.attr} onChange={onChangeSlider} value={typeof inputValue === 'number' ? inputValue : 0} /> | ||
</Col> | ||
<Col span={4}> | ||
<InputNumber {...data.ui.attr} style={{ margin: '0 16px' }} value={inputValue} onChange={onChangeSlider} /> | ||
</Col> | ||
</Row> | ||
) : ( | ||
<Slider {...data.ui.attr} onChange={onChangeSlider} value={typeof inputValue === 'number' ? inputValue : 0} /> | ||
)} | ||
</> | ||
) | ||
} | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,18 @@ | ||
import { IFlowNodeParameter } from "@/types/flow"; | ||
import { IFlowNodeParameter } from '@/types/flow'; | ||
import { Input } from 'antd'; | ||
import { uiAtrrtUnderlineToHump } from '@/utils/flow' | ||
import { uiAtrrtUnderlineToHump } from '@/utils/flow'; | ||
|
||
const { TextArea } = Input; | ||
|
||
type TextAreaProps = { | ||
data: IFlowNodeParameter; | ||
defaultValue: any; | ||
onChange: (value: any) => void; | ||
} | ||
|
||
}; | ||
|
||
export const RenderTextArea = (params: TextAreaProps) => { | ||
const { data, defaultValue, onChange } = params; | ||
if(data?.ui?.autosize){ | ||
uiAtrrtUnderlineToHump(data.ui.autosize) | ||
} | ||
return ( | ||
<TextArea {...data.ui.attr} defaultValue={defaultValue} onChange={(e) => onChange(e.target.value)} {...data.ui.autosize} rows={4} /> | ||
) | ||
} | ||
uiAtrrtUnderlineToHump(data?.ui?.attr?.autosize || {}); | ||
|
||
return <TextArea {...data.ui.attr} defaultValue={defaultValue} onChange={(e) => onChange(e.target.value)} {...data.ui.autosize} rows={4} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,23 @@ | ||
import React, { useState } from 'react'; | ||
import type { TimePickerProps } from 'antd'; | ||
import { TimePicker } from 'antd'; | ||
|
||
|
||
import { IFlowNodeParameter } from "@/types/flow"; | ||
import { IFlowNodeParameter } from '@/types/flow'; | ||
|
||
type TextAreaProps = { | ||
data: IFlowNodeParameter; | ||
defaultValue: any; | ||
onChange: (value: any) => void; | ||
} | ||
data: IFlowNodeParameter; | ||
defaultValue: any; | ||
onChange: (value: any) => void; | ||
}; | ||
export const RenderTimePicker = (params: TextAreaProps) => { | ||
const { data, defaultValue, onChange } = params; | ||
const [value, setValue] = useState(defaultValue); | ||
|
||
// dayjs.extend(customParseFormat); | ||
const { data, defaultValue, onChange } = params; | ||
const [value, setValue] = useState(defaultValue); | ||
|
||
const onChangeTime: TimePickerProps['onChange'] = (time, timeString) => { | ||
// console.log(timeString); | ||
onChange(timeString) | ||
setValue(time) | ||
}; | ||
// dayjs.extend(customParseFormat); | ||
|
||
return ( | ||
<TimePicker | ||
style={{ width: '100%' }} | ||
{...data.ui.attr} value={value} | ||
onChange={onChangeTime} /> | ||
) | ||
|
||
const onChangeTime: TimePickerProps['onChange'] = (time, timeString) => { | ||
onChange(timeString); | ||
setValue(time); | ||
}; | ||
|
||
} | ||
return <TimePicker style={{ width: '100%' }} {...data.ui.attr} value={value} onChange={onChangeTime} />; | ||
}; |
Oops, something went wrong.