mobile-more
Version:
基于 antd-mobile v5 扩展移动端 UI 组件
52 lines (51 loc) • 1.74 kB
TypeScript
import { SelectorProps } from 'antd-mobile';
import React from 'react';
type SelectorValue = string | number;
type SelectorOption<V = SelectorValue> = SelectorProps<V>['options'][0];
type Option<V = SelectorValue> = Partial<SelectorOption<V>> & Record<string, any>;
export interface SuperSelectorProps<V = SelectorValue> extends Omit<SelectorProps<V>, 'options' | 'value'> {
/**
* @description 当前值。
*/
value?: any;
/**
* @description 选择时触发。
* @param value 选择值。
* @param extend 额外信息。比如全部选项。
* @returns
*/
onChange?: (value: any, extend: any) => void;
/**
* @description 可选项。
*/
options?: Option<V>[] | undefined;
/**
* @description 单选模式,不允许取消选择。仅在 `multiple=false` 时生效。
* @default true
*/
radioMode?: boolean;
/**
* @description 数据转换为 `label` `value` `descriotion` `disabled` 键。
*/
mapKeys?: {
label?: string;
value?: string;
description?: string;
disabled?: string;
};
}
declare function SuperSelector<V extends SelectorValue = SelectorValue>(props: Omit<SuperSelectorProps<V>, 'multiple' | 'value' | 'onChange'> & {
multiple: true;
value?: V[];
onChange?: (value: V[], extend: {
items: Option[];
}) => void;
}): React.JSX.Element;
declare function SuperSelector<V extends SelectorValue = SelectorValue>(props: Omit<SuperSelectorProps<V>, 'multiple' | 'value' | 'onChange'> & {
multiple?: false | boolean;
value?: V;
onChange?: (value: V, extend: {
items: Option[];
}) => void;
}): React.JSX.Element;
export default SuperSelector;