|
3 | 3 | import { memo, useEffect, useRef, useState } from 'react' |
4 | 4 | import { zodResolver } from '@hookform/resolvers/zod' |
5 | 5 | import { createLogger } from '@sim/logger' |
6 | | -import { ChevronDown, Loader2, RotateCcw, X } from 'lucide-react' |
| 6 | +import { Loader2, RotateCcw, X } from 'lucide-react' |
7 | 7 | import { useParams } from 'next/navigation' |
8 | 8 | import { useForm } from 'react-hook-form' |
9 | 9 | import { z } from 'zod' |
10 | 10 | import { |
11 | 11 | Button, |
12 | | - DropdownMenu, |
13 | | - DropdownMenuContent, |
14 | | - DropdownMenuRadioGroup, |
15 | | - DropdownMenuRadioItem, |
16 | | - DropdownMenuTrigger, |
| 12 | + Combobox, |
| 13 | + type ComboboxOption, |
17 | 14 | Input, |
18 | 15 | Label, |
19 | 16 | Modal, |
@@ -50,6 +47,11 @@ const STRATEGY_OPTIONS = [ |
50 | 47 | { value: 'regex', label: 'Regex (custom pattern)' }, |
51 | 48 | ] as const |
52 | 49 |
|
| 50 | +const STRATEGY_COMBOBOX_OPTIONS: ComboboxOption[] = STRATEGY_OPTIONS.map((o) => ({ |
| 51 | + label: o.label, |
| 52 | + value: o.value, |
| 53 | +})) |
| 54 | + |
53 | 55 | const FormSchema = z |
54 | 56 | .object({ |
55 | 57 | name: z |
@@ -467,36 +469,13 @@ export const CreateBaseModal = memo(function CreateBaseModal({ |
467 | 469 |
|
468 | 470 | <div className='flex flex-col gap-2'> |
469 | 471 | <Label>Chunking Strategy</Label> |
470 | | - <DropdownMenu> |
471 | | - <DropdownMenuTrigger asChild> |
472 | | - <Button |
473 | | - type='button' |
474 | | - variant='default' |
475 | | - className='!bg-[var(--surface-1)] w-full justify-between border border-[var(--border-1)] font-normal' |
476 | | - > |
477 | | - {STRATEGY_OPTIONS.find((o) => o.value === strategyValue)?.label ?? |
478 | | - 'Auto (detect from content)'} |
479 | | - <ChevronDown className='h-[12px] w-[12px] text-[var(--text-icon)]' /> |
480 | | - </Button> |
481 | | - </DropdownMenuTrigger> |
482 | | - <DropdownMenuContent |
483 | | - align='start' |
484 | | - className='w-[var(--radix-dropdown-menu-trigger-width)]' |
485 | | - > |
486 | | - <DropdownMenuRadioGroup |
487 | | - value={strategyValue} |
488 | | - onValueChange={(value) => |
489 | | - setValue('strategy', value as FormValues['strategy']) |
490 | | - } |
491 | | - > |
492 | | - {STRATEGY_OPTIONS.map((option) => ( |
493 | | - <DropdownMenuRadioItem key={option.value} value={option.value}> |
494 | | - {option.label} |
495 | | - </DropdownMenuRadioItem> |
496 | | - ))} |
497 | | - </DropdownMenuRadioGroup> |
498 | | - </DropdownMenuContent> |
499 | | - </DropdownMenu> |
| 472 | + <Combobox |
| 473 | + options={STRATEGY_COMBOBOX_OPTIONS} |
| 474 | + value={strategyValue} |
| 475 | + onChange={(value) => setValue('strategy', value as FormValues['strategy'])} |
| 476 | + dropdownWidth='trigger' |
| 477 | + align='start' |
| 478 | + /> |
500 | 479 | <p className='text-[var(--text-muted)] text-xs'> |
501 | 480 | Auto detects the best strategy based on file content type. |
502 | 481 | </p> |
|
0 commit comments