import { Meta } from "@storybook/react";
import { MultiColumnComboBoxProps } from "./MultiColumnComboBoxProps";
import MultiColumnComboBox from "./MultiColumnComboBox";

import { employees } from "./mockData/data";

const columns = [
  { field: "id", header: "ID", width: "100px" },
  { field: "name", header: "Name", width: "300px" },
  { field: "position", header: "Position", width: "300px" },
];

export default {
  title: "Design System/Dropdowns/MultiColumnComboBox",
  component: MultiColumnComboBox,
  tags: ["autodocs"],
  parameters: {
    docs: {
      description: {
        component:
          'The MultiColumnComboBox is a ComboBox that can display data in multiple columns. You can think of it as a dropdown that has a grid-like layout. \n\n```javascript\nimport { MultiColumnComboBox } 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 MultiColumnComboBox.",
    },
    adaptive: {
      control: { type: "boolean" },
      description:
        "Providing different rendering of the popup element based on the screen dimensions.",
    },
    adaptiveFilter: {
      control: { type: "text" },
      description:
        "Sets the value of the adaptive filtering input of the of ComboBox.",
    },
    adaptiveTitle: {
      control: { type: "text" },
      description:
        "Specifies the text that is rendered as title in the adaptive popup.",
    },
    allowCustom: {
      control: { type: "boolean" },
      description:
        "Specifies whether the MultiColumnComboBox allows user-defined values that are not present in the dataset. Defaults to false.",
    },
    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 MultiColumnComboBox.",
    },
    clearButton: {
      control: { type: "boolean" },
      description:
        "If clearButton is set to true, the MultiColumnComboBox renders a button on hovering over the component.",
    },
    columns: {
      control: { type: "object" },
      description: "Determines the columns array of the MultiColumnComboBox.",
    },
    data: {
      control: { type: "object" },
      description: "Sets the data of the MultiColumnComboBox.",
    },
    dataItemKey: {
      control: { type: "text" },
      description:
        "Sets the key for comparing the data items of the MultiColumnComboBox.",
    },
    defaultValue: {
      control: { type: "text" },
      description:
        "Sets the default value of the MultiColumnComboBox. Similar to the native select HTML element.",
    },
    dir: {
      control: { type: "text" },
      description: "Represents the dir HTML attribute.",
    },
    disabled: {
      control: { type: "boolean" },
      description: "Sets the disabled state of the MultiColumnComboBox.",
    },
    fillMode: {
      control: { type: "select" },
      description: "Configures the fillMode of the MultiColumnComboBox.",
    },
    filter: {
      control: { type: "text" },
      description: "Sets the value of MultiColumnComboBox input.",
    },
    filterable: {
      control: { type: "boolean" },
      description:
        "Enables the filtering functionality of the MultiColumnComboBox.",
    },
    footer: {
      control: { type: "object" },
      description: "Sets the footer component of the MultiColumnComboBox.",
    },
    groupField: {
      control: { type: "text" },
      description:
        "Sets the data item field that represents the start of a group.",
    },
    groupMode: {
      control: { type: "text" },
      description:
        "Defines the classic or modern type of the grouping's visualization. Defaults to modern.",
    },
    header: {
      control: { type: "object" },
      description: "Sets the header component of the MultiColumnComboBox.",
    },
    iconClassName: {
      control: { type: "text" },
      description: "Sets CSS classes to the expand icon DOM element.",
    },
    id: {
      control: { type: "text" },
      description: "Specifies the id of the component.",
    },
    label: {
      control: { type: "text" },
      description: "Renders a floating label for the MultiColumnComboBox.",
    },
    loading: {
      control: { type: "boolean" },
      description: "Sets the loading state of the MultiColumnComboBox.",
    },
    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 MultiColumnComboBox.",
    },
    placeholder: {
      control: { type: "text" },
      description:
        "The hint that is displayed when the MultiColumnComboBox is empty.",
    },
    popupSettings: {
      control: { type: "object" },
      description: "Configures the popup of the MultiColumnComboBox.",
    },
    required: {
      control: { type: "boolean" },
      description: "Specifies if null is a valid value for the component.",
    },
    rounded: {
      control: { type: "select" },
      description: "Configures the roundness of the MultiColumnComboBox.",
    },
    size: {
      control: { type: "select" },
      description: "Configures the size of the MultiColumnComboBox.",
    },
    skipDisabledItems: {
      control: { type: "boolean" },
      description:
        "Defines if Combobox's disabled items will be skipped or focused when navigating through the list of items using a keyboard. Defaults to true.",
    },
    style: {
      control: { type: "object" },
      description: "The styles that are applied to the MultiColumnComboBox.",
    },
    suggest: {
      control: { type: "boolean" },
      description:
        "Enables the auto-completion of the text based on the first data item.",
    },
    svgIcon: {
      control: { type: "object" },
      description: "Sets the specified SVG icon.",
    },
    tabIndex: {
      control: { type: "number" },
      description: "Specifies the tabIndex of the MultiColumnComboBox.",
    },
    textField: {
      control: { type: "text" },
      description: "Sets the data item field that represents the item text.",
    },
    title: {
      control: { type: "text" },
      description:
        "Sets the title attribute to the underlying input element of the ComboBox.",
    },
    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 MultiColumnComboBox.",
    },
    virtual: {
      control: { type: "object" },
      description:
        "Configures the virtual scrolling of the MultiColumnComboBox.",
    },
    focusedItemIndex: {
      control: { type: "function" },
      description:
        "If set, the MultiColumnComboBox will use it to get the focused item index. Default functionality returns the first item which starts with the input text.",
    },
    groupHeaderItemRender: {
      control: { type: "function" },
      description:
        "Fires when a ComboBox group header item is about to be rendered. Used to override the default appearance of the group's headers when the component is configured in modern group mode.",
    },
    groupStickyHeaderItemRender: {
      control: { type: "function" },
      description:
        "Fires when a ComboBox sticky group header item is about to be rendered. Used to override the default appearance of the sticky group header of the component.",
    },
    itemRender: {
      control: { type: "function" },
      description:
        "Fires when a MultiColumnComboBox list item is about to be rendered. Used to override the default appearance of the list items.",
    },
    listNoDataRender: {
      control: { type: "function" },
      description:
        "Fires when the element which indicates no data in the popup is about to be rendered. Used to override the default appearance of the element.",
    },
    onBlur: {
      control: { type: "function" },
      description: "Fires each time the MultiColumnComboBox gets blurred.",
    },
    onChange: {
      control: { type: "function" },
      description:
        "Fires each time the value of the MultiColumnComboBox is about to change.",
    },
    onClose: {
      control: { type: "function" },
      description:
        "Fires each time the popup of the MultiColumnComboBox is about to close.",
    },
    onFilterChange: {
      control: { type: "function" },
      description:
        "Fires each time the user types in the filter input. You can filter the source based on the passed filtration value.",
    },
    onFocus: {
      control: { type: "function" },
      description: "Fires each time the user focuses the MultiColumnComboBox.",
    },
    onOpen: {
      control: { type: "function" },
      description:
        "Fires each time the popup of the MultiColumnComboBox is about to open.",
    },
    onPageChange: {
      control: { type: "function" },
      description:
        "Fires when both the virtual scrolling of the MultiColumnComboBox is enabled and the component requires data for another page.",
    },
    valueRender: {
      control: { type: "function" },
      description:
        "Fires when the ComboBox input element is about to be rendered. Use it to override the default appearance of the component.",
    },
  },
} as Meta;

export const Default = (args: MultiColumnComboBoxProps): JSX.Element => (
  <MultiColumnComboBox {...args} />
);

Default.args = {
  dataTestId: "mccb-data-testid",
  columns: columns,
  data: employees,
  textField: "name",
  fillMode: "solid",
  size: "large",
  rounded: "medium",
  placeholder: "Please select ...",
  style: { width: "300px" },
};
