MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / generateAttrs

Function generateAttrs

modules/code-generator/src/utils/nodeToJSX.ts:118–147  ·  view source on GitHub ↗
(
  nodeItem: IPublicTypeNodeSchema,
  scope: IScope,
  config?: NodeGeneratorConfig,
)

Source from the content-addressed store, hash-verified

116}
117
118function generateAttrs(
119 nodeItem: IPublicTypeNodeSchema,
120 scope: IScope,
121 config?: NodeGeneratorConfig,
122): CodePiece[] {
123 const { props } = nodeItem;
124
125 let pieces: CodePiece[] = [];
126
127 if (props) {
128 if (!Array.isArray(props)) {
129 Object.keys(props).forEach((propName: string) => {
130 if (isValidIdentifier(propName)) {
131 pieces = pieces.concat(generateAttr(propName, props[propName] as IPublicTypeCompositeValue, scope, config));
132 }
133 });
134 } else {
135 props.forEach((prop) => {
136 if (prop.name && isValidIdentifier(prop.name) && !prop.spread) {
137 pieces = pieces.concat(generateAttr(prop.name, prop.value, scope, config));
138 }
139
140 // TODO: 处理 spread 场景(<Xxx {...(something)}/>)
141 // 这种在 schema 里面怎么描述
142 });
143 }
144 }
145
146 return pieces;
147}
148
149function generateBasicNode(
150 nodeItem: IPublicTypeNodeSchema,

Callers 1

generateSimpleNodeFunction · 0.85

Calls 4

isValidIdentifierFunction · 0.90
generateAttrFunction · 0.85
concatMethod · 0.80
forEachMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…