import { Meta } from "@storybook/react";
import { SpreadsheetProps } from "./SpreadsheetProps";
import Spreadsheet from "./Spreadsheet";
import { sheets } from "./mockData/sheets";

export default {
  title: "Design System/Spreadsheet",
  component: Spreadsheet,
  tags: ["autodocs"],
  parameters: {
    docs: {
      description: {
        component:
          'The React Spreadsheet library allows you to edit and visualize tabular data by using cell formatting options, styles, and themes. \n\n```javascript\nimport { Spreadsheet } from "@renault-ui-library"\n```',
      },
    },
  },
  argTypes: {
    dataTestId: {
      control: { type: "text" },
      description: "Specifies the data-test-id attribute for testing purposes.",
    },
    className: {
      control: { type: "text" },
      description: "Sets additional classes to the Spreadsheet.",
    },
    defaultProps: {
      control: { type: "object" },
      description: "Represents the default props of the Spreadsheet.",
    },
    style: {
      control: { type: "object" },
      description:
        "Specifies the styles that will be applied to the wrapping element.",
    },
    toolbar: {
      control: { type: "boolean" },
      description:
        "A Boolean value which indicates if the toolbar will be displayed.",
    },
    onChange: {
      control: { type: "function" },
      description:
        "Triggered when a value in the Spreadsheet has been changed.",
    },
    onChangeFormat: {
      control: { type: "function" },
      description: "Triggered when the range format is changed from the UI.",
    },
    onExcelExport: {
      control: { type: "function" },
      description:
        "Fires when the user clicks the Export to Excel toolbar button.",
    },
    onExcelImport: {
      control: { type: "function" },
      description: "Fired when the user clicks the Open toolbar button.",
    },
    onSelect: {
      control: { type: "function" },
      description: "Triggered when the Spreadsheet selection is changed.",
    },
  },
} as Meta;

export const Default = (args: SpreadsheetProps): JSX.Element => (
  <Spreadsheet
    style={{
      width: "100%",
      height: 680,
    }}
    defaultProps={{ sheets }}
  />
);
