@reforgium/data-grid 2.3.6 → 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 CHANGED
@@ -72,22 +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
- pageSize: 50,
79
- }),
80
- ],
81
- };
75
+ provideDataGridDefaults({
76
+ mode: 'pagination',
77
+ hasIndexColumn: true,
78
+ resizable: true,
79
+ pageSize: 50,
80
+ translations: {
81
+ indexColumnHeader: 'No.',
82
+ },
83
+ }),
84
+ ],
85
+ };
82
86
  ```
83
87
 
84
88
  Supported default fields:
85
89
 
86
90
  - `mode`
87
91
  - `hasIndexColumn`
88
- - `selection`
89
- - `pageSize`
90
- - `rowHeight`
92
+ - `selection`
93
+ - `pageSize`
94
+ - `resizable`
95
+ - `rowHeight`
91
96
  - `headerHeight`
92
97
  - `height`
93
98
  - `virtualBuffer`
@@ -97,10 +102,100 @@ Supported default fields:
97
102
  - `deferPinned`
98
103
  - `deferCells`
99
104
  - `pageStartFromZero`
100
- - `translations`
101
- - `debounce`
102
-
103
- ### Inputs
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
+ ```
197
+
198
+ ### Inputs
104
199
 
105
200
  | Parameter | Type | Default | Description | |
106
201
  |--------------------|--------------------------------------------------|--------------------|-------------------------------------------------------------------------------------------------|------------------|
@@ -128,9 +223,14 @@ Supported default fields:
128
223
  | deferCells | `boolean` | `false` | Defers rendering of cell content | |
129
224
  | rowKey | `DataKey<T> \| ((item: T) => string \| number)` | `undefined` | Property name or function to resolve unique row key | |
130
225
 
131
- When selection mode is `'single'` or `'multi'`, provide a `key` (data property) and optionally `defaultSelected`.
132
-
133
- Feature lazy-loading behavior (runtime `import()`):
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()`):
134
234
 
135
235
  - Selection feature is loaded when `selection.mode !== 'none'`.
136
236
  - Sticky feature is loaded when `isRowSticky` is provided.
@@ -215,23 +315,25 @@ Common (base) fields:
215
315
  | `sortKey` | `string` | Alternative key used for sorting when display `key` differs from sortable data. | |
216
316
  | `sticky` | `'left' \| 'right' \| true` | Keeps the column fixed while horizontally scrolling. `true` pins to the left. | |
217
317
  | `expandBy` | `DataKey<T>` | Data key that controls expand/collapse behavior for the column. | |
218
- | `flex` | `number` | Flex grow factor for width distribution in flexible layouts. | |
219
- | `minWidth` / `maxWidth` | `number` | Column width limits in pixels. | |
220
- | `cellClass` | `string \| ((row: T) => string)` | Static CSS class or resolver per row. | |
221
- | `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]* |
222
323
 
223
324
  Renderer-specific fields:
224
325
 
225
326
  | Variant | Fields | Notes |
226
327
  |-------------------|-----------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|
227
- | 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. |
228
- | Value renderer | `value: (row: T) => string \| number`, `track: (row: T) => string` | `track` is required for stable row identity and efficient updates. |
229
- | 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. |
230
331
 
231
332
  Cell text wrapping/clamp behavior:
232
333
 
233
334
  - Default header text and default body renderers (`plain`, `date`, `number`, `index`) are limited to 2 lines with ellipsis.
234
- - 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.
235
337
 
236
338
  ### Declarative columns *[NEW in 2.0.0]*
237
339
 
@@ -263,7 +365,7 @@ Notes:
263
365
  - When used with column manager state, `visible`, `disabled`, and `sticky` are taken from state when defined.
264
366
  - `reHeader` maps to `headerTemplate`.
265
367
  - `reCell` receives value as `$implicit`, and the row is available as `let-row="row"` via `RenderTemplateData`.
266
- - Most `GridColumn<T>` fields are available as `<re-dg-column>` inputs (`sortKey`, `sticky`, `expandBy`, `disabled`, `width`, `minWidth`, `maxWidth`, `flex`, `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`).
267
369
  - `sticky` accepts `'left' | 'right'`; legacy `true` maps to `'left'` for backward compatibility.
268
370
 
269
371
  ### Tooltip
@@ -1,4 +1,4 @@
1
- import { c as computeScrollbarState, a as clampThumbTop, m as mapThumbTopToScrollTop } from './reforgium-data-grid-reforgium-data-grid-D5cKt3RW.mjs';
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-C1hp0DIj.mjs.map
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
- 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