chore: allow space in backend parameters
This commit is contained in:
@@ -8,13 +8,14 @@ interface HintInputProps {
|
||||
onChange: (value: string) => void;
|
||||
onBlur?: (e: any) => void;
|
||||
placeholder?: string;
|
||||
trim?: boolean;
|
||||
sourceOptions?: Global.HintOptions[];
|
||||
}
|
||||
|
||||
const matchReg = /[^=]+=[^=]*$/;
|
||||
|
||||
const HintInput: React.FC<HintInputProps> = (props) => {
|
||||
const { value, label, onChange, onBlur, sourceOptions } = props;
|
||||
const { value, label, onChange, onBlur, sourceOptions, trim = true } = props;
|
||||
const cursorPosRef = React.useRef(0);
|
||||
const contextBeforeCursorRef = React.useRef('');
|
||||
const [options, setOptions] = React.useState<
|
||||
@@ -70,11 +71,7 @@ const HintInput: React.FC<HintInputProps> = (props) => {
|
||||
|
||||
const handleInput = (e: any) => {
|
||||
getContextBeforeCursor(e);
|
||||
onChange(e.target.value?.trim());
|
||||
};
|
||||
|
||||
const handleOnChange = (value: string) => {
|
||||
onChange(value?.trim());
|
||||
onChange(e.target.value);
|
||||
};
|
||||
|
||||
const handleOnSelect = (value: string) => {
|
||||
@@ -93,9 +90,10 @@ const HintInput: React.FC<HintInputProps> = (props) => {
|
||||
onBlur={onBlur}
|
||||
label={label}
|
||||
options={options}
|
||||
trim={trim}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default React.memo(HintInput);
|
||||
export default HintInput;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { useIntl } from '@umijs/max';
|
||||
import _ from 'lodash';
|
||||
import React from 'react';
|
||||
import Wrapper from '../label-selector/wrapper';
|
||||
@@ -12,13 +11,13 @@ interface ListInputProps {
|
||||
options?: Global.HintOptions[];
|
||||
placeholder?: string;
|
||||
labelExtra?: React.ReactNode;
|
||||
trim?: boolean;
|
||||
onChange: (data: string[]) => void;
|
||||
onBlur?: (e: any, index: number) => void;
|
||||
onDelete?: (index: number) => void;
|
||||
}
|
||||
|
||||
const ListInput: React.FC<ListInputProps> = (props) => {
|
||||
const intl = useIntl();
|
||||
const {
|
||||
dataList,
|
||||
label,
|
||||
@@ -28,7 +27,8 @@ const ListInput: React.FC<ListInputProps> = (props) => {
|
||||
onDelete,
|
||||
btnText,
|
||||
options,
|
||||
labelExtra
|
||||
labelExtra,
|
||||
trim = true
|
||||
} = props;
|
||||
const [list, setList] = React.useState<{ value: string; uid: number }[]>([]);
|
||||
const countRef = React.useRef(0);
|
||||
@@ -97,6 +97,7 @@ const ListInput: React.FC<ListInputProps> = (props) => {
|
||||
onBlur={(e) => onBlur?.(e, index)}
|
||||
onRemove={() => handleOnRemove(index)}
|
||||
onChange={(val) => handleOnChange(val, index)}
|
||||
trim={trim}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -13,10 +13,19 @@ interface LabelItemProps {
|
||||
label?: string;
|
||||
placeholder?: string;
|
||||
options?: Global.HintOptions[];
|
||||
trim?: boolean;
|
||||
}
|
||||
|
||||
const ListItem: React.FC<LabelItemProps> = (props) => {
|
||||
const { onRemove, onChange, onBlur, label, value, options } = props;
|
||||
const {
|
||||
onRemove,
|
||||
onChange,
|
||||
onBlur,
|
||||
label,
|
||||
value,
|
||||
options,
|
||||
trim = true
|
||||
} = props;
|
||||
|
||||
const handleOnChange = (value: any) => {
|
||||
onChange(value);
|
||||
@@ -30,6 +39,7 @@ const ListItem: React.FC<LabelItemProps> = (props) => {
|
||||
onBlur={onBlur}
|
||||
label={label}
|
||||
sourceOptions={options}
|
||||
trim={trim}
|
||||
placeholder={props.placeholder}
|
||||
/>
|
||||
<Button
|
||||
@@ -44,4 +54,4 @@ const ListItem: React.FC<LabelItemProps> = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default React.memo(ListItem);
|
||||
export default ListItem;
|
||||
|
||||
@@ -90,6 +90,14 @@ const SealAutoComplete: React.FC<
|
||||
const handleOnSelect = (value: any, option: any) => {
|
||||
onSelect?.(value, option);
|
||||
};
|
||||
|
||||
const handleOnInput = (e: any) => {
|
||||
if (trim) {
|
||||
e.target.value = e.target.value?.trim();
|
||||
}
|
||||
props.onInput?.(e);
|
||||
};
|
||||
|
||||
const renderAfter = () => {
|
||||
if (loading) {
|
||||
return (
|
||||
@@ -123,6 +131,7 @@ const SealAutoComplete: React.FC<
|
||||
>
|
||||
<AutoComplete
|
||||
{...rest}
|
||||
trim={trim}
|
||||
ref={inputRef}
|
||||
placeholder={
|
||||
isFocus || !label ? (
|
||||
@@ -141,6 +150,7 @@ const SealAutoComplete: React.FC<
|
||||
onSearch={handleSearch}
|
||||
onChange={handleChange}
|
||||
popupRender={popupRender}
|
||||
onInput={handleOnInput}
|
||||
></AutoComplete>
|
||||
</Wrapper>
|
||||
</SelectWrapper>
|
||||
|
||||
@@ -39,6 +39,7 @@ const BackendParametersList: React.FC = () => {
|
||||
return (
|
||||
<Form.Item<FormData> name="backend_parameters">
|
||||
<ListInput
|
||||
trim={false}
|
||||
placeholder={
|
||||
backendParamsHolderTips[backend]
|
||||
? intl.formatMessage({
|
||||
|
||||
Reference in New Issue
Block a user