in packages/codegen-ui-react/lib/react-studio-template-renderer.ts [891:926]
private buildCollectionBindingStatements(component: StudioComponent): Statement[] {
const statements: Statement[] = [];
if (isStudioComponentWithCollectionProperties(component)) {
Object.entries(component.collectionProperties).forEach((collectionProp) => {
const [propName, { model, sort, predicate }] = collectionProp;
if (predicate) {
statements.push(this.buildPredicateDeclaration(propName, predicate));
statements.push(this.buildCreateDataStorePredicateCall(model, propName));
}
if (sort) {
this.importCollection.addMappedImport(ImportValue.SORT_DIRECTION);
this.importCollection.addMappedImport(ImportValue.SORT_PREDICATE);
statements.push(this.buildPaginationStatement(propName, model, sort));
}
this.importCollection.addImport(ImportSource.LOCAL_MODELS, model);
statements.push(
this.buildPropPrecedentStatement(
propName,
this.hasCollectionPropertyNamedItems(component) ? 'itemsProp' : 'items',
factory.createPropertyAccessExpression(
this.buildUseDataStoreBindingCall(
'collection',
model,
predicate ? this.getFilterName(propName) : undefined,
sort ? this.getPaginationName(propName) : undefined,
),
'items',
),
),
);
});
}
return statements;
}