@praxisui/list 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +6 -0
- package/README.md +136 -0
- package/fesm2022/praxisui-list.mjs +2929 -0
- package/fesm2022/praxisui-list.mjs.map +1 -0
- package/index.d.ts +451 -0
- package/package.json +38 -0
package/LICENSE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# @praxisui/list — Configurable List/Cards Component
|
|
2
|
+
|
|
3
|
+
Angular list/cards component for enterprise apps. Supports local or remote data, multiple layout variants, templating slots, actions, grouping and selection.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @praxisui/list
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peers (install in your app):
|
|
12
|
+
- `@angular/core`, `@angular/common`, `@angular/material` (Angular 16–20 compatible)
|
|
13
|
+
- `rxjs` (>=7 <9)
|
|
14
|
+
- `@praxisui/core` (icons, config storage, CRUD service)
|
|
15
|
+
- Optional: `@praxisui/settings-panel` (to open the in-app list configuration editor)
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { Component } from '@angular/core';
|
|
21
|
+
import { PraxisList } from '@praxisui/list';
|
|
22
|
+
|
|
23
|
+
@Component({
|
|
24
|
+
selector: 'app-list-demo',
|
|
25
|
+
standalone: true,
|
|
26
|
+
imports: [PraxisList],
|
|
27
|
+
template: `
|
|
28
|
+
<praxis-list
|
|
29
|
+
[config]="config"
|
|
30
|
+
(itemClick)="onItem($event)"
|
|
31
|
+
(actionClick)="onAction($event)"
|
|
32
|
+
(selectionChange)="onSelection($event)"
|
|
33
|
+
/>
|
|
34
|
+
`,
|
|
35
|
+
})
|
|
36
|
+
export class ListDemoComponent {
|
|
37
|
+
config = {
|
|
38
|
+
id: 'products-list',
|
|
39
|
+
dataSource: { data: [
|
|
40
|
+
{ id: 1, name: 'Phone', price: 699, image: '/assets/phone.png', rating: 4.5 },
|
|
41
|
+
{ id: 2, name: 'Laptop', price: 1499, image: '/assets/laptop.png', rating: 4.8 },
|
|
42
|
+
] },
|
|
43
|
+
layout: { variant: 'list', lines: 2, dividers: 'between' },
|
|
44
|
+
selection: { mode: 'single', return: 'item', compareBy: 'id' },
|
|
45
|
+
templating: {
|
|
46
|
+
leading: { type: 'image', expr: '${item.image}', imageAlt: 'Product image' },
|
|
47
|
+
primary: { type: 'text', expr: '${item.name}' },
|
|
48
|
+
secondary: { type: 'currency', expr: '${item.price}|:USD' },
|
|
49
|
+
meta: { type: 'rating', expr: '${item.rating}' },
|
|
50
|
+
trailing: { type: 'chip', expr: 'In stock', color: 'primary' },
|
|
51
|
+
features: [
|
|
52
|
+
{ icon: 'grade', expr: '${item.rating}' },
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
actions: [
|
|
56
|
+
{ id: 'favorite', icon: 'favorite', label: 'Like' },
|
|
57
|
+
{ id: 'buy', icon: 'shopping_cart', kind: 'button', buttonVariant: 'stroked', label: 'Buy' },
|
|
58
|
+
],
|
|
59
|
+
} satisfies import('@praxisui/list').PraxisListConfig;
|
|
60
|
+
|
|
61
|
+
onItem(e: any) { console.log('itemClick', e); }
|
|
62
|
+
onAction(e: any) { console.log('actionClick', e); }
|
|
63
|
+
onSelection(e: any) { console.log('selectionChange', e); }
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Remote Data (resourcePath)
|
|
68
|
+
|
|
69
|
+
Provide `dataSource.resourcePath` to fetch data and (optionally) infer templating from backend schema.
|
|
70
|
+
|
|
71
|
+
```html
|
|
72
|
+
<praxis-list [config]="{
|
|
73
|
+
id: 'employees',
|
|
74
|
+
dataSource: { resourcePath: 'employees', sort: ['name,asc'] },
|
|
75
|
+
layout: { variant: 'list', lines: 2, groupBy: 'department' },
|
|
76
|
+
templating: { primary: { type: 'text', expr: '${item.name}' } }
|
|
77
|
+
}"></praxis-list>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The component uses `GenericCrudService` from `@praxisui/core` when `resourcePath` is set. If no `primary` template is provided, it will try to infer templates using the backend schema once.
|
|
81
|
+
|
|
82
|
+
## Layout Variants
|
|
83
|
+
|
|
84
|
+
- `list` (default): Material list with optional selection and dividers.
|
|
85
|
+
- `cards`: Card grid layout with the same templating slots.
|
|
86
|
+
|
|
87
|
+
Layout options (`config.layout`):
|
|
88
|
+
- `lines`: 1 | 2 | 3 controls visible text lines.
|
|
89
|
+
- `dividers`: 'none' | 'between' | 'all'.
|
|
90
|
+
- `groupBy`: string key to group items; section headers can be templated via `templating.sectionHeader`.
|
|
91
|
+
- `pageSize`, `virtualScroll`, `density`, `model` for advanced tuning.
|
|
92
|
+
|
|
93
|
+
## Templating Slots
|
|
94
|
+
|
|
95
|
+
Every slot accepts a `TemplateDef` with `type`, `expr`, optional `class` and `style`.
|
|
96
|
+
- `leading`: 'icon' | 'image' with optional `badge`.
|
|
97
|
+
- `primary`: 'text' | 'html' | 'date' | 'currency' | 'rating' | 'chip'.
|
|
98
|
+
- `secondary`: same as primary; shown when `lines > 1`.
|
|
99
|
+
- `meta`: small text or chip/rating rendered inline or on the side (`metaPlacement`).
|
|
100
|
+
- `trailing`: optional trailing text/chip.
|
|
101
|
+
- `features`: array of `{ icon?, expr }` rendered below primary/secondary; control with `featuresVisible` and `featuresMode` ('icons+labels' | 'icons-only' | 'labels-only').
|
|
102
|
+
|
|
103
|
+
Expressions use `${...}` to read from `item` (e.g., `${item.name}`). For `currency`, you may pass code/locale as `|:USD` or `|:USD:en-US`.
|
|
104
|
+
|
|
105
|
+
## Actions
|
|
106
|
+
|
|
107
|
+
Configure contextual item actions via `config.actions`:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
actions: [
|
|
111
|
+
{ id: 'edit', icon: 'edit', label: 'Edit' },
|
|
112
|
+
{ id: 'delete', icon: 'delete', color: 'warn', showIf: "${item.status} == 'active'" },
|
|
113
|
+
{ id: 'details', kind: 'button', buttonVariant: 'raised', label: 'Details' },
|
|
114
|
+
]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
- `kind`: 'icon' (default) or 'button'.
|
|
118
|
+
- `showIf`: simple equality check is supported (left side must be an `${...}` expression).
|
|
119
|
+
- `emitPayload`: choose what the action emits ('item' | 'id' | 'value').
|
|
120
|
+
|
|
121
|
+
## Selection and Events
|
|
122
|
+
|
|
123
|
+
Selection (`config.selection`):
|
|
124
|
+
- `mode`: 'none' | 'single' | 'multiple'.
|
|
125
|
+
- `compareBy`: property used to track items.
|
|
126
|
+
- `return`: 'value' | 'item' | 'id' for `selectionChange` payload.
|
|
127
|
+
- Bind to an external `FormControl` via `formControlName`/`formControlPath` when using `form`.
|
|
128
|
+
|
|
129
|
+
Outputs:
|
|
130
|
+
- `(itemClick)`: `{ item, index, section? }`
|
|
131
|
+
- `(actionClick)`: `{ actionId, item, index }`
|
|
132
|
+
- `(selectionChange)`: `{ mode, value, items, ids? }`
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
Apache-2.0 — see `LICENSE` in this package or the repository root.
|