diff --git a/src/components/ui/HeaderInputList.tsx b/src/components/ui/HeaderInputList.tsx deleted file mode 100644 index 6aea347..0000000 --- a/src/components/ui/HeaderInputList.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import { Fragment } from 'react'; -import { Button } from './Button'; -import { IconX } from './icons'; -import type { HeaderEntry } from '@/utils/headers'; - -interface HeaderInputListProps { - entries: HeaderEntry[]; - onChange: (entries: HeaderEntry[]) => void; - addLabel: string; - disabled?: boolean; - keyPlaceholder?: string; - valuePlaceholder?: string; - removeButtonTitle?: string; - removeButtonAriaLabel?: string; -} - -export function HeaderInputList({ - entries, - onChange, - addLabel, - disabled = false, - keyPlaceholder = 'X-Custom-Header', - valuePlaceholder = 'value', - removeButtonTitle = 'Remove', - removeButtonAriaLabel = 'Remove', -}: HeaderInputListProps) { - const currentEntries = entries.length ? entries : [{ key: '', value: '' }]; - - const updateEntry = (index: number, field: 'key' | 'value', value: string) => { - const next = currentEntries.map((entry, idx) => (idx === index ? { ...entry, [field]: value } : entry)); - onChange(next); - }; - - const addEntry = () => { - onChange([...currentEntries, { key: '', value: '' }]); - }; - - const removeEntry = (index: number) => { - const next = currentEntries.filter((_, idx) => idx !== index); - onChange(next.length ? next : [{ key: '', value: '' }]); - }; - - return ( -
- {currentEntries.map((entry, index) => ( - -
- updateEntry(index, 'key', e.target.value)} - disabled={disabled} - /> - : - updateEntry(index, 'value', e.target.value)} - disabled={disabled} - /> - -
-
- ))} - -
- ); -} diff --git a/src/components/ui/ModelInputList.tsx b/src/components/ui/ModelInputList.tsx deleted file mode 100644 index a2b0a2c..0000000 --- a/src/components/ui/ModelInputList.tsx +++ /dev/null @@ -1,103 +0,0 @@ -import { Fragment } from 'react'; -import { Button } from './Button'; -import { IconX } from './icons'; -import type { ModelEntry } from './modelInputListUtils'; - -interface ModelInputListProps { - entries: ModelEntry[]; - onChange: (entries: ModelEntry[]) => void; - addLabel?: string; - disabled?: boolean; - namePlaceholder?: string; - aliasPlaceholder?: string; - hideAddButton?: boolean; - onAdd?: () => void; - className?: string; - rowClassName?: string; - inputClassName?: string; - removeButtonClassName?: string; - removeButtonTitle?: string; - removeButtonAriaLabel?: string; -} - -export function ModelInputList({ - entries, - onChange, - addLabel, - disabled = false, - namePlaceholder = 'model-name', - aliasPlaceholder = 'alias (optional)', - hideAddButton = false, - onAdd, - className = '', - rowClassName = '', - inputClassName = '', - removeButtonClassName = '', - removeButtonTitle = 'Remove', - removeButtonAriaLabel = 'Remove', -}: ModelInputListProps) { - const currentEntries = entries.length ? entries : [{ name: '', alias: '' }]; - const containerClassName = ['header-input-list', className].filter(Boolean).join(' '); - const inputClassNames = ['input', inputClassName].filter(Boolean).join(' '); - const rowClassNames = ['header-input-row', rowClassName].filter(Boolean).join(' '); - - const updateEntry = (index: number, field: 'name' | 'alias', value: string) => { - const next = currentEntries.map((entry, idx) => (idx === index ? { ...entry, [field]: value } : entry)); - onChange(next); - }; - - const addEntry = () => { - if (onAdd) { - onAdd(); - } else { - onChange([...currentEntries, { name: '', alias: '' }]); - } - }; - - const removeEntry = (index: number) => { - const next = currentEntries.filter((_, idx) => idx !== index); - onChange(next.length ? next : [{ name: '', alias: '' }]); - }; - - return ( -
- {currentEntries.map((entry, index) => ( - -
- updateEntry(index, 'name', e.target.value)} - disabled={disabled} - /> - - updateEntry(index, 'alias', e.target.value)} - disabled={disabled} - /> - -
-
- ))} - {!hideAddButton && addLabel && ( - - )} -
- ); -} diff --git a/src/components/ui/modelInputListUtils.ts b/src/components/ui/modelInputListUtils.ts deleted file mode 100644 index d7f8453..0000000 --- a/src/components/ui/modelInputListUtils.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { ModelAlias } from '@/types'; - -export interface ModelEntry { - name: string; - alias: string; -} - -export const modelsToEntries = (models?: ModelAlias[]): ModelEntry[] => { - if (!Array.isArray(models) || models.length === 0) { - return [{ name: '', alias: '' }]; - } - return models.map((model) => ({ - name: model.name || '', - alias: model.alias || '' - })); -}; - -export const entriesToModels = (entries: ModelEntry[]): ModelAlias[] => { - return entries - .filter((entry) => entry.name.trim()) - .map((entry) => { - const model: ModelAlias = { name: entry.name.trim() }; - const alias = entry.alias.trim(); - if (alias && alias !== model.name) { - model.alias = alias; - } - return model; - }); -};