/** * Cross-package helpers for per-column value formatting. Used by both * `viewer-datagrid` (cell formatting) and `viewer-charts` (axis ticks, * tooltips, legends) so a column's `number_format` / `date_format` * configuration produces identical output across plugins. * * The format configs mirror the `Intl.NumberFormatOptions` / * `Intl.DateTimeFormatOptions` shapes one-for-one — they're written * straight into the respective constructors. */ import type { CustomNumberFormatConfig } from "../../dist/ts-rs/CustomNumberFormatConfig.d.ts"; import type { NumberFormatStyle } from "../../dist/ts-rs/NumberFormatStyle.d.ts"; import type { Notation } from "../../dist/ts-rs/Notation.d.ts"; import type { DatetimeFormat } from "../../dist/ts-rs/DatetimeFormat.d.ts"; /** * A numeric column's `number_format` (`columns_config` value), exactly as * the Style tab's editor WRITES it — the ts-rs projection of the Rust * `CustomNumberFormatConfig`, re-composed with its serde-flattened * `style` and `notation` families (ts-rs cannot flatten `Option`, * so the Rust type `#[ts(skip)]`s them and they export separately). */ export type NumberFormatConfig = CustomNumberFormatConfig & Partial & Partial; /** * A datetime column's `date_format` (`columns_config` value), a subset of * `Intl.DateTimeFormatOptions`. */ export type DateFormatConfig = DatetimeFormat; /** The `date_format` keys that apply as one group. */ export declare const DATE_FORMAT_SHAPE_KEYS: readonly ["dateStyle", "timeStyle", "weekday", "year", "month", "day", "hour", "minute", "second", "fractionalSecondDigits"]; /** The `date_format` keys that apply individually. */ export declare const DATE_FORMAT_MODIFIER_KEYS: readonly ["timeZone", "hour12"]; /** Whether `cfg` sets any of the `date_format` keys that apply as one group. */ export declare function hasDateFormatShape(cfg: DateFormatConfig | undefined): cfg is DateFormatConfig; /** The `date_format` options that apply individually. */ export type DateFormatModifiers = Pick; /** The `date_format` keys of `cfg` that apply individually, if it sets any. */ export declare function dateFormatModifiers(cfg: DateFormatConfig | undefined): DateFormatModifiers | undefined; /** * `defaults` is the calling plugin's declared default format, filling in * the fields `cfg` leaves unset. */ export declare function createNumberFormatter(type: string, cfg?: NumberFormatConfig, defaults?: NumberFormatConfig): Intl.NumberFormat; /** * `cfg` layered over `defaults`, then over `base`, by the `date_format` * group rule, as `Intl.DateTimeFormat` options. */ export declare function resolveDateFormat(cfg: DateFormatConfig | undefined, defaults: DateFormatConfig | undefined, base: DateFormatConfig): Intl.DateTimeFormatOptions; /** * `defaults` is the calling plugin's declared default `date_format`, which * `cfg` overrides by the `date_format` group rule. */ export declare function createDatetimeFormatter(cfg?: DateFormatConfig, defaults?: DateFormatConfig): Intl.DateTimeFormat; /** * `defaults` follows the same contract as [`createDatetimeFormatter`]; * only `dateStyle` applies, in UTC. */ export declare function createDateFormatter(cfg?: DateFormatConfig, defaults?: DateFormatConfig): Intl.DateTimeFormat; /** * Recover the source column name from a synthetic split-by path. Split * pivoting produces paths of the form `|...|`; * per-column config (formatters, aggregate styling, …) is always keyed * on the trailing source column. */ export declare function sourceColumn(path: string): string;