mobile-more
Version:
基于 antd-mobile v5 扩展移动端 UI 组件
109 lines (108 loc) • 3.42 kB
TypeScript
import { CheckListProps, EmptyProps, SearchBarProps } from 'antd-mobile';
import * as React from 'react';
import { BizPopupProps } from '../BizPopup';
import './index.less';
type Option = {
label?: React.ReactNode;
value?: string;
readOnly?: boolean;
disabled?: boolean;
[key: string]: any;
};
export interface BizCheckListPopupProps extends BizPopupProps, Pick<CheckListProps, 'multiple'> {
/**
* @description 默认值。非受控生效。
*/
defaultValue?: string | string[];
/**
* @description 选中项。
*/
value?: any;
/**
* @description 选中项改变时触发。
* @param value 选择项。
* @returns
*/
onChange?: (value: any) => void;
/**
* @description 触发 onChange 后是否关闭弹层。仅在单选模式下且有值时生效。
*/
changeClosable?: boolean;
/**
* @description 自定义列表项渲染。
* @param option 选项。
* @returns
*/
renderLabel?: (option: Option) => React.ReactNode;
/**
* @description 可选项。
*/
options?: Option[];
/**
* @description 根据搜索内容过滤可选项。默认根据 `value` 和 `label` 模糊匹配。
* @param searchValue 搜索值。
* @param option 选项。
* @returns
*/
filterOption?: (searchValue: string, option: Option) => boolean;
/**
* @description 自定义字段名。
*/
fieldNames?: {
label?: string;
value?: string;
readOnly?: string;
disabled?: string;
};
/**
* @description 显示搜索框。如果为 `true`,浮层高度会固定 `70vh`,避免搜索过程中浮层高度不定问题,可以通过 `bodyStyle` 修改高度。
* @default false
*/
showSearch?: boolean;
/**
* @description 搜索值。如果有值表示为受控。
*/
searchValue?: string;
/**
* @description 搜索内容变化时触发。
* @param value 搜索值。
* @returns
*/
onSearch?: (value: string) => void;
/**
* @description 加载中。
* @default false
*/
loading?: boolean;
/**
* @description 单选模式,不允许取消选择。仅在 `multiple=false` 时生效。
* @default true
*/
radioMode?: boolean;
/**
* @description 勾选列表属性。
* @see {@link https://mobile.ant.design/zh/components/check-list#checklist|CheckListProps}
*/
checkListProps?: CheckListProps;
/**
* @description 搜索框属性。
* @see {@link https://mobile.ant.design/zh/components/search-bar#属性|SearchBarProps}
*/
searchBarProps?: Omit<SearchBarProps, 'value' | 'onSearch'>;
/**
* @description 空状态属性。
* @see {@link https://mobile.ant.design/zh/components/empty#属性|EmptyProps}
*/
emptyProps?: EmptyProps;
}
declare function BizCheckListPopup(props: Omit<BizCheckListPopupProps, 'value' | 'onChange' | 'multiple'> & {
multiple: true;
value?: string[];
onChange?: (value: string[]) => void;
}): React.ReactElement<any, any> | null;
declare function BizCheckListPopup(props: Omit<BizCheckListPopupProps, 'value' | 'onChange' | 'multiple'> & {
multiple?: false | boolean;
value?: string;
onChange?: (value: string) => void;
}): React.ReactElement<any, any> | null;
export default BizCheckListPopup;