@umituz/web-virtual 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,157 @@
1
+ import { type ReactNode, useState } from 'react'
2
+ import { Send, Sparkles, Bot, Loader2, ChevronDown } from 'lucide-react'
3
+ import type { WorldEntity } from '../core/types'
4
+
5
+ export interface PresetMission {
6
+ label: string
7
+ prompt: string
8
+ }
9
+
10
+ export interface VirtualCommandBarProps {
11
+ presetMissions?: PresetMission[]
12
+ entities?: WorldEntity[]
13
+ targetEntityId: string
14
+ onChangeTarget: (id: string) => void
15
+ prompt: string
16
+ onChangePrompt: (prompt: string) => void
17
+ onDispatch: () => void
18
+ isDemoMode?: boolean
19
+ onToggleDemoMode?: () => void
20
+ isLaunching?: boolean
21
+ defaultOpen?: boolean
22
+ placeholder?: string
23
+ className?: string
24
+ }
25
+
26
+ export function VirtualCommandBar({
27
+ presetMissions = [],
28
+ entities = [],
29
+ targetEntityId,
30
+ onChangeTarget,
31
+ prompt,
32
+ onChangePrompt,
33
+ onDispatch,
34
+ isDemoMode = true,
35
+ onToggleDemoMode,
36
+ isLaunching = false,
37
+ defaultOpen = true,
38
+ placeholder = "Genel Müdür'e veya bir uzmana görev verin... (Enter ile gönder)",
39
+ className = '',
40
+ }: VirtualCommandBarProps): ReactNode {
41
+ const [isOpen, setIsOpen] = useState(defaultOpen)
42
+
43
+ if (!isOpen) {
44
+ return (
45
+ <button
46
+ type="button"
47
+ onClick={() => setIsOpen(true)}
48
+ className="wv-command-collapsed-btn"
49
+ aria-label="Komut Barını Aç"
50
+ >
51
+ <Send size={14} color="#3b82f6" />
52
+ <span>Komut ve Görev Barını Aç ▲</span>
53
+ </button>
54
+ )
55
+ }
56
+
57
+ return (
58
+ <div className={`wv-command-bar-wrapper ${className}`}>
59
+ {/* Preset Missions Carousel / Chips */}
60
+ {presetMissions.length > 0 && (
61
+ <div className="wv-command-presets-row">
62
+ <div className="wv-command-presets-scroll">
63
+ {presetMissions.map((pm, idx) => (
64
+ <button
65
+ key={idx}
66
+ type="button"
67
+ onClick={() => onChangePrompt(pm.prompt)}
68
+ className="wv-preset-chip"
69
+ >
70
+ {pm.label}
71
+ </button>
72
+ ))}
73
+ </div>
74
+
75
+ <button
76
+ type="button"
77
+ onClick={() => setIsOpen(false)}
78
+ className="wv-collapse-btn"
79
+ title="Komut Barını Küçült"
80
+ >
81
+ Gizle ▼
82
+ </button>
83
+ </div>
84
+ )}
85
+
86
+ {/* Main Command Input Box */}
87
+ <div className="wv-command-box">
88
+ {/* Target Entity Selector */}
89
+ <div className="wv-target-selector-wrapper">
90
+ <select
91
+ value={targetEntityId}
92
+ onChange={(e) => onChangeTarget(e.target.value)}
93
+ className="wv-target-select"
94
+ >
95
+ <option value="auto">👑 Genel Müdür (Otomatik Delege)</option>
96
+ {entities.length > 0 && (
97
+ <optgroup label="Ofis Masaları / Çalışanlar">
98
+ {entities.map((en) => (
99
+ <option key={en.id} value={en.id}>
100
+ {en.pinNumber ? `#${en.pinNumber} ` : ''}
101
+ {en.name} {en.role ? `(${en.role})` : ''}
102
+ </option>
103
+ ))}
104
+ </optgroup>
105
+ )}
106
+ </select>
107
+ <ChevronDown size={14} className="wv-select-chevron" />
108
+ </div>
109
+
110
+ {/* Prompt Input */}
111
+ <input
112
+ type="text"
113
+ value={prompt}
114
+ onChange={(e) => onChangePrompt(e.target.value)}
115
+ onKeyDown={(e) => {
116
+ if (e.key === 'Enter' && !e.shiftKey) {
117
+ e.preventDefault()
118
+ onDispatch()
119
+ }
120
+ }}
121
+ placeholder={placeholder}
122
+ className="wv-prompt-input"
123
+ />
124
+
125
+ {/* Fast Demo / Real AI Toggle */}
126
+ {onToggleDemoMode && (
127
+ <button
128
+ type="button"
129
+ onClick={onToggleDemoMode}
130
+ className={`wv-demo-toggle-btn ${isDemoMode ? 'is-demo' : 'is-ai'}`}
131
+ title="Çalışma Modu"
132
+ >
133
+ {isDemoMode ? <Sparkles size={14} /> : <Bot size={14} />}
134
+ <span className="wv-demo-label">{isDemoMode ? 'Demo Hızlı' : 'Gerçek AI'}</span>
135
+ </button>
136
+ )}
137
+
138
+ {/* Submit / Dispatch Button */}
139
+ <button
140
+ type="button"
141
+ onClick={onDispatch}
142
+ disabled={isLaunching || !prompt.trim()}
143
+ className="wv-dispatch-btn"
144
+ >
145
+ {isLaunching ? (
146
+ <Loader2 size={16} className="wv-spin" />
147
+ ) : (
148
+ <>
149
+ <Send size={14} style={{ marginRight: 6 }} />
150
+ <span>Ateşle</span>
151
+ </>
152
+ )}
153
+ </button>
154
+ </div>
155
+ </div>
156
+ )
157
+ }
@@ -0,0 +1,195 @@
1
+ import { type ReactNode, useEffect } from 'react'
2
+ import { X, Clock, FileText, Send, Zap } from 'lucide-react'
3
+ import type { WorldEntity } from '../core/types'
4
+
5
+ export interface EntityRunMetrics {
6
+ totalRuns: number
7
+ successRate?: number
8
+ costUsd?: number
9
+ }
10
+
11
+ export interface EntityLatestTask {
12
+ prompt: string
13
+ summary?: string | null
14
+ createdAt?: string
15
+ status?: string
16
+ }
17
+
18
+ export interface VirtualEntityDrawerProps {
19
+ entity: WorldEntity | null
20
+ onClose: () => void
21
+ metrics?: EntityRunMetrics
22
+ latestTask?: EntityLatestTask | null
23
+ onViewReport?: () => void
24
+ dispatchPrompt?: string
25
+ onChangeDispatchPrompt?: (val: string) => void
26
+ onDispatch?: () => void
27
+ isDispatching?: boolean
28
+ className?: string
29
+ }
30
+
31
+ export function VirtualEntityDrawer({
32
+ entity,
33
+ onClose,
34
+ metrics,
35
+ latestTask,
36
+ onViewReport,
37
+ dispatchPrompt = '',
38
+ onChangeDispatchPrompt,
39
+ onDispatch,
40
+ isDispatching = false,
41
+ className = '',
42
+ }: VirtualEntityDrawerProps): ReactNode {
43
+ useEffect(() => {
44
+ const handleKeyDown = (e: KeyboardEvent) => {
45
+ if (e.key === 'Escape') onClose()
46
+ }
47
+ window.addEventListener('keydown', handleKeyDown)
48
+ return () => window.removeEventListener('keydown', handleKeyDown)
49
+ }, [onClose])
50
+
51
+ if (!entity) return null
52
+
53
+ const isRunning = entity.status === 'running' || entity.status === 'working'
54
+ const isAwaiting = entity.status === 'awaiting_approval'
55
+
56
+ return (
57
+ <div className={`wv-profile-drawer ${className}`} role="dialog" aria-modal="true">
58
+ {/* Header Banner */}
59
+ <div
60
+ className="wv-drawer-header-banner"
61
+ style={{ backgroundColor: entity.avatarColor || '#3b82f6' }}
62
+ >
63
+ <button
64
+ type="button"
65
+ onClick={onClose}
66
+ className="wv-drawer-close-btn"
67
+ title="Kapat (Esc)"
68
+ >
69
+ <X size={16} />
70
+ </button>
71
+
72
+ <div className="wv-drawer-meta-tags">
73
+ {entity.pinNumber && (
74
+ <span className="wv-drawer-pin-tag">Masa #{entity.pinNumber}</span>
75
+ )}
76
+ {entity.department && (
77
+ <span className="wv-drawer-dept-tag">{entity.department}</span>
78
+ )}
79
+ </div>
80
+
81
+ <h3 className="wv-drawer-title">{entity.name}</h3>
82
+ <p className="wv-drawer-role">{entity.role || entity.description}</p>
83
+ </div>
84
+
85
+ {/* Body Content */}
86
+ <div className="wv-drawer-body">
87
+ {/* Status Row */}
88
+ <div className="wv-drawer-status-card">
89
+ <span className="wv-drawer-status-label">Çalışma Durumu</span>
90
+ <span className={`wv-drawer-status-chip ${isRunning ? 'is-running' : isAwaiting ? 'is-awaiting' : 'is-idle'}`}>
91
+ {isRunning
92
+ ? '⚡ Görev Yürütüyor'
93
+ : isAwaiting
94
+ ? '⏳ Onay Bekliyor'
95
+ : '✓ Boşta / Göreve Hazır'}
96
+ </span>
97
+ </div>
98
+
99
+ {/* Metrics Grid */}
100
+ {metrics && (
101
+ <div className="wv-drawer-metrics-grid">
102
+ <div className="wv-drawer-metric-cell">
103
+ <div className="wv-metric-val">{metrics.totalRuns}</div>
104
+ <div className="wv-metric-lbl">Toplam Görev</div>
105
+ </div>
106
+ <div className="wv-drawer-metric-cell">
107
+ <div className="wv-metric-val is-success">
108
+ {metrics.successRate !== undefined ? `${Math.round(metrics.successRate)}%` : '100%'}
109
+ </div>
110
+ <div className="wv-metric-lbl">Başarı Oranı</div>
111
+ </div>
112
+ <div className="wv-drawer-metric-cell">
113
+ <div className="wv-metric-val">
114
+ ${metrics.costUsd !== undefined ? metrics.costUsd.toFixed(3) : '0.000'}
115
+ </div>
116
+ <div className="wv-metric-lbl">Son 24s Maliyet</div>
117
+ </div>
118
+ </div>
119
+ )}
120
+
121
+ {/* Current or Latest Task */}
122
+ {latestTask ? (
123
+ <div className="wv-drawer-task-section">
124
+ <div className="wv-task-header">
125
+ <span className="wv-task-title">Son / Aktif Görev</span>
126
+ {latestTask.createdAt && (
127
+ <span className="wv-task-time">
128
+ {new Date(latestTask.createdAt).toLocaleTimeString([], {
129
+ hour: '2-digit',
130
+ minute: '2-digit',
131
+ })}
132
+ </span>
133
+ )}
134
+ </div>
135
+
136
+ <div className="wv-task-box">
137
+ <p className="wv-task-prompt">{latestTask.prompt}</p>
138
+ {latestTask.summary && (
139
+ <div className="wv-task-summary">
140
+ <strong>Özet: </strong>
141
+ {latestTask.summary}
142
+ </div>
143
+ )}
144
+ {onViewReport && (
145
+ <button
146
+ type="button"
147
+ onClick={onViewReport}
148
+ className="wv-view-report-btn"
149
+ >
150
+ <FileText size={13} style={{ marginRight: 6 }} />
151
+ <span>Çıktı Raporunu İncele</span>
152
+ </button>
153
+ )}
154
+ </div>
155
+ </div>
156
+ ) : (
157
+ <div className="wv-drawer-empty-task">
158
+ <Clock size={20} className="wv-empty-icon" />
159
+ <p>Henüz bu masada bir görev yürütülmedi.</p>
160
+ </div>
161
+ )}
162
+
163
+ {/* Direct Dispatch to this Entity */}
164
+ {onDispatch && onChangeDispatchPrompt && (
165
+ <div className="wv-drawer-dispatch-section">
166
+ <span className="wv-dispatch-title">Doğrudan Bu Masaya Görev Ver</span>
167
+ <div className="wv-dispatch-row">
168
+ <input
169
+ type="text"
170
+ value={dispatchPrompt}
171
+ onChange={(e) => onChangeDispatchPrompt(e.target.value)}
172
+ onKeyDown={(e) => {
173
+ if (e.key === 'Enter' && !e.shiftKey) {
174
+ e.preventDefault()
175
+ onDispatch()
176
+ }
177
+ }}
178
+ placeholder="Örn: Yeni kampanya metinlerini hazırla..."
179
+ className="wv-dispatch-input"
180
+ />
181
+ <button
182
+ type="button"
183
+ onClick={onDispatch}
184
+ disabled={isDispatching || !dispatchPrompt.trim()}
185
+ className="wv-dispatch-submit-btn"
186
+ >
187
+ {isDispatching ? <Zap size={14} className="wv-spin" /> : <Send size={14} />}
188
+ </button>
189
+ </div>
190
+ </div>
191
+ )}
192
+ </div>
193
+ </div>
194
+ )
195
+ }
@@ -0,0 +1,79 @@
1
+ import { type ReactNode, useEffect } from 'react'
2
+ import { FileText, X } from 'lucide-react'
3
+
4
+ export interface VirtualReportData {
5
+ id?: string
6
+ prompt: string
7
+ summary?: string | null
8
+ status?: string
9
+ }
10
+
11
+ export interface VirtualReportModalProps {
12
+ report: VirtualReportData | null
13
+ onClose: () => void
14
+ title?: string
15
+ }
16
+
17
+ export function VirtualReportModal({
18
+ report,
19
+ onClose,
20
+ title = 'Görev ve Rapor Çıktısı',
21
+ }: VirtualReportModalProps): ReactNode {
22
+ useEffect(() => {
23
+ const handleKeyDown = (e: KeyboardEvent) => {
24
+ if (e.key === 'Escape') onClose()
25
+ }
26
+ window.addEventListener('keydown', handleKeyDown)
27
+ return () => window.removeEventListener('keydown', handleKeyDown)
28
+ }, [onClose])
29
+
30
+ if (!report) return null
31
+
32
+ return (
33
+ <div className="wv-modal-backdrop" onClick={onClose} role="dialog" aria-modal="true">
34
+ <div className="wv-modal-card" onClick={(e) => e.stopPropagation()}>
35
+ {/* Modal Header */}
36
+ <div className="wv-modal-header">
37
+ <div className="wv-modal-title-row">
38
+ <FileText size={16} color="#3b82f6" />
39
+ <h3 className="wv-modal-title">{title}</h3>
40
+ </div>
41
+ <button
42
+ type="button"
43
+ onClick={onClose}
44
+ className="wv-modal-close-btn"
45
+ title="Kapat"
46
+ >
47
+ <X size={16} />
48
+ </button>
49
+ </div>
50
+
51
+ {/* Modal Body */}
52
+ <div className="wv-modal-body">
53
+ <div className="wv-modal-prompt-box">
54
+ <span className="wv-modal-section-label">İstek / Görev Briefi:</span>
55
+ <p className="wv-modal-prompt-text">{report.prompt}</p>
56
+ </div>
57
+
58
+ <div className="wv-modal-output-section">
59
+ <span className="wv-modal-section-label">Üretilen Sonuç / Rapor:</span>
60
+ <div className="wv-modal-output-box">
61
+ {report.summary || 'Görev başarıyla tamamlandı. Çıktılar operasyon havuzuna aktarıldı.'}
62
+ </div>
63
+ </div>
64
+ </div>
65
+
66
+ {/* Modal Footer */}
67
+ <div className="wv-modal-footer">
68
+ <button
69
+ type="button"
70
+ onClick={onClose}
71
+ className="wv-modal-btn"
72
+ >
73
+ Kapat
74
+ </button>
75
+ </div>
76
+ </div>
77
+ </div>
78
+ )
79
+ }
@@ -0,0 +1,183 @@
1
+ import { type ReactNode } from 'react'
2
+ import {
3
+ Users,
4
+ Search,
5
+ X,
6
+ ChevronRight,
7
+ Briefcase,
8
+ Palette,
9
+ Megaphone,
10
+ Globe,
11
+ Shield,
12
+ } from 'lucide-react'
13
+ import type { WorldEntity } from '../core/types'
14
+ import type { DepartmentInfo } from '../presets/officePreset'
15
+
16
+ export interface VirtualRosterProps {
17
+ entities: WorldEntity[]
18
+ departments?: DepartmentInfo[]
19
+ selectedEntityId?: string | null
20
+ onSelectEntity: (id: string) => void
21
+ onClose: () => void
22
+ searchQuery: string
23
+ onSearchChange: (q: string) => void
24
+ selectedCategory: string
25
+ onSelectCategory: (cat: string) => void
26
+ title?: string
27
+ className?: string
28
+ }
29
+
30
+ export function VirtualRoster({
31
+ entities,
32
+ departments = [],
33
+ selectedEntityId,
34
+ onSelectEntity,
35
+ onClose,
36
+ searchQuery,
37
+ onSearchChange,
38
+ selectedCategory,
39
+ onSelectCategory,
40
+ title = 'Ofis Kadrosu',
41
+ className = '',
42
+ }: VirtualRosterProps): ReactNode {
43
+ // Filter entities based on search and category
44
+ const filtered = entities.filter((en) => {
45
+ const nameMatch = en.name.toLowerCase().includes(searchQuery.toLowerCase())
46
+ const roleMatch = (en.role || '').toLowerCase().includes(searchQuery.toLowerCase())
47
+ if (searchQuery && !nameMatch && !roleMatch) return false
48
+
49
+ if (selectedCategory !== 'all') {
50
+ const dept = departments.find((d) => d.slug === selectedCategory)
51
+ if (dept) {
52
+ if (!dept.slotIds.includes(en.id)) return false
53
+ } else if (en.department !== selectedCategory && en.zoneId !== selectedCategory) {
54
+ return false
55
+ }
56
+ }
57
+ return true
58
+ })
59
+
60
+ const getCategoryIcon = (slug?: string) => {
61
+ switch (slug) {
62
+ case 'management':
63
+ case 'executive':
64
+ return <Briefcase size={14} />
65
+ case 'creative':
66
+ return <Palette size={14} />
67
+ case 'marketing':
68
+ case 'growth':
69
+ return <Megaphone size={14} />
70
+ case 'tech':
71
+ return <Globe size={14} />
72
+ default:
73
+ return <Shield size={14} />
74
+ }
75
+ }
76
+
77
+ return (
78
+ <aside className={`wv-roster-sidebar ${className}`} role="complementary" aria-label={title}>
79
+ {/* Header */}
80
+ <div className="wv-roster-header">
81
+ <div className="wv-roster-title-row">
82
+ <div className="wv-roster-title-group">
83
+ <div className="wv-roster-icon-badge">
84
+ <Users size={16} />
85
+ </div>
86
+ <div>
87
+ <h3 className="wv-roster-heading">{title}</h3>
88
+ <p className="wv-roster-subheading">{entities.length} çalışan ofis masalarında</p>
89
+ </div>
90
+ </div>
91
+ <button
92
+ type="button"
93
+ onClick={onClose}
94
+ className="wv-roster-close-btn"
95
+ title="Kadro Panelini Gizle"
96
+ >
97
+ <X size={16} />
98
+ </button>
99
+ </div>
100
+
101
+ {/* Search Bar */}
102
+ <div className="wv-roster-search-wrapper">
103
+ <Search size={14} className="wv-roster-search-icon" />
104
+ <input
105
+ type="text"
106
+ value={searchQuery}
107
+ onChange={(e) => onSearchChange(e.target.value)}
108
+ placeholder="Çalışan veya rol ara..."
109
+ className="wv-roster-search-input"
110
+ />
111
+ </div>
112
+
113
+ {/* Category / Department Pills */}
114
+ {departments.length > 0 && (
115
+ <div className="wv-roster-filter-row">
116
+ <button
117
+ type="button"
118
+ onClick={() => onSelectCategory('all')}
119
+ className={`wv-roster-pill ${selectedCategory === 'all' ? 'is-active' : ''}`}
120
+ >
121
+ Tümü
122
+ </button>
123
+ {departments.map((dept) => (
124
+ <button
125
+ key={dept.id}
126
+ type="button"
127
+ onClick={() => onSelectCategory(dept.slug)}
128
+ className={`wv-roster-pill ${selectedCategory === dept.slug ? 'is-active' : ''}`}
129
+ >
130
+ {dept.name.split(' ')[0]}
131
+ </button>
132
+ ))}
133
+ </div>
134
+ )}
135
+ </div>
136
+
137
+ {/* Entity Item List */}
138
+ <div className="wv-roster-list">
139
+ {filtered.map((en) => {
140
+ const isSelected = selectedEntityId === en.id
141
+ const isRunning = en.status === 'running' || en.status === 'working'
142
+ const isAwaiting = en.status === 'awaiting_approval'
143
+
144
+ return (
145
+ <div
146
+ key={en.id}
147
+ onClick={() => onSelectEntity(en.id)}
148
+ className={`wv-roster-item ${isSelected ? 'is-selected' : ''}`}
149
+ >
150
+ <div className="wv-roster-item-left">
151
+ <div
152
+ className="wv-roster-avatar-dot"
153
+ style={{ backgroundColor: en.avatarColor || '#3b82f6' }}
154
+ >
155
+ {getCategoryIcon(en.department || en.zoneId)}
156
+ <span
157
+ className={`wv-roster-status-pip ${
158
+ isRunning
159
+ ? 'is-running'
160
+ : isAwaiting
161
+ ? 'is-awaiting'
162
+ : en.status || 'idle'
163
+ }`}
164
+ />
165
+ </div>
166
+
167
+ <div className="wv-roster-item-info">
168
+ <div className="wv-roster-name-row">
169
+ {en.pinNumber && <span className="wv-roster-pin">#{en.pinNumber}</span>}
170
+ <h4 className="wv-roster-name">{en.name}</h4>
171
+ </div>
172
+ <p className="wv-roster-role">{en.role || en.description || 'Çalışan'}</p>
173
+ </div>
174
+ </div>
175
+
176
+ <ChevronRight size={14} className="wv-roster-chevron" />
177
+ </div>
178
+ )
179
+ })}
180
+ </div>
181
+ </aside>
182
+ )
183
+ }
@@ -2,3 +2,8 @@ export * from './VirtualWorld'
2
2
  export * from './WorldControls'
3
3
  export * from './EntityPins'
4
4
  export * from './EntityInspector'
5
+ export * from './VirtualCommandBar'
6
+ export * from './VirtualRoster'
7
+ export * from './VirtualEntityDrawer'
8
+ export * from './VirtualReportModal'
9
+ export * from './DigitalHQView'
@@ -1,5 +1,4 @@
1
1
  import * as THREE from 'three'
2
- import type { WorldTheme } from '../core/types'
3
2
 
4
3
  export class MaterialPalette {
5
4
  private materials: Map<string, THREE.Material> = new Map()
@@ -1,5 +1,4 @@
1
1
  import * as THREE from 'three'
2
- import type { WorldEntity } from '../core/types'
3
2
 
4
3
  export interface RaycastHit {
5
4
  entityId: string
@@ -1,5 +1,5 @@
1
1
  import * as THREE from 'three'
2
- import type { WorldDefinition, WorldEntity, PinDisplayMode, EntitySelectedEvent } from '../core/types'
2
+ import type { WorldDefinition, WorldEntity, EntitySelectedEvent } from '../core/types'
3
3
  import { MaterialPalette } from './materials'
4
4
  import { WorldLighting } from './lighting'
5
5
  import { WorldCamera, type CameraPresetName } from './camera'