mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-05-09 04:04:29 +08:00
style(form): 完善filterFunction类型定义
This commit is contained in:
parent
ab02c2f3ee
commit
ad008b66b4
@ -72,19 +72,19 @@ export interface FormItem {
|
|||||||
/** 字段名 */
|
/** 字段名 */
|
||||||
name?: string | number;
|
name?: string | number;
|
||||||
/** 额外的提示信息,和 help 类似,当提示文案同时出现时,可以使用这个。 */
|
/** 额外的提示信息,和 help 类似,当提示文案同时出现时,可以使用这个。 */
|
||||||
extra?: string | FilterFunction;
|
extra?: string | FilterFunction<string>;
|
||||||
/** 配置提示信息 */
|
/** 配置提示信息 */
|
||||||
tooltip?: string | FilterFunction;
|
tooltip?: string | FilterFunction<string>;
|
||||||
/** 是否置灰 */
|
/** 是否置灰 */
|
||||||
disabled?: boolean | FilterFunction;
|
disabled?: boolean | FilterFunction;
|
||||||
/** 使用表单中的值作为key,例如配置了text,则使用model.text作为key */
|
/** 使用表单中的值作为key,例如配置了text,则使用model.text作为key */
|
||||||
key?: string;
|
key?: string;
|
||||||
/** 是否显示 */
|
/** 是否显示 */
|
||||||
display?: boolean | 'expand' | FilterFunction;
|
display?: boolean | 'expand' | FilterFunction<boolean | 'expand'>;
|
||||||
/** 值发生改变时调用的方法 */
|
/** 值发生改变时调用的方法 */
|
||||||
onChange?: OnChangeHandler;
|
onChange?: OnChangeHandler;
|
||||||
/** label 标签的文本 */
|
/** label 标签的文本 */
|
||||||
text?: string | FilterFunction;
|
text?: string | FilterFunction<string>;
|
||||||
/** 右侧感叹号 */
|
/** 右侧感叹号 */
|
||||||
tip?: string;
|
tip?: string;
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ export type TypeFunction = (
|
|||||||
},
|
},
|
||||||
) => string;
|
) => string;
|
||||||
|
|
||||||
export type FilterFunction = (
|
export type FilterFunction<T = boolean> = (
|
||||||
mForm: FormState | undefined,
|
mForm: FormState | undefined,
|
||||||
data: {
|
data: {
|
||||||
model: Record<any, any>;
|
model: Record<any, any>;
|
||||||
@ -168,7 +168,7 @@ export type FilterFunction = (
|
|||||||
prop: string;
|
prop: string;
|
||||||
config: any;
|
config: any;
|
||||||
},
|
},
|
||||||
) => boolean;
|
) => T;
|
||||||
|
|
||||||
type OnChangeHandler = (
|
type OnChangeHandler = (
|
||||||
mForm: FormState | undefined,
|
mForm: FormState | undefined,
|
||||||
@ -667,7 +667,7 @@ export interface TableConfig extends FormItem {
|
|||||||
/** 是否显示全屏按钮 */
|
/** 是否显示全屏按钮 */
|
||||||
enableFullscreen?: boolean;
|
enableFullscreen?: boolean;
|
||||||
fixed?: boolean;
|
fixed?: boolean;
|
||||||
itemExtra?: string | FilterFunction;
|
itemExtra?: string | FilterFunction<string>;
|
||||||
rowKey?: string;
|
rowKey?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -680,8 +680,8 @@ export interface GroupListConfig extends FormItem {
|
|||||||
tableItems?: FormConfig;
|
tableItems?: FormConfig;
|
||||||
titleKey?: string;
|
titleKey?: string;
|
||||||
titlePrefix?: string;
|
titlePrefix?: string;
|
||||||
title?: string | FilterFunction;
|
title?: string | FilterFunction<string>;
|
||||||
itemExtra?: string | FilterFunction;
|
itemExtra?: string | FilterFunction<string>;
|
||||||
expandAll?: boolean;
|
expandAll?: boolean;
|
||||||
addable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean;
|
addable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean;
|
||||||
defaultAdd?: (mForm: FormState | undefined, data: any) => any;
|
defaultAdd?: (mForm: FormState | undefined, data: any) => any;
|
||||||
|
@ -181,7 +181,7 @@ const getDefaultValue = function (mForm: FormState | undefined, { defaultValue,
|
|||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
|
|
||||||
export const filterFunction = (mForm: FormState | undefined, config: any, props: any) => {
|
export const filterFunction = <T = any>(mForm: FormState | undefined, config: T, props: any) => {
|
||||||
if (typeof config !== 'function') {
|
if (typeof config !== 'function') {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user