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

export const meta: Based.UI.Extractor.MetaDescriptor = {
  name: 'References Input',
  group: 'Inputs',
  section: 'components',
  icon: 'edit',
  component: ReferencesInput,
  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 ReferencesInput for selecting users.',
    style: {
      size: 'small',
      frame: false,
      flex: {
        justifyContent: 'center',
        alignItems: 'center',
      },
    },
    render: () => {
      const [value, setValue] = useState<string[]>([])
      return (
        <div style={{ width: 360 }}>
          <ReferencesInput value={value} onChange={setValue} type="user" />
        </div>
      )
    },
  },
  {
    name: 'SpecialCaseFile',
    type: 'component',
    description: 'Special case ReferencesInput for selecting files.',
    style: {
      size: 'small',
      frame: false,
      flex: {
        justifyContent: 'center',
        alignItems: 'center',
      },
    },
    render: () => {
      const [value, setValue] = useState<string[]>([])
      return (
        <div style={{ width: 360 }}>
          <ReferencesInput value={value} onChange={setValue} type="file" />
        </div>
      )
    },
  },
]
