jamis
Version:
一种支持通过JSON配置方式生成页面的组件库
77 lines (76 loc) • 3.29 kB
TypeScript
import React from 'react';
import type { ControllerStateAndHelpers } from 'downshift';
import type { Option } from 'jamis-core';
import type { SelectCompProps } from '../../types';
interface SelectState {
itemHeight: number;
isOpen: boolean;
isFocused: boolean;
inputValue: string;
highlightedIndex: number;
selection: Array<Option>;
pickerSelectItem: any;
loading?: boolean;
/** 最终的popover的位置信息 */
activePosition: 'top' | 'bottom';
}
export declare class SelectComp extends React.Component<SelectCompProps, SelectState> {
static defaultProps: Partial<SelectCompProps>;
input: HTMLInputElement;
target: HTMLElement;
menu: React.RefObject<HTMLDivElement>;
/** 显示在outer里的options数据 */
filtedOptions: Option[];
/** 是否保留搜索结果 */
keepSearchOptions: boolean;
handleInputChange: (evt: React.ChangeEvent<HTMLInputElement>) => void;
constructor(props: SelectCompProps);
componentDidUpdate(prevProps: SelectCompProps, prevState: SelectState): void;
open: () => void;
close: () => void;
confirm: () => void;
toggle: (e?: React.MouseEvent<HTMLDivElement>) => void;
onFocus: (e: any) => void;
onBlur: (e: any) => void;
/**
* 输入框键盘按下
*/
onKeyDownAtInput: (event: any) => void;
focus: () => void;
blur: () => void;
getTarget: () => HTMLElement;
inputRef: (ref: HTMLInputElement) => void;
toggleCheckAll: () => void;
removeItem(index: number, e?: React.MouseEvent<HTMLElement>): void;
handleInputChangeWrap: (searchDelay?: number | boolean) => (evt: React.ChangeEvent<HTMLInputElement>) => void;
handlePickerChange: (selectItem: any, index: number, confirm?: boolean) => void;
handleChange: (selectItem: Option) => void;
handleStateChange: ({ type }: {
type: string;
}) => void;
handleKeyPress: (e: React.KeyboardEvent) => void;
clearValue: (e: React.MouseEvent<any>) => void;
clearSearchValue: () => void;
handleAddClick: () => void;
handleEditClick: (e: Event, item: Option) => void;
handleDeleteClick: (e: Event, item: Option) => Promise<void>;
renderSelectValue: (item: Option, itemIndex: number, { showClose, onClick, className }: {
className?: string;
showClose?: boolean;
onClick?: (e: React.MouseEvent) => void;
}) => JSX.Element;
renderValue(_options: ControllerStateAndHelpers<any>): (string | JSX.Element)[];
renderSearchInput(inPopup?: boolean): JSX.Element;
/**
* 渲染单个选项
*/
renderOptionItem: ({ selectedItem, getItemProps }: Pick<ControllerStateAndHelpers<Option>, "selectedItem" | "getItemProps">, filtedOptions: Option[], enableVirtualRender: boolean) => ({ index, style }: {
index: number;
style?: Record<string, any>;
}) => JSX.Element | null;
renderOuter({ selectedItem, getItemProps, highlightedIndex, inputValue, isOpen }: ControllerStateAndHelpers<Option>): JSX.Element;
renderArrowIcon: () => JSX.Element | null;
render(): JSX.Element;
}
export { SelectComp as Select };
export declare const SelectWithRemoteOptions: React.ForwardRefExoticComponent<Pick<SelectCompProps, keyof SelectCompProps> & React.RefAttributes<unknown>>;