import React from 'react';
import {
  Title,
  Description,
  Primary,
  PRIMARY_STORY,
  ArgsTable,
} from '@storybook/addon-docs/blocks';

import CustomSelect from '.';

export default {
  title: 'Theme/Atoms/Custom Select',
  component: CustomSelect,
  argTypes: {
    items: {
      name: 'items',
      type: { name: 'array', required: true },
      defaultValue: '',
      description: 'The options array.',
      table: {
        type: { summary: 'array' },
        defaultValue: { summary: '' },
      },
    },
    itemsValue: {
      name: 'itemsValue',
      type: { name: 'string', required: false },
      defaultValue: 'field',
      description: 'The options object value key name.',
      table: {
        type: { summary: 'string' },
        defaultValue: { summary: 'field' },
      },
    },
    itemsLabel: {
      name: 'itemsLabel',
      type: { name: 'string', required: false },
      defaultValue: 'name',
      description: 'The options object label key name.',
      table: {
        type: { summary: 'string' },
        defaultValue: { summary: 'name' },
      },
    },
    activeItem: {
      name: 'activeItem',
      type: { name: 'object', required: false },
      defaultValue: '',
      description: 'The initial active item.',
      table: {
        type: { summary: 'object' },
        defaultValue: { summary: '' },
      },
    },
    onClick: {
      name: 'onClick',
      type: { name: 'function', required: false },
      defaultValue: '',
      description: 'The options click handler.',
      table: {
        type: { summary: 'function' },
        defaultValue: { summary: '' },
      },
    },
  },
  parameters: {
    docs: {
      description: {
        component: 'Generates a custom dropdown select box.',
      },
      page: () => (
        <>
          <Title />
          <Description />
          <Primary />
          <ArgsTable story={PRIMARY_STORY} />
        </>
      ),
    },
  },
};

const Template = (args) => <CustomSelect {...args} />;

export const Default = Template.bind({});
Default.args = {
  items: [
    { key: 'All', value: '0' },
    { key: 'option one', value: '1' },
    { key: 'option two', value: '2' },
    { key: 'option three', value: '3' },
  ],
  itemsValue: 'value',
  itemsLabel: 'key',
  activeItem: { key: 'All', value: '0' },
  onClick: () => {},
};
