@gravionlabs/helix-ag-grid 22.1.27 → 22.1.28
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,7 +1,9 @@
|
|
|
1
1
|
# @gravionlabs/helix-ag-grid
|
|
2
2
|
|
|
3
|
-
AG Grid helpers for Helix applications: locale-aware value formatters, robust
|
|
4
|
-
number parsing for editable cells, and shared cell styles.
|
|
3
|
+
AG Grid helpers for Helix applications: the Helix theme, locale-aware value formatters, robust
|
|
4
|
+
number parsing for editable cells, and shared cell styles. Interactive tables (sorting, filtering,
|
|
5
|
+
paging, selection, row actions) use AG Grid Community through this package; small static tables use
|
|
6
|
+
`table[hx-table]` of `@gravionlabs/helix-ui`.
|
|
5
7
|
|
|
6
8
|
## Installation
|
|
7
9
|
|
|
@@ -11,13 +13,68 @@ npm install @gravionlabs/helix-ag-grid
|
|
|
11
13
|
|
|
12
14
|
Peer dependencies: `@angular/core >=22`, `ag-grid-angular >=33`, `ag-grid-community >=33`.
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
## Theme
|
|
17
|
+
|
|
18
|
+
`helixGridTheme` is AG Grid's Quartz theme with its parameters pointed at the Helix design tokens. It needs no
|
|
19
|
+
stylesheet:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { AllCommunityModule, ModuleRegistry } from 'ag-grid-community';
|
|
23
|
+
import { helixGridTheme } from '@gravionlabs/helix-ag-grid';
|
|
24
|
+
|
|
25
|
+
ModuleRegistry.registerModules([AllCommunityModule]);
|
|
26
|
+
|
|
27
|
+
@Component({ template: `<ag-grid-angular [theme]="theme" [rowData]="rows" [columnDefs]="columns" />` })
|
|
28
|
+
class Grid { theme = helixGridTheme; }
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Every colour is a `var(--h-*)` reference (`--h-content-background`, `--h-text-color`, `--h-primary-color`, …), so the
|
|
32
|
+
grid follows dark mode (`.app-dark`) and a primary colour that changes at runtime without any code. Refine it with
|
|
33
|
+
`helixGridTheme.withParams({ rowHeight: 36 })`.
|
|
34
|
+
|
|
35
|
+
**Why the Theming API and not CSS variables:** since AG Grid 33 the default theme is configured through the `theme`
|
|
36
|
+
grid option; the `--ag-*` CSS custom properties only drive the legacy `ag-theme-*` classes (`theme="legacy"`). The
|
|
37
|
+
Theming API takes `var()` references as parameter values, is typed, and needs no stylesheet. The package still ships
|
|
38
|
+
`styles.css` with a `.helix-ag-grid` class for grids that remain on a legacy theme (also `--h-*` only); add it to the
|
|
39
|
+
global styles only then:
|
|
15
40
|
|
|
16
41
|
```json
|
|
17
42
|
// angular.json
|
|
18
43
|
"styles": ["node_modules/@gravionlabs/helix-ag-grid/styles.css", "src/styles.scss"]
|
|
19
44
|
```
|
|
20
45
|
|
|
46
|
+
## Data grids
|
|
47
|
+
|
|
48
|
+
The demo page "Helix UI Data grid" shows everything below.
|
|
49
|
+
|
|
50
|
+
- **Columns:** `columnDefs` with the Helix formatters (`valueFormatter: currencyFormatter('EUR')`) and
|
|
51
|
+
`cellStyle: numberCellStyle`; `defaultColDef: { sortable: true, filter: true, resizable: true }`; text and number
|
|
52
|
+
filters with `filter: 'agTextColumnFilter' | 'agNumberColumnFilter'`.
|
|
53
|
+
- **Row selection:** `[rowSelection]="{ mode: 'multiRow' }"` (add `checkboxes` / `headerCheckbox` as needed; a
|
|
54
|
+
checkbox column is on by default).
|
|
55
|
+
- **Row actions:** a cell renderer component built from `button[hx-button]`; hand it the callback through the grid's
|
|
56
|
+
`[context]` and read `params.context` in the renderer.
|
|
57
|
+
- **Status tags:** a cell renderer that renders `<hx-tag [severity]="…">` from the cell value.
|
|
58
|
+
- **Pagination:** `[pagination]="true" [paginationPageSize]="5" [paginationPageSizeSelector]="[5, 10]"`.
|
|
59
|
+
- **Quick filter:** `[quickFilterText]="text()"` bound to an `input[hx-input]`.
|
|
60
|
+
- **Empty and loading:** `[loading]="loading()"` shows the loading overlay; an empty `rowData` shows "No Rows To Show"
|
|
61
|
+
(change the text with `localeText`).
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
@Component({ standalone: true, imports: [HxTag], template: `<hx-tag [value]="status()" [severity]="severity()" rounded />` })
|
|
65
|
+
class StatusCell implements ICellRendererAngularComp {
|
|
66
|
+
status = signal(''); severity = signal<HxTagSeverity>('primary');
|
|
67
|
+
agInit(p: ICellRendererParams) { this.refresh(p); }
|
|
68
|
+
refresh(p: ICellRendererParams) { this.status.set(p.value); this.severity.set(MAP[p.value]); return true; }
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Community only.** Everything the demo CRUD and table pages need is in AG Grid Community (MIT): sorting, column
|
|
73
|
+
filters, quick filter, pagination, row selection with checkboxes, cell renderers and editors, column resizing,
|
|
74
|
+
moving and pinning, CSV export, overlays. These are **Enterprise** features and are left out: row grouping and
|
|
75
|
+
aggregation, pivoting, master/detail, Excel export, range selection and the clipboard range, integrated charts, the
|
|
76
|
+
side bar and tool panels, the set filter, the multi filter, the server-side row model, the status bar.
|
|
77
|
+
|
|
21
78
|
## Formatters
|
|
22
79
|
|
|
23
80
|
`Intl`-based value formatters for column definitions:
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { themeQuartz } from "ag-grid-community";
|
|
1
2
|
function numberCellStyle(params) {
|
|
2
3
|
return params.value ? {
|
|
3
4
|
textAlign: "right",
|
|
@@ -92,7 +93,24 @@ function parseNumberValue(value, options) {
|
|
|
92
93
|
function numberValueParser(params, options) {
|
|
93
94
|
return parseNumberValue(params.newValue, options);
|
|
94
95
|
}
|
|
96
|
+
const helixGridTheme = themeQuartz.withParams({
|
|
97
|
+
backgroundColor: "var(--h-content-background)",
|
|
98
|
+
foregroundColor: "var(--h-text-color)",
|
|
99
|
+
accentColor: "var(--h-primary-color)",
|
|
100
|
+
borderColor: "var(--h-content-border-color)",
|
|
101
|
+
invalidColor: "var(--h-form-field-invalid-border-color)",
|
|
102
|
+
chromeBackgroundColor: "var(--h-content-background)",
|
|
103
|
+
headerBackgroundColor: "var(--h-content-background)",
|
|
104
|
+
headerTextColor: "var(--h-text-color)",
|
|
105
|
+
headerFontWeight: 600,
|
|
106
|
+
oddRowBackgroundColor: "color-mix(in srgb, var(--h-content-border-color) 25%, transparent)",
|
|
107
|
+
rowHoverColor: "var(--h-content-hover-background)",
|
|
108
|
+
selectedRowBackgroundColor: "var(--h-highlight-background)",
|
|
109
|
+
inputBackgroundColor: "var(--h-form-field-background)",
|
|
110
|
+
fontFamily: "inherit",
|
|
111
|
+
wrapperBorderRadius: "var(--h-content-border-radius)"
|
|
112
|
+
});
|
|
95
113
|
const HELIX_AG_GRID_VERSION = "0.1.0";
|
|
96
|
-
export { HELIX_AG_GRID_VERSION, cetDateFormatter, cetDateTimeFormatter, cetTimeFormatter, coerceValue, currencyFormatter, intlNumberFormatter, numberCellStyle, numberFormatter, numberValueParser, parseNumber, parseNumberValue, rawNumberFormatter };
|
|
114
|
+
export { HELIX_AG_GRID_VERSION, cetDateFormatter, cetDateTimeFormatter, cetTimeFormatter, coerceValue, currencyFormatter, helixGridTheme, intlNumberFormatter, numberCellStyle, numberFormatter, numberValueParser, parseNumber, parseNumberValue, rawNumberFormatter };
|
|
97
115
|
|
|
98
116
|
//# sourceMappingURL=gravionlabs-helix-ag-grid.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gravionlabs-helix-ag-grid.mjs","names":[],"sources":["../../../projects/ag-grid/src/lib/cell-styles/cell-styles.ts","../../../projects/ag-grid/src/lib/formatters/ag-grid-formatters.ts","../../../projects/ag-grid/src/lib/parsers/number-parsers.ts","../../../projects/ag-grid/src/public-api.ts"],"sourcesContent":["import type { CellClassParams, CellStyle } from 'ag-grid-community';\n\n/**\n * AG Grid `cellStyle` callback that right-aligns numeric cells and colours\n * truthy (non-zero, non-null, non-undefined) values with the helix success\n * colour (`--h-green-500`).\n *\n * @example\n * ```ts\n * columnDefs = [{ field: 'amount', cellStyle: numberCellStyle }];\n * ```\n */\nexport function numberCellStyle(params: CellClassParams): CellStyle {\n return params.value\n ? { textAlign: 'right', color: 'var(--h-green-500)' }\n : { textAlign: 'right' };\n}\n","import type { ValueFormatterParams } from 'ag-grid-community';\n\n/** Type alias for AG Grid's `ValueFormatterParams`, used by all formatter functions. */\nexport type AgGridFormatterParams<TData = unknown, TValue = unknown> = ValueFormatterParams<\n TData,\n TValue\n>;\n\n// ── Number formatters ──────────────────────────────────────────────────────\n\n/**\n * Formats a numeric cell value using the system locale (`toLocaleString`).\n * Returns `''` for `null`, `undefined`, or `NaN`.\n *\n * @example\n * ```ts\n * { field: 'amount', valueFormatter: numberFormatter }\n * ```\n */\nexport function numberFormatter(\n params: AgGridFormatterParams<unknown, number | null | undefined>,\n): string {\n const v = params.value;\n if (v == null || Number.isNaN(v)) return '';\n return v.toLocaleString();\n}\n\n/**\n * Returns the raw string representation of a number without any locale\n * formatting. Returns `''` for `null` or `undefined`.\n *\n * @example\n * ```ts\n * { field: 'id', valueFormatter: rawNumberFormatter }\n * ```\n */\nexport function rawNumberFormatter(\n params: AgGridFormatterParams<unknown, number | null | undefined>,\n): string {\n const v = params.value;\n if (v == null) return '';\n return v.toString();\n}\n\n/**\n * Formats a number using a caller-supplied `Intl.NumberFormat` instance,\n * allowing full control over locale, currency, fraction digits, etc.\n * Returns `''` for `null` or `undefined`.\n *\n * @example\n * ```ts\n * const fmt = new Intl.NumberFormat('de-DE', { minimumFractionDigits: 2 });\n * { field: 'price', valueFormatter: (p) => intlNumberFormatter(p, fmt) }\n * ```\n */\nexport function intlNumberFormatter(\n params: AgGridFormatterParams<unknown, number | null | undefined>,\n numberFormat: Intl.NumberFormat,\n): string {\n const v = params.value;\n if (v == null || Number.isNaN(v)) return '';\n return numberFormat.format(v);\n}\n\n/**\n * Factory that returns a currency formatter closure using `Intl.NumberFormat`\n * with `style: 'currency'`. Defaults to EUR / de-DE.\n * Returns `''` for `null`, `undefined`, or `NaN`.\n *\n * @example\n * ```ts\n * { field: 'revenue', valueFormatter: currencyFormatter() } // '1.234,50 €'\n * { field: 'price', valueFormatter: currencyFormatter('USD','en-US') } // '$99.90'\n * ```\n */\nexport function currencyFormatter(\n currencyCode = 'EUR',\n locale = 'de-DE',\n): (params: AgGridFormatterParams<unknown, number | null | undefined>) => string {\n const fmt = new Intl.NumberFormat(locale, { style: 'currency', currency: currencyCode });\n return (params) => {\n const v = params.value;\n if (v == null || Number.isNaN(v)) return '';\n return fmt.format(v);\n };\n}\n\n// ── CET date formatters ────────────────────────────────────────────────────\n\ntype DateInput = Date | string | null | undefined;\n\nfunction toDate(value: DateInput): Date | null {\n if (value == null) return null;\n const d = value instanceof Date ? value : new Date(value);\n return Number.isNaN(d.getTime()) ? null : d;\n}\n\nconst cetDateFormat = new Intl.DateTimeFormat('de-DE', {\n timeZone: 'Europe/Berlin',\n day: '2-digit',\n month: '2-digit',\n year: 'numeric',\n});\n\nconst cetDateTimeFormat = new Intl.DateTimeFormat('de-DE', {\n timeZone: 'Europe/Berlin',\n day: '2-digit',\n month: '2-digit',\n year: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: false,\n});\n\nconst cetTimeFormat = new Intl.DateTimeFormat('de-DE', {\n timeZone: 'Europe/Berlin',\n hour: '2-digit',\n minute: '2-digit',\n hour12: false,\n});\n\n/**\n * Formats a `Date` or ISO string as a CET date: `'15.06.2024'`.\n * Returns `''` for `null`, `undefined`, or invalid dates.\n *\n * @example\n * ```ts\n * { field: 'date', valueFormatter: cetDateFormatter }\n * ```\n */\nexport function cetDateFormatter(params: AgGridFormatterParams<unknown, DateInput>): string {\n const d = toDate(params.value);\n return d ? cetDateFormat.format(d) : '';\n}\n\n/**\n * Formats a `Date` or ISO string as a CET date-time: `'15.06.2024 12:30:00'`.\n * Returns `''` for `null`, `undefined`, or invalid dates.\n *\n * @example\n * ```ts\n * { field: 'updatedAt', valueFormatter: cetDateTimeFormatter }\n * ```\n */\nexport function cetDateTimeFormatter(params: AgGridFormatterParams<unknown, DateInput>): string {\n const d = toDate(params.value);\n if (!d) return '';\n // Intl formats date and time parts separated by ', ' in de-DE — replace with ' '\n return cetDateTimeFormat.format(d).replace(', ', ' ');\n}\n\n/**\n * Formats a `Date` or ISO string as a CET time: `'12:30'`.\n * Returns `''` for `null`, `undefined`, or invalid dates.\n *\n * @example\n * ```ts\n * { field: 'startTime', valueFormatter: cetTimeFormatter }\n * ```\n */\nexport function cetTimeFormatter(params: AgGridFormatterParams<unknown, DateInput>): string {\n const d = toDate(params.value);\n return d ? cetTimeFormat.format(d) : '';\n}\n","import type { ValueParserParams } from 'ag-grid-community';\n\n/** Bounds for number validation. */\nexport interface ParseNumberOptions {\n min?: number;\n max?: number;\n}\n\n/**\n * Validates a number against optional `min`/`max` bounds.\n * Returns `null` if the value is `null`, `undefined`, `NaN`, or out of bounds.\n *\n * @example\n * ```ts\n * coerceValue(5, { min: 0, max: 10 }) // → 5\n * coerceValue(15, { max: 10 }) // → null\n * coerceValue(null) // → null\n * ```\n */\nexport function coerceValue(\n value: number | null | undefined,\n options?: ParseNumberOptions,\n): number | null {\n if (value == null || Number.isNaN(value)) return null;\n if (options?.min != null && value < options.min) return null;\n if (options?.max != null && value > options.max) return null;\n return value;\n}\n\n/**\n * Locale-aware string-to-number parser.\n * Handles thousand separators and decimal commas for the given locale.\n * Returns `null` for empty, `null`, or `undefined` input.\n *\n * @example\n * ```ts\n * parseNumber('1.234,56', 'de-DE') // → 1234.56\n * parseNumber('1,234.56', 'en-US') // → 1234.56\n * ```\n */\nexport function parseNumber(\n value: string | null | undefined,\n locale: string,\n options?: ParseNumberOptions,\n): number | null {\n if (value == null || value.trim() === '') return null;\n\n // Derive separators from the locale\n const parts = new Intl.NumberFormat(locale).formatToParts(1234.5);\n const group = parts.find((p) => p.type === 'group')?.value ?? '';\n const decimal = parts.find((p) => p.type === 'decimal')?.value ?? '.';\n\n const normalised = value.trim().replaceAll(group, '').replace(decimal, '.');\n\n const n = Number.parseFloat(normalised);\n return coerceValue(n, options);\n}\n\n/**\n * Smart string-to-number parser that detects the decimal separator\n * automatically:\n * - Strings containing a comma (e.g. `'1.234,56'` from spreadsheet paste)\n * are parsed as German locale (`de-DE`).\n * - All other strings (e.g. `'3.14'` from keyboard input) are parsed with\n * `parseFloat`.\n *\n * Returns `null` for empty, `null`, or `undefined` input.\n *\n * @example\n * ```ts\n * parseNumberValue('42') // → 42\n * parseNumberValue('3.14') // → 3.14\n * parseNumberValue('1.234,56') // → 1234.56 (German paste)\n * parseNumberValue(null) // → null\n * parseNumberValue('5', { min: 10 }) // → null (out of bounds)\n * ```\n */\nexport function parseNumberValue(\n value: string | null | undefined,\n options?: ParseNumberOptions,\n): number | null {\n if (value == null || value.trim() === '') return null;\n\n const hasComma = value.includes(',');\n if (hasComma) {\n return parseNumber(value, 'de-DE', options);\n }\n\n const n = Number.parseFloat(value.trim());\n return coerceValue(n, options);\n}\n\n/**\n * AG Grid `valueParser` adapter — wraps `parseNumberValue` to read\n * `params.newValue`. Drop-in for any editable numeric column.\n *\n * @example\n * ```ts\n * { field: 'quantity', editable: true, valueParser: numberValueParser }\n * // or with bounds:\n * { field: 'pct', editable: true, valueParser: (p) => numberValueParser(p, { min: 0, max: 100 }) }\n * ```\n */\nexport function numberValueParser(\n params: ValueParserParams,\n options?: ParseNumberOptions,\n): number | null {\n return parseNumberValue(params.newValue as string | null | undefined, options);\n}\n","export const HELIX_AG_GRID_VERSION = '0.1.0';\n\nexport { numberCellStyle } from './lib/cell-styles/cell-styles';\n\nexport type { AgGridFormatterParams } from './lib/formatters/ag-grid-formatters';\nexport {\n cetDateFormatter,\n cetDateTimeFormatter,\n cetTimeFormatter,\n currencyFormatter,\n intlNumberFormatter,\n numberFormatter,\n rawNumberFormatter,\n} from './lib/formatters/ag-grid-formatters';\n\nexport type { ParseNumberOptions } from './lib/parsers/number-parsers';\nexport {\n coerceValue,\n numberValueParser,\n parseNumber,\n parseNumberValue,\n} from './lib/parsers/number-parsers';\n"],"m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jD,IADiB,MAAM,SAAS,GAC5B,GACF,OAAO,YAAY,OAAO,SAAS,OAAO;CAI5C,OAAO,YADG,OAAO,WAAW,MAAM,KAAI,CACnB,GAAG,OAAO;AAC/B;AAaA,SAAgB,kBACd,QACA,SAA4B;CAE5B,OAAO,iBAAiB,OAAO,UAAuC,OAAO;AAC/E;AC5GA,MAAa,wBAAwB"}
|
|
1
|
+
{"version":3,"file":"gravionlabs-helix-ag-grid.mjs","names":[],"sources":["../../../projects/ag-grid/src/lib/cell-styles/cell-styles.ts","../../../projects/ag-grid/src/lib/formatters/ag-grid-formatters.ts","../../../projects/ag-grid/src/lib/parsers/number-parsers.ts","../../../projects/ag-grid/src/lib/theme/helix-theme.ts","../../../projects/ag-grid/src/public-api.ts"],"sourcesContent":["import type { CellClassParams, CellStyle } from 'ag-grid-community';\n\n/**\n * AG Grid `cellStyle` callback that right-aligns numeric cells and colours\n * truthy (non-zero, non-null, non-undefined) values with the helix success\n * colour (`--h-green-500`).\n *\n * @example\n * ```ts\n * columnDefs = [{ field: 'amount', cellStyle: numberCellStyle }];\n * ```\n */\nexport function numberCellStyle(params: CellClassParams): CellStyle {\n return params.value\n ? { textAlign: 'right', color: 'var(--h-green-500)' }\n : { textAlign: 'right' };\n}\n","import type { ValueFormatterParams } from 'ag-grid-community';\n\n/**\n * The row type of the formatters. A formatter only reads the value, so it must fit a column of any row type;\n * `unknown` would make it unusable in a typed `ColDef<Row>` (the row node type is invariant).\n */\n// biome-ignore lint/suspicious/noExplicitAny: any row type, see above\nexport type AnyRow = any;\n\n/** Type alias for AG Grid's `ValueFormatterParams`, used by all formatter functions. */\nexport type AgGridFormatterParams<TData = AnyRow, TValue = unknown> = ValueFormatterParams<\n TData,\n TValue\n>;\n\n// ── Number formatters ──────────────────────────────────────────────────────\n\n/**\n * Formats a numeric cell value using the system locale (`toLocaleString`).\n * Returns `''` for `null`, `undefined`, or `NaN`.\n *\n * @example\n * ```ts\n * { field: 'amount', valueFormatter: numberFormatter }\n * ```\n */\nexport function numberFormatter(\n params: AgGridFormatterParams<AnyRow, number | null | undefined>,\n): string {\n const v = params.value;\n if (v == null || Number.isNaN(v)) return '';\n return v.toLocaleString();\n}\n\n/**\n * Returns the raw string representation of a number without any locale\n * formatting. Returns `''` for `null` or `undefined`.\n *\n * @example\n * ```ts\n * { field: 'id', valueFormatter: rawNumberFormatter }\n * ```\n */\nexport function rawNumberFormatter(\n params: AgGridFormatterParams<AnyRow, number | null | undefined>,\n): string {\n const v = params.value;\n if (v == null) return '';\n return v.toString();\n}\n\n/**\n * Formats a number using a caller-supplied `Intl.NumberFormat` instance,\n * allowing full control over locale, currency, fraction digits, etc.\n * Returns `''` for `null` or `undefined`.\n *\n * @example\n * ```ts\n * const fmt = new Intl.NumberFormat('de-DE', { minimumFractionDigits: 2 });\n * { field: 'price', valueFormatter: (p) => intlNumberFormatter(p, fmt) }\n * ```\n */\nexport function intlNumberFormatter(\n params: AgGridFormatterParams<AnyRow, number | null | undefined>,\n numberFormat: Intl.NumberFormat,\n): string {\n const v = params.value;\n if (v == null || Number.isNaN(v)) return '';\n return numberFormat.format(v);\n}\n\n/**\n * Factory that returns a currency formatter closure using `Intl.NumberFormat`\n * with `style: 'currency'`. Defaults to EUR / de-DE.\n * Returns `''` for `null`, `undefined`, or `NaN`.\n *\n * @example\n * ```ts\n * { field: 'revenue', valueFormatter: currencyFormatter() } // '1.234,50 €'\n * { field: 'price', valueFormatter: currencyFormatter('USD','en-US') } // '$99.90'\n * ```\n */\nexport function currencyFormatter(\n currencyCode = 'EUR',\n locale = 'de-DE',\n): (params: AgGridFormatterParams<AnyRow, number | null | undefined>) => string {\n const fmt = new Intl.NumberFormat(locale, { style: 'currency', currency: currencyCode });\n return (params) => {\n const v = params.value;\n if (v == null || Number.isNaN(v)) return '';\n return fmt.format(v);\n };\n}\n\n// ── CET date formatters ────────────────────────────────────────────────────\n\ntype DateInput = Date | string | null | undefined;\n\nfunction toDate(value: DateInput): Date | null {\n if (value == null) return null;\n const d = value instanceof Date ? value : new Date(value);\n return Number.isNaN(d.getTime()) ? null : d;\n}\n\nconst cetDateFormat = new Intl.DateTimeFormat('de-DE', {\n timeZone: 'Europe/Berlin',\n day: '2-digit',\n month: '2-digit',\n year: 'numeric',\n});\n\nconst cetDateTimeFormat = new Intl.DateTimeFormat('de-DE', {\n timeZone: 'Europe/Berlin',\n day: '2-digit',\n month: '2-digit',\n year: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: false,\n});\n\nconst cetTimeFormat = new Intl.DateTimeFormat('de-DE', {\n timeZone: 'Europe/Berlin',\n hour: '2-digit',\n minute: '2-digit',\n hour12: false,\n});\n\n/**\n * Formats a `Date` or ISO string as a CET date: `'15.06.2024'`.\n * Returns `''` for `null`, `undefined`, or invalid dates.\n *\n * @example\n * ```ts\n * { field: 'date', valueFormatter: cetDateFormatter }\n * ```\n */\nexport function cetDateFormatter(params: AgGridFormatterParams<AnyRow, DateInput>): string {\n const d = toDate(params.value);\n return d ? cetDateFormat.format(d) : '';\n}\n\n/**\n * Formats a `Date` or ISO string as a CET date-time: `'15.06.2024 12:30:00'`.\n * Returns `''` for `null`, `undefined`, or invalid dates.\n *\n * @example\n * ```ts\n * { field: 'updatedAt', valueFormatter: cetDateTimeFormatter }\n * ```\n */\nexport function cetDateTimeFormatter(params: AgGridFormatterParams<AnyRow, DateInput>): string {\n const d = toDate(params.value);\n if (!d) return '';\n // Intl formats date and time parts separated by ', ' in de-DE — replace with ' '\n return cetDateTimeFormat.format(d).replace(', ', ' ');\n}\n\n/**\n * Formats a `Date` or ISO string as a CET time: `'12:30'`.\n * Returns `''` for `null`, `undefined`, or invalid dates.\n *\n * @example\n * ```ts\n * { field: 'startTime', valueFormatter: cetTimeFormatter }\n * ```\n */\nexport function cetTimeFormatter(params: AgGridFormatterParams<AnyRow, DateInput>): string {\n const d = toDate(params.value);\n return d ? cetTimeFormat.format(d) : '';\n}\n","import type { ValueParserParams } from 'ag-grid-community';\n\n/** Bounds for number validation. */\nexport interface ParseNumberOptions {\n min?: number;\n max?: number;\n}\n\n/**\n * Validates a number against optional `min`/`max` bounds.\n * Returns `null` if the value is `null`, `undefined`, `NaN`, or out of bounds.\n *\n * @example\n * ```ts\n * coerceValue(5, { min: 0, max: 10 }) // → 5\n * coerceValue(15, { max: 10 }) // → null\n * coerceValue(null) // → null\n * ```\n */\nexport function coerceValue(\n value: number | null | undefined,\n options?: ParseNumberOptions,\n): number | null {\n if (value == null || Number.isNaN(value)) return null;\n if (options?.min != null && value < options.min) return null;\n if (options?.max != null && value > options.max) return null;\n return value;\n}\n\n/**\n * Locale-aware string-to-number parser.\n * Handles thousand separators and decimal commas for the given locale.\n * Returns `null` for empty, `null`, or `undefined` input.\n *\n * @example\n * ```ts\n * parseNumber('1.234,56', 'de-DE') // → 1234.56\n * parseNumber('1,234.56', 'en-US') // → 1234.56\n * ```\n */\nexport function parseNumber(\n value: string | null | undefined,\n locale: string,\n options?: ParseNumberOptions,\n): number | null {\n if (value == null || value.trim() === '') return null;\n\n // Derive separators from the locale\n const parts = new Intl.NumberFormat(locale).formatToParts(1234.5);\n const group = parts.find((p) => p.type === 'group')?.value ?? '';\n const decimal = parts.find((p) => p.type === 'decimal')?.value ?? '.';\n\n const normalised = value.trim().replaceAll(group, '').replace(decimal, '.');\n\n const n = Number.parseFloat(normalised);\n return coerceValue(n, options);\n}\n\n/**\n * Smart string-to-number parser that detects the decimal separator\n * automatically:\n * - Strings containing a comma (e.g. `'1.234,56'` from spreadsheet paste)\n * are parsed as German locale (`de-DE`).\n * - All other strings (e.g. `'3.14'` from keyboard input) are parsed with\n * `parseFloat`.\n *\n * Returns `null` for empty, `null`, or `undefined` input.\n *\n * @example\n * ```ts\n * parseNumberValue('42') // → 42\n * parseNumberValue('3.14') // → 3.14\n * parseNumberValue('1.234,56') // → 1234.56 (German paste)\n * parseNumberValue(null) // → null\n * parseNumberValue('5', { min: 10 }) // → null (out of bounds)\n * ```\n */\nexport function parseNumberValue(\n value: string | null | undefined,\n options?: ParseNumberOptions,\n): number | null {\n if (value == null || value.trim() === '') return null;\n\n const hasComma = value.includes(',');\n if (hasComma) {\n return parseNumber(value, 'de-DE', options);\n }\n\n const n = Number.parseFloat(value.trim());\n return coerceValue(n, options);\n}\n\n/**\n * AG Grid `valueParser` adapter — wraps `parseNumberValue` to read\n * `params.newValue`. Drop-in for any editable numeric column.\n *\n * @example\n * ```ts\n * { field: 'quantity', editable: true, valueParser: numberValueParser }\n * // or with bounds:\n * { field: 'pct', editable: true, valueParser: (p) => numberValueParser(p, { min: 0, max: 100 }) }\n * ```\n */\nexport function numberValueParser(\n params: ValueParserParams,\n options?: ParseNumberOptions,\n): number | null {\n return parseNumberValue(params.newValue as string | null | undefined, options);\n}\n","import { themeQuartz } from 'ag-grid-community';\n\n/**\n * The AG Grid theme of Helix: Quartz with its parameters pointed at the Helix design tokens.\n *\n * ```ts\n * import { helixGridTheme } from '@gravionlabs/helix-ag-grid';\n * // <ag-grid-angular [theme]=\"theme\" …> theme = helixGridTheme;\n * ```\n *\n * Every colour is a `var(--h-*)` reference, so the grid follows dark mode (`.app-dark`) and a primary colour that\n * changes at runtime without any code, and it needs no stylesheet. This is the AG Grid 33+ Theming API; the CSS\n * `.helix-ag-grid` class of `styles.css` is only for grids that still use a legacy theme (`theme=\"legacy\"`).\n */\nexport const helixGridTheme = themeQuartz.withParams({\n backgroundColor: 'var(--h-content-background)',\n foregroundColor: 'var(--h-text-color)',\n accentColor: 'var(--h-primary-color)',\n borderColor: 'var(--h-content-border-color)',\n invalidColor: 'var(--h-form-field-invalid-border-color)',\n chromeBackgroundColor: 'var(--h-content-background)',\n headerBackgroundColor: 'var(--h-content-background)',\n headerTextColor: 'var(--h-text-color)',\n headerFontWeight: 600,\n oddRowBackgroundColor: 'color-mix(in srgb, var(--h-content-border-color) 25%, transparent)',\n rowHoverColor: 'var(--h-content-hover-background)',\n selectedRowBackgroundColor: 'var(--h-highlight-background)',\n inputBackgroundColor: 'var(--h-form-field-background)',\n fontFamily: 'inherit',\n wrapperBorderRadius: 'var(--h-content-border-radius)',\n});\n","export const HELIX_AG_GRID_VERSION = '0.1.0';\n\nexport { numberCellStyle } from './lib/cell-styles/cell-styles';\nexport type { AgGridFormatterParams, AnyRow } from './lib/formatters/ag-grid-formatters';\nexport {\n cetDateFormatter,\n cetDateTimeFormatter,\n cetTimeFormatter,\n currencyFormatter,\n intlNumberFormatter,\n numberFormatter,\n rawNumberFormatter,\n} from './lib/formatters/ag-grid-formatters';\nexport type { ParseNumberOptions } from './lib/parsers/number-parsers';\nexport {\n coerceValue,\n numberValueParser,\n parseNumber,\n parseNumberValue,\n} from './lib/parsers/number-parsers';\nexport { helixGridTheme } from './lib/theme/helix-theme';\n"],"mappings":";AAYA,SAAgB,gBAAgB,QAAuB;CACrD,OAAO,OAAO,QACV;EAAE,WAAW;EAAS,OAAO;CAAoB,IACjD,EAAE,WAAW,QAAO;AAC1B;ACUA,SAAgB,gBACd,QAAgE;CAEhE,MAAM,IAAI,OAAO;CACjB,IAAI,KAAK,QAAQ,OAAO,MAAM,CAAC,GAAG,OAAO;CACzC,OAAO,EAAE,eAAc;AACzB;AAWA,SAAgB,mBACd,QAAgE;CAEhE,MAAM,IAAI,OAAO;CACjB,IAAI,KAAK,MAAM,OAAO;CACtB,OAAO,EAAE,SAAQ;AACnB;AAaA,SAAgB,oBACd,QACA,cAA+B;CAE/B,MAAM,IAAI,OAAO;CACjB,IAAI,KAAK,QAAQ,OAAO,MAAM,CAAC,GAAG,OAAO;CACzC,OAAO,aAAa,OAAO,CAAC;AAC9B;AAaA,SAAgB,kBACd,eAAe,OACf,SAAS,SAAO;CAEhB,MAAM,MAAM,IAAI,KAAK,aAAa,QAAQ;EAAE,OAAO;EAAY,UAAU;CAAY,CAAE;CACvF,QAAQ,WAAU;EAChB,MAAM,IAAI,OAAO;EACjB,IAAI,KAAK,QAAQ,OAAO,MAAM,CAAC,GAAG,OAAO;EACzC,OAAO,IAAI,OAAO,CAAC;CAC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I,OAAO;CAGjD,MAAM,QAAQ,IAAI,KAAK,aAAa,MAAM,CAAC,CAAC,cAAc,MAAM;CAChE,MAAM,QAAQ,MAAM,MAAM,MAAM,EAAE,SAAS,OAAO,CAAC,EAAE,SAAS;CAC9D,MAAM,UAAU,MAAM,MAAM,MAAM,EAAE,SAAS,SAAS,CAAC,EAAE,SAAS;CAElE,MAAM,aAAa,MAAM,KAAI,CAAE,CAAC,WAAW,OAAO,EAAE,CAAC,CAAC,QAAQ,SAAS,GAAG;CAG1E,OAAO,YADG,OAAO,WAAW,UACT,GAAG,OAAO;AAC/B;AAqBA,SAAgB,iBACd,OACA,SAA4B;CAE5B,IAAI,SAAS,QAAQ,MAAM,KAAI,MAAO,IAAI,OAAO;CAGjD,IADiB,MAAM,SAAS,GAC5B,GACF,OAAO,YAAY,OAAO,SAAS,OAAO;CAI5C,OAAO,YADG,OAAO,WAAW,MAAM,KAAI,CACnB,GAAG,OAAO;AAC/B;AAaA,SAAgB,kBACd,QACA,SAA4B;CAE5B,OAAO,iBAAiB,OAAO,UAAuC,OAAO;AAC/E;AC9FA,MAAa,iBAAiB,YAAY,WAAW;CACnD,iBAAiB;CACjB,iBAAiB;CACjB,aAAa;CACb,aAAa;CACb,cAAc;CACd,uBAAuB;CACvB,uBAAuB;CACvB,iBAAiB;CACjB,kBAAkB;CAClB,uBAAuB;CACvB,eAAe;CACf,4BAA4B;CAC5B,sBAAsB;CACtB,YAAY;CACZ,qBAAqB;AACtB,CAAA;AC9BD,MAAa,wBAAwB"}
|
package/package.json
CHANGED
package/styles.css
CHANGED
|
@@ -1,43 +1,40 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AG Grid
|
|
2
|
+
* AG Grid theme for legacy-theme grids — Helix
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Prefer `helixGridTheme` (the Theming API of AG Grid 33+, see the README): it needs no stylesheet. This class is for
|
|
5
|
+
* grids that still use a legacy theme (`theme="legacy"` in AG Grid 33+, or the `ag-theme-*` classes before):
|
|
6
|
+
* put `.helix-ag-grid` next to the legacy theme class on the grid host.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
* --helix-* design tokens defined in @gravionlabs/helix styles.css
|
|
9
|
-
* --p-* PrimeNG Aura tokens injected at runtime by ThemeService
|
|
10
|
-
*
|
|
11
|
-
* Approach: https://www.ag-grid.com/javascript-data-grid/theming-css/#overriding-theme-parameters-with-custom-properties
|
|
8
|
+
* Only `--h-*` Helix tokens are read, so the grid follows dark mode (`.app-dark`) and a runtime primary colour change.
|
|
12
9
|
*/
|
|
13
10
|
|
|
14
11
|
.helix-ag-grid {
|
|
15
12
|
/* ── Colours ──────────────────────────────────────────────────────────── */
|
|
16
|
-
--ag-background-color: var(--
|
|
13
|
+
--ag-background-color: var(--h-content-background);
|
|
17
14
|
--ag-foreground-color: var(--h-text-color);
|
|
18
15
|
--ag-text-color: var(--ag-foreground-color);
|
|
19
16
|
--ag-accent-color: var(--h-primary-color);
|
|
20
17
|
--ag-invalid-color: var(--h-form-field-invalid-border-color);
|
|
21
|
-
--ag-border-color: var(--
|
|
18
|
+
--ag-border-color: var(--h-content-border-color);
|
|
22
19
|
--ag-wrapper-border: none;
|
|
23
|
-
--ag-row-border: solid 1px var(--
|
|
20
|
+
--ag-row-border: solid 1px var(--h-content-border-color);
|
|
24
21
|
--ag-odd-row-background-color: color-mix(
|
|
25
22
|
in srgb,
|
|
26
23
|
transparent,
|
|
27
|
-
var(--
|
|
24
|
+
var(--h-content-border-color) 10%
|
|
28
25
|
);
|
|
29
|
-
--ag-row-hover-color: var(--
|
|
26
|
+
--ag-row-hover-color: var(--h-content-hover-background);
|
|
30
27
|
|
|
31
28
|
/* ── Typography ───────────────────────────────────────────────────────── */
|
|
32
|
-
--ag-font-family:
|
|
33
|
-
--ag-font-size: 0.
|
|
29
|
+
--ag-font-family: inherit;
|
|
30
|
+
--ag-font-size: 0.875rem;
|
|
34
31
|
|
|
35
32
|
/* ── Header ───────────────────────────────────────────────────────────── */
|
|
36
|
-
--ag-header-background-color: var(--
|
|
37
|
-
--ag-header-font-family:
|
|
38
|
-
--ag-header-font-weight:
|
|
39
|
-
--ag-header-font-size: 0.
|
|
40
|
-
--ag-header-text-color: var(--h-
|
|
33
|
+
--ag-header-background-color: var(--h-content-background);
|
|
34
|
+
--ag-header-font-family: inherit;
|
|
35
|
+
--ag-header-font-weight: 600;
|
|
36
|
+
--ag-header-font-size: 0.875rem;
|
|
37
|
+
--ag-header-text-color: var(--h-text-color);
|
|
41
38
|
|
|
42
39
|
/* ── Cells ────────────────────────────────────────────────────────────── */
|
|
43
40
|
--ag-cell-text-color: var(--h-text-color);
|
|
@@ -69,10 +66,10 @@
|
|
|
69
66
|
}
|
|
70
67
|
|
|
71
68
|
.ag-dnd-ghost {
|
|
72
|
-
font-family:
|
|
73
|
-
font-size: 0.
|
|
74
|
-
font-weight:
|
|
75
|
-
color: var(--h-
|
|
69
|
+
font-family: inherit;
|
|
70
|
+
font-size: 0.875rem;
|
|
71
|
+
font-weight: 600;
|
|
72
|
+
color: var(--h-text-color);
|
|
76
73
|
}
|
|
77
74
|
|
|
78
75
|
.ag-paging-panel {
|
|
@@ -10,8 +10,13 @@ import { CellClassParams, CellStyle, ValueFormatterParams, ValueParserParams } f
|
|
|
10
10
|
* ```
|
|
11
11
|
*/
|
|
12
12
|
export declare function numberCellStyle(params: CellClassParams): CellStyle;
|
|
13
|
+
/**
|
|
14
|
+
* The row type of the formatters. A formatter only reads the value, so it must fit a column of any row type;
|
|
15
|
+
* `unknown` would make it unusable in a typed `ColDef<Row>` (the row node type is invariant).
|
|
16
|
+
*/
|
|
17
|
+
type AnyRow = any;
|
|
13
18
|
/** Type alias for AG Grid's `ValueFormatterParams`, used by all formatter functions. */
|
|
14
|
-
type AgGridFormatterParams<TData =
|
|
19
|
+
type AgGridFormatterParams<TData = AnyRow, TValue = unknown> = ValueFormatterParams<TData, TValue>;
|
|
15
20
|
/**
|
|
16
21
|
* Formats a numeric cell value using the system locale (`toLocaleString`).
|
|
17
22
|
* Returns `''` for `null`, `undefined`, or `NaN`.
|
|
@@ -21,7 +26,7 @@ type AgGridFormatterParams<TData = unknown, TValue = unknown> = ValueFormatterPa
|
|
|
21
26
|
* { field: 'amount', valueFormatter: numberFormatter }
|
|
22
27
|
* ```
|
|
23
28
|
*/
|
|
24
|
-
export declare function numberFormatter(params: AgGridFormatterParams<
|
|
29
|
+
export declare function numberFormatter(params: AgGridFormatterParams<AnyRow, number | null | undefined>): string;
|
|
25
30
|
/**
|
|
26
31
|
* Returns the raw string representation of a number without any locale
|
|
27
32
|
* formatting. Returns `''` for `null` or `undefined`.
|
|
@@ -31,7 +36,7 @@ export declare function numberFormatter(params: AgGridFormatterParams<unknown, n
|
|
|
31
36
|
* { field: 'id', valueFormatter: rawNumberFormatter }
|
|
32
37
|
* ```
|
|
33
38
|
*/
|
|
34
|
-
export declare function rawNumberFormatter(params: AgGridFormatterParams<
|
|
39
|
+
export declare function rawNumberFormatter(params: AgGridFormatterParams<AnyRow, number | null | undefined>): string;
|
|
35
40
|
/**
|
|
36
41
|
* Formats a number using a caller-supplied `Intl.NumberFormat` instance,
|
|
37
42
|
* allowing full control over locale, currency, fraction digits, etc.
|
|
@@ -43,7 +48,7 @@ export declare function rawNumberFormatter(params: AgGridFormatterParams<unknown
|
|
|
43
48
|
* { field: 'price', valueFormatter: (p) => intlNumberFormatter(p, fmt) }
|
|
44
49
|
* ```
|
|
45
50
|
*/
|
|
46
|
-
export declare function intlNumberFormatter(params: AgGridFormatterParams<
|
|
51
|
+
export declare function intlNumberFormatter(params: AgGridFormatterParams<AnyRow, number | null | undefined>, numberFormat: Intl.NumberFormat): string;
|
|
47
52
|
/**
|
|
48
53
|
* Factory that returns a currency formatter closure using `Intl.NumberFormat`
|
|
49
54
|
* with `style: 'currency'`. Defaults to EUR / de-DE.
|
|
@@ -55,7 +60,7 @@ export declare function intlNumberFormatter(params: AgGridFormatterParams<unknow
|
|
|
55
60
|
* { field: 'price', valueFormatter: currencyFormatter('USD','en-US') } // '$99.90'
|
|
56
61
|
* ```
|
|
57
62
|
*/
|
|
58
|
-
export declare function currencyFormatter(currencyCode?: string, locale?: string): (params: AgGridFormatterParams<
|
|
63
|
+
export declare function currencyFormatter(currencyCode?: string, locale?: string): (params: AgGridFormatterParams<AnyRow, number | null | undefined>) => string;
|
|
59
64
|
type DateInput = Date | string | null | undefined;
|
|
60
65
|
/**
|
|
61
66
|
* Formats a `Date` or ISO string as a CET date: `'15.06.2024'`.
|
|
@@ -66,7 +71,7 @@ type DateInput = Date | string | null | undefined;
|
|
|
66
71
|
* { field: 'date', valueFormatter: cetDateFormatter }
|
|
67
72
|
* ```
|
|
68
73
|
*/
|
|
69
|
-
export declare function cetDateFormatter(params: AgGridFormatterParams<
|
|
74
|
+
export declare function cetDateFormatter(params: AgGridFormatterParams<AnyRow, DateInput>): string;
|
|
70
75
|
/**
|
|
71
76
|
* Formats a `Date` or ISO string as a CET date-time: `'15.06.2024 12:30:00'`.
|
|
72
77
|
* Returns `''` for `null`, `undefined`, or invalid dates.
|
|
@@ -76,7 +81,7 @@ export declare function cetDateFormatter(params: AgGridFormatterParams<unknown,
|
|
|
76
81
|
* { field: 'updatedAt', valueFormatter: cetDateTimeFormatter }
|
|
77
82
|
* ```
|
|
78
83
|
*/
|
|
79
|
-
export declare function cetDateTimeFormatter(params: AgGridFormatterParams<
|
|
84
|
+
export declare function cetDateTimeFormatter(params: AgGridFormatterParams<AnyRow, DateInput>): string;
|
|
80
85
|
/**
|
|
81
86
|
* Formats a `Date` or ISO string as a CET time: `'12:30'`.
|
|
82
87
|
* Returns `''` for `null`, `undefined`, or invalid dates.
|
|
@@ -86,7 +91,7 @@ export declare function cetDateTimeFormatter(params: AgGridFormatterParams<unkno
|
|
|
86
91
|
* { field: 'startTime', valueFormatter: cetTimeFormatter }
|
|
87
92
|
* ```
|
|
88
93
|
*/
|
|
89
|
-
export declare function cetTimeFormatter(params: AgGridFormatterParams<
|
|
94
|
+
export declare function cetTimeFormatter(params: AgGridFormatterParams<AnyRow, DateInput>): string;
|
|
90
95
|
/** Bounds for number validation. */
|
|
91
96
|
interface ParseNumberOptions {
|
|
92
97
|
min?: number;
|
|
@@ -148,5 +153,18 @@ export declare function parseNumberValue(value: string | null | undefined, optio
|
|
|
148
153
|
* ```
|
|
149
154
|
*/
|
|
150
155
|
export declare function numberValueParser(params: ValueParserParams, options?: ParseNumberOptions): number | null;
|
|
156
|
+
/**
|
|
157
|
+
* The AG Grid theme of Helix: Quartz with its parameters pointed at the Helix design tokens.
|
|
158
|
+
*
|
|
159
|
+
* ```ts
|
|
160
|
+
* import { helixGridTheme } from '@gravionlabs/helix-ag-grid';
|
|
161
|
+
* // <ag-grid-angular [theme]="theme" …> theme = helixGridTheme;
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* Every colour is a `var(--h-*)` reference, so the grid follows dark mode (`.app-dark`) and a primary colour that
|
|
165
|
+
* changes at runtime without any code, and it needs no stylesheet. This is the AG Grid 33+ Theming API; the CSS
|
|
166
|
+
* `.helix-ag-grid` class of `styles.css` is only for grids that still use a legacy theme (`theme="legacy"`).
|
|
167
|
+
*/
|
|
168
|
+
export declare const helixGridTheme: import("ag-grid-community").Theme<import("ag-grid-community").ThemeDefaultParams>;
|
|
151
169
|
export declare const HELIX_AG_GRID_VERSION = "0.1.0";
|
|
152
|
-
export type { AgGridFormatterParams, ParseNumberOptions };
|
|
170
|
+
export type { AgGridFormatterParams, AnyRow, ParseNumberOptions };
|