Files
SRCmail/components/templates/placeholder-fill-modal.tsx
T
Linus Rath cf02f587de feat: resizable columns, nav rail overhaul, multi-select & drag-drop, UI polish
Resizable Columns
- Add ResizeHandle component with mouse drag, keyboard (Arrow keys),
  and double-click to reset to default width
- Add sidebarWidth/emailListWidth to ui-store with clamping + persistence
- Wire resize handles between sidebar/email-list panels on desktop

Navigation Rail Overhaul
- Move StorageQuotaCircle, push-status, sign-out from Sidebar to NavigationRail
- Interactive SVG ring with popover breakdown (used/free/total)
- Sidebar collapse state lifted to ui-store
- Show total email count per mailbox alongside unread badge

Email Multi-Selection & Drag-and-Drop
- Ctrl+Click (toggle) and Shift+Click (range) on all list items
- Add selectRangeEmails and lastSelectedEmailId to email-store
- Enable drag-and-drop on thread items and thread headers
- useEmailDrag accepts optional threadEmails for full-thread drag

Email Viewer Layout
- Remove card wrapper for cleaner full-width reading
- Always render HTML body when available
- Adjust skeleton loader to match flat layout

Modal & UI Polish
- Standardise backdrops, close buttons, padding, border-radius, transitions
- Migrate template-string classNames to cn() in settings
- Unify focus-ring token to ring-ring on form controls

i18n
- Add storage_used/free/total keys to all 8 locales

Dev Mock JMAP Server (new, gated by DEV_MOCK_JMAP=true)
- Session, Mailbox/Email/Thread/Identity CRUD, back-references, upload
- GET /download with Content-Disposition, GET /eventsource SSE

Tests (46 new)
- ui-store (13), email-selection (10), resize-handle (9), mock-server (14)
2026-03-09 16:46:25 +01:00

115 lines
3.8 KiB
TypeScript

'use client';
import { useState, useMemo } from 'react';
import { useTranslations } from 'next-intl';
import { X } from 'lucide-react';
import { cn } from '@/lib/utils';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { substitutePlaceholders, isBuiltInPlaceholder } from '@/lib/template-utils';
import { useFocusTrap } from '@/hooks/use-focus-trap';
import type { EmailTemplate } from '@/lib/template-types';
interface PlaceholderFillModalProps {
template: EmailTemplate;
placeholders: string[];
autoFilled: Record<string, string>;
onConfirm: (values: Record<string, string>) => void;
onSkip: () => void;
onClose: () => void;
}
export function PlaceholderFillModal({
template,
placeholders,
autoFilled,
onConfirm,
onSkip,
onClose,
}: PlaceholderFillModalProps) {
const t = useTranslations('templates');
const [values, setValues] = useState<Record<string, string>>(() => {
const initial: Record<string, string> = {};
for (const p of placeholders) {
initial[p] = autoFilled[p] || '';
}
return initial;
});
const modalRef = useFocusTrap({
isActive: true,
onEscape: onClose,
restoreFocus: true,
});
const preview = useMemo(() => {
return substitutePlaceholders(template.body, values);
}, [template.body, values]);
return (
<div className="fixed inset-0 bg-black/50 backdrop-blur-[1px] flex items-center justify-center z-[60] p-4 animate-in fade-in duration-150">
<div
ref={modalRef}
role="dialog"
aria-modal="true"
aria-labelledby="placeholder-fill-title"
className={cn(
'bg-background border border-border rounded-lg shadow-xl',
'w-full max-w-lg max-h-[85vh] overflow-hidden',
'animate-in zoom-in-95 duration-200'
)}
>
<div className="flex items-center justify-between px-6 py-4 border-b border-border">
<h2 id="placeholder-fill-title" className="text-lg font-semibold text-foreground">
{t('fill_placeholders')}
</h2>
<button
onClick={onClose}
className="p-1.5 rounded-md hover:bg-muted transition-colors duration-150 text-muted-foreground hover:text-foreground"
>
<X className="w-5 h-5" />
</button>
</div>
<div className="p-6 overflow-y-auto max-h-[calc(85vh-160px)] space-y-4">
{placeholders.map((p) => (
<div key={p}>
<label className="text-sm font-medium text-foreground flex items-center gap-2">
<span className="font-mono text-xs text-primary">{`{{${p}}}`}</span>
{isBuiltInPlaceholder(p) && (
<span className="text-xs text-muted-foreground">{t(`placeholders.${p}`)}</span>
)}
</label>
<Input
value={values[p]}
onChange={(e) => setValues((prev) => ({ ...prev, [p]: e.target.value }))}
placeholder={t('enter_value')}
className="mt-1"
/>
</div>
))}
{preview && (
<div className="mt-4 pt-4 border-t border-border">
<p className="text-xs font-medium text-muted-foreground mb-2">{t('preview')}</p>
<div className="text-sm text-foreground whitespace-pre-wrap p-3 rounded-md bg-muted/50 border border-border max-h-32 overflow-y-auto">
{preview}
</div>
</div>
)}
</div>
<div className="flex items-center justify-end gap-2 px-6 py-4 border-t border-border">
<Button variant="ghost" size="sm" onClick={onSkip}>
{t('insert_raw')}
</Button>
<Button size="sm" onClick={() => onConfirm(values)}>
{t('insert_with_values')}
</Button>
</div>
</div>
</div>
);
}