import { Meta } from "@storybook/react";
import Upload from "./Upload";
import { UploadProps } from "./UploadProps";

export default {
  title: "Design System/Upload",
  component: Upload,
  tags: ["autodocs"],
  parameters: {
    docs: {
      description: {
        component:
          'The KendoReact Upload helps users send files from their file systems to dedicated server handlers which are configured to receive them. \n\n```javascript\nimport { Upload } from "@renault-ui-library"\n```',
      },
    },
  },
  argTypes: {
    dataTestId: {
      control: { type: "text" },
      description: "Specifies the data-test-id attribute for testing purposes.",
    },
    accept: {
      control: { type: "text" },
      description: "Accepted file types",
    },
    actionsLayout: {
      control: { type: "select", options: ["start", "center", "end"] },
      description: "Layout of the action buttons",
    },
    ariaDescribedBy: {
      control: { type: "text" },
      description: "Aria described by attribute",
    },
    ariaLabelledBy: {
      control: { type: "text" },
      description: "Aria labelled by attribute",
    },
    autoUpload: {
      control: { type: "boolean" },
      description: "Automatically upload files upon selection",
    },
    batch: {
      control: { type: "boolean" },
      description: "Enable batch upload of files",
    },
    className: {
      control: { type: "text" },
      description: "CSS class name for the component",
    },
    defaultFiles: {
      control: { type: "object" },
      description: "Default files in the upload component",
    },
    disabled: {
      control: { type: "boolean" },
      description: "Disable the upload component",
    },
    id: {
      control: { type: "text" },
      description: "ID for the upload component",
    },
    listItemUI: {
      control: { type: "object" },
      description: "Custom UI for the list item",
    },
    multiple: {
      control: { type: "boolean" },
      description: "Allow multiple file selection",
    },
    onAdd: {
      action: "onAdd",
      description: "Event triggered when a file is added",
    },
    onBeforeRemove: {
      action: "onBeforeRemove",
      description: "Event triggered before a file is removed",
    },
    onBeforeUpload: {
      action: "onBeforeUpload",
      description: "Event triggered before a file is uploaded",
    },
    onCancel: {
      action: "onCancel",
      description: "Event triggered when the upload is cancelled",
    },
    onProgress: {
      action: "onProgress",
      description: "Event triggered during the upload progress",
    },
    onRemove: {
      action: "onRemove",
      description: "Event triggered when a file is removed",
    },
    onStatusChange: {
      action: "onStatusChange",
      description: "Event triggered when the status of the upload changes",
    },
  },
} as Meta;

export const Default = (args: UploadProps): JSX.Element => (
  <Upload
    batch={false}
    multiple={true}
    defaultFiles={[]}
    withCredentials={false}
    saveUrl={"https://demos.telerik.com/kendo-ui/service-v4/upload/save"}
    removeUrl={"https://demos.telerik.com/kendo-ui/service-v4/upload/remove"}
    {...args}
  />
);

Default.args = {
  dataTestId: "upload-data-testid",
  accept: "image/*",
  actionsLayout: "end",
  autoUpload: true,
  batch: false,
  disabled: false,
  multiple: true,
};
