@reforgium/data-grid 2.4.0 → 2.5.0
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/README.md +103 -9
- package/fesm2022/{reforgium-data-grid-grid-overlay-scroll.feature-CPzcczP6.mjs → reforgium-data-grid-grid-overlay-scroll.feature-CM8whbLz.mjs} +2 -2
- package/fesm2022/{reforgium-data-grid-grid-tooltip.feature-i-k8F-1I.mjs → reforgium-data-grid-grid-tooltip.feature-BsSL2d0T.mjs} +8 -5
- package/fesm2022/{reforgium-data-grid-reforgium-data-grid-DmoyegCD.mjs → reforgium-data-grid-reforgium-data-grid-Civdbsy1.mjs} +245 -162
- package/fesm2022/reforgium-data-grid.mjs +1 -1
- package/package.json +1 -1
- package/types/reforgium-data-grid.d.ts +52 -7
package/README.md
CHANGED
|
@@ -106,8 +106,96 @@ Supported default fields:
|
|
|
106
106
|
- `debounce`
|
|
107
107
|
|
|
108
108
|
`translations` supports: `emptyState`, `itemsPerPageLabel`, `nextPageLabel`, `prevPageLabel`, `indexColumnHeader`.
|
|
109
|
-
|
|
110
|
-
###
|
|
109
|
+
|
|
110
|
+
### Type registries (global + local)
|
|
111
|
+
|
|
112
|
+
You can register type-based transformers and renderers globally via DI.
|
|
113
|
+
|
|
114
|
+
- `provideDataGridTypeTransformers(...)` registers `type -> (row, ctx) => value`
|
|
115
|
+
- `provideDataGridTypeRenderers(...)` registers `type -> TemplateRef`
|
|
116
|
+
- `reDataGridTypeCell="..."` registers an instance-local renderer (only for that grid instance)
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
import {
|
|
120
|
+
provideDataGridTypeTransformers,
|
|
121
|
+
} from '@reforgium/data-grid';
|
|
122
|
+
|
|
123
|
+
export const routes: Routes = [
|
|
124
|
+
{
|
|
125
|
+
path: 'users',
|
|
126
|
+
providers: [
|
|
127
|
+
provideDataGridTypeTransformers({
|
|
128
|
+
money: (_row, ctx) => `$${Number(ctx.value ?? 0).toLocaleString('en-US')}`,
|
|
129
|
+
}),
|
|
130
|
+
],
|
|
131
|
+
loadComponent: () => import('./users.page').then((m) => m.UsersPage),
|
|
132
|
+
},
|
|
133
|
+
];
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
columns = [
|
|
138
|
+
{ key: 'salary', header: 'Salary', type: 'money' },
|
|
139
|
+
];
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
```html
|
|
143
|
+
<re-data-grid [data]="users" [columns]="columns">
|
|
144
|
+
<!-- Local renderer overrides global renderer for this grid only -->
|
|
145
|
+
<ng-template reDataGridTypeCell="money" let-value="value" let-row="row">
|
|
146
|
+
<b>{{ value }}</b> <small>{{ row.status }}</small>
|
|
147
|
+
</ng-template>
|
|
148
|
+
</re-data-grid>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Renderer precedence:
|
|
152
|
+
|
|
153
|
+
1. `column.renderTemplate`
|
|
154
|
+
2. local `reDataGridTypeCell`
|
|
155
|
+
3. DI `provideDataGridTypeRenderers(...)`
|
|
156
|
+
4. built-in renderer (`date`, `number`, `index`, ...)
|
|
157
|
+
5. default text renderer
|
|
158
|
+
|
|
159
|
+
Value transform precedence:
|
|
160
|
+
|
|
161
|
+
1. `column.transformer(row, ctx)`
|
|
162
|
+
2. DI `provideDataGridTypeTransformers(...)`
|
|
163
|
+
3. default value pipeline
|
|
164
|
+
|
|
165
|
+
`ctx` includes: `value`, `col`, `index`, `type`.
|
|
166
|
+
|
|
167
|
+
Type/value callback context (`ctx`) and pinned rows:
|
|
168
|
+
|
|
169
|
+
- `value(row, ctx)` receives: `ctx.col`, `ctx.index`, `ctx.isPinned`
|
|
170
|
+
- `transformer(row, ctx)` receives: `ctx.value`, `ctx.col`, `ctx.index`, `ctx.type`, `ctx.isPinned`
|
|
171
|
+
- Cell template contexts (including `reDataGridTypeCell`, `reDataGridCell`) expose `isPinned`
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
columns = [
|
|
175
|
+
{
|
|
176
|
+
key: 'code',
|
|
177
|
+
header: 'Code',
|
|
178
|
+
value: (row, ctx) => (ctx.isPinned ? 'PINNED' : row.code),
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
key: 'salary',
|
|
182
|
+
header: 'Salary',
|
|
183
|
+
type: 'money',
|
|
184
|
+
transformer: (row, ctx) => (ctx.isPinned ? `PIN: ${ctx.value}` : ctx.value),
|
|
185
|
+
},
|
|
186
|
+
];
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
```html
|
|
190
|
+
<ng-template reDataGridTypeCell="money" let-value="value" let-isPinned="isPinned">
|
|
191
|
+
<b>{{ value }}</b>
|
|
192
|
+
@if (isPinned) {
|
|
193
|
+
<small>PIN</small>
|
|
194
|
+
}
|
|
195
|
+
</ng-template>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Inputs
|
|
111
199
|
|
|
112
200
|
| Parameter | Type | Default | Description | |
|
|
113
201
|
|--------------------|--------------------------------------------------|--------------------|-------------------------------------------------------------------------------------------------|------------------|
|
|
@@ -135,9 +223,14 @@ Supported default fields:
|
|
|
135
223
|
| deferCells | `boolean` | `false` | Defers rendering of cell content | |
|
|
136
224
|
| rowKey | `DataKey<T> \| ((item: T) => string \| number)` | `undefined` | Property name or function to resolve unique row key | |
|
|
137
225
|
|
|
138
|
-
When selection mode is `'single'` or `'multi'`, provide a `key` (data property) and optionally `defaultSelected`.
|
|
139
|
-
|
|
140
|
-
|
|
226
|
+
When selection mode is `'single'` or `'multi'`, provide a `key` (data property) and optionally `defaultSelected`.
|
|
227
|
+
|
|
228
|
+
Selection mode guidance:
|
|
229
|
+
|
|
230
|
+
- Prefer using row selection with `mode="pagination"` for clearer UX and predictable “select all” behavior.
|
|
231
|
+
- In `mode="infinity"`, selection typically applies only to currently loaded rows, so use it only when that behavior is acceptable.
|
|
232
|
+
|
|
233
|
+
Feature lazy-loading behavior (runtime `import()`):
|
|
141
234
|
|
|
142
235
|
- Selection feature is loaded when `selection.mode !== 'none'`.
|
|
143
236
|
- Sticky feature is loaded when `isRowSticky` is provided.
|
|
@@ -232,14 +325,15 @@ Renderer-specific fields:
|
|
|
232
325
|
|
|
233
326
|
| Variant | Fields | Notes |
|
|
234
327
|
|-------------------|-----------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|
|
|
235
|
-
| Built-in renderer | `type?:
|
|
236
|
-
| Value renderer | `value: (row: T) => string \| number`, `track: (row: T) => string`
|
|
237
|
-
| Template renderer | `renderTemplate: TemplateRef<...>`, `track: (row: T) => string` | `track` is required when rendering through Angular templates. |
|
|
328
|
+
| Built-in / type renderer | `type?: GridBuiltInCellType \| string`, `typeParams?: any`, `defaultValue?: any` | Built-in types are `plain/date/number/index/checkbox`; custom string types can be handled by local/DI type registries. |
|
|
329
|
+
| Value renderer | `value: (row: T, ctx) => string \| number`, `track: (row: T) => string` | `track` is required for stable row identity and efficient updates. `ctx` includes `col`, `index`, `isPinned`. |
|
|
330
|
+
| Template renderer | `renderTemplate: TemplateRef<...>`, `track: (row: T) => string` | `track` is required when rendering through Angular templates. |
|
|
238
331
|
|
|
239
332
|
Cell text wrapping/clamp behavior:
|
|
240
333
|
|
|
241
334
|
- Default header text and default body renderers (`plain`, `date`, `number`, `index`) are limited to 2 lines with ellipsis.
|
|
242
|
-
- Template-based renderers (`renderTemplate`, `reDataGridCell`, `reDataGridTypeCell`, etc.) are not clamped by default and are fully controlled by your template styles.
|
|
335
|
+
- Template-based renderers (`renderTemplate`, `reDataGridCell`, `reDataGridTypeCell`, etc.) are not clamped by default and are fully controlled by your template styles.
|
|
336
|
+
- Cell template contexts also include `isPinned` so pinned top/bottom rows can be rendered differently.
|
|
243
337
|
|
|
244
338
|
### Declarative columns *[NEW in 2.0.0]*
|
|
245
339
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as computeScrollbarState, a as clampThumbTop, m as mapThumbTopToScrollTop } from './reforgium-data-grid-reforgium-data-grid-
|
|
1
|
+
import { c as computeScrollbarState, a as clampThumbTop, m as mapThumbTopToScrollTop } from './reforgium-data-grid-reforgium-data-grid-Civdbsy1.mjs';
|
|
2
2
|
|
|
3
3
|
function createGridOverlayScrollFeature(ctx) {
|
|
4
4
|
const showScrollbar = () => {
|
|
@@ -76,4 +76,4 @@ function createGridOverlayScrollFeature(ctx) {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
export { createGridOverlayScrollFeature };
|
|
79
|
-
//# sourceMappingURL=reforgium-data-grid-grid-overlay-scroll.feature-
|
|
79
|
+
//# sourceMappingURL=reforgium-data-grid-grid-overlay-scroll.feature-CM8whbLz.mjs.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// noinspection ES6PreferShortImport
|
|
2
2
|
function createGridTooltipFeature(ctx) {
|
|
3
|
-
const resolveCellValue = (row, col) => {
|
|
4
|
-
|
|
3
|
+
const resolveCellValue = (row, col, index, isPinned) => {
|
|
4
|
+
const valueCtx = { col, index, isPinned };
|
|
5
|
+
return 'value' in col ? col.value(row, valueCtx) : row[col.key];
|
|
5
6
|
};
|
|
6
7
|
const resolveTooltip = (row, col) => {
|
|
7
8
|
const tooltip = col.tooltip;
|
|
@@ -9,7 +10,7 @@ function createGridTooltipFeature(ctx) {
|
|
|
9
10
|
return null;
|
|
10
11
|
}
|
|
11
12
|
if (tooltip === true) {
|
|
12
|
-
const baseValue = resolveCellValue(row, col);
|
|
13
|
+
const baseValue = resolveCellValue(row, col, -1, false);
|
|
13
14
|
if (baseValue === null || baseValue === undefined || baseValue === '') {
|
|
14
15
|
return null;
|
|
15
16
|
}
|
|
@@ -32,13 +33,15 @@ function createGridTooltipFeature(ctx) {
|
|
|
32
33
|
if (!resolved) {
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
|
-
const
|
|
36
|
+
const isPinned = index < 0;
|
|
37
|
+
const baseValue = resolveCellValue(row, col, index, isPinned);
|
|
36
38
|
const context = {
|
|
37
39
|
$implicit: row,
|
|
38
40
|
row,
|
|
39
41
|
col: col,
|
|
40
42
|
index,
|
|
41
43
|
value: baseValue,
|
|
44
|
+
isPinned,
|
|
42
45
|
};
|
|
43
46
|
const offset = 12;
|
|
44
47
|
const x = event.clientX + offset;
|
|
@@ -87,4 +90,4 @@ function createGridTooltipFeature(ctx) {
|
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
export { createGridTooltipFeature };
|
|
90
|
-
//# sourceMappingURL=reforgium-data-grid-grid-tooltip.feature-
|
|
93
|
+
//# sourceMappingURL=reforgium-data-grid-grid-tooltip.feature-BsSL2d0T.mjs.map
|