mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-18 07:42:54 +00:00
36 lines
838 B
TypeScript
36 lines
838 B
TypeScript
import type { IPublicTypeNodeSchema, IPublicTypeCompositeObject } from '@alilc/lowcode-types';
|
|
import type { TComponentAnalyzer } from '../types';
|
|
|
|
import { handleSubNodes } from '../utils/schema';
|
|
|
|
export const componentAnalyzer: TComponentAnalyzer = (container) => {
|
|
let hasRefAttr = false;
|
|
const nodeValidator = (n: IPublicTypeNodeSchema) => {
|
|
if (n.props) {
|
|
const props = n.props as IPublicTypeCompositeObject;
|
|
if (props.ref) {
|
|
hasRefAttr = true;
|
|
}
|
|
}
|
|
};
|
|
|
|
nodeValidator(container);
|
|
|
|
if (!hasRefAttr && container.children) {
|
|
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
handleSubNodes<void>(
|
|
container.children,
|
|
{
|
|
node: nodeValidator,
|
|
},
|
|
{
|
|
rerun: true,
|
|
},
|
|
);
|
|
}
|
|
|
|
return {
|
|
isUsingRef: hasRefAttr,
|
|
};
|
|
};
|