@inandu-solutions/grid-core
The framework-agnostic core of the Inandu data grid. Pure TypeScript: sorting, filtering, parsing, formatting, aggregation, tree flattening, export helpers and translated messages.
Why one core
- A fix is made once. Filtering, sorting, dates, parsing and export are not copied into each framework, so they cannot drift apart.
- Parity is checkable. The same inputs produce the same outputs in Angular, React and Vue because they run the same code, tested here in several time zones.
- The server speaks the same contract. The query the grids send and what Inandu.Grid.Extensions accepts are checked against one shared fixture.
- Only the UI is framework code. Each grid keeps its component, its hooks or signals, and its rendering; nothing else.
Install
npm install @inandu-solutions/grid-core
If you use grid-angular, grid-react or grid-vue you already get it. Install it directly only to build your own grid or to reuse the helpers.
Use
import { formatCellValue, escapeCsvValue, matchesColumnFilter } from '@inandu-solutions/grid-core';
formatCellValue(1234.5, 'number', '1.0-2', 'en-US'); // "1,234.50"
formatCellValue('2024-01-05', 'date', 'YYYY-MM-DD', 'en-US'); // "2024-01-05", in every time zone
escapeCsvValue('=HYPERLINK("http://example.com","x")'); // a quote is prefixed: opens as text
What is inside
| Area | Exports |
|---|---|
| Formatting | formatCellValue, formatDateValue, coerceToDate, defaultNumberFormatter |
| Filtering | matchesColumnFilter, hasMeaningfulFilterValue |
| Sorting | compareCellValues |
| Trees | flattenTree, collectTreeRows |
| Aggregates | computeGroupAggregates, AGGREGATE_SYMBOLS |
| Parsing | parseDraftValue, parsePastedCellValue, parsePastedCell |
| Export helpers | escapeCsvValue, neutralizeCsvFormula, escapeMarkup, truncatePdfText, downloadBlob |
| i18n | en, es, fr, it, zh, INANDU_GRID_TRANSLATIONS |
Behaviours worth knowing
- Dates are calendar dates. A bare
yyyy-mm-ddis local midnight of that day, so it formats, filters and compares as that day west and east of UTC alike. - CSV cells are neutralized. A cell starting with
=,+,-,@, a tab or a carriage return gets a leading quote; plain numbers are left alone. - Excel markup drops what XML cannot carry, so a stray control character does not make Excel reject the file.
- Pasting never clears a cell by accident:
parsePastedCellreturnsundefinedfor text a column cannot hold. - PDF export and CJK text: jsPDF's built-in fonts have no CJK glyphs; embed a font that has them.
MIT, Inandu SAS.