@marimo-team/islands 0.22.1-dev7 → 0.22.1-dev9
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/dist/{ConnectedDataExplorerComponent-Dl1grr8z.js → ConnectedDataExplorerComponent-iT7t3FxV.js} +1 -1
- package/dist/{loader-3c9hT4kT.js → loader-CMMa6QVT.js} +4 -1
- package/dist/main.js +5 -5
- package/dist/style.css +1 -1
- package/dist/{useDeepCompareMemoize-X7clcrcQ.js → useDeepCompareMemoize-DOzKCTzc.js} +1 -1
- package/dist/{vega-component-A6unyUJS.js → vega-component-BaDgUvQP.js} +2 -2
- package/package.json +1 -1
- package/src/plugins/impl/vega/__tests__/utils.test.ts +68 -0
- package/src/plugins/impl/vega/utils.ts +14 -5
- package/src/plugins/impl/vega/vega.css +2 -1
|
@@ -5,7 +5,7 @@ import { t as toDate } from "./toDate-D6VXexnV.js";
|
|
|
5
5
|
import { a as cva, v as cn } from "./button-qsiIHncQ.js";
|
|
6
6
|
import { t as require_jsx_runtime } from "./jsx-runtime-9hcJiI23.js";
|
|
7
7
|
import { C as dequal } from "./useTheme-Dm1WaAGy.js";
|
|
8
|
-
import { i as tableFromIPC } from "./loader-
|
|
8
|
+
import { i as tableFromIPC } from "./loader-CMMa6QVT.js";
|
|
9
9
|
function isDate(t) {
|
|
10
10
|
return t instanceof Date || typeof t == "object" && Object.prototype.toString.call(t) === "[object Date]";
|
|
11
11
|
}
|
|
@@ -10,10 +10,10 @@ import { t as Tooltip } from "./tooltip-DGHTbHl5.js";
|
|
|
10
10
|
import { i as debounce_default } from "./constants-D1Am36hX.js";
|
|
11
11
|
import { n as useTheme, w as useEvent_default } from "./useTheme-Dm1WaAGy.js";
|
|
12
12
|
import { s as uniq } from "./arrays-Du-jRBAy.js";
|
|
13
|
-
import { a as AlertTitle, n as arrow, o as isValid, r as Alert, t as useDeepCompareMemoize } from "./useDeepCompareMemoize-
|
|
13
|
+
import { a as AlertTitle, n as arrow, o as isValid, r as Alert, t as useDeepCompareMemoize } from "./useDeepCompareMemoize-DOzKCTzc.js";
|
|
14
14
|
import { n as ErrorBanner } from "./error-banner-Bx9kIgrs.js";
|
|
15
15
|
import { n as formats } from "./vega-loader.browser-DqEcFOPD.js";
|
|
16
|
-
import { a as getContainerWidth, n as vegaLoadData, s as tooltipHandler } from "./loader-
|
|
16
|
+
import { a as getContainerWidth, n as vegaLoadData, s as tooltipHandler } from "./loader-CMMa6QVT.js";
|
|
17
17
|
import { t as useAsyncData } from "./useAsyncData-Cd4Urlww.js";
|
|
18
18
|
import { t as j } from "./react-vega-CzRAIHrv.js";
|
|
19
19
|
import "./defaultLocale-qS7DaAmi.js";
|
package/package.json
CHANGED
|
@@ -33,4 +33,72 @@ describe("getContainerWidth", () => {
|
|
|
33
33
|
it("should return undefined when width is explicitly undefined", () => {
|
|
34
34
|
expect(getContainerWidth({ width: undefined })).toBeUndefined();
|
|
35
35
|
});
|
|
36
|
+
|
|
37
|
+
it("should find width in nested facet spec", () => {
|
|
38
|
+
expect(
|
|
39
|
+
getContainerWidth({
|
|
40
|
+
$schema: "https://vega.github.io/schema/vega-lite/v6.json",
|
|
41
|
+
facet: { column: { field: "Origin", type: "nominal" } },
|
|
42
|
+
spec: {
|
|
43
|
+
mark: "point",
|
|
44
|
+
encoding: {},
|
|
45
|
+
width: "container",
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
48
|
+
).toBe("container");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("should find width in nested repeat spec", () => {
|
|
52
|
+
expect(
|
|
53
|
+
getContainerWidth({
|
|
54
|
+
$schema: "https://vega.github.io/schema/vega-lite/v6.json",
|
|
55
|
+
repeat: { row: ["A", "B"] },
|
|
56
|
+
spec: {
|
|
57
|
+
mark: "point",
|
|
58
|
+
encoding: {},
|
|
59
|
+
width: "container",
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
).toBe("container");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("should return undefined for nested spec without width", () => {
|
|
66
|
+
expect(
|
|
67
|
+
getContainerWidth({
|
|
68
|
+
facet: { column: { field: "Origin" } },
|
|
69
|
+
spec: { mark: "point", encoding: {} },
|
|
70
|
+
}),
|
|
71
|
+
).toBeUndefined();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("should return undefined for hconcat (width on sub-specs)", () => {
|
|
75
|
+
expect(
|
|
76
|
+
getContainerWidth({
|
|
77
|
+
hconcat: [{ width: "container" }, { width: "container" }],
|
|
78
|
+
}),
|
|
79
|
+
).toBeUndefined();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("should return undefined for vconcat (width on sub-specs)", () => {
|
|
83
|
+
expect(
|
|
84
|
+
getContainerWidth({
|
|
85
|
+
vconcat: [{ width: "container" }, { width: "container" }],
|
|
86
|
+
}),
|
|
87
|
+
).toBeUndefined();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("should return undefined for compiled Vega spec (width as signal)", () => {
|
|
91
|
+
expect(
|
|
92
|
+
getContainerWidth({
|
|
93
|
+
$schema: "https://vega.github.io/schema/vega/v6.json",
|
|
94
|
+
autosize: { contains: "padding", type: "fit-x" },
|
|
95
|
+
signals: [
|
|
96
|
+
{
|
|
97
|
+
name: "width",
|
|
98
|
+
init: "isFinite(containerSize()[0]) ? containerSize()[0] : 300",
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
}),
|
|
102
|
+
).toBeUndefined();
|
|
103
|
+
});
|
|
36
104
|
});
|
|
@@ -6,13 +6,22 @@ import type { DataType, FieldTypes, VegaDataType } from "./vega-loader";
|
|
|
6
6
|
export type ContainerWidth = number | "container";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Get the container width from a
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Get the container width from a Vega-Lite spec.
|
|
10
|
+
*
|
|
11
|
+
* For unit specs, `width` is at the top level. For facet/repeat specs,
|
|
12
|
+
* `width` is nested inside `spec`. This does not handle hconcat/vconcat and Vega spec
|
|
13
|
+
* where the width may be a signal. These cases are covered by
|
|
14
|
+
* the CSS fallback `.vega-embed:has(> .chart-wrapper.fit-x)`.
|
|
12
15
|
*/
|
|
13
16
|
export function getContainerWidth(spec: unknown): ContainerWidth | undefined {
|
|
14
|
-
if (typeof spec === "object" && spec !== null
|
|
15
|
-
|
|
17
|
+
if (typeof spec === "object" && spec !== null) {
|
|
18
|
+
if ("width" in spec) {
|
|
19
|
+
return spec.width as ContainerWidth | undefined;
|
|
20
|
+
}
|
|
21
|
+
// Faceted/repeated spec
|
|
22
|
+
if ("spec" in spec) {
|
|
23
|
+
return getContainerWidth(spec.spec);
|
|
24
|
+
}
|
|
16
25
|
}
|
|
17
26
|
return undefined;
|
|
18
27
|
}
|