@malloydata/render 0.0.210-dev241107210431 → 0.0.210
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/main.ts +4 -2
- package/.storybook/malloy-stories-indexer.ts +7 -1
- package/DEVELOPING.md +49 -3
- package/dist/component/chart/chart-dev-tool.d.ts +6 -0
- package/dist/component/chart/chart.d.ts +8 -2
- package/dist/component/chart/debug_icon.d.ts +1 -0
- package/dist/component/chart-layout-settings.d.ts +4 -2
- package/dist/component/dashboard/dashboard.d.ts +0 -1
- package/dist/component/render-link.d.ts +1 -1
- package/dist/component/render-list.d.ts +1 -1
- package/dist/component/render.d.ts +3 -0
- package/dist/component/table/table.d.ts +0 -1
- package/dist/component/types.d.ts +11 -3
- package/dist/component/vega/measure-axis.d.ts +4 -2
- package/dist/html/data_styles.d.ts +3 -2
- package/dist/register/register.mjs +22156 -21909
- package/dist/register/register.umd.js +366 -328
- package/dist/register/style.css +1 -1
- package/dist/stories/util.d.ts +1 -0
- package/dist/webcomponent/malloy-render.mjs +22156 -21909
- package/dist/webcomponent/malloy-render.umd.js +366 -328
- package/dist/webcomponent/style.css +1 -1
- package/package.json +2 -2
- package/vite.config.base.ts +26 -0
- package/vite.config.ts +3 -17
- package/vite.config.webcomponent-register.ts +3 -17
- package/vite.config.webcomponent.ts +3 -17
package/.storybook/main.ts
CHANGED
|
@@ -58,11 +58,13 @@ const config: StorybookConfig = {
|
|
|
58
58
|
},
|
|
59
59
|
},
|
|
60
60
|
server: {
|
|
61
|
-
// Disable HMR for now, as we can't seem to get malloy core nor
|
|
61
|
+
// Disable HMR for now, as we can't seem to get malloy core nor web component to fully support it
|
|
62
62
|
hmr: false,
|
|
63
63
|
},
|
|
64
64
|
define: {
|
|
65
|
-
'process.env': {
|
|
65
|
+
'process.env': {
|
|
66
|
+
'IS_STORYBOOK': true,
|
|
67
|
+
},
|
|
66
68
|
},
|
|
67
69
|
assetsInclude: ['/sb-preview/runtime.js'],
|
|
68
70
|
plugins: [viteMalloyStoriesPlugin()],
|
|
@@ -139,7 +139,7 @@ export function viteMalloyStoriesPlugin(): PluginOption {
|
|
|
139
139
|
};`
|
|
140
140
|
: `
|
|
141
141
|
import script from '${id}?raw';
|
|
142
|
-
import {createLoader} from './util';
|
|
142
|
+
import {createLoader, copyMalloyRenderHTML} from './util';
|
|
143
143
|
import './themes.css';
|
|
144
144
|
import '../component/render-webcomponent';
|
|
145
145
|
|
|
@@ -152,6 +152,12 @@ export function viteMalloyStoriesPlugin(): PluginOption {
|
|
|
152
152
|
const el = document.createElement('malloy-render');
|
|
153
153
|
if (classes) el.classList.add(classes);
|
|
154
154
|
el.result = context.loaded['result'];
|
|
155
|
+
|
|
156
|
+
const button = document.createElement('button');
|
|
157
|
+
button.innerHTML = "Copy HTML";
|
|
158
|
+
button.addEventListener("click", () => copyMalloyRenderHTML(el));
|
|
159
|
+
|
|
160
|
+
parent.appendChild(button);
|
|
155
161
|
parent.appendChild(el);
|
|
156
162
|
return parent;
|
|
157
163
|
},
|
package/DEVELOPING.md
CHANGED
|
@@ -75,6 +75,44 @@ Renderers are applied based on tags parsed on an Explore or Field. This is done
|
|
|
75
75
|
1. Update the `shouldRenderAs` function that looks at the field tags and returns an enum for your renderer type
|
|
76
76
|
2. Update the switch statement in the `applyRenderer` function to add a case for your new renderer. Your case statement should update the `renderValue` variable using your renderer.
|
|
77
77
|
|
|
78
|
+
## Adding component CSS
|
|
79
|
+
|
|
80
|
+
The renderer is shipped as webcomponent, and any stylesheets should be appended to the ShadowDOM root instead of to the document. A utility is provided for doing this like so:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
// in file my-component.ts
|
|
84
|
+
|
|
85
|
+
// import your stylesheet as a string
|
|
86
|
+
import myCss from "./style.css?raw";
|
|
87
|
+
|
|
88
|
+
export function MyComponent() {
|
|
89
|
+
// Add your imported CSS to the ShadowRoot
|
|
90
|
+
const config = useConfig();
|
|
91
|
+
config.addCSSToShadowRoot(myCSS);
|
|
92
|
+
|
|
93
|
+
// Use your classes in your markup
|
|
94
|
+
return <div class="my-component-class">hello world</div>
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
There are certain cases where you may need to append CSS to the document; for example, when rendering a tooltip or modal that is attached to the DOM outside of the web component. You can add this document CSS like so:
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
// in file my-component.ts
|
|
102
|
+
|
|
103
|
+
// import your stylesheet as a string
|
|
104
|
+
import myCss from "./style.css?raw";
|
|
105
|
+
|
|
106
|
+
export function MyComponent() {
|
|
107
|
+
// Add your imported CSS to the document
|
|
108
|
+
const config = useConfig();
|
|
109
|
+
config.addCSSToDocument(myCSS);
|
|
110
|
+
|
|
111
|
+
// Use your classes in your markup
|
|
112
|
+
return <div class="my-component-class">hello world</div>
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
78
116
|
## Renderer Metadata
|
|
79
117
|
|
|
80
118
|
Some of the renderers, especially charts, benefit from having metadata about the data table being rendered. This can include attributes like the min and max values in a numeric column, the number of rows in a nested table, etc. This metadata is derived in `src/component/render-result-metadata.ts`. The `getResultMetadata` function is used to create the `RenderResultMetadata` object. This object is shared throughout our SolidJS component tree using the Context api. To access the metadata, use the `useResultContext()` method in a component.
|
|
@@ -118,10 +156,18 @@ For examples of how to use brushIn data and export brushOut data, see the bar ch
|
|
|
118
156
|
|
|
119
157
|
## Debugging tips
|
|
120
158
|
|
|
121
|
-
|
|
159
|
+
In the Storybook, hovering any of the new charts will show a debug icon in the top right. Clicking the debug icon will open that chart with a text editor of the spec and a signal and data inspector. This UI can be used to see what is happening under the hood with the Vega chart, and allow you to experiment with changing the spec.
|
|
122
160
|
|
|
123
|
-
|
|
124
|
-
|
|
161
|
+
You can also use the signal logger utility to log signal changes. This can be done in `chart.tsx` or `vega-chart.tsx` like so:
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
import {signalLogger} from './vega-utils';
|
|
165
|
+
|
|
166
|
+
// Somewhere in component code where View is accessible, create logger and log some signals
|
|
167
|
+
const logger = signalLogger(view, optionalId); // Optional string id which will be logged as well
|
|
168
|
+
|
|
169
|
+
logger('signalA', 'signalB'); // Logs any value changes to signalA or signalB
|
|
170
|
+
```
|
|
125
171
|
|
|
126
172
|
## Generating builds
|
|
127
173
|
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
/// <reference path="../../../src/vega.d.ts" />
|
|
1
2
|
import { Explore, ExploreField, QueryData } from '@malloydata/malloy';
|
|
2
3
|
import { RenderResultMetadata } from '../types';
|
|
3
|
-
|
|
4
|
+
import { Runtime, View } from 'vega';
|
|
5
|
+
export type ChartProps = {
|
|
4
6
|
field: Explore | ExploreField;
|
|
5
7
|
data: QueryData;
|
|
6
8
|
metadata: RenderResultMetadata;
|
|
7
|
-
|
|
9
|
+
devMode?: boolean;
|
|
10
|
+
runtime?: Runtime;
|
|
11
|
+
onView?: (view: View) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare function Chart(props: ChartProps): import("solid-js").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function DebugIcon(): import("solid-js").JSX.Element;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
/// <reference path="../../src/vega.d.ts" />
|
|
1
2
|
import { Explore, ExploreField, Field, Tag } from '@malloydata/malloy';
|
|
3
|
+
import { AlignValue, TextBaselineValue } from 'vega';
|
|
2
4
|
import { RenderResultMetadata } from './types';
|
|
3
5
|
export type ChartLayoutSettings = {
|
|
4
6
|
plotWidth: number;
|
|
5
7
|
plotHeight: number;
|
|
6
8
|
xAxis: {
|
|
7
9
|
labelAngle: number;
|
|
8
|
-
labelAlign?:
|
|
9
|
-
labelBaseline?:
|
|
10
|
+
labelAlign?: AlignValue;
|
|
11
|
+
labelBaseline?: TextBaselineValue;
|
|
10
12
|
labelLimit: number;
|
|
11
13
|
height: number;
|
|
12
14
|
titleSize: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AtomicField, DataColumn } from '@malloydata/malloy';
|
|
2
|
-
export declare function renderLink(f: AtomicField, data: DataColumn): import("solid-js").JSX.Element
|
|
2
|
+
export declare function renderLink(f: AtomicField, data: DataColumn): "∅" | import("solid-js").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { RendererProps } from './apply-renderer';
|
|
2
|
-
export declare function renderList(props: RendererProps): import("solid-js").JSX.Element
|
|
2
|
+
export declare function renderList(props: RendererProps): "∅" | import("solid-js").JSX.Element;
|
|
@@ -13,6 +13,9 @@ export type MalloyRenderProps = {
|
|
|
13
13
|
export declare const useConfig: () => {
|
|
14
14
|
onClick?: ((payload: MalloyClickEventPayload) => void) | undefined;
|
|
15
15
|
vegaConfigOverride?: VegaConfigHandler | undefined;
|
|
16
|
+
element: ICustomElement;
|
|
17
|
+
addCSSToShadowRoot: (css: string) => void;
|
|
18
|
+
addCSSToDocument: (id: string, css: string) => void;
|
|
16
19
|
};
|
|
17
20
|
export declare function MalloyRender(props: MalloyRenderProps, { element }: ComponentOptions): import("solid-js").JSX.Element;
|
|
18
21
|
export declare function MalloyRenderInner(props: {
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
/// <reference path="../../src/vega.d.ts" />
|
|
2
2
|
import { DataColumn, DataRecord, Explore, Field, QueryData, QueryDataRow, Tag } from '@malloydata/malloy';
|
|
3
|
-
import { Item, Runtime, View } from 'vega';
|
|
3
|
+
import { Item, Runtime, Spec, View } from 'vega';
|
|
4
4
|
import { JSX } from 'solid-js';
|
|
5
5
|
import { ResultStore } from './result-store/result-store';
|
|
6
|
-
export type
|
|
6
|
+
export type VegaSignalRef = {
|
|
7
|
+
signal: string;
|
|
8
|
+
};
|
|
9
|
+
export type VegaPadding = {
|
|
10
|
+
top?: number;
|
|
11
|
+
left?: number;
|
|
12
|
+
right?: number;
|
|
13
|
+
bottom?: number;
|
|
14
|
+
};
|
|
7
15
|
export type MalloyDataToChartDataHandler = (field: Explore, data: QueryData) => unknown[];
|
|
8
16
|
export type VegaChartProps = {
|
|
9
|
-
spec:
|
|
17
|
+
spec: Spec;
|
|
10
18
|
plotWidth: number;
|
|
11
19
|
plotHeight: number;
|
|
12
20
|
totalWidth: number;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference path="../../../src/vega.d.ts" />
|
|
2
|
+
import { Axis, GroupMark, RectMark } from 'vega';
|
|
1
3
|
import { ChartLayoutSettings } from '../chart-layout-settings';
|
|
2
4
|
type MeasureAxisOptions = {
|
|
3
5
|
type: 'y';
|
|
@@ -11,8 +13,8 @@ type MeasureAxisOptions = {
|
|
|
11
13
|
axisSettings: ChartLayoutSettings['yAxis'];
|
|
12
14
|
};
|
|
13
15
|
export declare function createMeasureAxis({ type, title, tickCount, labelLimit, fieldPath, showBrushes, axisSettings, }: MeasureAxisOptions): {
|
|
14
|
-
axis:
|
|
15
|
-
interactiveMarks:
|
|
16
|
+
axis: Axis;
|
|
17
|
+
interactiveMarks: (GroupMark | RectMark)[];
|
|
16
18
|
interactiveSignals: never[];
|
|
17
19
|
brushMeasureEvents: {
|
|
18
20
|
events: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
/// <reference path="../../src/vega.d.ts" />
|
|
1
2
|
import * as lite from 'vega-lite';
|
|
2
|
-
import {
|
|
3
|
+
import { Config } from 'vega';
|
|
3
4
|
export type DataStyles = {
|
|
4
5
|
[fieldName: string]: RenderDef;
|
|
5
6
|
};
|
|
@@ -159,7 +160,7 @@ export interface ChartRenderOptions extends DataRenderOptions {
|
|
|
159
160
|
color?: string;
|
|
160
161
|
shape?: string;
|
|
161
162
|
};
|
|
162
|
-
vegaConfigOverride?:
|
|
163
|
+
vegaConfigOverride?: Config;
|
|
163
164
|
}
|
|
164
165
|
export interface CartesianChartRenderOptions extends ChartRenderOptions {
|
|
165
166
|
chart?: {
|