@akohn/dashql-react 0.0.20-dev.908.gd791a771f → 0.0.20-dev.910.gb19698f46
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,7 +1,7 @@
|
|
|
1
1
|
import { chart } from "./vegalite_view.module.js";
|
|
2
2
|
import { loadVega } from "../vegalite/vegalite_loader.js";
|
|
3
3
|
import { CHART_ROWS, arrowTableToRows } from "../vegalite/vegalite_rows.js";
|
|
4
|
-
import { createEmbedOptions, createVegaLiteConfig, resolveChartColors } from "../vegalite/vegalite_theme.js";
|
|
4
|
+
import { createEmbedOptions, createVegaLiteConfig, resolveChartColors, withoutWindowResize } from "../vegalite/vegalite_theme.js";
|
|
5
5
|
import { useColorScheme } from "../theme/color_scheme.js";
|
|
6
6
|
import { useBrand } from "../brand/brand.js";
|
|
7
7
|
import { useComputationTables } from "./data_table/computation_tables.js";
|
|
@@ -151,7 +151,7 @@ function VegaLiteView(props) {
|
|
|
151
151
|
return embed(el, runtimeSpec, {
|
|
152
152
|
...options,
|
|
153
153
|
patch: (compiledSpec) => {
|
|
154
|
-
const stableScales = injectVegaStableScaleDomains(compiledSpec);
|
|
154
|
+
const stableScales = injectVegaStableScaleDomains(withoutWindowResize(compiledSpec));
|
|
155
155
|
stableScaleDomains = stableScales.domains;
|
|
156
156
|
return stableScales.spec;
|
|
157
157
|
},
|
|
@@ -20,5 +20,10 @@ export declare class CalmFrameSchedule implements RenderSchedule {
|
|
|
20
20
|
private notify;
|
|
21
21
|
private wake;
|
|
22
22
|
}
|
|
23
|
+
interface Viewport extends EventTarget {
|
|
24
|
+
readonly innerWidth: number;
|
|
25
|
+
}
|
|
26
|
+
export declare function suspendWhileWidthChanges(schedule: RenderSchedule, view?: Viewport): () => void;
|
|
23
27
|
export declare const IMMEDIATE_SCHEDULE: RenderSchedule;
|
|
24
28
|
export declare const CALM_FRAMES: RenderSchedule;
|
|
29
|
+
export {};
|
package/dist/dom/calm_frames.js
CHANGED
|
@@ -82,6 +82,30 @@ var CalmFrameSchedule = class {
|
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
|
+
var WIDTH_QUIET_MS = 200;
|
|
86
|
+
function suspendWhileWidthChanges(schedule, view = window) {
|
|
87
|
+
let width = view.innerWidth;
|
|
88
|
+
let resume = null;
|
|
89
|
+
let timeout = null;
|
|
90
|
+
const settle = () => {
|
|
91
|
+
if (timeout != null) clearTimeout(timeout);
|
|
92
|
+
timeout = null;
|
|
93
|
+
resume?.();
|
|
94
|
+
resume = null;
|
|
95
|
+
};
|
|
96
|
+
const onResize = () => {
|
|
97
|
+
if (view.innerWidth === width) return;
|
|
98
|
+
width = view.innerWidth;
|
|
99
|
+
resume ??= schedule.suspend();
|
|
100
|
+
if (timeout != null) clearTimeout(timeout);
|
|
101
|
+
timeout = setTimeout(settle, WIDTH_QUIET_MS);
|
|
102
|
+
};
|
|
103
|
+
view.addEventListener("resize", onResize);
|
|
104
|
+
return () => {
|
|
105
|
+
view.removeEventListener("resize", onResize);
|
|
106
|
+
settle();
|
|
107
|
+
};
|
|
108
|
+
}
|
|
85
109
|
var IMMEDIATE_SCHEDULE = {
|
|
86
110
|
schedule: (task) => {
|
|
87
111
|
task();
|
|
@@ -93,4 +117,4 @@ var IMMEDIATE_SCHEDULE = {
|
|
|
93
117
|
subscribe: () => () => {}
|
|
94
118
|
};
|
|
95
119
|
var CALM_FRAMES = new CalmFrameSchedule();
|
|
96
|
-
export { CALM_FRAMES, CalmFrameSchedule, IMMEDIATE_SCHEDULE, transitionsEnd };
|
|
120
|
+
export { CALM_FRAMES, CalmFrameSchedule, IMMEDIATE_SCHEDULE, suspendWhileWidthChanges, transitionsEnd };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Spec as VegaSpec } from 'vega';
|
|
1
2
|
import type { Config } from 'vega-lite';
|
|
2
3
|
import type { EmbedOptions } from 'vega-embed';
|
|
3
4
|
import { type ChartColors } from '@akohn/dashql/platform/workbook/chart_config';
|
|
@@ -9,3 +10,4 @@ export declare function createVegaLiteConfig(colors: ChartColors): Config;
|
|
|
9
10
|
export declare function createVegaLitePreviewConfig(colors: ChartColors): Config;
|
|
10
11
|
export declare const VEGA_TOOLTIP_THEME = "dashql";
|
|
11
12
|
export declare function createEmbedOptions(colors: ChartColors, expressionInterpreter: EmbedOptions['expr']): EmbedOptions;
|
|
13
|
+
export declare function withoutWindowResize(spec: VegaSpec): VegaSpec;
|
|
@@ -118,8 +118,24 @@ function createEmbedOptions(colors, expressionInterpreter) {
|
|
|
118
118
|
expr: expressionInterpreter,
|
|
119
119
|
config: createVegaLiteConfig(colors),
|
|
120
120
|
tooltip: { theme: VEGA_TOOLTIP_THEME },
|
|
121
|
-
logLevel: VEGA_LOG_LEVEL_ERROR
|
|
121
|
+
logLevel: VEGA_LOG_LEVEL_ERROR,
|
|
122
|
+
patch: withoutWindowResize
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
var WINDOW_RESIZE = "window:resize";
|
|
126
|
+
function withoutWindowResize(spec) {
|
|
127
|
+
if (spec.signals == null) return spec;
|
|
128
|
+
return {
|
|
129
|
+
...spec,
|
|
130
|
+
signals: spec.signals.map((signal) => {
|
|
131
|
+
if (!("on" in signal) || signal.on == null) return signal;
|
|
132
|
+
const on = signal.on.filter((update) => update.events !== WINDOW_RESIZE);
|
|
133
|
+
return on.length === signal.on.length ? signal : {
|
|
134
|
+
...signal,
|
|
135
|
+
on
|
|
136
|
+
};
|
|
137
|
+
})
|
|
122
138
|
};
|
|
123
139
|
}
|
|
124
140
|
var VEGA_LOG_LEVEL_ERROR = 1;
|
|
125
|
-
export { CATEGORICAL_COLOR_TOKENS, VEGA_TOOLTIP_THEME, createEmbedOptions, createVegaLiteConfig, createVegaLitePreviewConfig, resolveChartColors };
|
|
141
|
+
export { CATEGORICAL_COLOR_TOKENS, VEGA_TOOLTIP_THEME, createEmbedOptions, createVegaLiteConfig, createVegaLitePreviewConfig, resolveChartColors, withoutWindowResize };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akohn/dashql-react",
|
|
3
|
-
"version": "0.0.20-dev.
|
|
3
|
+
"version": "0.0.20-dev.910.gb19698f46",
|
|
4
4
|
"description": "DashQL in React: the hooks of the runtime of @akohn/dashql, the models that components show, the components, and the design tokens, fonts and icons of DashQL",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"react-window": "^2.5.3"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@akohn/dashql": "0.0.20-dev.
|
|
36
|
+
"@akohn/dashql": "0.0.20-dev.910.gb19698f46",
|
|
37
37
|
"apache-arrow": "^21.2.0",
|
|
38
38
|
"react": "^19.3.1",
|
|
39
39
|
"react-dom": "^19.3.1",
|