mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-05 19:08:38 +08:00
### What problem does this PR solve? Feat: Globally defined conversation variables can be selected in the operator's query variables. #10427 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
24 lines
769 B
TypeScript
24 lines
769 B
TypeScript
import { Input, InputProps } from '@/components/ui/input';
|
|
import { ChangeEvent, forwardRef, useCallback } from 'react';
|
|
|
|
type KeyInputProps = {
|
|
value?: string;
|
|
onChange?: (value: string) => void;
|
|
searchValue?: string | RegExp;
|
|
} & Omit<InputProps, 'onChange'>;
|
|
|
|
export const KeyInput = forwardRef<HTMLInputElement, KeyInputProps>(
|
|
function KeyInput({ value, onChange, searchValue = /[^a-zA-Z0-9_]/g }, ref) {
|
|
const handleChange = useCallback(
|
|
(e: ChangeEvent<HTMLInputElement>) => {
|
|
const value = e.target.value ?? '';
|
|
const filteredValue = value.replace(searchValue, '');
|
|
onChange?.(filteredValue);
|
|
},
|
|
[onChange, searchValue],
|
|
);
|
|
|
|
return <Input value={value} onChange={handleChange} ref={ref} />;
|
|
},
|
|
);
|