import { SwitchInput } from '@based/ui'
import { useState } from 'react'

export const meta: Based.UI.Extractor.MetaDescriptor = {
  name: 'Switch Input',
  group: 'Inputs',
  section: 'components',
  icon: 'edit',
  component: SwitchInput,
  subtitle:
    'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
  showApi: true,
  showUsage: true,
}

export const blocks: Based.UI.Extractor.BlocksDescriptor[] = [
  {
    name: 'Default',
    type: 'component',
    description: 'Default SwitchInput.',
    style: {
      size: 'small',
      frame: false,
      flex: {
        justifyContent: 'center',
        alignItems: 'center',
      },
    },
    render: () => {
      const [value, setValue] = useState(false)
      return <SwitchInput value={value} onChange={setValue} />
    },
  },
  {
    name: 'Disabled',
    type: 'component',
    description: 'Disabled SwitchInput.',
    style: {
      size: 'small',
      frame: false,
      flex: {
        justifyContent: 'center',
        alignItems: 'center',
      },
    },
    render: () => {
      const [value, setValue] = useState(true)
      return <SwitchInput value={value} onChange={setValue} disabled />
    },
  },
  {
    name: 'WithLabel',
    type: 'component',
    description: 'SwitchInput with dynamic label.',
    style: {
      size: 'small',
      frame: false,
      flex: {
        justifyContent: 'center',
        alignItems: 'center',
      },
    },
    render: () => {
      const [value, setValue] = useState(true)
      return (
        <SwitchInput
          value={value}
          onChange={setValue}
          label={value ? 'Enabled' : 'Disabled'}
        />
      )
    },
  },
]
