@gravionlabs/helix-ag-grid 22.5.0 → 22.6.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.
|
@@ -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/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;CACrB;AACF;AAMA,SAAS,OAAO,OAAgB;CAC9B,IAAI,SAAS,MAAM,OAAO;CAC1B,MAAM,IAAI,iBAAiB,OA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,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"}
|
|
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 */\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;ACSA,SAAgB,gBACd,QAAgE;CAEhE,MAAM,IAAI,OAAO;CACjB,IAAI,KAAK,QAAQ,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uC,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
|
@@ -18,11 +18,7 @@
|
|
|
18
18
|
--ag-border-color: var(--h-content-border-color);
|
|
19
19
|
--ag-wrapper-border: none;
|
|
20
20
|
--ag-row-border: solid 1px var(--h-content-border-color);
|
|
21
|
-
--ag-odd-row-background-color: color-mix(
|
|
22
|
-
in srgb,
|
|
23
|
-
transparent,
|
|
24
|
-
var(--h-content-border-color) 10%
|
|
25
|
-
);
|
|
21
|
+
--ag-odd-row-background-color: color-mix(in srgb, transparent, var(--h-content-border-color) 10%);
|
|
26
22
|
--ag-row-hover-color: var(--h-content-hover-background);
|
|
27
23
|
|
|
28
24
|
/* ── Typography ───────────────────────────────────────────────────────── */
|