@lemonriver/core 0.2.0 → 0.4.0
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.
- package/dist/{build-Df_xwIpg.js → build-Nl7EeJ6x.js} +1 -1
- package/dist/cli/bin.js +4 -4
- package/dist/{config-rMGCkz6i.d.ts → config-CYNOR93W.d.ts} +1 -1
- package/dist/{config-BjWCLoMQ.js → config-CpC0nM3r.js} +3152 -1837
- package/dist/{dev-Ctsx9IeO.js → dev-BB3THd5I.js} +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +1 -1
- package/dist/{preview-CJgcqsPk.js → preview-BGjgTg7H.js} +1 -1
- package/dist/{types-8VUyA2bu.d.ts → types-tdaXSyah.d.ts} +1 -35
- package/dist/{update-BKOA3Z6o.js → update-DsxZBtwv.js} +2 -70
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +1 -1
- package/dist/{zh-tw-CeLrYwRE.js → zh-tw-DcrDeKxr.js} +11 -172
- package/package.json +1 -1
- package/src/agent/prompt.ts +2 -0
- package/src/app/app.tsx +5 -18
- package/src/app/components/agent/agent-panel.tsx +5 -0
- package/src/app/components/agent/agent-presence.tsx +2 -2
- package/src/app/components/agent/history-view.tsx +3 -2
- package/src/app/components/agent/transcript.tsx +15 -4
- package/src/app/components/asset-view.tsx +6 -6
- package/src/app/components/command/command-menu.tsx +2 -1
- package/src/app/components/inspector/asset-picker-dialog.tsx +7 -5
- package/src/app/components/inspector/comment-layer.tsx +2 -1
- package/src/app/components/inspector/inspector-panel.tsx +2 -2
- package/src/app/components/player.tsx +105 -23
- package/src/app/components/present/curtain.tsx +52 -0
- package/src/app/components/present/last-slide-hint.tsx +36 -0
- package/src/app/components/sidebar/sidebar-footer.tsx +7 -2
- package/src/app/components/sidebar/sidebar.tsx +3 -2
- package/src/app/components/themes/theme-detail.tsx +4 -2
- package/src/app/components/thumbnail-rail.tsx +2 -28
- package/src/app/index.html +2 -2
- package/src/app/lemonriver/agent/lemon.tsx +79 -0
- package/src/app/lemonriver/agent-prefs/prefs.test.ts +173 -0
- package/src/app/lemonriver/agent-prefs/prefs.ts +137 -0
- package/src/app/lemonriver/agent-prefs/use-prefs.ts +36 -0
- package/src/app/{components → lemonriver}/board/board-canvas.tsx +17 -17
- package/src/app/{routes/board.tsx → lemonriver/board/board-page.tsx} +16 -15
- package/src/app/{components → lemonriver}/board/layout.ts +1 -1
- package/src/app/lemonriver/board/model/cards.test.ts +239 -0
- package/src/app/lemonriver/board/model/cards.ts +234 -0
- package/src/app/lemonriver/board/model/structure.test.ts +101 -0
- package/src/app/lemonriver/board/model/structure.ts +82 -0
- package/src/app/{components → lemonriver}/board/page-node.tsx +34 -31
- package/src/app/{components → lemonriver}/board/use-board-cards.ts +6 -6
- package/src/app/{components → lemonriver}/board/use-board-columns.ts +7 -7
- package/src/app/{components → lemonriver}/board/use-page-order.ts +10 -6
- package/src/app/lemonriver/brand/app-icon.svg +44 -0
- package/src/app/lemonriver/brand/apple-touch-icon.png +0 -0
- package/src/app/lemonriver/brand/favicon-32.png +0 -0
- package/src/app/lemonriver/brand/mascot.tsx +145 -0
- package/src/app/lemonriver/brand/mascots/design-done.png +0 -0
- package/src/app/lemonriver/brand/mascots/design-idle.png +0 -0
- package/src/app/lemonriver/brand/mascots/design-needs-you.png +0 -0
- package/src/app/lemonriver/brand/mascots/design-working.png +0 -0
- package/src/app/lemonriver/brand/mascots/lemon-done.png +0 -0
- package/src/app/lemonriver/brand/mascots/lemon-idle.png +0 -0
- package/src/app/lemonriver/brand/mascots/lemon-needs-you.png +0 -0
- package/src/app/lemonriver/brand/mascots/lemon-thinking.png +0 -0
- package/src/app/lemonriver/brand/mascots/lemon-working.png +0 -0
- package/src/app/lemonriver/brand/mascots/outline-done.png +0 -0
- package/src/app/lemonriver/brand/mascots/outline-idle.png +0 -0
- package/src/app/lemonriver/brand/mascots/outline-needs-you.png +0 -0
- package/src/app/lemonriver/brand/mascots/outline-working.png +0 -0
- package/src/app/lemonriver/brand/mascots/research-done.png +0 -0
- package/src/app/lemonriver/brand/mascots/research-idle.png +0 -0
- package/src/app/lemonriver/brand/mascots/research-needs-you.png +0 -0
- package/src/app/lemonriver/brand/mascots/research-working.png +0 -0
- package/src/app/lemonriver/brand/mascots/review-done.png +0 -0
- package/src/app/lemonriver/brand/mascots/review-idle.png +0 -0
- package/src/app/lemonriver/brand/mascots/review-needs-you.png +0 -0
- package/src/app/lemonriver/brand/mascots/review-working.png +0 -0
- package/src/app/lemonriver/chrome/app-chrome.tsx +101 -0
- package/src/app/lemonriver/chrome/nav-row.tsx +34 -0
- package/src/app/lemonriver/chrome/not-found.tsx +34 -0
- package/src/app/lemonriver/chrome/sidebar-extras.tsx +57 -0
- package/src/app/lemonriver/chrome/use-slot.ts +23 -0
- package/src/app/lemonriver/features.test.ts +34 -0
- package/src/app/lemonriver/features.ts +27 -0
- package/src/app/lemonriver/feedback/export.ts +7 -0
- package/src/app/lemonriver/feedback/lemon-empty.tsx +54 -0
- package/src/app/lemonriver/feedback/offline-banner.tsx +41 -0
- package/src/app/lemonriver/feedback/pending-toast.test.ts +44 -0
- package/src/app/lemonriver/feedback/pending-toast.ts +39 -0
- package/src/app/lemonriver/feedback/toaster.tsx +34 -0
- package/src/app/lemonriver/feedback/upload.test.ts +26 -0
- package/src/app/lemonriver/feedback/upload.ts +19 -0
- package/src/app/lemonriver/home/brief-card.tsx +70 -0
- package/src/app/lemonriver/home/brief.test.ts +38 -0
- package/src/app/lemonriver/home/brief.ts +34 -0
- package/src/app/lemonriver/home/controls.tsx +93 -0
- package/src/app/lemonriver/home/deck-card.tsx +183 -0
- package/src/app/lemonriver/home/dialogs.tsx +292 -0
- package/src/app/lemonriver/home/home-page.tsx +339 -0
- package/src/app/lemonriver/home/sorting.test.ts +24 -0
- package/src/app/lemonriver/home/sorting.ts +59 -0
- package/src/app/lemonriver/home/time.test.ts +33 -0
- package/src/app/lemonriver/home/time.ts +33 -0
- package/src/app/lemonriver/home/use-deck-times.ts +27 -0
- package/src/app/lemonriver/home/use-delayed.ts +15 -0
- package/src/app/lemonriver/onboarding/onboarding.tsx +182 -0
- package/src/app/lemonriver/outline/build-team.tsx +278 -0
- package/src/app/lemonriver/outline/describe-page.tsx +380 -0
- package/src/app/lemonriver/outline/files.test.ts +90 -0
- package/src/app/lemonriver/outline/files.ts +69 -0
- package/src/app/lemonriver/outline/model.test.ts +633 -0
- package/src/app/lemonriver/outline/model.ts +443 -0
- package/src/app/lemonriver/outline/outline-page.tsx +504 -0
- package/src/app/lemonriver/outline/pending-pages.tsx +39 -0
- package/src/app/lemonriver/outline/rule.ts +3 -0
- package/src/app/lemonriver/outline/steps.tsx +43 -0
- package/src/app/lemonriver/outline/use-build-driver.ts +258 -0
- package/src/app/lemonriver/routes.test.tsx +37 -0
- package/src/app/lemonriver/routes.tsx +66 -0
- package/src/app/lemonriver/settings/settings-page.tsx +314 -0
- package/src/app/lemonriver/slide-extensions.tsx +80 -0
- package/src/app/lemonriver/text/all.ts +19 -0
- package/src/app/lemonriver/text/en.ts +255 -0
- package/src/app/lemonriver/text/es.ts +256 -0
- package/src/app/lemonriver/text/index.ts +9 -0
- package/src/app/lemonriver/text/ja.ts +256 -0
- package/src/app/lemonriver/text/text.test.ts +90 -0
- package/src/app/lemonriver/text/types.ts +280 -0
- package/src/app/lemonriver/text/zh-cn.ts +247 -0
- package/src/app/lemonriver/text/zh-tw.ts +247 -0
- package/src/app/lemonriver/theme/app.css +299 -0
- package/src/app/lemonriver/theme/controls.css +463 -0
- package/src/app/lemonriver/theme/index.css +3 -0
- package/src/app/lemonriver/theme/motion.ts +52 -0
- package/src/app/lemonriver/theme/pages.test.ts +70 -0
- package/src/app/lemonriver/theme/pages.ts +65 -0
- package/src/app/lemonriver/theme/theme-menu.tsx +64 -0
- package/src/app/lemonriver/theme/themes.test.ts +18 -0
- package/src/app/lemonriver/theme/themes.ts +16 -0
- package/src/app/lemonriver/theme/tokens.css +226 -0
- package/src/app/lemonriver/theme/use-theme.tsx +49 -0
- package/src/app/lemonriver/trash/api.test.ts +19 -0
- package/src/app/lemonriver/trash/api.ts +77 -0
- package/src/app/lemonriver/trash/trash-page.tsx +131 -0
- package/src/app/lemonriver/update/beta-badge.tsx +26 -0
- package/src/app/lemonriver/update/prompt.test.ts +84 -0
- package/src/app/lemonriver/update/prompt.ts +48 -0
- package/src/app/lemonriver/update/update-prompt.tsx +113 -0
- package/src/app/lib/pptx/raster.ts +1 -1
- package/src/app/main.tsx +8 -1
- package/src/app/routes/home-shell.tsx +4 -2
- package/src/app/routes/home.tsx +13 -5
- package/src/app/routes/slide.tsx +81 -28
- package/src/app/styles.css +1 -0
- package/src/locale/en.ts +1 -35
- package/src/locale/es.ts +1 -34
- package/src/locale/ja.ts +1 -34
- package/src/locale/types.ts +1 -36
- package/src/locale/zh-cn.ts +4 -37
- package/src/locale/zh-tw.ts +4 -37
- /package/src/app/{components → lemonriver}/board/board.css +0 -0
- /package/src/app/{components → lemonriver}/board/layout.test.ts +0 -0
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
import {
|
|
2
|
+
closestCenter,
|
|
3
|
+
DndContext,
|
|
4
|
+
type DragEndEvent,
|
|
5
|
+
KeyboardSensor,
|
|
6
|
+
PointerSensor,
|
|
7
|
+
useSensor,
|
|
8
|
+
useSensors,
|
|
9
|
+
} from '@dnd-kit/core';
|
|
10
|
+
import {
|
|
11
|
+
SortableContext,
|
|
12
|
+
sortableKeyboardCoordinates,
|
|
13
|
+
useSortable,
|
|
14
|
+
verticalListSortingStrategy,
|
|
15
|
+
} from '@dnd-kit/sortable';
|
|
16
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
17
|
+
import { ArrowDown, ArrowLeft, ArrowUp, GripVertical, Trash2 } from 'lucide-react';
|
|
18
|
+
import type { ReactNode } from 'react';
|
|
19
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
20
|
+
import { useNavigate, useParams } from 'react-router-dom';
|
|
21
|
+
import { toast } from 'sonner';
|
|
22
|
+
import { Button } from '@/components/ui/button';
|
|
23
|
+
import {
|
|
24
|
+
Select,
|
|
25
|
+
SelectContent,
|
|
26
|
+
SelectGroup,
|
|
27
|
+
SelectItem,
|
|
28
|
+
SelectTrigger,
|
|
29
|
+
SelectValue,
|
|
30
|
+
} from '@/components/ui/select';
|
|
31
|
+
import {
|
|
32
|
+
createSession,
|
|
33
|
+
sendMessage,
|
|
34
|
+
setActiveSession,
|
|
35
|
+
setDockOpen,
|
|
36
|
+
useAgentSessions,
|
|
37
|
+
useAgentStatus,
|
|
38
|
+
} from '@/lib/agent/use-agent';
|
|
39
|
+
import { format, useLocale } from '@/lib/use-locale';
|
|
40
|
+
import { cn } from '@/lib/utils';
|
|
41
|
+
import { readPrefs } from '../agent-prefs/prefs';
|
|
42
|
+
import { Mascot } from '../brand/mascot';
|
|
43
|
+
import { useLrText } from '../text';
|
|
44
|
+
import type { LrText } from '../text/types';
|
|
45
|
+
import {
|
|
46
|
+
insertPage,
|
|
47
|
+
movePage,
|
|
48
|
+
type Outline,
|
|
49
|
+
type OutlinePage,
|
|
50
|
+
outlinePrompt,
|
|
51
|
+
PAGE_KINDS,
|
|
52
|
+
type PageKind,
|
|
53
|
+
removePage,
|
|
54
|
+
renamePage,
|
|
55
|
+
setKind,
|
|
56
|
+
} from './model';
|
|
57
|
+
import { Steps } from './steps';
|
|
58
|
+
|
|
59
|
+
const SAVE_DELAY_MS = 400;
|
|
60
|
+
const POLL_MS = 1500;
|
|
61
|
+
|
|
62
|
+
function basePath(): string {
|
|
63
|
+
return import.meta.env.BASE_URL.replace(/\/$/, '');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function kindLabel(t: LrText['outline'], kind: PageKind): string {
|
|
67
|
+
const labels: Record<PageKind, string> = {
|
|
68
|
+
cover: t.kindCover,
|
|
69
|
+
kpi: t.kindKpi,
|
|
70
|
+
chart: t.kindChart,
|
|
71
|
+
list: t.kindList,
|
|
72
|
+
page: t.kindPage,
|
|
73
|
+
end: t.kindEnd,
|
|
74
|
+
};
|
|
75
|
+
return labels[kind];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function OutlineView() {
|
|
79
|
+
const { slideId = '' } = useParams();
|
|
80
|
+
const lr = useLrText().outline;
|
|
81
|
+
const buildLr = useLrText().build;
|
|
82
|
+
const prefsLr = useLrText().prefs;
|
|
83
|
+
const locale = useLocale();
|
|
84
|
+
const navigate = useNavigate();
|
|
85
|
+
const { sessions } = useAgentSessions();
|
|
86
|
+
const { provider } = useAgentStatus();
|
|
87
|
+
const [outline, setOutline] = useState<Outline | null | undefined>(undefined);
|
|
88
|
+
const [items, setItems] = useState<OutlinePage[]>([]);
|
|
89
|
+
const [building, setBuilding] = useState(false);
|
|
90
|
+
const dirty = useRef(false);
|
|
91
|
+
const saveTimer = useRef<number | null>(null);
|
|
92
|
+
const redirected = useRef(false);
|
|
93
|
+
|
|
94
|
+
const load = useCallback(async () => {
|
|
95
|
+
try {
|
|
96
|
+
const res = await fetch(`/__lr/outline?slideId=${encodeURIComponent(slideId)}`);
|
|
97
|
+
if (!res.ok) return;
|
|
98
|
+
const body = (await res.json()) as { outline: Outline | null };
|
|
99
|
+
setOutline(body.outline);
|
|
100
|
+
if (!dirty.current) setItems(body.outline?.items ?? []);
|
|
101
|
+
} catch {}
|
|
102
|
+
}, [slideId]);
|
|
103
|
+
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
void load();
|
|
106
|
+
}, [load]);
|
|
107
|
+
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (outline?.state !== 'drafting' && outline?.state !== 'building') return;
|
|
110
|
+
const timer = window.setInterval(() => void load(), POLL_MS);
|
|
111
|
+
return () => window.clearInterval(timer);
|
|
112
|
+
}, [outline?.state, load]);
|
|
113
|
+
|
|
114
|
+
// A "direct" outline starts building on its own at the turn's end; the outline
|
|
115
|
+
// page hands the user straight to the editor, which writes page 1.
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (redirected.current || !outline) return;
|
|
118
|
+
if (outline.state !== 'building' || outline.built !== 0) return;
|
|
119
|
+
if (outline.prefs.outline !== 'direct') return;
|
|
120
|
+
redirected.current = true;
|
|
121
|
+
setDockOpen(true);
|
|
122
|
+
window.location.assign(`${basePath()}/s/${encodeURIComponent(slideId)}`);
|
|
123
|
+
}, [outline, slideId]);
|
|
124
|
+
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
const hot = import.meta.hot;
|
|
127
|
+
if (!hot) return;
|
|
128
|
+
const onChange = () => void load();
|
|
129
|
+
hot.on('open-slide:slide-changed', onChange);
|
|
130
|
+
return () => hot.off('open-slide:slide-changed', onChange);
|
|
131
|
+
}, [load]);
|
|
132
|
+
|
|
133
|
+
const save = useCallback(
|
|
134
|
+
async (next: OutlinePage[]) => {
|
|
135
|
+
try {
|
|
136
|
+
const res = await fetch('/__lr/outline', {
|
|
137
|
+
method: 'PUT',
|
|
138
|
+
headers: { 'content-type': 'application/json' },
|
|
139
|
+
body: JSON.stringify({ slideId, items: next }),
|
|
140
|
+
});
|
|
141
|
+
if (res.ok) dirty.current = false;
|
|
142
|
+
} catch {}
|
|
143
|
+
},
|
|
144
|
+
[slideId],
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
const edit = useCallback(
|
|
148
|
+
(next: OutlinePage[]) => {
|
|
149
|
+
setItems(next);
|
|
150
|
+
dirty.current = true;
|
|
151
|
+
if (saveTimer.current) window.clearTimeout(saveTimer.current);
|
|
152
|
+
saveTimer.current = window.setTimeout(() => void save(next), SAVE_DELAY_MS);
|
|
153
|
+
},
|
|
154
|
+
[save],
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
const sensors = useSensors(
|
|
158
|
+
useSensor(PointerSensor, { activationConstraint: { distance: 5 } }),
|
|
159
|
+
useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
async function sessionForDeck(): Promise<string> {
|
|
163
|
+
const found = sessions.find((session) => session.slideId === slideId);
|
|
164
|
+
if (found) {
|
|
165
|
+
setActiveSession(found.id);
|
|
166
|
+
return found.id;
|
|
167
|
+
}
|
|
168
|
+
if (!provider) throw new Error('no agent');
|
|
169
|
+
const session = await createSession(provider.id, slideId);
|
|
170
|
+
return session.id;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async function build() {
|
|
174
|
+
if (!outline || building) return;
|
|
175
|
+
setBuilding(true);
|
|
176
|
+
try {
|
|
177
|
+
const res = await fetch('/__lr/outline/build', {
|
|
178
|
+
method: 'POST',
|
|
179
|
+
headers: { 'content-type': 'application/json' },
|
|
180
|
+
body: JSON.stringify({ slideId, prefs: readPrefs(localStorage) }),
|
|
181
|
+
});
|
|
182
|
+
if (!res.ok) throw new Error('build failed');
|
|
183
|
+
setDockOpen(true);
|
|
184
|
+
window.location.assign(`${basePath()}/s/${encodeURIComponent(slideId)}`);
|
|
185
|
+
} catch {
|
|
186
|
+
toast.error(lr.startFailed);
|
|
187
|
+
setBuilding(false);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async function retry() {
|
|
192
|
+
if (!outline) return;
|
|
193
|
+
try {
|
|
194
|
+
const prefs = readPrefs(localStorage);
|
|
195
|
+
const res = await fetch('/__lr/outline/start', {
|
|
196
|
+
method: 'POST',
|
|
197
|
+
headers: { 'content-type': 'application/json' },
|
|
198
|
+
body: JSON.stringify({
|
|
199
|
+
slideId,
|
|
200
|
+
brief: outline.brief,
|
|
201
|
+
pages: outline.pages,
|
|
202
|
+
files: outline.files,
|
|
203
|
+
prefs,
|
|
204
|
+
}),
|
|
205
|
+
});
|
|
206
|
+
if (!res.ok) throw new Error('start failed');
|
|
207
|
+
const sessionId = await sessionForDeck();
|
|
208
|
+
await sendMessage(sessionId, outlinePrompt({ ...outline, prefs }, slideId, locale.id), {
|
|
209
|
+
slideId,
|
|
210
|
+
});
|
|
211
|
+
await load();
|
|
212
|
+
} catch {
|
|
213
|
+
toast.error(lr.startFailed);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function editBrief() {
|
|
218
|
+
navigate(`/new?deck=${encodeURIComponent(slideId)}`);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function onDragEnd(event: DragEndEvent) {
|
|
222
|
+
const { active, over } = event;
|
|
223
|
+
if (!over || active.id === over.id) return;
|
|
224
|
+
const from = items.findIndex((page) => page.id === active.id);
|
|
225
|
+
const to = items.findIndex((page) => page.id === over.id);
|
|
226
|
+
if (from === -1 || to === -1) return;
|
|
227
|
+
edit(movePage(items, from, to));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const running = sessions.some(
|
|
231
|
+
(session) => session.slideId === slideId && session.status === 'running',
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
return (
|
|
235
|
+
<div data-lr-outline className="min-h-dvh bg-background text-foreground">
|
|
236
|
+
<div className="mx-auto w-full max-w-[820px] px-6 py-8">
|
|
237
|
+
<button
|
|
238
|
+
type="button"
|
|
239
|
+
onClick={() => navigate('/')}
|
|
240
|
+
className="mb-6 inline-flex items-center gap-1.5 text-[13px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
241
|
+
>
|
|
242
|
+
<ArrowLeft className="size-3.5" />
|
|
243
|
+
{lr.back}
|
|
244
|
+
</button>
|
|
245
|
+
|
|
246
|
+
<Steps current={2} />
|
|
247
|
+
|
|
248
|
+
{outline === undefined && <div className="mt-10 h-24" />}
|
|
249
|
+
|
|
250
|
+
{outline?.state === 'drafting' && (
|
|
251
|
+
<div
|
|
252
|
+
data-lr-outline-state="drafting"
|
|
253
|
+
className="mt-10 flex flex-col items-center gap-3 rounded-[16px] border border-border bg-card px-6 py-12 text-center"
|
|
254
|
+
>
|
|
255
|
+
<Mascot state="thinking" size={56} float />
|
|
256
|
+
<p className="text-[14px] text-muted-foreground">
|
|
257
|
+
{outline.files.length > 0
|
|
258
|
+
? format(lr.drafting, { n: outline.files.length })
|
|
259
|
+
: lr.draftingNoFiles}
|
|
260
|
+
</p>
|
|
261
|
+
</div>
|
|
262
|
+
)}
|
|
263
|
+
|
|
264
|
+
{(outline === null || outline?.state === 'failed') && (
|
|
265
|
+
<div
|
|
266
|
+
data-lr-outline-state="failed"
|
|
267
|
+
className="mt-10 flex items-start gap-3 rounded-[16px] border border-border bg-card px-5 py-5"
|
|
268
|
+
>
|
|
269
|
+
<Mascot state="needs-you" size={40} />
|
|
270
|
+
<div className="min-w-0 flex-1">
|
|
271
|
+
<p className="text-[15px] font-semibold">{lr.failedTitle}</p>
|
|
272
|
+
<p className="mt-1 text-[13px] text-muted-foreground">{lr.failedHint}</p>
|
|
273
|
+
<div className="mt-3 flex gap-2">
|
|
274
|
+
<Button
|
|
275
|
+
type="button"
|
|
276
|
+
variant="outline"
|
|
277
|
+
size="sm"
|
|
278
|
+
disabled={!outline || !provider}
|
|
279
|
+
onClick={() => void retry()}
|
|
280
|
+
>
|
|
281
|
+
{lr.retry}
|
|
282
|
+
</Button>
|
|
283
|
+
<Button type="button" variant="ghost" size="sm" onClick={editBrief}>
|
|
284
|
+
{lr.editBrief}
|
|
285
|
+
</Button>
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
289
|
+
)}
|
|
290
|
+
|
|
291
|
+
{outline?.state === 'building' && (
|
|
292
|
+
<div
|
|
293
|
+
data-lr-outline-state="building"
|
|
294
|
+
className="mt-10 flex flex-col items-center gap-3 rounded-[16px] border border-border bg-card px-6 py-12 text-center"
|
|
295
|
+
>
|
|
296
|
+
<Mascot state="working" size={56} float />
|
|
297
|
+
<p className="text-[14px] text-muted-foreground">
|
|
298
|
+
{format(buildLr.buildingHere, { k: outline.built, n: outline.items.length })}
|
|
299
|
+
</p>
|
|
300
|
+
<Button
|
|
301
|
+
type="button"
|
|
302
|
+
variant="outline"
|
|
303
|
+
size="sm"
|
|
304
|
+
onClick={() => navigate(`/s/${encodeURIComponent(slideId)}`)}
|
|
305
|
+
>
|
|
306
|
+
{buildLr.backToEditor}
|
|
307
|
+
</Button>
|
|
308
|
+
</div>
|
|
309
|
+
)}
|
|
310
|
+
|
|
311
|
+
{outline &&
|
|
312
|
+
outline.state !== 'drafting' &&
|
|
313
|
+
outline.state !== 'failed' &&
|
|
314
|
+
outline.state !== 'building' && (
|
|
315
|
+
<>
|
|
316
|
+
<ul className="mt-8 flex flex-col gap-2">
|
|
317
|
+
<DndContext
|
|
318
|
+
sensors={sensors}
|
|
319
|
+
collisionDetection={closestCenter}
|
|
320
|
+
onDragEnd={onDragEnd}
|
|
321
|
+
>
|
|
322
|
+
<SortableContext
|
|
323
|
+
items={items.map((page) => page.id)}
|
|
324
|
+
strategy={verticalListSortingStrategy}
|
|
325
|
+
>
|
|
326
|
+
{items.map((page, index) => (
|
|
327
|
+
<OutlineRow
|
|
328
|
+
key={page.id}
|
|
329
|
+
page={page}
|
|
330
|
+
index={index}
|
|
331
|
+
first={index === 0}
|
|
332
|
+
last={index === items.length - 1}
|
|
333
|
+
canDelete={items.length > 2}
|
|
334
|
+
onTitle={(title) => edit(renamePage(items, index, title))}
|
|
335
|
+
onKind={(kind) => edit(setKind(items, index, kind))}
|
|
336
|
+
onUp={() => edit(movePage(items, index, index - 1))}
|
|
337
|
+
onDown={() => edit(movePage(items, index, index + 1))}
|
|
338
|
+
onRemove={() => edit(removePage(items, index))}
|
|
339
|
+
/>
|
|
340
|
+
))}
|
|
341
|
+
</SortableContext>
|
|
342
|
+
</DndContext>
|
|
343
|
+
</ul>
|
|
344
|
+
|
|
345
|
+
<div className="mt-4 flex flex-wrap items-center gap-2">
|
|
346
|
+
<Button
|
|
347
|
+
type="button"
|
|
348
|
+
variant="outline"
|
|
349
|
+
size="sm"
|
|
350
|
+
onClick={() => edit(insertPage(items, items.length))}
|
|
351
|
+
>
|
|
352
|
+
{lr.addPage}
|
|
353
|
+
</Button>
|
|
354
|
+
<Button type="button" variant="ghost" size="sm" onClick={editBrief}>
|
|
355
|
+
{lr.editBrief}
|
|
356
|
+
</Button>
|
|
357
|
+
<span className="ml-auto text-[12.5px] text-muted-foreground tabular-nums">
|
|
358
|
+
{format(lr.total, { n: items.length })}
|
|
359
|
+
</span>
|
|
360
|
+
</div>
|
|
361
|
+
|
|
362
|
+
<div className="mt-6 flex justify-end">
|
|
363
|
+
<Button
|
|
364
|
+
type="button"
|
|
365
|
+
disabled={outline.state !== 'ready' || running || building}
|
|
366
|
+
onClick={() => void build()}
|
|
367
|
+
>
|
|
368
|
+
{lr.build}
|
|
369
|
+
</Button>
|
|
370
|
+
</div>
|
|
371
|
+
</>
|
|
372
|
+
)}
|
|
373
|
+
|
|
374
|
+
{outline && outline.decisions.length > 0 && (
|
|
375
|
+
<section
|
|
376
|
+
data-lr-decisions
|
|
377
|
+
className="mt-8 rounded-[16px] border border-border bg-card px-5 py-4"
|
|
378
|
+
>
|
|
379
|
+
<h2 className="text-[13px] font-semibold">{prefsLr.decisionsTitle}</h2>
|
|
380
|
+
<ul className="mt-2 space-y-1">
|
|
381
|
+
{outline.decisions.map((decision) => (
|
|
382
|
+
<li key={decision.id} className="text-[12.5px] leading-snug text-muted-foreground">
|
|
383
|
+
{decision.question} → {decision.answer}
|
|
384
|
+
</li>
|
|
385
|
+
))}
|
|
386
|
+
</ul>
|
|
387
|
+
</section>
|
|
388
|
+
)}
|
|
389
|
+
</div>
|
|
390
|
+
</div>
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function OutlineRow({
|
|
395
|
+
page,
|
|
396
|
+
index,
|
|
397
|
+
first,
|
|
398
|
+
last,
|
|
399
|
+
canDelete,
|
|
400
|
+
onTitle,
|
|
401
|
+
onKind,
|
|
402
|
+
onUp,
|
|
403
|
+
onDown,
|
|
404
|
+
onRemove,
|
|
405
|
+
}: {
|
|
406
|
+
page: OutlinePage;
|
|
407
|
+
index: number;
|
|
408
|
+
first: boolean;
|
|
409
|
+
last: boolean;
|
|
410
|
+
canDelete: boolean;
|
|
411
|
+
onTitle: (title: string) => void;
|
|
412
|
+
onKind: (kind: PageKind) => void;
|
|
413
|
+
onUp: () => void;
|
|
414
|
+
onDown: () => void;
|
|
415
|
+
onRemove: () => void;
|
|
416
|
+
}) {
|
|
417
|
+
const lr = useLrText().outline;
|
|
418
|
+
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
|
|
419
|
+
id: page.id,
|
|
420
|
+
});
|
|
421
|
+
const style = { transform: CSS.Transform.toString(transform), transition };
|
|
422
|
+
|
|
423
|
+
return (
|
|
424
|
+
<li
|
|
425
|
+
ref={setNodeRef}
|
|
426
|
+
style={style}
|
|
427
|
+
data-lr-outline-row
|
|
428
|
+
className={cn(
|
|
429
|
+
'flex items-center gap-2 rounded-[10px] border border-border bg-card px-2.5 py-2',
|
|
430
|
+
isDragging && 'opacity-70 shadow-[var(--lr-shadow-1)]',
|
|
431
|
+
)}
|
|
432
|
+
>
|
|
433
|
+
<button
|
|
434
|
+
type="button"
|
|
435
|
+
aria-label={lr.dragPage}
|
|
436
|
+
className="cursor-grab rounded p-1 text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
437
|
+
{...attributes}
|
|
438
|
+
{...listeners}
|
|
439
|
+
>
|
|
440
|
+
<GripVertical className="size-4" />
|
|
441
|
+
</button>
|
|
442
|
+
<span className="w-5 text-right text-[12px] text-muted-foreground tabular-nums">
|
|
443
|
+
{index + 1}
|
|
444
|
+
</span>
|
|
445
|
+
<Select
|
|
446
|
+
items={Object.fromEntries(PAGE_KINDS.map((kind) => [kind, kindLabel(lr, kind)]))}
|
|
447
|
+
value={page.kind}
|
|
448
|
+
onValueChange={(value) => onKind(value as PageKind)}
|
|
449
|
+
>
|
|
450
|
+
<SelectTrigger size="sm" className="w-[104px] shrink-0 text-[12.5px]">
|
|
451
|
+
<SelectValue />
|
|
452
|
+
</SelectTrigger>
|
|
453
|
+
<SelectContent>
|
|
454
|
+
<SelectGroup>
|
|
455
|
+
{PAGE_KINDS.map((kind) => (
|
|
456
|
+
<SelectItem key={kind} value={kind} className="text-[12.5px]">
|
|
457
|
+
{kindLabel(lr, kind)}
|
|
458
|
+
</SelectItem>
|
|
459
|
+
))}
|
|
460
|
+
</SelectGroup>
|
|
461
|
+
</SelectContent>
|
|
462
|
+
</Select>
|
|
463
|
+
<input
|
|
464
|
+
value={page.title}
|
|
465
|
+
onChange={(e) => onTitle(e.target.value)}
|
|
466
|
+
aria-label={format(lr.pageTitle, { n: index + 1 })}
|
|
467
|
+
className="min-w-0 flex-1 rounded-[5px] bg-transparent px-2 py-1 text-[14px] outline-none focus:bg-muted/60"
|
|
468
|
+
/>
|
|
469
|
+
<IconButton label={lr.moveUp} disabled={first} onClick={onUp}>
|
|
470
|
+
<ArrowUp className="size-3.5" />
|
|
471
|
+
</IconButton>
|
|
472
|
+
<IconButton label={lr.moveDown} disabled={last} onClick={onDown}>
|
|
473
|
+
<ArrowDown className="size-3.5" />
|
|
474
|
+
</IconButton>
|
|
475
|
+
<IconButton label={lr.removePage} disabled={!canDelete} onClick={onRemove}>
|
|
476
|
+
<Trash2 className="size-3.5" />
|
|
477
|
+
</IconButton>
|
|
478
|
+
</li>
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
function IconButton({
|
|
483
|
+
label,
|
|
484
|
+
disabled,
|
|
485
|
+
onClick,
|
|
486
|
+
children,
|
|
487
|
+
}: {
|
|
488
|
+
label: string;
|
|
489
|
+
disabled?: boolean;
|
|
490
|
+
onClick: () => void;
|
|
491
|
+
children: ReactNode;
|
|
492
|
+
}) {
|
|
493
|
+
return (
|
|
494
|
+
<button
|
|
495
|
+
type="button"
|
|
496
|
+
aria-label={label}
|
|
497
|
+
disabled={disabled}
|
|
498
|
+
onClick={onClick}
|
|
499
|
+
className="rounded p-1 text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40 disabled:opacity-35"
|
|
500
|
+
>
|
|
501
|
+
{children}
|
|
502
|
+
</button>
|
|
503
|
+
);
|
|
504
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createPortal } from 'react-dom';
|
|
2
|
+
import { format } from '@/lib/use-locale';
|
|
3
|
+
import { useSlot } from '../chrome/use-slot';
|
|
4
|
+
import { useLrText } from '../text';
|
|
5
|
+
import { useBuildDriver } from './use-build-driver';
|
|
6
|
+
|
|
7
|
+
/** The pages the build has not reached yet, listed under the thumbnail rail. */
|
|
8
|
+
export function PendingPages({ slideId }: { slideId: string }) {
|
|
9
|
+
const lr = useLrText().build;
|
|
10
|
+
const slot = useSlot('data-lr-rail-pending');
|
|
11
|
+
const { outline } = useBuildDriver(slideId);
|
|
12
|
+
|
|
13
|
+
if (!slot || !outline || outline.state !== 'building') return null;
|
|
14
|
+
const pending = outline.items.slice(outline.built);
|
|
15
|
+
if (pending.length === 0) return null;
|
|
16
|
+
|
|
17
|
+
return createPortal(
|
|
18
|
+
<div data-lr-pending-pages className="max-h-[240px] overflow-y-auto px-2 py-2">
|
|
19
|
+
<ul className="flex flex-col gap-1">
|
|
20
|
+
{pending.map((item, index) => (
|
|
21
|
+
<li
|
|
22
|
+
key={item.id}
|
|
23
|
+
data-lr-pending-page
|
|
24
|
+
className="rounded-[8px] border border-dashed border-border px-2 py-1.5 opacity-70"
|
|
25
|
+
>
|
|
26
|
+
<p className="truncate text-[11.5px] text-foreground">
|
|
27
|
+
{format(lr.pendingPage, {
|
|
28
|
+
k: outline.built + index + 1,
|
|
29
|
+
title: item.title || lr.pending,
|
|
30
|
+
})}
|
|
31
|
+
</p>
|
|
32
|
+
<span className="text-[10.5px] text-muted-foreground">{lr.pending}</span>
|
|
33
|
+
</li>
|
|
34
|
+
))}
|
|
35
|
+
</ul>
|
|
36
|
+
</div>,
|
|
37
|
+
slot,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { cn } from '@/lib/utils';
|
|
2
|
+
import { useLrText } from '../text';
|
|
3
|
+
|
|
4
|
+
/** The four moves of the guided flow, with the current one marked. */
|
|
5
|
+
export function Steps({ current }: { current: 1 | 2 | 3 | 4 }) {
|
|
6
|
+
const lr = useLrText().outline;
|
|
7
|
+
const labels = [lr.stepDescribe, lr.stepOutline, lr.stepBuild, lr.stepDone];
|
|
8
|
+
return (
|
|
9
|
+
<ol data-lr-steps className="flex flex-wrap items-center gap-x-3 gap-y-2">
|
|
10
|
+
{labels.map((label, index) => {
|
|
11
|
+
const step = index + 1;
|
|
12
|
+
const active = step === current;
|
|
13
|
+
const done = step < current;
|
|
14
|
+
return (
|
|
15
|
+
<li key={label} className="flex items-center gap-2">
|
|
16
|
+
<span
|
|
17
|
+
aria-current={active ? 'step' : undefined}
|
|
18
|
+
className={cn(
|
|
19
|
+
'flex size-6 items-center justify-center rounded-full border text-[11.5px] font-semibold tabular-nums',
|
|
20
|
+
active
|
|
21
|
+
? 'border-transparent bg-brand text-brand-foreground'
|
|
22
|
+
: done
|
|
23
|
+
? 'border-[var(--lr-focus)] text-foreground'
|
|
24
|
+
: 'border-border text-muted-foreground',
|
|
25
|
+
)}
|
|
26
|
+
>
|
|
27
|
+
{step}
|
|
28
|
+
</span>
|
|
29
|
+
<span
|
|
30
|
+
className={cn(
|
|
31
|
+
'text-[13px]',
|
|
32
|
+
active ? 'font-semibold text-foreground' : 'text-muted-foreground',
|
|
33
|
+
)}
|
|
34
|
+
>
|
|
35
|
+
{label}
|
|
36
|
+
</span>
|
|
37
|
+
{step < labels.length && <span aria-hidden className="h-px w-5 bg-border" />}
|
|
38
|
+
</li>
|
|
39
|
+
);
|
|
40
|
+
})}
|
|
41
|
+
</ol>
|
|
42
|
+
);
|
|
43
|
+
}
|