Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

1.8 KB
Raw Blame
/* Copyright 2026 Marimo. All rights reserved. */
/* oxlint-disable react-hooks/rules-of-hooks */
import type { Meta, StoryObj } from "@storybook/react-vite";
import { useState } from "react";
import { DataFrameComponent } from "@/plugins/impl/data-frames/DataFramePlugin";
import type { Transformations } from "@/plugins/impl/data-frames/schema";
import type { ColumnId } from "@/plugins/impl/data-frames/types";
import { Functions } from "@/utils/functions";

const meta: Meta = {
  title: "DataFrame",
  args: {},
};

export default meta;

export const DataFrame: StoryObj = {
  render: () => {
    const [value, setValue] = useState<Transformations>();
    return (
      <DataFrameComponent
        get_column_values={async () => ({
          values: Array.from({ length: 100 }).map((_, i) => `value ${i}`),
          too_many_values: false,
        })}
        columns={
          new Map<ColumnId, string>([
            ["name" as ColumnId, "object"],
            ["age" as ColumnId, "int"],
            ["height" as ColumnId, "float"],
            ["picture" as ColumnId, "bytes"],
          ])
        }
        pageSize={5}
        value={value}
        setValue={(v) => {
          console.log(v);
          setValue(v);
        }}
        get_dataframe={() => Promise.reject(new Error("not implemented"))}
        search={Functions.THROW}
        host={document.body}
        showDownload={false}
        download_as={async () => ({ url: "", filename: "" })}
        download_geojson={async () => ({ url: "", filename: "" })}
        get_export_metadata={async () => ({
          geometry_columns: [],
          primary_geometry_column: null,
          default_geometry_column: null,
          formats: {},
        })}
        get_size_bytes={async () => ({ size_bytes: null })}
        lazy={false}
      />
    );
  },
};