import { Meta } from "@storybook/react";
import { AutoCompleteProps } from "./AutoCompleteProps";
import AutoComplete from "./AutoComplete";
import countries from "./mockData/countries";

export default {
  title: "Design System/Dropdowns/AutoComplete",
  component: AutoComplete,
  tags: ["autodocs"],
  parameters: {
    docs: {
      description: {
        component:
          'The KendoReact AutoComplete is a form component that provides suggestions depending on the typed text and is a richer version of the input element and supports data binding, filtering, and custom rendering. \n\n```javascript\nimport { AutoComplete } from "@renault-ui-library"\n```',
      },
    },
  },
  argTypes: {
    dataTestId: {
      control: { type: "text" },
      description: "Specifies the data-test-id attribute for testing purposes.",
    },
    accessKey: {
      control: { type: "text" },
      description: "Specifies the accessKey of the AutoComplete.",
    },
    ariaDescribedBy: {
      control: { type: "text" },
      description:
        "Identifies the element(s) which will describe the component, similar to HTML aria-describedby attribute.",
    },
    ariaLabelledBy: {
      control: { type: "text" },
      description: "Identifies the element(s) which will label the component.",
    },
    className: {
      control: { type: "text" },
      description: "Sets additional classes to the AutoComplete.",
    },
    clearButton: {
      control: { type: "boolean" },
      description:
        "Renders a button on hovering over the component, which resets the value.",
    },
    data: {
      control: { type: "array" },
      description: "Sets the data of the AutoComplete.",
    },
    dataItemKey: {
      control: { type: "text" },
      description:
        "Sets the key for comparing the data items of the AutoComplete.",
    },
    defaultValue: {
      control: { type: "text" },
      description: "Sets the default value of the AutoComplete.",
    },
    dir: {
      control: { type: "text" },
      description: "Represents the dir HTML attribute.",
    },
    disabled: {
      control: { type: "boolean" },
      description: "Sets the disabled state of the AutoComplete.",
    },
    fillMode: {
      control: {
        type: "select",
        options: ["null", "flat", "outline", "solid"],
      },
      description: "Configures the fillMode of the AutoComplete.",
    },
    footer: {
      control: { type: "object" },
      description: "Sets the footer component of the AutoComplete.",
    },
    groupField: {
      control: { type: "text" },
      description:
        "Sets the data item field that represents the start of a group.",
    },
    header: {
      control: { type: "object" },
      description: "Sets the header component of the AutoComplete.",
    },
    id: {
      control: { type: "text" },
      description: "Specifies the id of the component.",
    },
    label: {
      control: { type: "text" },
      description: "Renders a floating label for the AutoComplete.",
    },
    loading: {
      control: { type: "boolean" },
      description: "Sets the loading state of the AutoComplete.",
    },
    name: {
      control: { type: "text" },
      description: "Specifies the name property of the input DOM element.",
    },
    opened: {
      control: { type: "boolean" },
      description: "Sets the opened and closed state of the AutoComplete.",
    },
    placeholder: {
      control: { type: "text" },
      description: "The hint that is displayed when the AutoComplete is empty.",
    },
    popupSettings: {
      control: { type: "object" },
      description: "Configures the popup of the AutoComplete.",
    },
    readonly: {
      control: { type: "boolean" },
      description: "Sets the read-only state of the AutoComplete.",
    },
    required: {
      control: { type: "boolean" },
      description: "Specifies if null is a valid value for the component.",
    },
    rounded: {
      control: {
        type: "select",
        options: ["null", "small", "medium", "full", "large"],
      },
      description: "Configures the roundness of the AutoComplete.",
    },
    size: {
      control: {
        type: "select",
        options: ["null", "small", "medium", "large"],
      },
      description: "Configures the size of the AutoComplete.",
    },
    skipDisabledItems: {
      control: { type: "boolean" },
      description:
        "Defines if AutoComplete's disabled items will be skipped or focused when navigating through the list of items using a keyboard.",
    },
    style: {
      control: { type: "object" },
      description: "The styles that are applied to the AutoComplete.",
    },
    suggest: {
      control: { type: "boolean" },
      description:
        "Enables the auto-completion of the text based on the first data item.",
    },
    tabIndex: {
      control: { type: "number" },
      description: "Specifies the tabIndex of the AutoComplete.",
    },
    textField: {
      control: { type: "text" },
      description: "Sets the data item field that represents the item text.",
    },
    valid: {
      control: { type: "boolean" },
      description: "Overrides the validity state of the component.",
    },
    validationMessage: {
      control: { type: "text" },
      description: "Controls the form error message of the component.",
    },
    validityStyles: {
      control: { type: "boolean" },
      description:
        "If set to false, no visual representation of the invalid state of the component will be applied.",
    },
    value: {
      control: { type: "text" },
      description: "Sets the value of the AutoComplete.",
    },
    focusedItemIndex: {
      control: { type: "function" },
      description:
        "If set, the AutoComplete will use it to get the focused item index.",
    },
    groupHeaderItemRender: {
      control: { type: "function" },
      description:
        "Fires when a AutoComplete group header item is about to be rendered.",
    },
    groupStickyHeaderItemRender: {
      control: { type: "function" },
      description:
        "Fires when a AutoComplete sticky group header item is about to be rendered.",
    },
    itemRender: {
      control: { type: "function" },
      description:
        "Fires when an AutoComplete list item is about to be rendered.",
    },
    listNoDataRender: {
      control: { type: "function" },
      description:
        "Fires when the element which indicates no data in the popup is about to be rendered.",
    },
    onBlur: {
      control: { type: "function" },
      description: "Fires each time the AutoComplete gets blurred.",
    },
    onChange: {
      control: { type: "function" },
      description:
        "Fires each time the value of the AutoComplete is about to change.",
    },
    onClose: {
      control: { type: "function" },
      description:
        "Fires each time the popup of the AutoComplete is about to close.",
    },
    onFocus: {
      control: { type: "function" },
      description: "Fires each time the user focuses the AutoComplete.",
    },
    onOpen: {
      control: { type: "function" },
      description:
        "Fires each time the popup of the AutoComplete is about to open.",
    },
    valueRender: {
      control: { type: "function" },
      description:
        "Fires when the AutoComplete input element is about to be rendered.",
    },
  },
} as Meta;

export const Default = (args: AutoCompleteProps): JSX.Element => (
  <AutoComplete data={countries} {...args} />
);

Default.args = {
  dataTestId: "autocomplete-data-testid",
  defaultValue: "Turkey",
  fillMode: "solid",
  rounded: "medium",
  size: "large",
  style: { width: "240px" },
};
