@thkl/agrid 0.1.12 → 0.1.14

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
@@ -1,8 +1,8 @@
1
1
  # @thkl/agrid
2
2
 
3
- A signal-based, standalone data grid for Angular 21 with virtual scrolling, editing,
3
+ A signal-based, standalone data grid for Angular 21 and 22 with virtual scrolling, editing,
4
4
  filtering, sorting, grouping, tree data, pinned columns, selection, clipboard operations,
5
- and pagination.
5
+ pagination, and linked SVG charts/graphs.
6
6
 
7
7
  ## Install
8
8
 
@@ -10,6 +10,16 @@ and pagination.
10
10
  npm install @thkl/agrid @angular/cdk
11
11
  ```
12
12
 
13
+ ## Feature Highlights
14
+
15
+ - Virtual rows and virtual columns for large and wide datasets.
16
+ - Text, value, quick, and condition filters with local or server-side workflows.
17
+ - Inline editing, validation, undo/redo, paste, fill, custom editors, and custom renderers.
18
+ - Range selection, selection summaries, row selection, row marking, column marking, and row numbers.
19
+ - Grouping, aggregate footers, tree data with descendant rollups, pivot tables, and master/detail rows.
20
+ - Pinned columns, pinned rows, column reordering, column autosize, and persistable settings.
21
+ - CSV, zero-dependency `.xlsx` export, sparklines, and linked SVG charts/graphs.
22
+
13
23
  ## Usage
14
24
 
15
25
  ```ts
@@ -72,6 +82,10 @@ be dragged.
72
82
  `confirmRowDelete` protects grid delete actions with a localized in-row Yes/No confirmation.
73
83
  Direct calls to `AgridDataSource.removeRow()` remain immediate.
74
84
 
85
+ `showRowNumbers` displays 1-based row numbers in the control column for the current filtered and
86
+ sorted row order. When row reordering is enabled, the number replaces the drag-handle glyph while
87
+ the control cell remains draggable.
88
+
75
89
  `enableRowMarking` makes each control-cell row header clickable and adds a checkbox. Clicking the
76
90
  header outside its nested controls toggles the same mark state and emits `(rowMark)` with the row,
77
91
  its original datasource index, and the resulting `marked` state. Marked rows are included in
@@ -86,6 +100,52 @@ Selecting numeric cells displays a live status bar with count, sum, average, min
86
100
  Read the same values from `grid.selectionSummary()`. The signal is `null` when the active selection
87
101
  contains no finite numeric values.
88
102
 
103
+ ## Charts / Graphs
104
+
105
+ Use `AgridChartComponent` with an `AgridChartProvider` to render zero-dependency SVG graphs. The
106
+ same provider pattern as the grid keeps setup predictable:
107
+
108
+ ```ts
109
+ import { AgridChartComponent, AgridChartProvider } from '@thkl/agrid';
110
+
111
+ readonly chartProvider = new AgridChartProvider({
112
+ type: 'column',
113
+ data: {
114
+ categories: ['Q1', 'Q2', 'Q3', 'Q4'],
115
+ series: [
116
+ { name: 'North', values: [120, 145, 138, 162] },
117
+ { name: 'South', values: [98, 110, 134, 128] },
118
+ ],
119
+ },
120
+ height: 300,
121
+ });
122
+ ```
123
+
124
+ ```html
125
+ <agrid-chart [provider]="chartProvider" />
126
+ ```
127
+
128
+ Supported `type` values are `column`, `bar`, `line`, `area`, `pie`, and `donut`. `type`, `height`,
129
+ `showLegend`, `showAxis`, and `palette` are signals, so runtime changes redraw immediately.
130
+
131
+ To link a graph to a grid, pass `provider.visibleRows` as `source` and provide a `transform`. The
132
+ chart follows filtering, sorting, and edits live:
133
+
134
+ ```ts
135
+ readonly chartProvider = new AgridChartProvider<Person>({
136
+ type: 'bar',
137
+ source: this.provider.visibleRows,
138
+ transform: rows => ({
139
+ categories: rows.map(row => row.name),
140
+ series: [{ name: 'Score', values: rows.map(row => Number(row.score ?? 0)) }],
141
+ }),
142
+ });
143
+ ```
144
+
145
+ `visibleRows` is the filtered and sorted row set. It intentionally ignores grouping and pagination;
146
+ aggregate inside `transform` when the graph should show grouped totals or page-specific summaries.
147
+ Pie and donut graphs use the first series and label slices from `categories`.
148
+
89
149
  Set `enableColumnMarking: true` to toggle complete-column highlighting by clicking a header outside
90
150
  its menu and resize controls. The grid exposes `markedColumnFields()` and emits `(columnMark)`.
91
151
 
@@ -167,6 +227,9 @@ readonly provider = new AgridProvider<Person>({
167
227
  `visible`, `active`, and `disabled` may be booleans or callbacks. Callback context includes
168
228
  `rows`, `selectedRows`, `selectedCell`, `provider`, and `datasource`.
169
229
 
230
+ For imperative selection reads, call `grid.getCurrentRow()` or `grid.getCurrentCell()`. The
231
+ `(cellSelect)` output emits the same selected-cell shape and `null` when cell selection clears.
232
+
170
233
  ## Input masks
171
234
 
172
235
  Use `inputMask` to select a string mask for each row and cell. The callback
@@ -278,15 +341,40 @@ readonly provider = new AgridProvider<Person>({ columns, datasource, enableQuick
278
341
  Drive it programmatically with `control.setQuickFilter(text)`; it's part of `toJSON()` state and is
279
342
  cleared by `control.clearAllFilters()`.
280
343
 
344
+ Use `control.getFilterModel()` and `control.setFilterModel(model)` to persist or restore just the
345
+ filter, quick-filter, and sort state without the rest of the grid settings.
346
+
347
+ Rows inserted while filters or sorts are active stay visible in insertion order even if their values
348
+ do not currently match. Wire `control.reapplyFilters()` to a button or save action when those
349
+ inserted rows should be filtered and sorted like the rest of the datasource again. Use
350
+ `control.filterReapplyNeeded()` to show visual feedback when that action is available.
351
+
281
352
  ## Server-side filtering
282
353
 
283
- With `serverSideFiltering: true` the grid never filters locally it emits events so the host can
284
- refetch:
354
+ With `serverSideFiltering: true` the grid never filters locally. The recommended integration point
355
+ is the complete query snapshot:
356
+
357
+ ```html
358
+ <agrid [provider]="provider" (serverQueryChange)="loadRows($event)" />
359
+ ```
360
+
361
+ ```ts
362
+ effect(() => {
363
+ const query = provider.serverQuery();
364
+ if (!query) return;
365
+ store.load(query);
366
+ });
367
+ ```
368
+
369
+ `AgridServerQuery` contains column filters, value selections, menu conditions, ordered sorts,
370
+ quick-filter text, and page range (`startRow..endRow`, inclusive). The older granular outputs remain
371
+ available for compatibility:
285
372
 
286
- - `(filterChange)` — header text filters emit `{ field, value }`; menu conditions emit
373
+ - `(filterChange)` — header text filters emit `{ field, value }`; value filters emit
374
+ `{ field, value: '', selectedValues }`; menu conditions emit
287
375
  `{ field, value: '', operator, operand, operand2 }` (operator `null` clears the condition).
288
376
  - `(sortChange)` — `{ field, direction }`.
289
- - `(quickFilterChange)` — the quick-filter text (debounced by `filterDebounceMs`).
377
+ - `(quickFilterChange)` — the quick-filter text.
290
378
 
291
379
  ```html
292
380
  <agrid [provider]="provider"
@@ -296,7 +384,7 @@ refetch:
296
384
  ```
297
385
 
298
386
  Text/range/quick events are debounced by `filterDebounceMs` (default 300 ms; `0` disables). The
299
- The distinct-value picker is hidden in this mode unless the column supplies an explicit `values`
387
+ distinct-value picker is hidden in this mode unless the column supplies an explicit `values`
300
388
  list representing the complete server-side value set.
301
389
 
302
390
  ## Grouping and aggregates