@malloydata/render 0.0.330 → 0.0.332
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/.storybook/registered_data.json +1 -1
- package/dist/module/component/cell-utils.d.ts +40 -0
- package/dist/module/component/render-numeric-field.d.ts +37 -5
- package/dist/module/data_tree/cells/atomic.d.ts +2 -7
- package/dist/module/html/data_styles.d.ts +8 -0
- package/dist/module/index.mjs +24783 -23993
- package/dist/module/index.umd.js +600 -345
- package/dist/module/plugins/big-value/big-value-component.d.ts +17 -0
- package/dist/module/plugins/big-value/big-value-plugin.d.ts +42 -0
- package/dist/module/plugins/big-value/big-value-settings.d.ts +46 -0
- package/dist/module/plugins/big-value/index.d.ts +2 -0
- package/dist/module/plugins/big-value/settings-to-tag.d.ts +3 -0
- package/dist/module/plugins/index.d.ts +1 -0
- package/dist/module/util.d.ts +55 -0
- package/package.json +17 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
["products.parquet", "logos.csv", "missing_data.csv"]
|
|
1
|
+
["products.parquet", "logos.csv", "missing_data.csv", "order_items.parquet"]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Cell } from '../data_tree';
|
|
2
|
+
import { Tag } from '@malloydata/malloy-tag';
|
|
3
|
+
export interface RenderCellValueOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Value to return for null cells.
|
|
6
|
+
* Defaults to NULL_SYMBOL ('∅').
|
|
7
|
+
*/
|
|
8
|
+
nullValue?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Override tag for formatting.
|
|
11
|
+
* Use this when rendering array elements - pass the array field's tag
|
|
12
|
+
* so formatting (currency, percent, etc.) is applied from the array definition.
|
|
13
|
+
* If not provided, uses the cell's own field tag.
|
|
14
|
+
*/
|
|
15
|
+
tag?: Tag;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Render a Cell value to a formatted display string.
|
|
19
|
+
*
|
|
20
|
+
* Handles all cell types with appropriate formatting:
|
|
21
|
+
* - Numbers: uses renderNumberCell (handles bigint precision + formatting tags)
|
|
22
|
+
* - Dates: uses renderDateTimeField with isDate: true
|
|
23
|
+
* - Timestamps: uses renderDateTimeField with isDate: false
|
|
24
|
+
* - Strings: returns value directly
|
|
25
|
+
* - Booleans: returns 'true' or 'false'
|
|
26
|
+
* - Null: returns nullValue option (defaults to NULL_SYMBOL)
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Basic usage (pivot headers, etc.)
|
|
30
|
+
* renderCellValue(cell)
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // Array elements - use array field's tag for formatting
|
|
34
|
+
* renderCellValue(elementCell, { tag: arrayField.tag })
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Custom null display
|
|
38
|
+
* renderCellValue(cell, { nullValue: '' })
|
|
39
|
+
*/
|
|
40
|
+
export declare function renderCellValue(cell: Cell, options?: RenderCellValueOptions): string;
|
|
@@ -1,11 +1,43 @@
|
|
|
1
1
|
import { RenderTimeStringOptions } from '../util';
|
|
2
|
-
import { Field } from '../data_tree';
|
|
3
|
-
|
|
2
|
+
import { Field, NumberCell } from '../data_tree';
|
|
3
|
+
import { Tag } from '@malloydata/malloy-tag';
|
|
4
|
+
/**
|
|
5
|
+
* Renders a numeric field with formatting based on tags.
|
|
6
|
+
*
|
|
7
|
+
* Supports:
|
|
8
|
+
* - Currency shorthand: # currency=usd2m, # currency=eur0k
|
|
9
|
+
* - Currency verbose: # currency { scale=m decimals=2 suffix=finance }
|
|
10
|
+
* - Number shorthand: # number=1k, # number=0m, # number=auto
|
|
11
|
+
* - Number verbose: # number { scale=m decimals=2 suffix=word }
|
|
12
|
+
* - Legacy: # number=big, # currency=euro
|
|
13
|
+
*/
|
|
14
|
+
export declare function renderNumericField(f: Field, value: number | null | undefined, tagOverride?: Tag): string;
|
|
4
15
|
/**
|
|
5
16
|
* Render a big number value (stored as string for precision).
|
|
6
17
|
* Used when NumberCell.stringValue is defined (bigint/bigdecimal subtypes).
|
|
7
18
|
* Default formatting preserves full precision with comma separators.
|
|
8
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* Note: percent, duration, and custom number formats are lossy for values > 2^53
|
|
21
|
+
* because they require numeric operations. Currency preserves precision.
|
|
22
|
+
*/
|
|
23
|
+
export declare function renderBigNumberField(f: Field, value: string | null | undefined, tagOverride?: Tag): string;
|
|
24
|
+
/**
|
|
25
|
+
* Render a NumberCell for display, automatically handling bigint precision.
|
|
26
|
+
*
|
|
27
|
+
* USE THIS FUNCTION when rendering numeric values from cells in plugins/components.
|
|
28
|
+
*
|
|
29
|
+
* Why this exists:
|
|
30
|
+
* - NumberCell.value is always a JS number, which loses precision for integers > 2^53
|
|
31
|
+
* - NumberCell.stringValue preserves full precision for bigint fields
|
|
32
|
+
* - This function automatically picks the right representation
|
|
33
|
+
*
|
|
34
|
+
* Example:
|
|
35
|
+
* import {renderNumberCell} from '@/component/render-numeric-field';
|
|
36
|
+
* const displayValue = renderNumberCell(cell);
|
|
37
|
+
*
|
|
38
|
+
* @param cell - A NumberCell from the data tree
|
|
39
|
+
* @param tagOverride - Optional tag to use for formatting (e.g., for array elements, use the array field's tag)
|
|
40
|
+
* @returns Formatted string for display, respecting field tags (currency, percent, etc.)
|
|
9
41
|
*/
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function renderDateTimeField(f: Field, value: Date | null | undefined, options?: RenderTimeStringOptions): string;
|
|
42
|
+
export declare function renderNumberCell(cell: NumberCell, tagOverride?: Tag): string;
|
|
43
|
+
export declare function renderDateTimeField(f: Field, value: Date | null | undefined, options?: RenderTimeStringOptions, tagOverride?: Tag): string;
|
|
@@ -10,19 +10,15 @@ export declare class NullCell extends CellBase {
|
|
|
10
10
|
get value(): null;
|
|
11
11
|
get literalValue(): Malloy.LiteralValue | undefined;
|
|
12
12
|
}
|
|
13
|
-
/** Type for either regular or big number cells from Thrift */
|
|
14
|
-
type NumberCellInput = Malloy.CellWithNumberCell | Malloy.CellWithBigNumberCell;
|
|
15
13
|
/**
|
|
16
14
|
* Unified cell for all numeric values.
|
|
17
15
|
* Handles both regular numbers and big numbers (bigint/bigdecimal).
|
|
18
16
|
*/
|
|
19
17
|
export declare class NumberCell extends CellBase {
|
|
20
|
-
readonly cell:
|
|
18
|
+
readonly cell: Malloy.CellWithNumberCell;
|
|
21
19
|
readonly field: NumberField;
|
|
22
20
|
readonly parent: NestCell | undefined;
|
|
23
|
-
|
|
24
|
-
private readonly _stringValue;
|
|
25
|
-
constructor(cell: NumberCellInput, field: NumberField, parent: NestCell | undefined);
|
|
21
|
+
constructor(cell: Malloy.CellWithNumberCell, field: NumberField, parent: NestCell | undefined);
|
|
26
22
|
/**
|
|
27
23
|
* Returns the numeric value as a JS number.
|
|
28
24
|
* May be lossy for bigint/bigdecimal values > 2^53.
|
|
@@ -109,4 +105,3 @@ export declare class BooleanCell extends CellBase {
|
|
|
109
105
|
compareTo(other: Cell): 1 | 0 | -1;
|
|
110
106
|
get literalValue(): Malloy.LiteralValue | undefined;
|
|
111
107
|
}
|
|
112
|
-
export {};
|
|
@@ -86,14 +86,22 @@ export declare enum Currency {
|
|
|
86
86
|
Euros = "euro",
|
|
87
87
|
Pounds = "pound"
|
|
88
88
|
}
|
|
89
|
+
export type Scale = 'k' | 'm' | 'b' | 't' | 'q' | 'auto';
|
|
90
|
+
export type SuffixFormat = 'letter' | 'lower' | 'word' | 'short' | 'finance' | 'scientific' | 'none';
|
|
89
91
|
export interface CurrencyRenderOptions extends TextRenderOptions {
|
|
90
92
|
currency?: Currency;
|
|
93
|
+
scale?: Scale;
|
|
94
|
+
decimals?: number;
|
|
95
|
+
suffix?: SuffixFormat;
|
|
91
96
|
}
|
|
92
97
|
export interface TimeRenderOptions extends TextRenderOptions {
|
|
93
98
|
time?: Record<string, unknown>;
|
|
94
99
|
}
|
|
95
100
|
export interface NumberRenderOptions extends TextRenderOptions {
|
|
96
101
|
value_format?: string;
|
|
102
|
+
scale?: Scale;
|
|
103
|
+
decimals?: number;
|
|
104
|
+
suffix?: SuffixFormat;
|
|
97
105
|
}
|
|
98
106
|
export declare enum DataVolumeUnit {
|
|
99
107
|
Bytes = "bytes",
|