// Command Palette — Cmd+K const CPIcons = window.Icons; const VIEWS = [ { id: 'dashboard', label: 'Panel', icon: 'Dashboard' }, { id: 'all-tasks', label: 'Tüm Görevler', icon: 'CheckSquare' }, { id: 'table', label: 'Tablo Görünümü', icon: 'Table' }, { id: 'calendar', label: 'Takvim', icon: 'Calendar' }, { id: 'gantt', label: 'Gantt', icon: 'GanttChart' }, { id: 'content', label: 'İçerik Takvimi', icon: 'Instagram' }, { id: 'reports', label: 'Raporlar', icon: 'TrendingUp' }, { id: 'team', label: 'Ekip', icon: 'Users' }, { id: 'profile', label: 'Profil', icon: 'User' }, ]; function CommandPalette({ state, onClose, onNavigate, onSelectTask, onCreateTask, onSetTheme }) { const [query, setQuery] = React.useState(''); const [sel, setSel] = React.useState(0); const inputRef = React.useRef(null); React.useEffect(() => { setTimeout(() => inputRef.current?.focus(), 10); }, []); const results = React.useMemo(() => { const q = query.trim().toLowerCase(); const items = []; if (!q) { // Quick actions items.push({ type: 'action', label: 'Yeni Görev', icon: 'Plus', hint: 'N', run: () => onCreateTask() }); VIEWS.forEach(v => items.push({ type: 'view', label: v.label, icon: v.icon, run: () => onNavigate(v.id) })); items.push({ type: 'action', label: 'Temayı Değiştir', icon: 'Sun', run: () => { const n={auto:'light',light:'dark',dark:'auto'}; onSetTheme(n[state.theme]||'light'); } }); state.projects.filter(p => !p.archived).slice(0, 5).forEach(p => { items.push({ type: 'project', label: p.name, color: p.color, run: () => onNavigate('kanban', p.id) }); }); return items; } // Search tasks — tüm firmalar genelinde: başlık, açıklama ve etiketlerde ara const tagById = Object.fromEntries((state.tags || []).map(t => [t.id, t])); state.tasks .filter(t => !t.archived && ( t.title.toLowerCase().includes(q) || (t.description || '').toLowerCase().includes(q) || (t.tags || []).some(tid => (tagById[tid]?.name || '').toLowerCase().includes(q)) )) .slice(0, 10) .forEach(t => { const proj = state.projects.find(p => p.id === t.projectId); items.push({ type: 'task', label: t.title, meta: proj?.name, color: proj?.color, id: t.id, run: () => onSelectTask(t.id) }); }); // Search projects state.projects.filter(p => p.name.toLowerCase().includes(q)).forEach(p => { items.push({ type: 'project', label: p.name, color: p.color, run: () => onNavigate('kanban', p.id) }); }); // Search views VIEWS.filter(v => v.label.toLowerCase().includes(q)).forEach(v => { items.push({ type: 'view', label: v.label, icon: v.icon, run: () => onNavigate(v.id) }); }); return items; }, [query, state]); React.useEffect(() => { setSel(0); }, [query]); React.useEffect(() => { const onKey = (e) => { if (e.key === 'Escape') { onClose(); return; } if (e.key === 'ArrowDown') { setSel(s => Math.min(s + 1, results.length - 1)); e.preventDefault(); } if (e.key === 'ArrowUp') { setSel(s => Math.max(s - 1, 0)); e.preventDefault(); } if (e.key === 'Enter' && results[sel]) { results[sel].run(); onClose(); } }; window.addEventListener('keydown', onKey); return () => window.removeEventListener('keydown', onKey); }, [results, sel, onClose]); const typeLabel = { task: 'Görev', project: 'Proje', view: 'Sayfa', action: 'Aksiyon' }; return (
e.stopPropagation()}>
setQuery(e.target.value)} placeholder="Görev ara, sayfa geç, aksiyon çalıştır..." /> {query ? ( ) : ( Esc )}
{!query && (
Hızlı Erişim
)} {results.length === 0 && (
"{query}" için sonuç bulunamadı
)} {results.map((r, i) => { const Icon = r.icon ? CPIcons[r.icon] : null; return ( ); })}
↑↓ Gezin Enter Seç Esc Kapat
); } function ShortcutsOverlay({ onClose }) { React.useEffect(() => { const fn = (e) => { if (e.key === 'Escape') onClose(); }; window.addEventListener('keydown', fn); return () => window.removeEventListener('keydown', fn); }, [onClose]); const shortcuts = [ { keys: ['⌘', 'K'], label: 'Komut paleti' }, { keys: ['N'], label: 'Yeni görev' }, { keys: ['/'], label: 'Arama odağı' }, { keys: ['?'], label: 'Kısayolları göster' }, { keys: ['⌘', 'Z'], label: 'Son işlemi geri al' }, { keys: ['Esc'], label: 'Kapat / Geri' }, { keys: ['←', '→'], label: 'Görevler arası gezin' }, ]; return (
e.stopPropagation()}>

Klavye Kısayolları

{shortcuts.map((s, i) => (
{s.label}
{s.keys.map((k, j) => {k})}
))}
); } window.CommandPalette = CommandPalette; window.ShortcutsOverlay = ShortcutsOverlay;