@marimo-team/islands 0.25.1-dev17 → 0.25.1-dev18
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-KVhjDMSe.js → ConnectedDataExplorerComponent-CwMXfDQR.js} +3 -3
- package/dist/{ErrorBoundary-B4i0ev18.js → ErrorBoundary-BCANhTrt.js} +1 -1
- package/dist/{code-visibility-CRc1C5g4.js → code-visibility-DIUkT8x-.js} +1 -1
- package/dist/{common-DQS4JILK.js → common-BfERj74g.js} +5 -5
- package/dist/{data-grid-overlay-editor-D0-p5694.js → data-grid-overlay-editor-ByNOrM5s.js} +1 -1
- package/dist/{feedback-button-DD68Ij-B.js → feedback-button-C6WatdDY.js} +2 -2
- package/dist/{formats-C8rLgZT9.js → formats-Cl_67ghI.js} +1 -1
- package/dist/{glide-data-editor-DqTwUsOq.js → glide-data-editor-BaQLny21.js} +3 -3
- package/dist/{globals-RG69U5-c.js → globals-DDOIQV3b.js} +1 -1
- package/dist/{loader-D2W4oM-3.js → loader-DEZSzvma.js} +253 -248
- package/dist/main.js +46 -39
- package/dist/{number-overlay-editor-DB4g1nLo.js → number-overlay-editor-pI5HWUmx.js} +1 -1
- package/dist/{react-vega-5AcMW8gG.js → react-vega-ewj7q_U5.js} +1 -1
- package/dist/{reveal-component-QBu-zZNO.js → reveal-component-BeyJErFp.js} +2 -2
- package/dist/{vega-component-CNf5gcrm.js → vega-component-tFOzgarw.js} +4 -4
- package/dist/{vega-embed-container-CbnTccZi.js → vega-embed-container-sSR5hAsy.js} +2 -2
- package/dist/{vega-loader.browser-D95WfUcj.js → vega-loader.browser-DNST6uVf.js} +2 -2
- package/package.json +1 -1
- package/src/components/data-table/charts/__tests__/chart-panel.test.tsx +286 -0
- package/src/components/data-table/charts/charts.tsx +26 -13
- package/src/plugins/impl/vega/__tests__/utils.test.ts +16 -1
- package/src/plugins/impl/vega/__tests__/vega.test.ts +37 -0
- package/src/plugins/impl/vega/loader.ts +23 -1
- package/src/plugins/impl/vega/utils.ts +5 -4
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import { describe, expect, it } from "vitest";
|
|
4
|
-
import { getContainerWidth } from "../utils";
|
|
4
|
+
import { getContainerWidth, getVegaFieldTypes } from "../utils";
|
|
5
|
+
|
|
6
|
+
describe("getVegaFieldTypes", () => {
|
|
7
|
+
it("preserves date strings unless the caller requests date parsing", () => {
|
|
8
|
+
expect(getVegaFieldTypes({ day: "date", timestamp: "datetime" })).toEqual({
|
|
9
|
+
day: "string",
|
|
10
|
+
timestamp: "date",
|
|
11
|
+
});
|
|
12
|
+
expect(
|
|
13
|
+
getVegaFieldTypes(
|
|
14
|
+
{ day: "date", timestamp: "datetime" },
|
|
15
|
+
{ parseDates: true },
|
|
16
|
+
),
|
|
17
|
+
).toEqual({ day: "date", timestamp: "date" });
|
|
18
|
+
});
|
|
19
|
+
});
|
|
5
20
|
|
|
6
21
|
describe("getContainerWidth", () => {
|
|
7
22
|
it('should return "container" when spec width is "container"', () => {
|
|
@@ -13,6 +13,43 @@ const { ZERO_WIDTH_SPACE, replacePeriodsInColumnNames, uniquifyColumnNames } =
|
|
|
13
13
|
exportedForTesting;
|
|
14
14
|
|
|
15
15
|
describe("vega loader", () => {
|
|
16
|
+
it("parses infinities only in explicitly numeric CSV fields", async () => {
|
|
17
|
+
vi.spyOn(vegaLoader, "load").mockResolvedValue(
|
|
18
|
+
"value,label,id\ninf,inf,1\n-inf,-inf,2\n+inf,+inf,3\n2.5,002.5,4\n,,5\nNaN,NaN,6\n",
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const data = await vegaLoadData("chart.csv", {
|
|
22
|
+
type: "csv",
|
|
23
|
+
parse: { value: "number", label: "string", id: "integer" },
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
expect(data).toEqual([
|
|
27
|
+
{ value: Infinity, label: "inf", id: 1 },
|
|
28
|
+
{ value: -Infinity, label: "-inf", id: 2 },
|
|
29
|
+
{ value: Infinity, label: "+inf", id: 3 },
|
|
30
|
+
{ value: 2.5, label: "002.5", id: 4 },
|
|
31
|
+
{ value: null, label: null, id: 5 },
|
|
32
|
+
{ value: Number.NaN, label: "NaN", id: 6 },
|
|
33
|
+
]);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("preserves the table's large integer and infinity handling", async () => {
|
|
37
|
+
vi.spyOn(vegaLoader, "load").mockResolvedValue(
|
|
38
|
+
"id,value\n9007199254740993,inf\n9007199254740995,-inf\n",
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const data = await vegaLoadData(
|
|
42
|
+
"table.csv",
|
|
43
|
+
{ type: "csv", parse: { id: "integer", value: "number" } },
|
|
44
|
+
{ handleBigIntAndNumberLike: true },
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
expect(data).toEqual([
|
|
48
|
+
{ id: BigInt("9007199254740993"), value: "inf" },
|
|
49
|
+
{ id: BigInt("9007199254740995"), value: "-inf" },
|
|
50
|
+
]);
|
|
51
|
+
});
|
|
52
|
+
|
|
16
53
|
it("should parse csv data with dates", async () => {
|
|
17
54
|
const csvData = `
|
|
18
55
|
active,username,id
|
|
@@ -16,6 +16,26 @@ const previousNumberParser = typeParsers.number;
|
|
|
16
16
|
const previousDateParser = typeParsers.date;
|
|
17
17
|
const previousBooleanParser = typeParsers.boolean;
|
|
18
18
|
|
|
19
|
+
const NUMBER_MIDDLEWARE: Middleware = () => {
|
|
20
|
+
const parseNumber = (value: string) => {
|
|
21
|
+
if (value === "inf" || value === "+inf") {
|
|
22
|
+
return Number.POSITIVE_INFINITY;
|
|
23
|
+
}
|
|
24
|
+
if (value === "-inf") {
|
|
25
|
+
return Number.NEGATIVE_INFINITY;
|
|
26
|
+
}
|
|
27
|
+
return previousNumberParser(value);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
typeParsers.integer = parseNumber;
|
|
31
|
+
typeParsers.number = parseNumber;
|
|
32
|
+
|
|
33
|
+
return () => {
|
|
34
|
+
typeParsers.integer = previousIntegerParser;
|
|
35
|
+
typeParsers.number = previousNumberParser;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
19
39
|
const BIG_INT_MIDDLEWARE: Middleware = () => {
|
|
20
40
|
// Custom parser to:
|
|
21
41
|
// - handle BigInt
|
|
@@ -159,6 +179,8 @@ export async function vegaLoadData<T = object>(
|
|
|
159
179
|
const middleware: Middleware[] = [DATE_MIDDLEWARE];
|
|
160
180
|
if (handleBigIntAndNumberLike) {
|
|
161
181
|
middleware.push(BIG_INT_MIDDLEWARE);
|
|
182
|
+
} else {
|
|
183
|
+
middleware.push(NUMBER_MIDDLEWARE);
|
|
162
184
|
}
|
|
163
185
|
|
|
164
186
|
let unsubscribes: Unsubscribe[] = [];
|
|
@@ -216,7 +238,7 @@ export async function vegaLoadData<T = object>(
|
|
|
216
238
|
|
|
217
239
|
// Apply middleware
|
|
218
240
|
unsubscribes = middleware.map((m) => m());
|
|
219
|
-
//
|
|
241
|
+
// CSV defaults to inference when no explicit column types are available.
|
|
220
242
|
const results = isCsv
|
|
221
243
|
? // csv -> json
|
|
222
244
|
read(csvOrJsonData, {
|
|
@@ -45,21 +45,22 @@ function toArray<T>(value: T | T[] | undefined): T[] {
|
|
|
45
45
|
|
|
46
46
|
export function getVegaFieldTypes(
|
|
47
47
|
types: Record<string, DataType> | undefined | null,
|
|
48
|
+
{ parseDates = false }: { parseDates?: boolean } = {},
|
|
48
49
|
): FieldTypes | "auto" {
|
|
49
50
|
if (!types || Object.keys(types).length === 0) {
|
|
50
51
|
// If fieldTypes is provided, use it to parse the data
|
|
51
52
|
// Otherwise, infer the data types
|
|
52
53
|
return "auto";
|
|
53
54
|
}
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
55
|
+
// Preserve date-only strings for callers such as the data editor.
|
|
56
|
+
// Parsing creates Date objects that JSON serializes as full timestamps.
|
|
57
|
+
// Charts opt into date parsing for temporal axes.
|
|
57
58
|
return Objects.mapValues(types, (type): VegaDataType => {
|
|
58
59
|
if (type === "geometry") {
|
|
59
60
|
return "string";
|
|
60
61
|
}
|
|
61
62
|
if (type === "date") {
|
|
62
|
-
return "string";
|
|
63
|
+
return parseDates ? "date" : "string";
|
|
63
64
|
}
|
|
64
65
|
if (type === "time") {
|
|
65
66
|
return "string";
|