@malloydata/render 0.0.353 → 0.0.355
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/malloy-stories-indexer.ts +3 -2
- package/dist/module/component/cell-utils.d.ts +9 -8
- package/dist/module/component/render-numeric-field.d.ts +7 -21
- package/dist/module/component/table/pivot-utils.d.ts +1 -1
- package/dist/module/component/tag-configs.d.ts +76 -0
- package/dist/module/component/types.d.ts +0 -1
- package/dist/module/data_tree/fields/base.d.ts +27 -0
- package/dist/module/html/main_renderer_factory.d.ts +1 -1
- package/dist/module/index.mjs +25791 -25230
- package/dist/module/index.umd.js +78 -78
- package/dist/module/plugins/big-value/big-value-component.d.ts +8 -2
- package/dist/module/plugins/big-value/big-value-settings.d.ts +28 -0
- package/dist/module/plugins/scatter-chart/scatter-chart-plugin.d.ts +2 -0
- package/dist/module/plugins/segment-map/segment-map-plugin.d.ts +2 -0
- package/dist/module/plugins/shape-map/shape-map-plugin.d.ts +2 -0
- package/dist/module/render-field-metadata.d.ts +4 -1
- package/dist/module/util.d.ts +1 -0
- package/package.json +5 -5
- package/dist/module/component/legacy-charts/legacy_chart.d.ts +0 -5
|
@@ -187,8 +187,9 @@ export function viteMalloyStoriesPlugin(): PluginOption {
|
|
|
187
187
|
console.log('initial state', metadata);
|
|
188
188
|
console.log('render properties', metadata.getFieldEntry(metadata.rootField.key).renderProperties);
|
|
189
189
|
const plugin = viz.getActivePlugin(metadata.rootField.key);
|
|
190
|
-
|
|
191
|
-
|
|
190
|
+
const isCoreViz = plugin && 'getSettings' in plugin;
|
|
191
|
+
console.log('plugin', plugin, isCoreViz ? plugin.getSettings() : undefined);
|
|
192
|
+
const tag = isCoreViz ? plugin.settingsToTag(plugin.getSettings()) : undefined;
|
|
192
193
|
console.log('tag', tag, tag?.toString());
|
|
193
194
|
console.groupEnd();
|
|
194
195
|
viz.render(targetElement);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Cell } from '../data_tree';
|
|
2
|
-
import {
|
|
2
|
+
import { CellFormatConfig } from './tag-configs';
|
|
3
3
|
export interface RenderCellValueOptions {
|
|
4
4
|
/**
|
|
5
5
|
* Value to return for null cells.
|
|
@@ -7,12 +7,13 @@ export interface RenderCellValueOptions {
|
|
|
7
7
|
*/
|
|
8
8
|
nullValue?: string;
|
|
9
9
|
/**
|
|
10
|
-
* Override
|
|
11
|
-
* Use this when rendering array elements - pass the array field's
|
|
12
|
-
* so formatting (currency, percent, etc.) is
|
|
13
|
-
*
|
|
10
|
+
* Override format config.
|
|
11
|
+
* Use this when rendering array elements - pass the array field's
|
|
12
|
+
* pre-resolved config so formatting (currency, percent, etc.) is
|
|
13
|
+
* applied from the array definition.
|
|
14
|
+
* If not provided, uses the cell's own field's tag config.
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
+
config?: CellFormatConfig;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* Render a Cell value to a formatted display string.
|
|
@@ -30,8 +31,8 @@ export interface RenderCellValueOptions {
|
|
|
30
31
|
* renderCellValue(cell)
|
|
31
32
|
*
|
|
32
33
|
* @example
|
|
33
|
-
* // Array elements - use array field's
|
|
34
|
-
* renderCellValue(elementCell, {
|
|
34
|
+
* // Array elements - use array field's config for formatting
|
|
35
|
+
* renderCellValue(elementCell, { config: arrayField.getTagConfig() })
|
|
35
36
|
*
|
|
36
37
|
* @example
|
|
37
38
|
* // Custom null display
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RenderTimeStringOptions } from '../util';
|
|
2
2
|
import { Field, NumberCell } from '../data_tree';
|
|
3
|
-
import {
|
|
3
|
+
import { CellFormatConfig } from './tag-configs';
|
|
4
4
|
/**
|
|
5
|
-
* Renders a numeric field with formatting based on
|
|
5
|
+
* Renders a numeric field with formatting based on pre-resolved tag config.
|
|
6
6
|
*
|
|
7
7
|
* Supports:
|
|
8
8
|
* - Currency shorthand: # currency=usd2m, # currency=eur0k
|
|
@@ -11,33 +11,19 @@ import { Tag } from '@malloydata/malloy-tag';
|
|
|
11
11
|
* - Number verbose: # number { scale=m decimals=2 suffix=word }
|
|
12
12
|
* - Legacy: # number=big, # currency=euro
|
|
13
13
|
*/
|
|
14
|
-
export declare function renderNumericField(f: Field, value: number | null | undefined,
|
|
14
|
+
export declare function renderNumericField(f: Field, value: number | null | undefined, configOverride?: CellFormatConfig): string;
|
|
15
15
|
/**
|
|
16
16
|
* Render a big number value (stored as string for precision).
|
|
17
17
|
* Used when NumberCell.stringValue is defined (bigint/bigdecimal subtypes).
|
|
18
|
-
* Default formatting preserves full precision with comma separators.
|
|
19
|
-
*
|
|
20
|
-
* Note: percent, duration, scale, and custom number formats are lossy for values > 2^53
|
|
21
|
-
* because they require numeric operations. This is acceptable for abbreviated display.
|
|
22
18
|
*/
|
|
23
|
-
export declare function renderBigNumberField(f: Field, value: string | null | undefined,
|
|
19
|
+
export declare function renderBigNumberField(f: Field, value: string | null | undefined, configOverride?: CellFormatConfig): string;
|
|
24
20
|
/**
|
|
25
21
|
* Render a NumberCell for display, automatically handling bigint precision.
|
|
26
22
|
*
|
|
27
23
|
* USE THIS FUNCTION when rendering numeric values from cells in plugins/components.
|
|
28
24
|
*
|
|
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
25
|
* @param cell - A NumberCell from the data tree
|
|
39
|
-
* @param
|
|
40
|
-
* @returns Formatted string for display, respecting field tags (currency, percent, etc.)
|
|
26
|
+
* @param configOverride - Optional config override (e.g., for array elements, use the array field's config)
|
|
41
27
|
*/
|
|
42
|
-
export declare function renderNumberCell(cell: NumberCell,
|
|
43
|
-
export declare function renderDateTimeField(f: Field, value: Date | null | undefined, options?: RenderTimeStringOptions,
|
|
28
|
+
export declare function renderNumberCell(cell: NumberCell, configOverride?: CellFormatConfig): string;
|
|
29
|
+
export declare function renderDateTimeField(f: Field, value: Date | null | undefined, options?: RenderTimeStringOptions, configOverride?: CellFormatConfig): string;
|
|
@@ -119,7 +119,7 @@ export declare function getPivotDimensionValue(pivotedField: PivotedField, dimen
|
|
|
119
119
|
*/
|
|
120
120
|
export declare function shouldPivot(field: Field): boolean;
|
|
121
121
|
/**
|
|
122
|
-
* Gets user-defined pivot dimensions from the tag.
|
|
122
|
+
* Gets user-defined pivot dimensions from the pre-resolved tag config.
|
|
123
123
|
* Syntax: # pivot { dimensions=[d1, d2] }
|
|
124
124
|
*/
|
|
125
125
|
export declare function getUserDefinedDimensions(field: Field): string[] | undefined;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Field } from '../data_tree';
|
|
2
|
+
import { ScaleKey, SuffixFormatKey } from '../util';
|
|
3
|
+
export interface ImageTagConfig {
|
|
4
|
+
width?: string;
|
|
5
|
+
height?: string;
|
|
6
|
+
alt?: string;
|
|
7
|
+
altField?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function resolveImageTags(field: Field): ImageTagConfig;
|
|
10
|
+
export interface LinkTagConfig {
|
|
11
|
+
linkField?: string;
|
|
12
|
+
urlTemplate?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function resolveLinkTags(field: Field): LinkTagConfig;
|
|
15
|
+
export interface ListTagConfig {
|
|
16
|
+
isListDetail: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function resolveListTags(field: Field): ListTagConfig;
|
|
19
|
+
export interface CurrencyConfig {
|
|
20
|
+
symbol: string;
|
|
21
|
+
scale?: ScaleKey | 'auto';
|
|
22
|
+
decimals?: number;
|
|
23
|
+
suffixFormat: SuffixFormatKey;
|
|
24
|
+
}
|
|
25
|
+
export interface NumberConfig {
|
|
26
|
+
formatString?: string;
|
|
27
|
+
scale?: ScaleKey | 'auto';
|
|
28
|
+
decimals?: number;
|
|
29
|
+
suffixFormat?: SuffixFormatKey;
|
|
30
|
+
isId?: boolean;
|
|
31
|
+
isBig?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface DurationConfig {
|
|
34
|
+
unit: string;
|
|
35
|
+
terse: boolean;
|
|
36
|
+
}
|
|
37
|
+
export type CellFormatConfig = {
|
|
38
|
+
mode: 'currency';
|
|
39
|
+
currency: CurrencyConfig;
|
|
40
|
+
} | {
|
|
41
|
+
mode: 'percent';
|
|
42
|
+
} | {
|
|
43
|
+
mode: 'duration';
|
|
44
|
+
duration: DurationConfig;
|
|
45
|
+
} | {
|
|
46
|
+
mode: 'number';
|
|
47
|
+
number: NumberConfig;
|
|
48
|
+
} | {
|
|
49
|
+
mode: 'dateFormat';
|
|
50
|
+
formatString: string;
|
|
51
|
+
} | {
|
|
52
|
+
mode: 'default';
|
|
53
|
+
};
|
|
54
|
+
export declare function resolveCellFormatTags(field: Field): CellFormatConfig;
|
|
55
|
+
export interface ColumnTagConfig {
|
|
56
|
+
width: number | null;
|
|
57
|
+
height: number | null;
|
|
58
|
+
wordBreak: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface TableNestConfig {
|
|
61
|
+
fillSize: boolean;
|
|
62
|
+
transposeLimit?: number;
|
|
63
|
+
pivotDimensions?: string[];
|
|
64
|
+
}
|
|
65
|
+
export interface DashboardNestConfig {
|
|
66
|
+
maxTableHeight: number | null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Run the appropriate tag resolver for a field based on its renderAs type
|
|
70
|
+
* and store the result on the field. Called during registerFields().
|
|
71
|
+
*
|
|
72
|
+
* Also resolves cross-cutting tag properties (label, column, tooltip, break)
|
|
73
|
+
* for ALL fields, ensuring all tag access happens at setup time.
|
|
74
|
+
* Components use the resolved configs instead of reading tags directly.
|
|
75
|
+
*/
|
|
76
|
+
export declare function resolveBuiltInTags(field: Field): void;
|
|
@@ -5,7 +5,6 @@ import { Cell, DrillEntry, Field, RecordCell, RepeatedRecordCell } from '../data
|
|
|
5
5
|
import type * as Malloy from '@malloydata/malloy-interfaces';
|
|
6
6
|
export type RendererProps = {
|
|
7
7
|
dataColumn: Cell;
|
|
8
|
-
tag: Tag;
|
|
9
8
|
customProps?: Record<string, Record<string, unknown>>;
|
|
10
9
|
};
|
|
11
10
|
export type VegaSignalRef = {
|
|
@@ -11,8 +11,35 @@ export declare abstract class FieldBase {
|
|
|
11
11
|
readonly valueSet: Set<string | number | boolean>;
|
|
12
12
|
protected plugins: RenderPluginInstance[];
|
|
13
13
|
protected _renderAs: string;
|
|
14
|
+
private _tagConfig;
|
|
15
|
+
private _resolvedLabel;
|
|
16
|
+
private _columnConfig;
|
|
14
17
|
getPlugins(): RenderPluginInstance[];
|
|
15
18
|
setPlugins(plugins: RenderPluginInstance[]): void;
|
|
19
|
+
/**
|
|
20
|
+
* Get the pre-resolved tag configuration for this field.
|
|
21
|
+
* Tag configs are extracted at setup time (during setResult)
|
|
22
|
+
* so components never need to read tags at render time.
|
|
23
|
+
*/
|
|
24
|
+
getTagConfig<T>(): T | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Store pre-resolved tag configuration on this field.
|
|
27
|
+
* Called during registerFields() for built-in renderers.
|
|
28
|
+
*/
|
|
29
|
+
setTagConfig(config: unknown): void;
|
|
30
|
+
/**
|
|
31
|
+
* Get the resolved display label for this field.
|
|
32
|
+
* Returns the custom label from # label tag if set, otherwise the field name.
|
|
33
|
+
* Resolved at setup time so components never read the label tag.
|
|
34
|
+
*/
|
|
35
|
+
getLabel(): string;
|
|
36
|
+
setResolvedLabel(label: string | undefined): void;
|
|
37
|
+
/**
|
|
38
|
+
* Get the pre-resolved column configuration for this field.
|
|
39
|
+
* Column configs are extracted at setup time (width, height, word_break).
|
|
40
|
+
*/
|
|
41
|
+
getColumnConfig<T>(): T | undefined;
|
|
42
|
+
setColumnConfig(config: unknown): void;
|
|
16
43
|
renderAs(): string;
|
|
17
44
|
constructor(field: Malloy.DimensionInfo, parent: Field | undefined,
|
|
18
45
|
/**
|
|
@@ -29,7 +29,7 @@ import { NumberRendererFactory } from './number';
|
|
|
29
29
|
import { UnsupportedRendererFactory } from './unsupported';
|
|
30
30
|
import { TextRendererFactory } from './text';
|
|
31
31
|
export declare class MainRendererFactory {
|
|
32
|
-
static renderFactories: (
|
|
32
|
+
static renderFactories: (JSONRendererFactory | TextRendererFactory | NumberRendererFactory | ShapeMapRendererFactory | PointMapRendererFactory | SegmentMapRendererFactory | VegaRendererFactory | ScatterChartRendererFactory | ImageRendererFactory | LineChartRendererFactory | BarChartRendererFactory | ColumnSparkLineRendererFactory | BarSparkLineRendererFactory | SparkLineRendererFactory | AreaSparkLineRendererFactory | DateRendererFactory | CurrencyRendererFactory | PercentRendererFactory | DataVolumeRendererFactory | BytesRendererFactory | LinkRendererFactory | DurationRendererFactory | BooleanRendererFactory | UnsupportedRendererFactory)[];
|
|
33
33
|
create(renderDef: RenderDef | undefined, tagged: Tag, document: Document, styleDefaults: StyleDefaults, rendererOptions: RendererOptions, field: Field, timezone?: string | undefined): Renderer | undefined;
|
|
34
34
|
matchesRenderDef(renderDef: RenderDef | undefined, factory: RendererFactory<DataRenderOptions>): boolean | "" | undefined;
|
|
35
35
|
matchesTag(tagged: Tag, factory: RendererFactory<DataRenderOptions>): boolean | "" | undefined;
|