@malloydata/render 0.0.329 → 0.0.331

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
- ["products.parquet", "logos.csv", "missing_data.csv"]
1
+ ["products.parquet", "logos.csv", "missing_data.csv", "order_items.parquet"]
@@ -1,4 +1,31 @@
1
1
  import { RenderTimeStringOptions } from '../util';
2
- import { Field } from '../data_tree';
2
+ import { Field, NumberCell } from '../data_tree';
3
3
  export declare function renderNumericField(f: Field, value: number | null | undefined): string;
4
+ /**
5
+ * Render a big number value (stored as string for precision).
6
+ * Used when NumberCell.stringValue is defined (bigint/bigdecimal subtypes).
7
+ * Default formatting preserves full precision with comma separators.
8
+ *
9
+ * Note: percent, duration, and custom number formats are lossy for values > 2^53
10
+ * because they require numeric operations. Currency preserves precision.
11
+ */
12
+ export declare function renderBigNumberField(f: Field, value: string | null | undefined): string;
13
+ /**
14
+ * Render a NumberCell for display, automatically handling bigint precision.
15
+ *
16
+ * USE THIS FUNCTION when rendering numeric values from cells in plugins/components.
17
+ *
18
+ * Why this exists:
19
+ * - NumberCell.value is always a JS number, which loses precision for integers > 2^53
20
+ * - NumberCell.stringValue preserves full precision for bigint fields
21
+ * - This function automatically picks the right representation
22
+ *
23
+ * Example:
24
+ * import {renderNumberCell} from '@/component/render-numeric-field';
25
+ * const displayValue = renderNumberCell(cell);
26
+ *
27
+ * @param cell - A NumberCell from the data tree
28
+ * @returns Formatted string for display, respecting field tags (currency, percent, etc.)
29
+ */
30
+ export declare function renderNumberCell(cell: NumberCell): string;
4
31
  export declare function renderDateTimeField(f: Field, value: Date | null | undefined, options?: RenderTimeStringOptions): string;
@@ -10,38 +10,42 @@ export declare class NullCell extends CellBase {
10
10
  get value(): null;
11
11
  get literalValue(): Malloy.LiteralValue | undefined;
12
12
  }
13
+ /**
14
+ * Unified cell for all numeric values.
15
+ * Handles both regular numbers and big numbers (bigint/bigdecimal).
16
+ */
13
17
  export declare class NumberCell extends CellBase {
14
18
  readonly cell: Malloy.CellWithNumberCell;
15
19
  readonly field: NumberField;
16
20
  readonly parent: NestCell | undefined;
17
21
  constructor(cell: Malloy.CellWithNumberCell, field: NumberField, parent: NestCell | undefined);
18
- get value(): number;
19
22
  /**
20
23
  * Returns the numeric value as a JS number.
21
- * For NumberCell, this is the same as `.value`.
24
+ * May be lossy for bigint/bigdecimal values > 2^53.
22
25
  */
23
- number(): number;
24
- compareTo(other: Cell): 1 | 0 | -1;
25
- get literalValue(): Malloy.LiteralValue | undefined;
26
- }
27
- export declare class BigNumberCell extends CellBase {
28
- readonly cell: Malloy.CellWithBigNumberCell;
29
- readonly field: NumberField;
30
- readonly parent: NestCell | undefined;
31
- constructor(cell: Malloy.CellWithBigNumberCell, field: NumberField, parent: NestCell | undefined);
26
+ get value(): number;
32
27
  /**
33
- * Returns the string representation of the big number value.
34
- * Use this for display or when precision matters.
28
+ * Returns the precise string representation for large values.
29
+ * Undefined for regular numbers that fit in JS number.
35
30
  */
36
- get value(): string;
31
+ get stringValue(): string | undefined;
32
+ /**
33
+ * Returns the number subtype from the schema.
34
+ * 'integer' | 'decimal' | 'bigint' | future 'bigdecimal'
35
+ */
36
+ get subtype(): Malloy.NumberSubtype | undefined;
37
37
  /**
38
- * Returns the value as a JS number (potentially lossy for large values).
39
- * Use this when a number is required (e.g., for charts, calculations).
38
+ * Returns true if this value needs string representation for precision.
39
+ */
40
+ needsStringPrecision(): boolean;
41
+ /**
42
+ * Returns the numeric value as a JS number.
43
+ * Alias for .value for API consistency.
40
44
  */
41
- number(): number;
45
+ numberValue(): number;
42
46
  /**
43
47
  * Returns the value as a JS BigInt for precise integer arithmetic.
44
- * Only valid when subtype is 'bigint'.
48
+ * Only valid when stringValue is defined and subtype is 'bigint'.
45
49
  */
46
50
  bigint(): bigint;
47
51
  compareTo(other: Cell): 1 | 0 | -1;
@@ -1,4 +1,4 @@
1
- import { Cell, NestCell, RecordCell, ArrayCell, BigNumberCell, BooleanCell, DateCell, JSONCell, NullCell, NumberCell, RepeatedRecordCell, StringCell, TimestampCell, TimeCell, RecordOrRepeatedRecordCell, CellValue } from '.';
1
+ import { Cell, NestCell, RecordCell, ArrayCell, BooleanCell, DateCell, JSONCell, NullCell, NumberCell, RepeatedRecordCell, StringCell, TimestampCell, TimeCell, RecordOrRepeatedRecordCell, CellValue } from '.';
2
2
  import { Field } from '../fields';
3
3
  import { DrillEntry } from '../types';
4
4
  import type * as Malloy from '@malloydata/malloy-interfaces';
@@ -16,7 +16,6 @@ export declare abstract class CellBase {
16
16
  isRecordOrRepeatedRecord(): this is RecordOrRepeatedRecordCell;
17
17
  isNest(): this is NestCell;
18
18
  isNumber(): this is NumberCell;
19
- isBigNumber(): this is BigNumberCell;
20
19
  isDate(): this is DateCell;
21
20
  isTime(): this is TimeCell;
22
21
  isJSON(): this is JSONCell;
@@ -1,13 +1,13 @@
1
1
  import { Field } from '../fields';
2
2
  import { ArrayCell, RecordCell, RepeatedRecordCell } from './nest';
3
- import { BigNumberCell, BooleanCell, DateCell, JSONCell, NullCell, NumberCell, SQLNativeCell, StringCell, TimestampCell } from './atomic';
3
+ import { BooleanCell, DateCell, JSONCell, NullCell, NumberCell, SQLNativeCell, StringCell, TimestampCell } from './atomic';
4
4
  import type * as Malloy from '@malloydata/malloy-interfaces';
5
5
  export { ArrayCell, RecordCell, RepeatedRecordCell, RootCell } from './nest';
6
- export { BigNumberCell, BooleanCell, DateCell, JSONCell, NullCell, NumberCell, SQLNativeCell, StringCell, TimestampCell, } from './atomic';
6
+ export { BooleanCell, DateCell, JSONCell, NullCell, NumberCell, SQLNativeCell, StringCell, TimestampCell, } from './atomic';
7
7
  export type NestCell = ArrayCell | RecordCell;
8
8
  export type RecordOrRepeatedRecordCell = RepeatedRecordCell | RecordCell;
9
9
  export type TimeCell = DateCell | TimestampCell;
10
- export type Cell = ArrayCell | RecordCell | NullCell | NumberCell | BigNumberCell | DateCell | JSONCell | StringCell | TimestampCell | BooleanCell | SQLNativeCell;
10
+ export type Cell = ArrayCell | RecordCell | NullCell | NumberCell | DateCell | JSONCell | StringCell | TimestampCell | BooleanCell | SQLNativeCell;
11
11
  export type CellValue = string | number | boolean | Date | Cell[] | Record<string, Cell> | null;
12
12
  export declare const Cell: {
13
13
  from(cell: Malloy.Cell, field: Field, parent: NestCell): Cell;