@malloydata/render 0.0.419 → 0.0.421

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,6 +1,81 @@
1
1
  import { DashboardConfig, DrillData, MalloyClickEventPayload, TableConfig, VegaConfigHandler } from '../component/types';
2
2
  import { RenderPluginFactory } from './plugin-types';
3
3
  export type { RenderFieldMetadata } from '../render-field-metadata';
4
+ /**
5
+ * Explicit theme overrides applied by the embedder.
6
+ *
7
+ * @experimental Provisional surface, not the finished theming feature.
8
+ * The property set here is deliberately narrow (mostly table and font
9
+ * chrome) and will be superseded by a designed theme that also covers the
10
+ * categorical chart palette, typography by role, and continuous color
11
+ * schemes. Expect this interface to change; pin a renderer version if you
12
+ * depend on its current shape.
13
+ *
14
+ * Resolution order (highest wins): explicit theme key here, then
15
+ * `# theme.<key>` on the result, then `## theme.<key>` on the model,
16
+ * then the CSS fallback `var(--malloy-theme--<kebab>)`. Every key is
17
+ * optional; omitted keys fall through the chain. An empty string is
18
+ * treated the same as `undefined` so a cleared input drops back to
19
+ * the next layer.
20
+ *
21
+ * This full resolution chain applies to the CSS-variable chrome keys
22
+ * (the table and font keys, plus `background`), which are emitted as
23
+ * `--malloy-render--*` variables and must be valid CSS values (e.g.
24
+ * `"#ff0000"`, `"1px solid #ccc"`, `"14px"`). The `mapColor` key and
25
+ * the map canvas `background` are consumed inside the Vega spec rather
26
+ * than via CSS and are read only from this embedder prop; `# theme`
27
+ * and `## theme` annotations and the CSS fallback do not reach the map
28
+ * canvas. See the `mapColor` field doc.
29
+ *
30
+ * Note: this theme is only read by the modern `MalloyRenderer` /
31
+ * `MalloyViz` API. The legacy `HTMLView` / `JSONView` exports do not
32
+ * consult it.
33
+ *
34
+ * Note: because the embedder layer is the highest precedence, a model
35
+ * publisher cannot override an embedder-supplied value with a
36
+ * `# theme.*` annotation. If you need the model to win for a specific
37
+ * key, omit that key from the embedder theme.
38
+ */
39
+ export interface MalloyExplicitTheme {
40
+ tableRowHeight?: string;
41
+ tableBodyColor?: string;
42
+ tableFontSize?: string;
43
+ tableHeaderColor?: string;
44
+ tableHeaderWeight?: string;
45
+ tableBodyWeight?: string;
46
+ tableBorder?: string;
47
+ tableBackground?: string;
48
+ tableGutterSize?: string;
49
+ tablePinnedBackground?: string;
50
+ tablePinnedBorder?: string;
51
+ fontFamily?: string;
52
+ background?: string;
53
+ /**
54
+ * @experimental Provisional, and the last bespoke color knob of this
55
+ * kind. `mapColor` is the one property that crosses from chrome into
56
+ * chart-data color; it is kept as a one-off to unblock current embedders.
57
+ * Further color or theme surface will arrive through the designed theme,
58
+ * not as additional standalone properties like this one.
59
+ *
60
+ * Saturated end of the gradient used by sequential color scales on
61
+ * `# shape_map` and `# segment_map` choropleth visualizations.
62
+ *
63
+ * Unlike the other keys on this interface, `mapColor` is consumed
64
+ * programmatically by `getColorScale` and baked into the Vega scale
65
+ * range at render time. It is NOT emitted as a `--malloy-render--*`
66
+ * CSS variable, so `var()` references won't resolve. Pass a literal
67
+ * colour string (e.g. `"#ff0000"`).
68
+ *
69
+ * The renderer derives the low end of the gradient automatically
70
+ * (light neutral for dark/medium high-ends, dark neutral for light
71
+ * high-ends) so the operator only has to pick the brand-saturated
72
+ * colour. When unset, the renderer uses its built-in blue gradient.
73
+ *
74
+ * Rect-mark heatmaps and the legacy `HTMLView` chart paths keep
75
+ * their existing palettes and ignore this key.
76
+ */
77
+ mapColor?: string;
78
+ }
4
79
  export interface MalloyRendererOptions {
5
80
  onClick?: (payload: MalloyClickEventPayload) => void;
6
81
  onDrill?: (drillData: DrillData) => void;
@@ -13,4 +88,14 @@ export interface MalloyRendererOptions {
13
88
  plugins?: RenderPluginFactory[];
14
89
  pluginOptions?: Record<string, unknown>;
15
90
  useVegaInterpreter?: boolean;
91
+ /**
92
+ * Optional explicit theme overrides. Keys here take precedence over
93
+ * any `# theme.*` annotations on the result and over the renderer's
94
+ * own CSS variable defaults. See {@link MalloyExplicitTheme}.
95
+ *
96
+ * @experimental Provisional surface, the shape may change. This is not
97
+ * yet the finished theming feature; see {@link MalloyExplicitTheme} for
98
+ * the current property set and that caveat.
99
+ */
100
+ theme?: MalloyExplicitTheme;
16
101
  }
@@ -1,2 +1,2 @@
1
1
  import { Cell, Field } from '../data_tree';
2
- export declare function renderLink(f: Field, data: Cell): "∅" | import("solid-js").JSX.Element;
2
+ export declare function renderLink(f: Field, data: Cell): import("solid-js").JSX.Element | "∅";
@@ -1,2 +1,2 @@
1
1
  import { RendererProps } from './types';
2
- export declare function renderList(props: RendererProps): "∅" | import("solid-js").JSX.Element;
2
+ export declare function renderList(props: RendererProps): import("solid-js").JSX.Element | "∅";
@@ -4,6 +4,7 @@ import { ResultStore } from './result-store/result-store';
4
4
  import { Runtime } from 'vega';
5
5
  import { RootField } from '../data_tree';
6
6
  import { RenderFieldMetadata } from '../render-field-metadata';
7
+ import { MalloyExplicitTheme } from '../api/types';
7
8
  export type GetResultMetadataOptions = {
8
9
  renderFieldMetadata: RenderFieldMetadata;
9
10
  getVegaConfigOverride?: VegaConfigHandler;
@@ -12,6 +13,14 @@ export type GetResultMetadataOptions = {
12
13
  height: number;
13
14
  };
14
15
  useVegaInterpreter?: boolean;
16
+ /**
17
+ * Operator-level theme passed by the embedding app (e.g. Publisher).
18
+ * The `# shape_map` and `# segment_map` plugins build their own
19
+ * colour scales and forward this to {@link getColorScale} so the
20
+ * gradient picks up the operator's `mapColor` instead of the
21
+ * hardcoded blue ramp.
22
+ */
23
+ explicitTheme?: MalloyExplicitTheme;
15
24
  };
16
25
  export interface FieldVegaInfo {
17
26
  runtime: Runtime | null;
@@ -1,5 +1,6 @@
1
1
  import { Accessor } from 'solid-js';
2
2
  import { DashboardConfig, DrillData, MalloyClickEventPayload, TableConfig, VegaConfigHandler } from './types';
3
+ import { MalloyExplicitTheme } from '../api/types';
3
4
  import { RenderFieldMetadata } from '../render-field-metadata';
4
5
  export type { DrillData } from './types';
5
6
  import type * as Malloy from '@malloydata/malloy-interfaces';
@@ -16,6 +17,7 @@ export type MalloyRenderProps = {
16
17
  dashboardConfig?: Partial<DashboardConfig>;
17
18
  renderFieldMetadata: RenderFieldMetadata;
18
19
  useVegaInterpreter?: boolean;
20
+ theme?: MalloyExplicitTheme;
19
21
  onReady?: () => void;
20
22
  };
21
23
  export declare const useConfig: () => {
@@ -35,4 +37,5 @@ export declare function MalloyRenderInner(props: {
35
37
  vegaConfigOverride?: VegaConfigHandler;
36
38
  renderFieldMetadata: RenderFieldMetadata;
37
39
  useVegaInterpreter?: boolean;
40
+ theme?: MalloyExplicitTheme;
38
41
  }): import("solid-js").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { Tag } from '@malloydata/malloy-tag';
2
+ import { MalloyExplicitTheme } from '../api/types';
3
+ export declare function themeOverridesAsCssVarNames(theme: MalloyExplicitTheme | undefined): Set<string>;
4
+ export declare function getThemeValue(prop: keyof MalloyExplicitTheme, explicitTheme: MalloyExplicitTheme | undefined, ...themes: Array<Tag | undefined>): string;
5
+ export declare function generateThemeStyle(modelTheme?: Tag, localTheme?: Tag, explicitTheme?: MalloyExplicitTheme): string;
6
+ export declare function mergeThemeOption(prev: MalloyExplicitTheme | undefined, hasThemeKey: boolean, next: MalloyExplicitTheme | undefined): MalloyExplicitTheme | undefined;
@@ -48,7 +48,7 @@ export declare class NumberCell extends CellBase {
48
48
  * Only valid when stringValue is defined and subtype is 'bigint'.
49
49
  */
50
50
  bigint(): bigint;
51
- compareTo(other: Cell): 1 | 0 | -1;
51
+ compareTo(other: Cell): 0 | 1 | -1;
52
52
  get literalValue(): Malloy.LiteralValue | undefined;
53
53
  }
54
54
  export declare class DateCell extends CellBase {
@@ -58,7 +58,7 @@ export declare class DateCell extends CellBase {
58
58
  constructor(cell: Malloy.CellWithDateCell, field: DateField, parent: NestCell | undefined);
59
59
  get value(): Date;
60
60
  get timeframe(): Malloy.DateTimeframe | undefined;
61
- compareTo(other: Cell): 1 | 0 | -1;
61
+ compareTo(other: Cell): 0 | 1 | -1;
62
62
  get literalValue(): Malloy.LiteralValue | undefined;
63
63
  }
64
64
  export declare class TimestampCell extends CellBase {
@@ -68,7 +68,7 @@ export declare class TimestampCell extends CellBase {
68
68
  constructor(cell: Malloy.CellWithTimestampCell, field: TimestampField, parent: NestCell | undefined);
69
69
  get value(): Date;
70
70
  get timeframe(): Malloy.TimestampTimeframe | undefined;
71
- compareTo(other: Cell): 1 | 0 | -1;
71
+ compareTo(other: Cell): 0 | 1 | -1;
72
72
  get literalValue(): Malloy.LiteralValue | undefined;
73
73
  }
74
74
  export declare class JSONCell extends CellBase {
@@ -77,7 +77,7 @@ export declare class JSONCell extends CellBase {
77
77
  readonly parent: NestCell | undefined;
78
78
  constructor(cell: Malloy.CellWithJSONCell, field: JSONField, parent: NestCell | undefined);
79
79
  get value(): any;
80
- compareTo(other: Cell): 1 | 0 | -1;
80
+ compareTo(other: Cell): 0 | 1 | -1;
81
81
  }
82
82
  export declare class SQLNativeCell extends CellBase {
83
83
  readonly cell: Malloy.CellWithSQLNativeCell;
@@ -85,7 +85,7 @@ export declare class SQLNativeCell extends CellBase {
85
85
  readonly parent: NestCell | undefined;
86
86
  constructor(cell: Malloy.CellWithSQLNativeCell, field: SQLNativeField, parent: NestCell | undefined);
87
87
  get value(): any;
88
- compareTo(other: Cell): 1 | 0 | -1;
88
+ compareTo(other: Cell): 0 | 1 | -1;
89
89
  }
90
90
  export declare class StringCell extends CellBase {
91
91
  readonly cell: Malloy.CellWithStringCell;
@@ -102,6 +102,6 @@ export declare class BooleanCell extends CellBase {
102
102
  readonly parent: NestCell | undefined;
103
103
  constructor(cell: Malloy.CellWithBooleanCell, field: BooleanField, parent: NestCell | undefined);
104
104
  get value(): boolean;
105
- compareTo(other: Cell): 1 | 0 | -1;
105
+ compareTo(other: Cell): 0 | 1 | -1;
106
106
  get literalValue(): Malloy.LiteralValue | undefined;
107
107
  }
@@ -1,10 +1,12 @@
1
1
  import { RenderDef } from './data_styles';
2
2
  import { RendererOptions } from './renderer_types';
3
+ import { MalloyExplicitTheme } from '../api/types';
3
4
  import { Field } from '../data_tree';
4
5
  import type * as Malloy from '@malloydata/malloy-interfaces';
5
- export declare function getColorScale(type: 'temporal' | 'ordinal' | 'quantitative' | 'nominal' | undefined, isRectMark: boolean, hasOverlappingText?: boolean): {
6
+ export declare function getColorScale(type: 'temporal' | 'ordinal' | 'quantitative' | 'nominal' | undefined, isRectMark: boolean, hasOverlappingText?: boolean, explicitTheme?: MalloyExplicitTheme): {
6
7
  range: string[];
7
8
  } | undefined;
9
+ export declare function mapCanvasBackground(explicitTheme?: MalloyExplicitTheme): string;
8
10
  export declare function timeToString(time: Date, timeframe: Malloy.DateTimeframe | Malloy.TimestampTimeframe | undefined, timezone?: string): string;
9
11
  export declare function normalizeToTimezone(date: Date, timezone: string | undefined): Date;
10
12
  export declare function yieldTask(): Promise<void>;
@@ -5,7 +5,7 @@ export { MalloyRenderer } from './api/malloy-renderer';
5
5
  export type { MalloyViz } from './api/malloy-viz';
6
6
  export type { CoreVizPluginInstance, RenderPluginInstance, } from './api/plugin-types';
7
7
  export { isCoreVizPluginInstance } from './api/plugin-types';
8
- export type { MalloyRendererOptions, RenderFieldMetadata } from './api/types';
8
+ export type { MalloyExplicitTheme, MalloyRendererOptions, RenderFieldMetadata, } from './api/types';
9
9
  export type * from './api/json-schema-types';
10
10
  export type { DrillData, MalloyClickEventPayload, TableConfig, DashboardConfig, VegaConfigHandler, } from './component/types';
11
11
  export * from './plugins';