amis-rpc-design/node_modules/rc-mentions/lib/Mentions.d.ts
2023-10-07 19:42:30 +08:00

49 lines
1.9 KiB
TypeScript

import type { TextAreaProps } from 'rc-textarea';
import React from 'react';
import type { OptionProps } from './Option';
import Option from './Option';
import { filterOption as defaultFilterOption, validateSearch as defaultValidateSearch } from './util';
type BaseTextareaAttrs = Omit<TextAreaProps, 'prefix' | 'onChange' | 'onSelect' | 'allowClear' | 'showCount'>;
export type Placement = 'top' | 'bottom';
export type Direction = 'ltr' | 'rtl';
export interface DataDrivenOptionProps extends Omit<OptionProps, 'children'> {
label?: React.ReactNode;
}
export interface MentionsProps extends BaseTextareaAttrs {
autoFocus?: boolean;
className?: string;
defaultValue?: string;
notFoundContent?: React.ReactNode;
split?: string;
style?: React.CSSProperties;
transitionName?: string;
placement?: Placement;
direction?: Direction;
prefix?: string | string[];
prefixCls?: string;
value?: string;
filterOption?: false | typeof defaultFilterOption;
validateSearch?: typeof defaultValidateSearch;
onChange?: (text: string) => void;
onSelect?: (option: OptionProps, prefix: string) => void;
onSearch?: (text: string, prefix: string) => void;
onFocus?: React.FocusEventHandler<HTMLTextAreaElement>;
onBlur?: React.FocusEventHandler<HTMLTextAreaElement>;
getPopupContainer?: () => HTMLElement;
dropdownClassName?: string;
/** @private Testing usage. Do not use in prod. It will not work as your expect. */
open?: boolean;
children?: React.ReactNode;
options?: DataDrivenOptionProps[];
}
export interface MentionsRef {
focus: VoidFunction;
blur: VoidFunction;
/** @deprecated It may not work as expected */
textarea: HTMLTextAreaElement | null;
}
declare const Mentions: React.ForwardRefExoticComponent<MentionsProps & React.RefAttributes<MentionsRef>> & {
Option: typeof Option;
};
export default Mentions;