import { Meta, Preview, Props, Story } from "@storybook/addon-docs/blocks";
import { boolean, select, text, array, withKnobs } from "@storybook/addon-knobs";
import RadioButtons from "../../RadioButtons";

<Meta title="Forms/Radio Buttons" component={RadioButtons} decorators={[withKnobs]} />

<Story name="Demo" parameters={{
  docs: {
    disable: true
    },
    options: {
      showPanel: true
    }
  }
}>
  {{
    components: {
      'h-radio-buttons': RadioButtons
    },
    template: `
      <div>
          <h-radio-buttons
            v-model="value"
            :buttons="options"
            :has-background="hasBackground"
            :isListView="isListView"
          />
        <p>value = {{ value }}</p>
      </div>
    `,
    data() {
      return {
        value: "dog",
        options: [
          {
            value: "dog",
            label: "Dog",
          },
          {
            value: "cat",
            label: {
              title: "Mr",
              description: "Cat",
            },
          },
          {
            value: "horse",
            label: "Horse",
          },
          {
            value: "dinosaur",
            label: "Dinosaur",
            disabled: true,
          },
        ],
      }
    },
    props: {
      hasBackground: {
        default: boolean("hasBackground", false),
      },
      isListView: {
        default: boolean("isListView", false),
      },
    },
  }}
</Story>

<Preview>
  <Story name="Source" parameters={{
    options: {
      showPanel: true
    }
  }}>
    {{
      components: {
        'h-radio-buttons': RadioButtons,
      },
      template: `
        <div>
          <h-radio-buttons
            v-model="value"
            :buttons="options"
            :has-background="hasBackground"
            :isListView="isListView"
          />
          <p>value = {{ value }}</p>
        </div>
      `,
      data() {
        return {
          value: "dog",
          options: [
            {
              value: "dog",
              label: "Dog",
            },
            {
              value: "cat",
              label: {
                title: "Mr",
                description: "Cat",
              },
            },
            {
              value: "horse",
              label: "Horse",
            },
            {
              value: "dinosaur",
              label: "Dinosaur",
              disabled: true,
            },
          ],
        }
      },
      props: {
        hasBackground: {
          default: boolean("hasBackground", false),
        },
        isListView: {
          default: boolean("isListView", false),
        }
      }
    }}
  </Story>
</Preview>

<Preview>
  <Story name="Grouped options" parameters={{
    options: {
      showPanel: true
    }
  }}>
    {{
      components: {
        'h-radio-buttons': RadioButtons,
      },
      template: `
        <div>
          <h-radio-buttons
            v-model="value"
            :buttons="options"
            :has-background="hasBackground"
            :isListView="isListView"
          />
          <p>value = {{ value }}</p>
        </div>
      `,
      data() {
        return {
          value: "dog",
          options: {
            value1: {
              label: 'Value 1'
            },
            value2: {
              label: 'Value 2',
              disabled: true
            },
            value3: {
              label: 'Value 3'
            },
            Tags: [
              {
                value: 'tag1',
                label: 'Tag 1'
              },
              {
                value: 'tag2',
                label: 'Tag 2',
                disabled: true
              },
              {
                value: 'tag3',
                label: 'Tag 3'
              },
            ],
            Categories: [
              {
                value: 'category1',
                label: 'Category 1'
              },
              {
                value: 'category2',
                label: 'Category 2',
                disabled: true
              },
              {
                value: 'category3',
                label: 'Category 3'
              },
            ]
          }
        }
      },
      props: {
        hasBackground: {
          default: boolean("hasBackground", false),
        },
        isListView: {
          default: boolean("isListView", false),
        }
      }
    }}
  </Story>
</Preview>

<Props of={RadioButtons} />
