Publish the current application, design, and Phase 1 deployment updates. Excludes ignored personal notes, local MCP config, and generated TypeScript build info.
137 lines
4.5 KiB
TypeScript
137 lines
4.5 KiB
TypeScript
import { cn } from '@/lib/utils';
|
|
import React from 'react';
|
|
import { Icon } from './Icon';
|
|
|
|
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
label?: string;
|
|
error?: string;
|
|
icon?: string;
|
|
compact?: boolean;
|
|
}
|
|
|
|
export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
({ label, error, icon, compact = false, className, id, ...props }, ref) => {
|
|
const inputId = id || (label ? label.toLowerCase().replace(/\s+/g, '-') : undefined);
|
|
|
|
return (
|
|
<div className="flex flex-col gap-1 w-full text-left">
|
|
{label && (
|
|
<label
|
|
htmlFor={inputId}
|
|
className="text-[12px] font-medium text-[var(--text-muted)]"
|
|
>
|
|
{label}
|
|
</label>
|
|
)}
|
|
<div className="relative flex items-center w-full">
|
|
{icon && (
|
|
<div className="absolute left-2.5 flex items-center pointer-events-none text-[var(--text-dim)]">
|
|
<Icon name={icon} size={13} />
|
|
</div>
|
|
)}
|
|
<input
|
|
id={inputId}
|
|
ref={ref}
|
|
className={cn(
|
|
'w-full bg-[var(--bg-main)] text-[var(--text)] border border-[var(--border-strong)] placeholder:text-[var(--text-dim)] transition-colors focus:outline-none focus:border-[var(--accent)] disabled:opacity-50 disabled:cursor-not-allowed',
|
|
compact ? 'h-9 px-3 text-[13px]' : 'h-10 px-3.5 text-[14px]',
|
|
icon && 'pl-8',
|
|
error && 'border-[var(--danger)]',
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
</div>
|
|
{error && <span className="text-[12px] text-[var(--danger)]">{error}</span>}
|
|
</div>
|
|
);
|
|
}
|
|
);
|
|
|
|
Input.displayName = 'Input';
|
|
|
|
export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
label?: string;
|
|
error?: string;
|
|
}
|
|
|
|
export const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
({ label, error, className, id, ...props }, ref) => {
|
|
const textareaId = id || (label ? label.toLowerCase().replace(/\s+/g, '-') : undefined);
|
|
|
|
return (
|
|
<div className="flex flex-col gap-1 w-full text-left">
|
|
{label && (
|
|
<label
|
|
htmlFor={textareaId}
|
|
className="text-[12px] font-medium text-[var(--text-muted)]"
|
|
>
|
|
{label}
|
|
</label>
|
|
)}
|
|
<textarea
|
|
id={textareaId}
|
|
ref={ref}
|
|
className={cn(
|
|
'w-full bg-[var(--bg-main)] text-[var(--text)] border border-[var(--border-strong)] p-3.5 text-[14px] placeholder:text-[var(--text-dim)] focus:outline-none focus:border-[var(--accent)] min-h-[96px] resize-y font-mono',
|
|
error && 'border-[var(--danger)]',
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
{error && <span className="text-[12px] text-[var(--danger)]">{error}</span>}
|
|
</div>
|
|
);
|
|
}
|
|
);
|
|
|
|
Textarea.displayName = 'Textarea';
|
|
|
|
export interface SelectProps extends React.SelectHTMLAttributes<HTMLSelectElement> {
|
|
label?: string;
|
|
error?: string;
|
|
compact?: boolean;
|
|
options?: { value: string; label: string }[];
|
|
}
|
|
|
|
export const Select = React.forwardRef<HTMLSelectElement, SelectProps>(
|
|
({ label, error, compact = false, options, children, className, id, ...props }, ref) => {
|
|
const selectId = id || (label ? label.toLowerCase().replace(/\s+/g, '-') : undefined);
|
|
|
|
return (
|
|
<div className="flex flex-col gap-1 w-full text-left">
|
|
{label && (
|
|
<label
|
|
htmlFor={selectId}
|
|
className="text-[12px] font-medium text-[var(--text-muted)]"
|
|
>
|
|
{label}
|
|
</label>
|
|
)}
|
|
<select
|
|
id={selectId}
|
|
ref={ref}
|
|
className={cn(
|
|
'w-full bg-[var(--bg-main)] text-[var(--text)] border border-[var(--border-strong)] focus:outline-none focus:border-[var(--accent)] cursor-pointer',
|
|
compact ? 'h-9 px-2.5 text-[13px]' : 'h-10 px-3 text-[14px]',
|
|
error && 'border-[var(--danger)]',
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
{options
|
|
? options.map((opt) => (
|
|
<option key={opt.value} value={opt.value} className="bg-[var(--bg-elevated)] text-[var(--text)]">
|
|
{opt.label}
|
|
</option>
|
|
))
|
|
: children}
|
|
</select>
|
|
{error && <span className="text-[12px] text-[var(--danger)]">{error}</span>}
|
|
</div>
|
|
);
|
|
}
|
|
);
|
|
|
|
Select.displayName = 'Select';
|