Marks class properties to show as columns in a list/table view
npm install @itrocks/list-properties




Marks class properties to show as columns in a list/table view.
This module extends the @itrocks/reflect
system to determine which class properties should be displayed in a list or table view.
To enable these extensions, call initListProperties() once at application startup.
Use the @List() decorator on a class to explicitly declare which properties are shown in list views.
You can also rely on default behaviour that omits
CollectionType properties
or selects only @Representative ones when more than 5 properties exist.
```
initListProperties(): void
Call this once at runtime during app initialisation.\
This must be called before any module using listOf() or ReflectClass.listProperties() is loaded.
This extends the ReflectClass prototype with two new methods:
- listProperties(): ReflectProperty[] - returns ReflectProperty instanceslistPropertyNames(): string[]
- - returns only the names
``
@List(...properties: KeyOf
Marks the given properties to be listed in a table-like UI.
When no explicit property list is provided, a default list is inferred using:
- all non-collection properties (when ≤ 5),
- otherwise (more than 5) only the @Representative properties.
Parameters:
- properties: the property names you want to include in list views.
Example:
`ts`
@List('name', 'email', 'role')
class User {
email: string
name: string
password: string
role: Role
}
``
listOf(target: ObjectOrType
Returns an ordered list of property names to be used in list views,
based on the @List() decorator value or default rules.
This module is used in list rendering templates to dynamically generate column headers and data cells.
The following example uses the new ReflectClass.listProperties() method into an
@itrocks/template-insight template:
`html``{@display}
These directives will iterate over the selected list properties, producing one column per entry.
This allows the UI to adapt automatically to changes in your model classes.