@reforgium/data-grid 2.4.0 → 2.5.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/README.md CHANGED
@@ -72,27 +72,27 @@ import { provideDataGridDefaults } from '@reforgium/data-grid';
72
72
 
73
73
  export const appConfig: ApplicationConfig = {
74
74
  providers: [
75
- provideDataGridDefaults({
76
- mode: 'pagination',
77
- hasIndexColumn: true,
78
- resizable: true,
79
- pageSize: 50,
80
- translations: {
81
- indexColumnHeader: 'No.',
82
- },
83
- }),
84
- ],
85
- };
75
+ provideDataGridDefaults({
76
+ mode: 'pagination',
77
+ hasIndexColumn: true,
78
+ resizable: true,
79
+ pageSize: 50,
80
+ translations: {
81
+ indexColumnHeader: 'No.',
82
+ },
83
+ }),
84
+ ],
85
+ };
86
86
  ```
87
87
 
88
88
  Supported default fields:
89
89
 
90
90
  - `mode`
91
91
  - `hasIndexColumn`
92
- - `selection`
93
- - `pageSize`
94
- - `resizable`
95
- - `rowHeight`
92
+ - `selection`
93
+ - `pageSize`
94
+ - `resizable`
95
+ - `rowHeight`
96
96
  - `headerHeight`
97
97
  - `height`
98
98
  - `virtualBuffer`
@@ -102,10 +102,98 @@ Supported default fields:
102
102
  - `deferPinned`
103
103
  - `deferCells`
104
104
  - `pageStartFromZero`
105
- - `translations`
106
- - `debounce`
107
-
108
- `translations` supports: `emptyState`, `itemsPerPageLabel`, `nextPageLabel`, `prevPageLabel`, `indexColumnHeader`.
105
+ - `translations`
106
+ - `debounce`
107
+
108
+ `translations` supports: `emptyState`, `itemsPerPageLabel`, `nextPageLabel`, `prevPageLabel`, `indexColumnHeader`.
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
+ ```
109
197
 
110
198
  ### Inputs
111
199
 
@@ -137,6 +225,11 @@ Supported default fields:
137
225
 
138
226
  When selection mode is `'single'` or `'multi'`, provide a `key` (data property) and optionally `defaultSelected`.
139
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
+
140
233
  Feature lazy-loading behavior (runtime `import()`):
141
234
 
142
235
  - Selection feature is loaded when `selection.mode !== 'none'`.
@@ -222,24 +315,25 @@ Common (base) fields:
222
315
  | `sortKey` | `string` | Alternative key used for sorting when display `key` differs from sortable data. | |
223
316
  | `sticky` | `'left' \| 'right' \| true` | Keeps the column fixed while horizontally scrolling. `true` pins to the left. | |
224
317
  | `expandBy` | `DataKey<T>` | Data key that controls expand/collapse behavior for the column. | |
225
- | `flex` | `number` | Flex grow factor for width distribution in flexible layouts. | |
226
- | `minWidth` / `maxWidth` | `number` | Column width limits in pixels. | |
227
- | `resizable` | `boolean` | Enables drag resize from header. `false` disables resize handle for the column. | |
228
- | `cellClass` | `string \| ((row: T) => string)` | Static CSS class or resolver per row. | |
229
- | `tooltip` | `true \| string \| ((row: T) => string) \| TemplateRef<GridTooltipContext>` | Popover tooltip content shown on cell hover. `true` uses the cell value automatically. | *[NEW in 2.2.0]* |
318
+ | `flex` | `number` | Flex grow factor for width distribution in flexible layouts. | |
319
+ | `minWidth` / `maxWidth` | `number` | Column width limits in pixels. | |
320
+ | `resizable` | `boolean` | Enables drag resize from header. `false` disables resize handle for the column. | |
321
+ | `cellClass` | `string \| ((row: T) => string)` | Static CSS class or resolver per row. | |
322
+ | `tooltip` | `true \| string \| ((row: T) => string) \| TemplateRef<GridTooltipContext>` | Popover tooltip content shown on cell hover. `true` uses the cell value automatically. | *[NEW in 2.2.0]* |
230
323
 
231
324
  Renderer-specific fields:
232
325
 
233
326
  | Variant | Fields | Notes |
234
327
  |-------------------|-----------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|
235
- | Built-in renderer | `type?: 'plain' \| 'date' \| 'number' \| 'index' \| 'checkbox'`, `typeParams?: any`, `defaultValue?: any` | `defaultValue` is used when source value is `null`/`undefined`; `typeParams` passes formatter config. |
236
- | Value renderer | `value: (row: T) => string \| number`, `track: (row: T) => string` | `track` is required for stable row identity and efficient updates. |
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`. |
237
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
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
 
@@ -271,7 +365,7 @@ Notes:
271
365
  - When used with column manager state, `visible`, `disabled`, and `sticky` are taken from state when defined.
272
366
  - `reHeader` maps to `headerTemplate`.
273
367
  - `reCell` receives value as `$implicit`, and the row is available as `let-row="row"` via `RenderTemplateData`.
274
- - Most `GridColumn<T>` fields are available as `<re-dg-column>` inputs (`sortKey`, `sticky`, `expandBy`, `disabled`, `width`, `minWidth`, `maxWidth`, `flex`, `resizable`, `align`, `cellClass`, `type`, `typeParams`, `defaultValue`, `value`, `track`, `tooltip`).
368
+ - Most `GridColumn<T>` fields are available as `<re-dg-column>` inputs (`sortKey`, `sticky`, `expandBy`, `disabled`, `width`, `minWidth`, `maxWidth`, `flex`, `resizable`, `align`, `cellClass`, `type`, `typeParams`, `defaultValue`, `value`, `track`, `tooltip`).
275
369
  - `sticky` accepts `'left' | 'right'`; legacy `true` maps to `'left'` for backward compatibility.
276
370
 
277
371
  ### Tooltip
@@ -1,4 +1,4 @@
1
- import { c as computeScrollbarState, a as clampThumbTop, m as mapThumbTopToScrollTop } from './reforgium-data-grid-reforgium-data-grid-DmoyegCD.mjs';
1
+ import { c as computeScrollbarState, a as clampThumbTop, m as mapThumbTopToScrollTop } from './reforgium-data-grid-reforgium-data-grid-D_DDE2E7.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-CPzcczP6.mjs.map
79
+ //# sourceMappingURL=reforgium-data-grid-grid-overlay-scroll.feature-DlgNSvfN.mjs.map
@@ -1,7 +1,8 @@
1
1
  // noinspection ES6PreferShortImport
2
2
  function createGridTooltipFeature(ctx) {
3
- const resolveCellValue = (row, col) => {
4
- return 'value' in col ? col.value(row) : row[col.key];
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 baseValue = resolveCellValue(row, col);
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-i-k8F-1I.mjs.map
93
+ //# sourceMappingURL=reforgium-data-grid-grid-tooltip.feature-BsSL2d0T.mjs.map