feat(custom-request): improve x button of variable (#2829)
* fix: revert the modal style * feat: improve x button of variable
This commit is contained in:
parent
0c99c81c93
commit
df552619dd
@ -333,7 +333,16 @@ export function Input(props) {
|
|||||||
changeOnSelect={changeOnSelect}
|
changeOnSelect={changeOnSelect}
|
||||||
fieldNames={fieldNames}
|
fieldNames={fieldNames}
|
||||||
>
|
>
|
||||||
{button ?? <XButton type={variable ? 'primary' : 'default'} />}
|
{button ?? (
|
||||||
|
<XButton
|
||||||
|
className={css(`
|
||||||
|
&:not(:hover) {
|
||||||
|
border-left-color: transparent;
|
||||||
|
}
|
||||||
|
`)}
|
||||||
|
type={variable ? 'primary' : 'default'}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Cascader>
|
</Cascader>
|
||||||
) : null}
|
) : null}
|
||||||
</Space.Compact>,
|
</Space.Compact>,
|
||||||
|
@ -2,7 +2,23 @@ import React from 'react';
|
|||||||
|
|
||||||
import { Input } from '../input';
|
import { Input } from '../input';
|
||||||
import { RawTextArea } from './RawTextArea';
|
import { RawTextArea } from './RawTextArea';
|
||||||
|
import { css } from '@emotion/css';
|
||||||
|
|
||||||
export function JSONInput(props) {
|
export function JSONInput(props) {
|
||||||
return <RawTextArea {...props} component={Input.JSON} />;
|
return (
|
||||||
|
<div>
|
||||||
|
<RawTextArea
|
||||||
|
buttonClass={css`
|
||||||
|
&:not(:hover) {
|
||||||
|
border-right-color: transparent;
|
||||||
|
border-top-color: transparent;
|
||||||
|
}
|
||||||
|
background-color: transparent;
|
||||||
|
`}
|
||||||
|
{...props}
|
||||||
|
component={Input.JSON}
|
||||||
|
/>
|
||||||
|
;
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ function setNativeInputValue(input, value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function RawTextArea(props): JSX.Element {
|
export function RawTextArea(props): JSX.Element {
|
||||||
|
console.log('🚀 ~ file: RawTextArea.tsx:20 ~ RawTextArea ~ props:', props);
|
||||||
const inputRef = useRef<any>(null);
|
const inputRef = useRef<any>(null);
|
||||||
const { changeOnSelect, component: Component = Input.TextArea, ...others } = props;
|
const { changeOnSelect, component: Component = Input.TextArea, ...others } = props;
|
||||||
const scope = typeof props.scope === 'function' ? props.scope() : props.scope;
|
const scope = typeof props.scope === 'function' ? props.scope() : props.scope;
|
||||||
@ -58,6 +59,17 @@ export function RawTextArea(props): JSX.Element {
|
|||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
<VariableSelect
|
<VariableSelect
|
||||||
|
className={
|
||||||
|
props.buttonClass ??
|
||||||
|
css`
|
||||||
|
&:not(:hover) {
|
||||||
|
border-right-color: transparent;
|
||||||
|
border-top-color: transparent;
|
||||||
|
border-bottom-color: transparent;
|
||||||
|
}
|
||||||
|
background-color: transparent;
|
||||||
|
`
|
||||||
|
}
|
||||||
fieldNames={props.fieldNames}
|
fieldNames={props.fieldNames}
|
||||||
options={options}
|
options={options}
|
||||||
setOptions={setOptions}
|
setOptions={setOptions}
|
||||||
|
@ -391,7 +391,20 @@ export function TextArea(props) {
|
|||||||
dangerouslySetInnerHTML={{ __html: html }}
|
dangerouslySetInnerHTML={{ __html: html }}
|
||||||
/>
|
/>
|
||||||
{!disabled ? (
|
{!disabled ? (
|
||||||
<VariableSelect options={options} setOptions={setOptions} onInsert={onInsert} changeOnSelect={changeOnSelect} />
|
<VariableSelect
|
||||||
|
className={css`
|
||||||
|
&:not(:hover) {
|
||||||
|
border-right-color: transparent;
|
||||||
|
border-top-color: transparent;
|
||||||
|
// border-bottom-color: transparent;
|
||||||
|
}
|
||||||
|
background-color: transparent;
|
||||||
|
`}
|
||||||
|
options={options}
|
||||||
|
setOptions={setOptions}
|
||||||
|
onInsert={onInsert}
|
||||||
|
changeOnSelect={changeOnSelect}
|
||||||
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</Input.Group>,
|
</Input.Group>,
|
||||||
);
|
);
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { cx } from '@emotion/css';
|
import { cx } from '@emotion/css';
|
||||||
import { Button, Cascader } from 'antd';
|
import { Cascader } from 'antd';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useToken } from '../__builtins__';
|
import { useToken } from '../__builtins__';
|
||||||
import useStyles from './VariableSelect.style';
|
import useStyles from './VariableSelect.style';
|
||||||
|
import { XButton } from './XButton';
|
||||||
|
|
||||||
export function VariableSelect({
|
export function VariableSelect({
|
||||||
options,
|
options,
|
||||||
@ -11,6 +12,7 @@ export function VariableSelect({
|
|||||||
onInsert,
|
onInsert,
|
||||||
changeOnSelect = false,
|
changeOnSelect = false,
|
||||||
fieldNames = {},
|
fieldNames = {},
|
||||||
|
className,
|
||||||
}): JSX.Element {
|
}): JSX.Element {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [selectedVar, setSelectedVar] = useState<string[]>([]);
|
const [selectedVar, setSelectedVar] = useState<string[]>([]);
|
||||||
@ -26,8 +28,7 @@ export function VariableSelect({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return wrapSSR(
|
return wrapSSR(
|
||||||
<Button className={cx('x-button', componentCls, hashId)}>
|
<XButton className={cx('x-button', componentCls, hashId, className)}>
|
||||||
<span className={'variable-btn'}>x</span>
|
|
||||||
<Cascader
|
<Cascader
|
||||||
placeholder={t('Select a variable')}
|
placeholder={t('Select a variable')}
|
||||||
value={[]}
|
value={[]}
|
||||||
@ -75,6 +76,6 @@ export function VariableSelect({
|
|||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</Button>,
|
</XButton>,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
|
import { css } from '@emotion/css';
|
||||||
import { Button, ButtonProps } from 'antd';
|
import { Button, ButtonProps } from 'antd';
|
||||||
|
import { cx } from 'antd-style';
|
||||||
import React, { forwardRef, useMemo } from 'react';
|
import React, { forwardRef, useMemo } from 'react';
|
||||||
|
|
||||||
export const XButton = forwardRef((props: ButtonProps, ref: any) => {
|
export const XButton = forwardRef((props: ButtonProps, ref: any) => {
|
||||||
@ -11,7 +13,7 @@ export const XButton = forwardRef((props: ButtonProps, ref: any) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Button ref={ref} style={style} {...props}>
|
<Button ref={ref} style={style} {...props}>
|
||||||
x
|
x{props.children}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -895,10 +895,6 @@ SchemaSettings.ActionModalItem = React.memo((props: any) => {
|
|||||||
<Modal
|
<Modal
|
||||||
width={'50%'}
|
width={'50%'}
|
||||||
title={compile(title)}
|
title={compile(title)}
|
||||||
bodyStyle={{
|
|
||||||
maxHeight: '70vh',
|
|
||||||
overflowY: 'scroll',
|
|
||||||
}}
|
|
||||||
{...others}
|
{...others}
|
||||||
destroyOnClose
|
destroyOnClose
|
||||||
open={visible}
|
open={visible}
|
||||||
|
Loading…
Reference in New Issue
Block a user