MCPcopy
hub / github.com/alibaba/x-render / parseAllExpression

Function parseAllExpression

packages/form-render/src/models/expression.ts:124–162  ·  view source on GitHub ↗
(_schema: any, _formData: any, dataPath: string, formSchema?: any)

Source from the content-addressed store, hash-verified

122}
123
124export const parseAllExpression = (_schema: any, _formData: any, dataPath: string, formSchema?: any) => {
125 const schema = _cloneDeep(_schema);
126 let formData = _formData;
127 if (formSchema) {
128 formData = createDataSkeleton(formSchema, formData);
129 }
130
131 const recursionArray = (list: any[]) => {
132 const result = list.map(item => {
133 if (isArray(item)) {
134 return recursionArray(item);
135 }
136 if (isObject(item)) {
137 return parseAllExpression(item, formData, dataPath);
138 }
139
140 if (isExpression(item)) {
141 return parseExpression(item, formData, dataPath);
142 }
143 return item;
144 });
145
146 return result;
147 }
148
149 Object.keys(schema).forEach(key => {
150 const value = schema[key];
151
152 if (isArray(value)) {
153 schema[key] = recursionArray(value);
154 } if (isObject(value) && (value.mustacheParse ?? true)) {
155 schema[key] = parseAllExpression(value, formData, dataPath);
156 } else if (isExpression(value)) {
157 schema[key] = parseExpression(value, formData, dataPath);
158 }
159 });
160
161 return schema;
162};
163

Callers 6

index.tsxFile · 0.90
index.tsxFile · 0.90
index.tsxFile · 0.90
main.tsxFile · 0.90
index.tsxFile · 0.90
recursionArrayFunction · 0.70

Calls 6

createDataSkeletonFunction · 0.90
isArrayFunction · 0.90
isObjectFunction · 0.90
recursionArrayFunction · 0.70
isExpressionFunction · 0.70
parseExpressionFunction · 0.70

Tested by

no test coverage detected