mobile-more
Version:
基于 antd-mobile v5 扩展移动端 UI 组件
31 lines (30 loc) • 1.33 kB
TypeScript
import React from 'react';
import { BizFormItemProps } from '../FormItem';
import { BizColorPickerColorResult, BizColorPickerFormat, BizColorPickerProps } from '../../BizColorPicker';
/**
* 转换颜色值为指定格式
* @param color 颜色值
* @param format 颜色格式
* @returns 转换后的颜色值
* @example
* // 颜色值为undefined 或 字符串,直接返回原值
* transformColor(undefined, 'rgb') // undefined
* transformColor('', 'rgb') // ''
* transformColor('#e60000', 'rgb') // '#e60000'
*
* // 颜色值为颜色对象,根据格式转换
* const color = { hex: '#e60000', hexa: '#e60000ff', hsva: { ..., a: 1 }, ... };
* transformColor(color, 'hsl') // 'hsl(0, 100%, 45%)'
* transformColor(color, 'rgb') // 'rgb(230, 0, 0)'
*/
declare function transformColor(color: string | BizColorPickerColorResult | undefined, format: BizColorPickerFormat): string | undefined;
export interface BizFormItemColorPickerProps extends Omit<BizFormItemProps, 'children'>, Pick<BizColorPickerProps, 'showAlpha' | 'showText' | 'format'> {
/**
* @description 颜色选择器属性。
*/
colorPickerProps?: BizColorPickerProps;
}
declare const BizFormItemColorPicker: React.FC<BizFormItemColorPickerProps> & {
transformColor: typeof transformColor;
};
export default BizFormItemColorPicker;