mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 17:31:25 +08:00
e46d414b11
* support getFieldInstance * update doc * fix lint * move func * move into hooks * update ref logic * fix lint * rm only * fix docs
15 lines
480 B
TypeScript
15 lines
480 B
TypeScript
import { InternalNamePath } from './interface';
|
|
|
|
export function toArray<T>(candidate?: T | T[] | false): T[] {
|
|
if (candidate === undefined || candidate === false) return [];
|
|
|
|
return Array.isArray(candidate) ? candidate : [candidate];
|
|
}
|
|
|
|
export function getFieldId(namePath: InternalNamePath, formName?: string): string | undefined {
|
|
if (!namePath.length) return undefined;
|
|
|
|
const mergedId = namePath.join('_');
|
|
return formName ? `${formName}_${mergedId}` : mergedId;
|
|
}
|