{
  "name": "tsf-select-field",
  "type": "registry:ui",
  "registryDependencies": [
    "field",
    "select",
    "tsf-form-context"
  ],
  "files": [
    {
      "path": "./items/tanstack-form/select-field/component.tsx",
      "type": "registry:ui",
      "target": "./components/ui/shuip/tanstack-form/select-field.tsx",
      "content": "'use client';\n\nimport { Field, FieldDescription, FieldError, FieldLabel } from '@/components/ui/field';\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';\nimport { useFieldContext } from '@/components/ui/shuip/tanstack-form/form-context';\n\nexport type SelectFieldOption = Record<string, string>;\n\nexport interface SelectFieldProps {\n  options: SelectFieldOption;\n  label?: string;\n  placeholder?: string;\n  description?: string;\n  fieldProps?: React.ComponentProps<typeof Field>;\n  props?: React.ComponentProps<typeof Select>;\n}\n\nexport function SelectField({ options, label, description, placeholder, fieldProps, props }: SelectFieldProps) {\n  const field = useFieldContext<string>();\n  const { isValid, errors } = field.state.meta;\n\n  return (\n    <Field className='gap-2' data-invalid={!isValid} {...fieldProps}>\n      {label && <FieldLabel>{label}</FieldLabel>}\n      <Select\n        name={field.name}\n        value={field.state.value}\n        onValueChange={(value) => field.handleChange(value)}\n        {...props}\n      >\n        <SelectTrigger aria-invalid={!isValid}>\n          <SelectValue placeholder={placeholder} />\n        </SelectTrigger>\n        <SelectContent>\n          {Object.entries(options).map(([optionLabel, value]) => (\n            <SelectItem key={value} value={value}>\n              {optionLabel}\n            </SelectItem>\n          ))}\n        </SelectContent>\n      </Select>\n      {!isValid && (\n        <FieldError\n          className='text-xs text-left'\n          errors={errors.map((error) => ({ message: typeof error === 'string' ? error : error?.message }))}\n        />\n      )}\n      {description && <FieldDescription className='text-xs'>{description}</FieldDescription>}\n    </Field>\n  );\n}\n"
    }
  ],
  "$schema": "https://ui.shadcn.com/schema/registry-item.json"
}
