@marimo-team/islands 0.25.1-dev16 → 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.
Files changed (41) hide show
  1. package/dist/{ConnectedDataExplorerComponent-KVhjDMSe.js → ConnectedDataExplorerComponent-CwMXfDQR.js} +3 -3
  2. package/dist/{ErrorBoundary-Dw6ePT6V.js → ErrorBoundary-BCANhTrt.js} +1 -1
  3. package/dist/{cells-B5-y5EY3.js → cells-Cksce8br.js} +2 -2
  4. package/dist/{chat-ui-HJZsTl7o.js → chat-ui-4lXygZ8L.js} +4 -4
  5. package/dist/{code-visibility-nEXuRCpZ.js → code-visibility-DIUkT8x-.js} +2 -2
  6. package/dist/{common-CKVUP-3T.js → common-BfERj74g.js} +13 -13
  7. package/dist/{data-grid-overlay-editor-Dl4u0MM_.js → data-grid-overlay-editor-ByNOrM5s.js} +1 -1
  8. package/dist/{error-entries-Bkbpx0T0.js → error-entries-CvCFdpY2.js} +1 -1
  9. package/dist/{feedback-button-7UQpHERA.js → feedback-button-C6WatdDY.js} +4 -4
  10. package/dist/{formats-C8rLgZT9.js → formats-Cl_67ghI.js} +1 -1
  11. package/dist/{glide-data-editor-Cau1B1SH.js → glide-data-editor-BaQLny21.js} +3 -3
  12. package/dist/{globals-BQb7ei48.js → globals-DDOIQV3b.js} +1 -1
  13. package/dist/{html-to-image-BAgJOlSW.js → html-to-image-jTwYSWRc.js} +1 -1
  14. package/dist/{loader-D2W4oM-3.js → loader-DEZSzvma.js} +253 -248
  15. package/dist/main.js +53 -51
  16. package/dist/{number-overlay-editor-CmsthUKy.js → number-overlay-editor-pI5HWUmx.js} +1 -1
  17. package/dist/{process-output-zDX4jbhd.js → process-output-DevJrL3v.js} +2 -2
  18. package/dist/{react-vega-5AcMW8gG.js → react-vega-ewj7q_U5.js} +1 -1
  19. package/dist/{reveal-component-IMWiBhGb.js → reveal-component-BeyJErFp.js} +3 -3
  20. package/dist/{vega-component-CNf5gcrm.js → vega-component-tFOzgarw.js} +4 -4
  21. package/dist/{vega-embed-container-CbnTccZi.js → vega-embed-container-sSR5hAsy.js} +2 -2
  22. package/dist/{vega-loader.browser-D95WfUcj.js → vega-loader.browser-DNST6uVf.js} +2 -2
  23. package/package.json +1 -1
  24. package/src/components/data-table/charts/__tests__/chart-panel.test.tsx +286 -0
  25. package/src/components/data-table/charts/charts.tsx +26 -13
  26. package/src/components/editor/chrome/components/contribute-snippet-button.tsx +6 -1
  27. package/src/components/editor/notebook-cell.tsx +2 -2
  28. package/src/components/editor/output/MarimoTracebackOutput.tsx +1 -1
  29. package/src/components/editor/output/VideoOutput.tsx +1 -1
  30. package/src/components/editor/output/ansi-reduce.ts +8 -4
  31. package/src/components/editor/output/console/text-rendering.tsx +3 -1
  32. package/src/components/home/components.tsx +1 -0
  33. package/src/components/pages/run-page.tsx +1 -0
  34. package/src/components/static-html/share-modal.tsx +2 -1
  35. package/src/components/static-html/static-banner.tsx +2 -1
  36. package/src/components/ui/links.tsx +6 -1
  37. package/src/plugins/impl/vega/__tests__/utils.test.ts +16 -1
  38. package/src/plugins/impl/vega/__tests__/vega.test.ts +37 -0
  39. package/src/plugins/impl/vega/loader.ts +23 -1
  40. package/src/plugins/impl/vega/utils.ts +5 -4
  41. package/src/plugins/layout/RoutesPlugin.tsx +4 -6
@@ -23,9 +23,11 @@ import { Form } from "@/components/ui/form";
23
23
  import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
24
24
  import type { CellId } from "@/core/cells/ids";
25
25
  import { useAsyncData } from "@/hooks/useAsyncData";
26
+ import { useDeepCompareMemoize } from "@/hooks/useDeepCompareMemoize";
26
27
  import { useDebouncedCallback } from "@/hooks/useDebounce";
27
28
  import type { GetDataUrl } from "@/plugins/impl/DataTablePlugin";
28
29
  import { vegaLoadData } from "@/plugins/impl/vega/loader";
30
+ import { getVegaFieldTypes } from "@/plugins/impl/vega/utils";
29
31
  import { useTheme } from "@/theme/useTheme";
30
32
  import { uniqueBy } from "@/utils/arrays";
31
33
  import { inferFieldTypes } from "../columns";
@@ -284,6 +286,7 @@ export const TablePanel: React.FC<TablePanelProps> = ({
284
286
  saveChart={saveChart}
285
287
  saveChartType={saveChartType}
286
288
  getDataUrl={getDataUrl}
289
+ hasSchema={Boolean(fieldTypes?.length)}
287
290
  fieldTypes={mergeIndexFields(
288
291
  fieldTypes ?? inferFieldTypes(dataTable.props.data),
289
292
  rowHeaders,
@@ -307,6 +310,7 @@ export const ChartPanel: React.FC<{
307
310
  saveChartType: (chartType: ChartType) => void;
308
311
  getDataUrl?: GetDataUrl;
309
312
  fieldTypes?: FieldTypesWithExternalType | null;
313
+ hasSchema?: boolean;
310
314
  isLargeDataset: boolean;
311
315
  }> = ({
312
316
  tableData,
@@ -316,6 +320,7 @@ export const ChartPanel: React.FC<{
316
320
  saveChartType,
317
321
  getDataUrl,
318
322
  fieldTypes,
323
+ hasSchema = Boolean(fieldTypes?.length),
319
324
  isLargeDataset,
320
325
  }) => {
321
326
  const { theme } = useTheme();
@@ -331,6 +336,8 @@ export const ChartPanel: React.FC<{
331
336
  const [renderLargeCharts, setRenderLargeCharts] = useState(!isLargeDataset);
332
337
 
333
338
  const { ref: chartContainerRef } = useResizeObserver();
339
+ // Sample-inferred types are useful for controls, but not full CSV parsing.
340
+ const csvFieldTypes = useDeepCompareMemoize(hasSchema ? fieldTypes : null);
334
341
 
335
342
  const { data, isPending, error } = useAsyncData(async () => {
336
343
  if (!getDataUrl || tableData.length === 0 || !renderLargeCharts) {
@@ -342,20 +349,26 @@ export const ChartPanel: React.FC<{
342
349
  return response.data_url;
343
350
  }
344
351
 
345
- const chartData = await vegaLoadData(
346
- response.data_url,
347
- response.format === "arrow"
348
- ? { type: "arrow" }
349
- : response.format === "json"
350
- ? { type: "json" }
351
- : { type: "csv", parse: "auto" },
352
- {
353
- replacePeriod: true,
354
- },
355
- );
356
- return chartData;
352
+ let format: Parameters<typeof vegaLoadData>[1];
353
+ if (response.format === "arrow") {
354
+ format = { type: "arrow" };
355
+ } else if (response.format === "json") {
356
+ format = { type: "json" };
357
+ } else {
358
+ format = {
359
+ type: "csv",
360
+ parse: getVegaFieldTypes(
361
+ csvFieldTypes &&
362
+ Object.fromEntries(
363
+ csvFieldTypes.map(([name, [type]]) => [name, type]),
364
+ ),
365
+ { parseDates: true },
366
+ ),
367
+ };
368
+ }
369
+ return vegaLoadData(response.data_url, format);
357
370
  // Re-run when the data table changes
358
- }, [tableData, renderLargeCharts]);
371
+ }, [tableData, renderLargeCharts, csvFieldTypes]);
359
372
 
360
373
  const formValues = form.watch();
361
374
 
@@ -40,7 +40,12 @@ const ContributeSnippetModal: React.FC<{
40
40
  <DialogDescription>
41
41
  Have a useful snippet you want to share with the community? Make a
42
42
  pull request{" "}
43
- <a href={Constants.githubPage} target="_blank" className="underline">
43
+ <a
44
+ href={Constants.githubPage}
45
+ target="_blank"
46
+ rel="noreferrer"
47
+ className="underline"
48
+ >
44
49
  on GitHub
45
50
  </a>
46
51
  .
@@ -762,7 +762,7 @@ const EditableCellComponent = ({
762
762
  href="https://links.marimo.app/reusable-definitions"
763
763
  target="_blank"
764
764
  className="hover:underline text-muted-foreground text-xs font-bold"
765
- rel="noopener"
765
+ rel="noreferrer"
766
766
  >
767
767
  reusable
768
768
  </a>
@@ -801,7 +801,7 @@ const EditableCellComponent = ({
801
801
  <a
802
802
  href="https://links.marimo.app/reusable-definitions"
803
803
  target="_blank"
804
- rel="noopener"
804
+ rel="noreferrer"
805
805
  >
806
806
  <HelpCircleIcon
807
807
  size={16}
@@ -177,7 +177,7 @@ export const MarimoTracebackOutput = ({
177
177
  <a
178
178
  target="_blank"
179
179
  href="https://marimo.io/discord?ref=notebook"
180
- rel="noopener"
180
+ rel="noreferrer"
181
181
  >
182
182
  <MessageCircleIcon className="h-4 w-4 mr-2" />
183
183
  Ask in Discord
@@ -7,5 +7,5 @@ interface Props {
7
7
  }
8
8
 
9
9
  export const VideoOutput = ({ src, className }: Props): JSX.Element => {
10
- return <iframe className={className} src={src} />;
10
+ return <iframe className={className} src={src} title="Video output" />;
11
11
  };
@@ -13,8 +13,10 @@ export interface Cursor {
13
13
  export class TerminalBuffer {
14
14
  private lines: string[] = [""];
15
15
  private cursor: Cursor = { row: 0, col: 0 };
16
- // oxlint-ignore-next-line no-control-regex -- Needed for ANSI escape sequence parsing
17
- private static readonly ESCAPE_REGEX = /\u001B\[([0-9;]*)([A-DJKH])/u;
16
+ private static readonly ESCAPE_REGEX = new RegExp(
17
+ String.raw`\u001B\[([0-9;]*)([A-DJKH])`,
18
+ "u",
19
+ );
18
20
 
19
21
  /** Ensure the internal lines array is large enough. */
20
22
  private ensureLine(row: number) {
@@ -180,8 +182,10 @@ export class TerminalBuffer {
180
182
  */
181
183
  export class AnsiParser {
182
184
  // Matches both CSI sequences (ESC[...letter) and other escape sequences like character set selection (ESC(B)
183
- // oxlint-ignore-next-line no-control-regex -- Needed for ANSI parsing
184
- private ESC_REGEX = /\u001B(?:\[[0-9;]*[A-Za-z]|\([0-9A-Za-z])/gu;
185
+ private ESC_REGEX = new RegExp(
186
+ String.raw`\u001B(?:\[[0-9;]*[A-Za-z]|\([0-9A-Za-z])`,
187
+ "gu",
188
+ );
185
189
 
186
190
  parse(input: string): { type: "text" | "escape"; value: string }[] {
187
191
  const tokens: { type: "text" | "escape"; value: string }[] = [];
@@ -256,6 +256,7 @@ export const pipInstallReplacer: Replacer = (domNode: DOMNode) => {
256
256
  );
257
257
  }
258
258
 
259
+ // oxlint-disable-next-line react/jsx-no-useless-fragment -- html-react-parser replacers must return a React element.
259
260
  return <>{segments}</>;
260
261
  };
261
262
 
@@ -283,6 +284,7 @@ export const urlReplacer: Replacer = (domNode: DOMNode) => {
283
284
  return undefined;
284
285
  }
285
286
 
287
+ // oxlint-disable-next-line react/jsx-no-useless-fragment -- html-react-parser replacers must return a React element.
286
288
  return <>{result}</>;
287
289
  };
288
290
 
@@ -331,5 +333,5 @@ export const RenderTextWithLinks = ({ text }: { text: string }) => {
331
333
  );
332
334
  }, [text]);
333
335
 
334
- return <>{content}</>;
336
+ return content;
335
337
  };
@@ -170,6 +170,7 @@ export const ResourceLinks: React.FC = () => {
170
170
  key={resource.title}
171
171
  href={resource.url}
172
172
  target="_blank"
173
+ rel="noreferrer"
173
174
  aria-label={`${resource.title}: ${resource.description}`}
174
175
  className="flex items-start gap-3 py-3 px-3 rounded-lg border hover:bg-accent/20 transition-colors shadow-xs"
175
176
  >
@@ -50,6 +50,7 @@ const Watermark = () => {
50
50
  <a
51
51
  href={Constants.githubPage}
52
52
  target="_blank"
53
+ rel="noreferrer"
53
54
  className="text-sm text-(--grass-11) font-bold tracking-wide transition-colors bg-(--grass-4) hover:bg-(--grass-5) border-t border-l border-(--grass-8) px-3 py-1 rounded-tl-md flex items-center gap-2"
54
55
  >
55
56
  <span>made with marimo</span>
@@ -74,6 +74,7 @@ export const ShareStaticNotebookModal: React.FC<{
74
74
  <a
75
75
  href={Constants.issuesPage}
76
76
  target="_blank"
77
+ rel="noreferrer"
77
78
  className="underline"
78
79
  >
79
80
  GitHub
@@ -102,7 +103,7 @@ export const ShareStaticNotebookModal: React.FC<{
102
103
  <DialogDescription>
103
104
  You can publish a static, non-interactive version of this notebook
104
105
  to the public web. We will create a link for you that lives on{" "}
105
- <a href={BASE_URL} target="_blank">
106
+ <a href={BASE_URL} target="_blank" rel="noreferrer">
106
107
  {BASE_URL}
107
108
  </a>
108
109
  .
@@ -1,6 +1,5 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
  /* oxlint-disable react/jsx-no-comment-textnodes */
3
- /* oxlint-disable react/jsx-no-target-blank */
4
3
 
5
4
  import { useAtomValue } from "jotai";
6
5
  import { CopyIcon, DownloadIcon } from "lucide-react";
@@ -49,6 +48,7 @@ export const StaticBanner: React.FC = () => {
49
48
  <a
50
49
  href={Constants.githubPage}
51
50
  target="_blank"
51
+ rel="noreferrer"
52
52
  className="text-(--sky-11) font-medium underline"
53
53
  >
54
54
  marimo
@@ -93,6 +93,7 @@ const StaticBannerDialog = ({ code }: { code: string }) => {
93
93
  <a
94
94
  href={Constants.githubPage}
95
95
  target="_blank"
96
+ rel="noreferrer"
96
97
  className="text-(--sky-11) hover:underline font-medium"
97
98
  >
98
99
  marimo
@@ -21,7 +21,12 @@ export const ExternalLink = ({
21
21
  children: React.ReactNode;
22
22
  }) => {
23
23
  return (
24
- <a href={href} target="_blank" className="text-link hover:underline">
24
+ <a
25
+ href={href}
26
+ target="_blank"
27
+ rel="noreferrer"
28
+ className="text-link hover:underline"
29
+ >
25
30
  {children}
26
31
  </a>
27
32
  );
@@ -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
- // Always set parse to auto for csv data, to be able to parse dates and floats
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
- // Convert all 'date' to 'string', because dates don't format back to
55
- // the correct formatting. For example, a date like '2024-01-01' will
56
- // be formatted to '2024-01-01T00:00:00.000Z'.
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";
@@ -1,6 +1,5 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
  import React, {
3
- type JSX,
4
3
  type PropsWithChildren,
5
4
  useEffect,
6
5
  useMemo,
@@ -28,7 +27,7 @@ export class RoutesPlugin implements IStatelessPlugin<Data> {
28
27
  routes: z.array(z.string()),
29
28
  });
30
29
 
31
- render(props: IStatelessPluginProps<Data>): JSX.Element {
30
+ render(props: IStatelessPluginProps<Data>): React.ReactElement {
32
31
  return <RoutesComponent {...props.data}>{props.children}</RoutesComponent>;
33
32
  }
34
33
  }
@@ -36,7 +35,7 @@ export class RoutesPlugin implements IStatelessPlugin<Data> {
36
35
  const RoutesComponent = ({
37
36
  routes,
38
37
  children,
39
- }: PropsWithChildren<Data>): JSX.Element => {
38
+ }: PropsWithChildren<Data>): React.ReactNode => {
40
39
  const childCount = React.Children.count(children);
41
40
  if (childCount !== routes.length) {
42
41
  throw new Error(
@@ -69,12 +68,11 @@ const RoutesComponent = ({
69
68
  }, [handleFindMatch]);
70
69
 
71
70
  if (!matched) {
72
- // oxlint-disable-next-line react/jsx-no-useless-fragment
73
- return <></>;
71
+ return null;
74
72
  }
75
73
 
76
74
  const matchedIndex = routes.indexOf(matched);
77
75
  const child = React.Children.toArray(children)[matchedIndex];
78
76
 
79
- return <>{child}</>;
77
+ return child;
80
78
  };