dracosh 0.5.0 → 0.7.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/README.md +22 -9
- package/locales/de.json +215 -21
- package/locales/en.json +215 -21
- package/locales/fr.json +231 -22
- package/locales/pl.json +245 -21
- package/locales/uk.json +248 -24
- package/package.json +3 -2
- package/src/backup.js +10 -1
- package/src/cli.js +14 -7
- package/src/commands.js +3 -0
- package/src/firstwords.js +49 -0
- package/src/judge.js +1 -1
- package/src/language.js +11 -6
- package/src/library.js +122 -2
- package/src/manage.js +149 -4
- package/src/progress.js +12 -4
- package/src/scheduler.js +107 -15
- package/src/session.js +59 -17
- package/src/settings.js +7 -1
- package/src/store.js +33 -9
- package/src/transfer.js +22 -5
- package/src/ui/AddCard.js +13 -11
- package/src/ui/AnswerInput.js +24 -3
- package/src/ui/App.js +242 -18
- package/src/ui/Cards.js +236 -0
- package/src/ui/Choice.js +6 -1
- package/src/ui/Decks.js +181 -15
- package/src/ui/Help.js +2 -3
- package/src/ui/Import.js +316 -0
- package/src/ui/Languages.js +48 -9
- package/src/ui/Preview.js +22 -1
- package/src/ui/Settings.js +18 -6
- package/src/ui/Trash.js +63 -0
- package/src/ui/Welcome.js +79 -0
- package/src/words.js +27 -4
package/src/ui/Decks.js
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { Fragment, useEffect, useRef, useState } from "react";
|
|
2
2
|
import { Box, useInput } from "ink";
|
|
3
3
|
import { t } from "../i18n.js";
|
|
4
|
+
import { AnswerInput } from "./AnswerInput.js";
|
|
4
5
|
import { Choice, choiceHints } from "./Choice.js";
|
|
5
6
|
import { LanguagePicker, pairText } from "./Languages.js";
|
|
6
7
|
import { isKnown, languageName } from "../language.js";
|
|
8
|
+
import { TRASH_DAYS } from "../library.js";
|
|
7
9
|
import { cutToWidth, html, KeyHints, Text, theme, usePanelWidth } from "./kit.js";
|
|
8
10
|
|
|
9
11
|
const DIRECTIONS = ["forward", "backward", "both"];
|
|
10
12
|
|
|
11
13
|
// /decks: your decks with their card counts; Enter quizzes the chosen one from now on, and
|
|
12
|
-
// "+ New deck" starts one (`onNew`). → on a deck of yours: which way it's asked
|
|
13
|
-
//
|
|
14
|
-
|
|
14
|
+
// "+ New deck" starts one (`onNew`). → on a deck of yours: which way it's asked, its languages, its
|
|
15
|
+
// name, and Delete: asked first, then into the trash, and u brings it straight back. `onDeleted`
|
|
16
|
+
// ({ cardIds, next }) and `onRestored`({ deck, progress, removed }) let the app follow (progress, the
|
|
17
|
+
// deck practised); `onRenamed`(from, to) too. Space marks decks to practise together (`mix`: "all" or
|
|
18
|
+
// their names, set with `onPractise`({ deck, mix })), and "All decks" takes every deck of yours.
|
|
19
|
+
export function Decks({ current, mix = null, actions, onPick, onPractise, onNew, onClose, onDirections, onLanguages, onDeleted, onRestored, onRenamed, onMerged }) {
|
|
15
20
|
const panel = usePanelWidth();
|
|
16
21
|
const [decks, setDecks] = useState(null);
|
|
17
22
|
const [picked, setPicked] = useState(0);
|
|
@@ -19,30 +24,40 @@ export function Decks({ current, actions, onPick, onNew, onClose, onDirections,
|
|
|
19
24
|
const [menu, setMenu] = useState(null); // { deck, selected }: a deck's settings
|
|
20
25
|
const [setting, setSetting] = useState(null); // { deck, selected }: the direction being picked
|
|
21
26
|
const [naming, setNaming] = useState(null); // the deck whose languages are being picked
|
|
27
|
+
const [renaming, setRenaming] = useState(null); // the deck being renamed
|
|
28
|
+
const [deleting, setDeleting] = useState(null); // { deck, selected }: Delete, asked first
|
|
29
|
+
const [merging, setMerging] = useState(null); // { deck, into, selected }: Merge into another deck, then asked
|
|
30
|
+
const [undo, setUndo] = useState(null); // { entry, name }: the deck just deleted, u brings it back
|
|
22
31
|
const saving = useRef(false);
|
|
23
32
|
const [message, setMessage] = useState("");
|
|
24
33
|
|
|
25
|
-
|
|
34
|
+
const reload = (select) =>
|
|
26
35
|
actions.allDecks().then(
|
|
27
36
|
(all) => {
|
|
28
37
|
setDecks(all);
|
|
29
|
-
setPicked(Math.max(0, all.findIndex((d) => d.name ===
|
|
38
|
+
setPicked(Math.max(0, all.findIndex((d) => d.name === select)));
|
|
30
39
|
},
|
|
31
40
|
(err) => setError(err.message)
|
|
32
41
|
);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
reload(current);
|
|
33
44
|
}, []);
|
|
34
45
|
|
|
35
46
|
useInput((input, key) => {
|
|
36
47
|
if (!decks?.length && (key.escape || input === "q")) onClose();
|
|
48
|
+
const listing = !menu && !setting && !naming && !renaming && !deleting && !merging && !saving.current;
|
|
49
|
+
if (input === "u" && undo && listing) return restore();
|
|
37
50
|
const deck = decks?.[picked];
|
|
51
|
+
if (input === " " && listing && deck && !deck.tour && own.length >= 2) return together(deck);
|
|
38
52
|
// → into a deck's settings, ← back out of them (Esc works too)
|
|
39
|
-
if (key.leftArrow && !naming) {
|
|
53
|
+
if (key.leftArrow && !naming && !renaming && !deleting && !merging) {
|
|
40
54
|
if (setting) return setSetting(null);
|
|
41
55
|
if (menu) return setMenu(null);
|
|
42
56
|
}
|
|
43
57
|
// not while a change is still being saved: the menu would show the deck as it was
|
|
44
|
-
if (key.rightArrow && !menu && !setting && !naming && !saving.current && deck && !deck.tour) {
|
|
58
|
+
if (key.rightArrow && !menu && !setting && !naming && !renaming && !deleting && !merging && !saving.current && deck && !deck.tour) {
|
|
45
59
|
setMessage("");
|
|
60
|
+
setUndo(null);
|
|
46
61
|
setMenu({ deck, selected: 0 });
|
|
47
62
|
}
|
|
48
63
|
});
|
|
@@ -66,17 +81,102 @@ export function Decks({ current, actions, onPick, onNew, onClose, onDirections,
|
|
|
66
81
|
}
|
|
67
82
|
}
|
|
68
83
|
|
|
84
|
+
// your decks, and the ones practised now: every one for "all", the marked ones, or the one deck
|
|
85
|
+
const own = (decks ?? []).filter((d) => !d.tour);
|
|
86
|
+
const practised = mix === "all" ? own.map((d) => d.name) : mix ?? [current];
|
|
87
|
+
|
|
88
|
+
// space on a deck: in or out of the decks practised together (one left is that deck alone)
|
|
89
|
+
function together(deck) {
|
|
90
|
+
setMessage("");
|
|
91
|
+
const now = practised.filter((name) => own.some((d) => d.name === name));
|
|
92
|
+
const next = now.includes(deck.name) ? now.filter((name) => name !== deck.name) : [...now, deck.name];
|
|
93
|
+
if (!next.length) return setMessage(t("decks.onlyOne", { deck: deck.name }));
|
|
94
|
+
const main = next.includes(current) ? current : next[0];
|
|
95
|
+
onPractise({ deck: main, mix: next.length >= 2 ? (next.length === own.length ? "all" : next) : null }); // every deck marked: all of them, new ones too
|
|
96
|
+
setMessage(next.length >= 2 ? t("decks.togetherNow", { count: next.length }) : t("decks.aloneNow", { deck: next[0] }));
|
|
97
|
+
}
|
|
98
|
+
|
|
69
99
|
// the menu stays underneath: Esc in the direction or language picker comes back to it
|
|
100
|
+
const menuRows = (deck) => ["ask", "languages", ...(deck.learning ? ["learning"] : []), ...(deck.languages.guessed ? [] : ["detect"]), "rename", ...(own.length >= 2 ? ["merge"] : []), "delete"];
|
|
70
101
|
function openSetting(index) {
|
|
71
102
|
const { deck } = menu;
|
|
72
103
|
setMenu((m) => ({ ...m, selected: index })); // coming back, the cursor is on the row you opened
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
if (
|
|
76
|
-
if (
|
|
104
|
+
const row = menuRows(deck)[index];
|
|
105
|
+
if (row === "ask") return setSetting({ deck, selected: Math.max(0, DIRECTIONS.indexOf(deck.directions)) });
|
|
106
|
+
if (row === "languages") return setNaming(deck);
|
|
107
|
+
if (row === "learning") return setNaming({ ...deck, only: "learning" });
|
|
108
|
+
if (row === "rename") return setRenaming(deck);
|
|
109
|
+
if (row === "delete") return setDeleting({ deck, selected: 1 }); // Cancel first: Enter by habit keeps the deck
|
|
110
|
+
if (row === "merge") return setMerging({ deck, into: null, selected: 0 });
|
|
77
111
|
setLanguages(null, deck); // detect them from the cards again
|
|
78
112
|
}
|
|
79
113
|
|
|
114
|
+
async function rename(deck, name) {
|
|
115
|
+
if (saving.current) return;
|
|
116
|
+
if (name.trim() === deck.name) return setRenaming(null);
|
|
117
|
+
saving.current = true;
|
|
118
|
+
try {
|
|
119
|
+
const renamed = await actions.renameDeck(deck.name, name);
|
|
120
|
+
setRenaming(null);
|
|
121
|
+
setMenu(null);
|
|
122
|
+
onRenamed?.(deck.name, renamed.name);
|
|
123
|
+
await reload(renamed.name);
|
|
124
|
+
setMessage(t("decks.renamed", { from: deck.name, to: renamed.name }));
|
|
125
|
+
} catch (err) {
|
|
126
|
+
setError(err.message);
|
|
127
|
+
} finally {
|
|
128
|
+
saving.current = false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function remove(deck) {
|
|
133
|
+
if (saving.current) return;
|
|
134
|
+
saving.current = true;
|
|
135
|
+
setDeleting(null);
|
|
136
|
+
setMenu(null);
|
|
137
|
+
try {
|
|
138
|
+
const done = await onDeleted(deck.name);
|
|
139
|
+
setUndo({ entry: done.entry, name: deck.name });
|
|
140
|
+
await reload(done.next === deck.name ? null : current === deck.name ? done.next : current);
|
|
141
|
+
setMessage(t("decks.deleted", { deck: deck.name, days: TRASH_DAYS }));
|
|
142
|
+
} catch (err) {
|
|
143
|
+
setError(err.message);
|
|
144
|
+
} finally {
|
|
145
|
+
saving.current = false;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async function merge(from, into) {
|
|
150
|
+
if (saving.current) return;
|
|
151
|
+
saving.current = true;
|
|
152
|
+
setMerging(null);
|
|
153
|
+
setMenu(null);
|
|
154
|
+
try {
|
|
155
|
+
const done = await onMerged(from.name, into.name);
|
|
156
|
+
setUndo({ entry: done.entry, name: from.name });
|
|
157
|
+
await reload(into.name);
|
|
158
|
+
setMessage(t("decks.merged", { from: from.name, into: into.name, count: done.moved.length }) + (done.left.length ? ` ${t("decks.mergedLeft", { count: done.left.length })}` : ""));
|
|
159
|
+
} catch (err) {
|
|
160
|
+
setError(err.message);
|
|
161
|
+
} finally {
|
|
162
|
+
saving.current = false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async function restore() {
|
|
167
|
+
saving.current = true;
|
|
168
|
+
try {
|
|
169
|
+
const back = await onRestored(undo.entry);
|
|
170
|
+
setUndo(null);
|
|
171
|
+
await reload(back.deck);
|
|
172
|
+
setMessage(t("decks.restored", { deck: back.deck }));
|
|
173
|
+
} catch (err) {
|
|
174
|
+
setError(err.message);
|
|
175
|
+
} finally {
|
|
176
|
+
saving.current = false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
80
180
|
// the language you're learning in the deck (pronunciation reads it, "almost" applies to it)
|
|
81
181
|
async function saveLearning(deck, lang) {
|
|
82
182
|
setNaming(null);
|
|
@@ -136,6 +236,64 @@ export function Decks({ current, actions, onPick, onNew, onClose, onDirections,
|
|
|
136
236
|
|
|
137
237
|
if (setting) return directionPicker();
|
|
138
238
|
|
|
239
|
+
if (renaming)
|
|
240
|
+
return html`
|
|
241
|
+
<${Fragment}>
|
|
242
|
+
<${Box} flexDirection="column" borderStyle="round" borderColor=${theme.accent} paddingX=${2} width=${panel}>
|
|
243
|
+
<${Text} bold color=${theme.accent}>${t("decks.renameTitle", { deck: renaming.name })}<//>
|
|
244
|
+
<${Box} marginTop=${1}><${AnswerInput} plain escLeaves initial=${renaming.name} onSubmit=${(name) => rename(renaming, name)} onExit=${() => (setRenaming(null), setError(""))} onChange=${() => setError("")} /><//>
|
|
245
|
+
${error && html`<${Box} marginTop=${1}><${Text} color=${theme.bad}>${error}<//><//>`}
|
|
246
|
+
<//>
|
|
247
|
+
<${Box} paddingX=${1}><${KeyHints} text=${t("keyHints.rename")} /><//>
|
|
248
|
+
<//>
|
|
249
|
+
`;
|
|
250
|
+
|
|
251
|
+
// two decks whose cards are in other languages: merging them is likely a slip
|
|
252
|
+
const differ = (a, b) => [a, b].every((d) => isKnown(d.languages.front) && isKnown(d.languages.back)) && (a.languages.front !== b.languages.front || a.languages.back !== b.languages.back);
|
|
253
|
+
|
|
254
|
+
if (merging) {
|
|
255
|
+
const { deck } = merging;
|
|
256
|
+
const others = own.filter((d) => d.name !== deck.name);
|
|
257
|
+
const back = () => setMerging(null);
|
|
258
|
+
if (!merging.into)
|
|
259
|
+
return html`
|
|
260
|
+
<${Fragment}>
|
|
261
|
+
<${Box} flexDirection="column" borderStyle="round" borderColor=${theme.accent} paddingX=${2} width=${panel}>
|
|
262
|
+
<${Text} bold color=${theme.accent}>${t("decks.mergeTitle", { deck: deck.name })}<//>
|
|
263
|
+
<${Box} marginTop=${1}><${Choice} options=${others.map((d) => ({ label: d.name, note: t("count.cards", { count: d.cards }) }))} selected=${merging.selected} onMove=${(selected) => setMerging((m) => ({ ...m, selected }))} onPick=${(i) => setMerging((m) => ({ ...m, into: others[i], selected: 1 }))} onCancel=${back} /><//>
|
|
264
|
+
<//>
|
|
265
|
+
<${Box} paddingX=${1}><${KeyHints} text=${choiceHints("back")} /><//>
|
|
266
|
+
<//>
|
|
267
|
+
`;
|
|
268
|
+
return html`
|
|
269
|
+
<${Fragment}>
|
|
270
|
+
<${Box} flexDirection="column" borderStyle="round" borderColor=${theme.warn} paddingX=${2} width=${panel}>
|
|
271
|
+
<${Text} bold color=${theme.warn}>${t("decks.mergeQuestion", { from: deck.name, into: merging.into.name, cards: t("count.cards", { count: deck.cards }) })}<//>
|
|
272
|
+
<${Text} dimColor>${t("decks.mergeNote", { from: deck.name, into: merging.into.name, days: TRASH_DAYS })}<//>
|
|
273
|
+
${differ(deck, merging.into) && html`<${Text} color=${theme.warn}>${t("decks.mergeLanguages", { from: deck.name, into: merging.into.name, fromPair: pairText(deck.languages), intoPair: pairText(merging.into.languages) })}<//>`}
|
|
274
|
+
<${Box} marginTop=${1}><${Choice} options=${[{ label: t("decks.mergeYes") }, { label: t("decks.mergeNo") }]} selected=${merging.selected} onMove=${(selected) => setMerging((m) => ({ ...m, selected }))} onPick=${(i) => (i === 0 ? merge(deck, merging.into) : back())} onCancel=${() => setMerging((m) => ({ ...m, into: null, selected: 0 }))} /><//>
|
|
275
|
+
<//>
|
|
276
|
+
<${Box} paddingX=${1}><${KeyHints} text=${choiceHints("back")} /><//>
|
|
277
|
+
<//>
|
|
278
|
+
`;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (deleting) {
|
|
282
|
+
const { deck } = deleting;
|
|
283
|
+
return html`
|
|
284
|
+
<${Fragment}>
|
|
285
|
+
<${Box} flexDirection="column" borderStyle="round" borderColor=${theme.bad} paddingX=${2} width=${panel}>
|
|
286
|
+
<${Text} bold color=${theme.bad}>${t("decks.deleteQuestion", { deck: deck.name, cards: t("count.cards", { count: deck.cards }) })}<//>
|
|
287
|
+
<${Text} dimColor>${t("decks.deleteNote", { days: TRASH_DAYS })}<//>
|
|
288
|
+
<${Box} marginTop=${1}>
|
|
289
|
+
<${Choice} options=${[{ label: t("decks.deleteYes"), danger: true }, { label: t("decks.deleteNo") }]} selected=${deleting.selected} onMove=${(selected) => setDeleting((d) => ({ ...d, selected }))} onPick=${(i) => (i === 0 ? remove(deck) : setDeleting(null))} onCancel=${() => setDeleting(null)} />
|
|
290
|
+
<//>
|
|
291
|
+
<//>
|
|
292
|
+
<${Box} paddingX=${1}><${KeyHints} text=${choiceHints("cancel")} /><//>
|
|
293
|
+
<//>
|
|
294
|
+
`;
|
|
295
|
+
}
|
|
296
|
+
|
|
139
297
|
if (menu) {
|
|
140
298
|
const { deck } = menu;
|
|
141
299
|
const guessedNote = deck.languages.guessed && deck.cards > 0 && (isKnown(deck.languages.front) || isKnown(deck.languages.back)) ? ` · ${t("languages.guessed")}` : "";
|
|
@@ -150,7 +308,10 @@ export function Decks({ current, actions, onPick, onNew, onClose, onDirections,
|
|
|
150
308
|
{ label: t("decks.askRow"), note: deck.directions === "both" ? t("add.bothWays") : how },
|
|
151
309
|
{ label: t("decks.languagesRow"), note: pairText(deck.languages) + guessedNote },
|
|
152
310
|
...(deck.learning ? [{ label: t("decks.learningRow"), note: languageName(deck.learning.lang) + (deck.learning.sure ? "" : ` · ${t("languages.guessShort")}`) }] : []),
|
|
153
|
-
...(deck.languages.guessed ? [] : [{ label: t("decks.detectRow") }])
|
|
311
|
+
...(deck.languages.guessed ? [] : [{ label: t("decks.detectRow") }]),
|
|
312
|
+
{ label: t("decks.renameRow") },
|
|
313
|
+
...(own.length >= 2 ? [{ label: t("decks.mergeRow") }] : []),
|
|
314
|
+
{ label: t("decks.deleteRow"), note: t("count.cards", { count: deck.cards }), danger: true }
|
|
154
315
|
]}
|
|
155
316
|
selected=${menu.selected}
|
|
156
317
|
onMove=${(selected) => setMenu((m) => ({ ...m, selected }))}
|
|
@@ -179,6 +340,7 @@ export function Decks({ current, actions, onPick, onNew, onClose, onDirections,
|
|
|
179
340
|
`;
|
|
180
341
|
}
|
|
181
342
|
|
|
343
|
+
const mixing = own.length >= 2; // with two decks or more, each shows whether it's practised (space)
|
|
182
344
|
// a deck's languages show in the list once the cards tell at least one
|
|
183
345
|
const languagesNote = (d) => (d.tour || !d.cards ? "" : d.learning ? t("decks.learningShort", { language: languageName(d.learning.lang) }) : isKnown(d.languages.front) && isKnown(d.languages.back) ? pairText(d.languages) : "");
|
|
184
346
|
|
|
@@ -190,10 +352,14 @@ export function Decks({ current, actions, onPick, onNew, onClose, onDirections,
|
|
|
190
352
|
html`
|
|
191
353
|
<${Box} marginTop=${1}>
|
|
192
354
|
<${Choice}
|
|
193
|
-
options=${[
|
|
355
|
+
options=${[
|
|
356
|
+
...decks.map((d) => ({ label: `${mixing ? (practised.includes(d.name) ? "■ " : "□ ") : ""}${d.name}`, note: [t("count.cards", { count: d.cards }), languagesNote(d), d.tour && t("decks.tour"), !mix && d.name === current && t("decks.now")].filter(Boolean).join(" · ") })),
|
|
357
|
+
...(own.length >= 2 ? [{ label: t("decks.allRow"), note: [t("count.decks", { count: own.length }), mix === "all" && t("decks.now")].filter(Boolean).join(" · ") }] : []),
|
|
358
|
+
{ label: t("decks.newDeck") }
|
|
359
|
+
]}
|
|
194
360
|
selected=${picked}
|
|
195
361
|
onMove=${setPicked}
|
|
196
|
-
onPick=${(i) => (i === decks.length ? onNew() : onPick(decks[i].name))}
|
|
362
|
+
onPick=${(i) => (i === decks.length && own.length >= 2 ? (onPractise({ deck: current, mix: "all" }), onClose()) : i >= decks.length ? onNew() : onPick(decks[i].name))}
|
|
197
363
|
onCancel=${onClose}
|
|
198
364
|
/>
|
|
199
365
|
<//>
|
|
@@ -201,7 +367,7 @@ export function Decks({ current, actions, onPick, onNew, onClose, onDirections,
|
|
|
201
367
|
${message && html`<${Box} marginTop=${1}><${Text} color=${theme.good}>${message}<//><//>`}
|
|
202
368
|
${error && html`<${Box} marginTop=${1}><${Text} color=${theme.bad}>${error}<//><//>`}
|
|
203
369
|
<//>
|
|
204
|
-
<${Box} paddingX=${1}><${KeyHints} text=${decks?.[picked] && !decks[picked].tour ? t("keyHints.decks", { choose: choiceHints() }) : choiceHints()} /><//>
|
|
370
|
+
<${Box} paddingX=${1}><${KeyHints} text=${(undo ? `${t("keyHints.undo")} · ` : "") + (decks?.[picked] && !decks[picked].tour ? (mix ? t("keyHints.decksMixing") : t(own.length >= 2 ? "keyHints.decksTogether" : "keyHints.decks", { choose: choiceHints() })) : choiceHints())} /><//>
|
|
205
371
|
<//>
|
|
206
372
|
`;
|
|
207
373
|
}
|
package/src/ui/Help.js
CHANGED
|
@@ -2,7 +2,6 @@ import { Fragment } from "react";
|
|
|
2
2
|
import { Box, useInput } from "ink";
|
|
3
3
|
import { t } from "../i18n.js";
|
|
4
4
|
import { MAX_FREEZES } from "../progress.js";
|
|
5
|
-
import { BOX_INTERVALS_DAYS } from "../scheduler.js";
|
|
6
5
|
import { cellWidth, html, KeyHints, Text, theme, usePanelWidth } from "./kit.js";
|
|
7
6
|
|
|
8
7
|
// built at render time, so the texts follow the app language
|
|
@@ -16,7 +15,7 @@ const keys = () => [
|
|
|
16
15
|
];
|
|
17
16
|
|
|
18
17
|
const how = () => [
|
|
19
|
-
t("help.how.
|
|
18
|
+
t("help.how.spacing"),
|
|
20
19
|
t("help.how.typos"),
|
|
21
20
|
t("help.how.cards"),
|
|
22
21
|
t("help.how.streak"),
|
|
@@ -62,7 +61,7 @@ const Section = ({ title, children }) => html`
|
|
|
62
61
|
<//>
|
|
63
62
|
`;
|
|
64
63
|
|
|
65
|
-
// How Dracosh works, on one screen: the keys, the rules behind the
|
|
64
|
+
// How Dracosh works, on one screen: the keys, the rules behind the spacing and the streak,
|
|
66
65
|
// and what you can do from the shell.
|
|
67
66
|
export function Help({ onClose }) {
|
|
68
67
|
const panel = usePanelWidth();
|
package/src/ui/Import.js
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { Fragment, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { Box, useInput } from "ink";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { basename, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { t } from "../i18n.js";
|
|
7
|
+
import { plainFront } from "../cardline.js";
|
|
8
|
+
import { planCounts } from "../importer.js";
|
|
9
|
+
import { deckLanguages, isKnown, languageName } from "../language.js";
|
|
10
|
+
import { cardText, deckFromFile, describeRead, issueText, readImportFile } from "../transfer.js";
|
|
11
|
+
import { AnswerInput } from "./AnswerInput.js";
|
|
12
|
+
import { Choice, choiceHints } from "./Choice.js";
|
|
13
|
+
import { cutToWidth, html, KeyHints, Text, theme, usePanelWidth } from "./kit.js";
|
|
14
|
+
|
|
15
|
+
const SHOWN = 3; // cards of each deck, changed cards and lines that can't be added, before "… and N more"
|
|
16
|
+
const SETTLE_MS = 400; // a key right after a screen appears is the second half of the Enter before it
|
|
17
|
+
|
|
18
|
+
// A path as a terminal pastes a file dragged into it: in quotes, with its spaces escaped, or as a
|
|
19
|
+
// file:// address; "~" is your home folder
|
|
20
|
+
export function cleanPath(typed) {
|
|
21
|
+
let path = typed.trim();
|
|
22
|
+
if (/^(['"]).*\1$/.test(path)) path = path.slice(1, -1);
|
|
23
|
+
else path = path.replace(/\\(.)/g, "$1");
|
|
24
|
+
if (path.startsWith("file://")) {
|
|
25
|
+
try {
|
|
26
|
+
path = fileURLToPath(path);
|
|
27
|
+
} catch {
|
|
28
|
+
// not a file address after all: read as typed
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (path === "~" || path.startsWith("~/")) path = homedir() + path.slice(1);
|
|
32
|
+
return path && resolve(path);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const answers = (back) => back.join("; ");
|
|
36
|
+
const sideText = (card) => (card.cloze ? plainFront(card.front) : answers(card.back));
|
|
37
|
+
|
|
38
|
+
// the next question a file still needs, or the review once there is none
|
|
39
|
+
function stepFor(plan, choices) {
|
|
40
|
+
if (plan.problems.some((p) => p.issue === "noDeck") && !choices.deckName) return "deck";
|
|
41
|
+
if (plan.read.splittable && choices.split === null) return "split";
|
|
42
|
+
return sampleOf(unaskedOf(plan, choices)) ? "direction" : "review";
|
|
43
|
+
}
|
|
44
|
+
const unaskedOf = (plan, choices) => plan.decks.filter((deck) => !deck.deck && !deck.direction && !choices.directions[deck.name]);
|
|
45
|
+
// a card of the decks still to be asked about, to show which way it would ask (cloze cards ask their gaps)
|
|
46
|
+
const sampleOf = (decks) => decks.flatMap((deck) => deck.items).find((item) => !item.fields.cloze)?.fields ?? null;
|
|
47
|
+
|
|
48
|
+
// /import: the same import as `dracosh import`, asked on screen. A file's path (typed, or a file dragged
|
|
49
|
+
// in), then the questions the file needs (which deck, several answers in one, which way new decks ask),
|
|
50
|
+
// then what it would do; nothing is saved before you say so, and Esc goes back a step. `actions`: the
|
|
51
|
+
// library's (manage.js); `fromWelcome`: opened from the welcome, where there was no tour to speak of.
|
|
52
|
+
// onDone({ deck, removed, added }) after an import: the deck to practise (null: stay), the tour's cards
|
|
53
|
+
// gone with it; onCancel when nothing was saved.
|
|
54
|
+
export function ImportScreen({ actions, onDone, onCancel, fromWelcome = false, read = readImportFile }) {
|
|
55
|
+
const panel = usePanelWidth();
|
|
56
|
+
const [step, setStep] = useState("path"); // path | reading | deck | split | direction | review | saving | done
|
|
57
|
+
const [history, setHistory] = useState([]); // the steps behind this one, for Esc: { step, choices, plan }
|
|
58
|
+
const [error, setError] = useState("");
|
|
59
|
+
const [source, setSource] = useState(null); // { file, text, list, isPackage, csv }
|
|
60
|
+
const [choices, setChoices] = useState(null);
|
|
61
|
+
const [plan, setPlan] = useState(null);
|
|
62
|
+
const [selected, setSelected] = useState(0);
|
|
63
|
+
const [naming, setNaming] = useState(false); // typing another deck's name
|
|
64
|
+
const [own, setOwn] = useState([]); // your decks, to put the cards in
|
|
65
|
+
const [result, setResult] = useState(null);
|
|
66
|
+
const [typed, setTyped] = useState({ text: "", key: 0 }); // the path as typed, kept when it can't be read
|
|
67
|
+
const busy = useRef(false);
|
|
68
|
+
const shownAt = useRef(0);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
shownAt.current = Date.now();
|
|
71
|
+
}, [step, naming]);
|
|
72
|
+
// a choice made by a double Enter, on a screen not yet seen, doesn't count
|
|
73
|
+
const settled = (pick) => (...args) => (Date.now() - shownAt.current < SETTLE_MS ? undefined : pick(...args));
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
actions.ownDecks().then(setOwn, () => {});
|
|
77
|
+
}, []);
|
|
78
|
+
|
|
79
|
+
useInput((input, key) => {
|
|
80
|
+
if (step === "done" && (key.return || key.escape) && Date.now() - shownAt.current >= SETTLE_MS) onDone(result.next);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
function advance(made, picked, from = { step, choices, plan }) {
|
|
84
|
+
setHistory((list) => [...list, from]);
|
|
85
|
+
setPlan(made);
|
|
86
|
+
setChoices(picked);
|
|
87
|
+
setSelected(0);
|
|
88
|
+
setNaming(false);
|
|
89
|
+
setError("");
|
|
90
|
+
setStep(stepFor(made, picked));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// one step back; from the first question, back to the path; from the path, out
|
|
94
|
+
function back() {
|
|
95
|
+
if (naming) return setNaming(false);
|
|
96
|
+
const last = history.at(-1);
|
|
97
|
+
if (!last || step === "path") return onCancel();
|
|
98
|
+
setHistory((list) => list.slice(0, -1));
|
|
99
|
+
setStep(last.step);
|
|
100
|
+
setChoices(last.choices);
|
|
101
|
+
setPlan(last.plan);
|
|
102
|
+
setSelected(0);
|
|
103
|
+
setError("");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function replan(picked) {
|
|
107
|
+
try {
|
|
108
|
+
const made = await actions.previewImport(source, picked);
|
|
109
|
+
// a deck name that can't take the cards (the tour's, or too long) is asked again
|
|
110
|
+
const refused = step === "deck" && made.problems.find((p) => p.issue === "tour" || p.issue === "tooLong");
|
|
111
|
+
if (refused && !made.decks.length) return setError(issueText(refused, source.isPackage));
|
|
112
|
+
advance(made, picked);
|
|
113
|
+
} catch (err) {
|
|
114
|
+
setError(err.message);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function open(text) {
|
|
119
|
+
setTyped((now) => ({ text, key: now.key + 1 }));
|
|
120
|
+
const file = cleanPath(text);
|
|
121
|
+
if (!file) return setError(t("importScreen.needPath"));
|
|
122
|
+
setError("");
|
|
123
|
+
setStep("reading");
|
|
124
|
+
try {
|
|
125
|
+
const src = { file, ...(await read(file)) };
|
|
126
|
+
const picked = { deck: null, deckName: null, csv: src.csv, directions: {}, split: null };
|
|
127
|
+
const made = await actions.previewImport(src, { ...picked, split: false });
|
|
128
|
+
if (!made.read.count) throw new Error(t("importScreen.empty"));
|
|
129
|
+
setSource(src);
|
|
130
|
+
advance(made, picked, { step: "path", choices: null, plan: null });
|
|
131
|
+
} catch (err) {
|
|
132
|
+
setError(err.message);
|
|
133
|
+
setStep("path");
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function save(update) {
|
|
138
|
+
if (busy.current) return;
|
|
139
|
+
busy.current = true;
|
|
140
|
+
setStep("saving");
|
|
141
|
+
try {
|
|
142
|
+
const done = await actions.importCards(source, { ...choices, split: Boolean(choices.split) }, { update });
|
|
143
|
+
const first = done.decks.find((deck) => deck.isNew && deck.added) ?? done.decks.find((deck) => deck.added) ?? done.decks.find((deck) => deck.updated);
|
|
144
|
+
setResult({ ...done, next: { deck: first?.name ?? null, removed: done.removedTour, added: done.added, updated: done.updated } });
|
|
145
|
+
setStep("done");
|
|
146
|
+
} catch (err) {
|
|
147
|
+
setError(t("quiz.saveFailed", { error: err.message }));
|
|
148
|
+
setStep("review");
|
|
149
|
+
} finally {
|
|
150
|
+
busy.current = false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const frame = (body, hints) => html`
|
|
155
|
+
<${Fragment}>
|
|
156
|
+
<${Box} flexDirection="column" borderStyle="round" borderColor=${theme.accent} paddingX=${2} width=${panel}>
|
|
157
|
+
<${Text} bold color=${theme.accent}>${t("importScreen.title")}<//>
|
|
158
|
+
${source && plan && step !== "path" && step !== "reading" && html`<${Text} dimColor>${t("import.reading", { file: basename(source.file), what: describeRead(plan.read) })}<//>`}
|
|
159
|
+
${body}
|
|
160
|
+
${error && html`<${Box} marginTop=${1}><${Text} color=${theme.bad}>${error}<//><//>`}
|
|
161
|
+
<//>
|
|
162
|
+
<${Box} paddingX=${1}><${KeyHints} text=${hints} /><//>
|
|
163
|
+
<//>
|
|
164
|
+
`;
|
|
165
|
+
const indented = (key, content, props = {}) => html`<${Box} key=${key} paddingLeft=${2}><${Text} ...${props}>${content}<//><//>`;
|
|
166
|
+
|
|
167
|
+
if (step === "path" || step === "reading")
|
|
168
|
+
return frame(
|
|
169
|
+
html`
|
|
170
|
+
<${Box} flexDirection="column" marginTop=${1}>
|
|
171
|
+
<${Text}>${t("importScreen.pathLabel")}<//>
|
|
172
|
+
<${Text} dimColor>${t("importScreen.pathHint")}<//>
|
|
173
|
+
<${Box} marginTop=${1}>${step === "reading" ? html`<${Text} dimColor>${t("importScreen.reading")}<//>` : html`<${AnswerInput} key=${typed.key} plain escLeaves initial=${typed.text} onSubmit=${open} onExit=${onCancel} onChange=${() => setError("")} />`}<//>
|
|
174
|
+
<//>
|
|
175
|
+
`,
|
|
176
|
+
t("keyHints.importPath")
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
if (step === "deck") {
|
|
180
|
+
const suggested = deckFromFile(source.file);
|
|
181
|
+
const sample = plan.problems.filter((p) => p.issue === "noDeck").slice(0, SHOWN);
|
|
182
|
+
const mine = own.find((deck) => deck.name.toLowerCase() === suggested.toLowerCase());
|
|
183
|
+
const options = [
|
|
184
|
+
...(suggested && !mine ? [{ name: suggested, label: t("importScreen.newDeck", { deck: suggested }) }] : []),
|
|
185
|
+
...own.map((deck) => ({ name: deck.name, label: deck.name, note: t("count.cards", { count: deck.cards }) })),
|
|
186
|
+
{ name: null, label: t("importScreen.otherName") }
|
|
187
|
+
];
|
|
188
|
+
const pick = (i) => (options[i].name ? replan({ ...choices, deckName: options[i].name }) : setNaming(true));
|
|
189
|
+
return frame(
|
|
190
|
+
html`
|
|
191
|
+
<${Box} flexDirection="column" marginTop=${1}>
|
|
192
|
+
<${Text} dimColor>${t("importScreen.fromFile")}<//>
|
|
193
|
+
${sample.map((p, i) => indented(i, p.text.replace(/\t/g, " "), { dimColor: true, wrap: "truncate-end" }))}
|
|
194
|
+
<${Box} marginTop=${1}><${Text} bold>${t("importScreen.deckLabel")}<//><//>
|
|
195
|
+
<${Box} marginTop=${1}>
|
|
196
|
+
${naming
|
|
197
|
+
? html`<${AnswerInput} plain escLeaves onSubmit=${(name) => (name.trim() ? replan({ ...choices, deckName: name.trim() }) : setError(t("add.needName")))} onExit=${back} onChange=${() => setError("")} />`
|
|
198
|
+
: html`<${Choice} options=${options} selected=${Math.min(selected, options.length - 1)} onMove=${setSelected} onPick=${settled(pick)} onCancel=${back} />`}
|
|
199
|
+
<//>
|
|
200
|
+
<//>
|
|
201
|
+
`,
|
|
202
|
+
naming ? t("keyHints.importName") : choiceHints("back")
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (step === "split")
|
|
207
|
+
return frame(
|
|
208
|
+
html`
|
|
209
|
+
<${Box} flexDirection="column" marginTop=${1}>
|
|
210
|
+
<${Text}>${t("import.listed", { count: plan.read.splittable, example: cutToWidth(plan.read.splitExample, 40) })}<//>
|
|
211
|
+
<${Text} bold>${t("import.splitAsk")}<//>
|
|
212
|
+
<${Box} marginTop=${1}><${Choice} options=${[{ label: t("importScreen.splitYes") }, { label: t("importScreen.splitNo") }]} selected=${selected} onMove=${setSelected} onPick=${settled((i) => replan({ ...choices, split: i === 0 }))} onCancel=${back} /><//>
|
|
213
|
+
<//>
|
|
214
|
+
`,
|
|
215
|
+
choiceHints("back")
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
if (step === "direction") {
|
|
219
|
+
const unasked = unaskedOf(plan, choices);
|
|
220
|
+
const sample = sampleOf(unasked);
|
|
221
|
+
const ways = ["forward", "backward", "both"];
|
|
222
|
+
const options = [
|
|
223
|
+
{ label: `${cutToWidth(sample.front, 24)} → ?`, note: t("add.youType", { answer: cutToWidth(answers(sample.back), 24) }) },
|
|
224
|
+
{ label: `${cutToWidth(answers(sample.back), 24)} → ?`, note: t("add.youType", { answer: cutToWidth(sample.front, 24) }) },
|
|
225
|
+
{ label: t("add.bothWays"), note: t("add.bothWaysNote") }
|
|
226
|
+
];
|
|
227
|
+
const pick = (i) => replan({ ...choices, directions: { ...choices.directions, ...Object.fromEntries(unasked.map((deck) => [deck.name, ways[i]])) } });
|
|
228
|
+
return frame(
|
|
229
|
+
html`
|
|
230
|
+
<${Box} flexDirection="column" marginTop=${1}>
|
|
231
|
+
<${Text} bold>${unasked.length === 1 ? t("add.directionQuestion", { deck: unasked[0].name }) : t("import.directionTitleMany", { count: unasked.length })}<//>
|
|
232
|
+
<${Box} marginTop=${1}><${Choice} options=${options} selected=${selected} onMove=${setSelected} onPick=${settled(pick)} onCancel=${back} /><//>
|
|
233
|
+
<${Box} marginTop=${1}><${Text} dimColor>${t("add.directionLater")}<//><//>
|
|
234
|
+
<//>
|
|
235
|
+
`,
|
|
236
|
+
choiceHints("back")
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (step === "done") {
|
|
241
|
+
const lines = result.decks.map((deck) =>
|
|
242
|
+
deck.isNew ? t("import.doneNew", { deck: deck.name, count: deck.added }) : !deck.added ? t("import.doneOnlyUpdated", { deck: deck.name, count: deck.updated }) : t("import.done", { deck: deck.name, count: deck.added }) + (deck.updated ? t("import.doneUpdated", { count: deck.updated }) : "")
|
|
243
|
+
);
|
|
244
|
+
return frame(
|
|
245
|
+
html`
|
|
246
|
+
<${Box} flexDirection="column" marginTop=${1}>
|
|
247
|
+
${lines.map((line, i) => html`<${Text} key=${i} color=${theme.good}>✓ ${line}<//>`)}
|
|
248
|
+
${result.slash.length > 0 && html`<${Text} dimColor>${t("importScreen.slashLeft", { count: result.slash.length })}<//>`}
|
|
249
|
+
${result.removedTour.length > 0 && !fromWelcome && html`<${Text} dimColor>${t("import.tourGone")}<//>`}
|
|
250
|
+
${result.backedUp && html`<${Text} dimColor>${t("importScreen.undo")}<//>`}
|
|
251
|
+
${result.next.deck && html`<${Box} marginTop=${1}><${Text}>${t("importScreen.practise", { deck: result.next.deck })}<//><//>`}
|
|
252
|
+
<//>
|
|
253
|
+
`,
|
|
254
|
+
t("keyHints.importDone")
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// review (and saving): what the file would add and change, and the go-ahead
|
|
259
|
+
const counts = planCounts(plan);
|
|
260
|
+
const problems = plan.problems.filter((p) => p.issue !== "noDeck");
|
|
261
|
+
const changed = plan.decks.flatMap((deck) => deck.items.filter((item) => item.kind === "changed"));
|
|
262
|
+
const nested = source.isPackage && plan.decks.find((deck) => !deck.deck && deck.name.includes("::"));
|
|
263
|
+
const options = [
|
|
264
|
+
counts.new > 0 && { id: "add", label: t("importScreen.add", { count: counts.new }) },
|
|
265
|
+
counts.changed > 0 && { id: "both", label: counts.new ? t("importScreen.addUpdate", { cards: t("count.cards", { count: counts.new }), count: counts.changed }) : t("importScreen.update", { count: counts.changed }) },
|
|
266
|
+
{ id: "cancel", label: counts.new || counts.changed ? t("importScreen.cancel") : t("importScreen.close") }
|
|
267
|
+
].filter(Boolean);
|
|
268
|
+
return frame(
|
|
269
|
+
html`
|
|
270
|
+
<${Box} flexDirection="column">
|
|
271
|
+
${plan.decks.map((target) => {
|
|
272
|
+
const added = target.items.filter((item) => item.kind === "new");
|
|
273
|
+
if (target.deck && !added.length) return null;
|
|
274
|
+
const languages = !target.deck && deckLanguages({ name: target.name }, target.items.map((item) => item.fields));
|
|
275
|
+
const sure = languages && isKnown(languages.front) && isKnown(languages.back) && languages.front !== languages.back;
|
|
276
|
+
return html`
|
|
277
|
+
<${Box} key=${target.name} flexDirection="column" marginTop=${1}>
|
|
278
|
+
<${Text} bold>${target.deck ? t("import.intoDeck", { deck: target.name, cards: t("count.cards", { count: target.cards }) }) : t("import.intoNewDeck", { deck: target.name })}<//>
|
|
279
|
+
${added.slice(0, SHOWN).map((item, i) => indented(i, html`<${Fragment}><${Text} color=${theme.good}>+<//> ${cardText(item.fields)}${item.fields.example ? html`<${Text} dimColor> // ${item.fields.example}<//>` : ""}<//>`, { wrap: "truncate-end" }))}
|
|
280
|
+
${added.length > SHOWN && indented("more", t("import.more", { count: added.length - SHOWN }), { dimColor: true })}
|
|
281
|
+
${languages && indented("languages", sure ? t("import.languagesGuess", { front: languageName(languages.front), back: languageName(languages.back) }) : t("import.languagesUnsure"), { dimColor: true })}
|
|
282
|
+
<//>
|
|
283
|
+
`;
|
|
284
|
+
})}
|
|
285
|
+
${nested && html`<${Box} marginTop=${1}><${Text} dimColor>${t("import.subdecks", { deck: nested.name })}<//><//>`}
|
|
286
|
+
<${Box} marginTop=${1}><${Text}>${[t("import.counts.new", { count: counts.new }), counts.same && t("import.counts.same", { count: counts.same }), counts.changed && t("import.counts.changed", { count: counts.changed })].filter(Boolean).join(" · ")}<//><//>
|
|
287
|
+
${changed.length > 0 &&
|
|
288
|
+
html`
|
|
289
|
+
<${Box} flexDirection="column">
|
|
290
|
+
${changed.slice(0, SHOWN).map((item, i) => indented(i, `~ ${plainFront(item.card.front)}: ${sideText(item.card)} → ${sideText(item.fields)}`, { wrap: "truncate-end" }))}
|
|
291
|
+
${changed.length > SHOWN && indented("more", t("import.more", { count: changed.length - SHOWN }), { dimColor: true })}
|
|
292
|
+
<${Text} dimColor>${t("importScreen.changedNote")}<//>
|
|
293
|
+
<//>
|
|
294
|
+
`}
|
|
295
|
+
${problems.length > 0 &&
|
|
296
|
+
html`
|
|
297
|
+
<${Box} flexDirection="column" marginTop=${1}>
|
|
298
|
+
<${Text} color=${theme.warn}>${t(source.isPackage ? "import.problemsNotes" : "import.problems", { count: problems.length })}<//>
|
|
299
|
+
${problems.slice(0, SHOWN).map((p, i) => indented(i, t(source.isPackage ? "importScreen.problemNote" : "importScreen.problemLine", { line: p.line, issue: issueText(p, source.isPackage), text: p.text.replace(/\t/g, " ") }), { dimColor: true, wrap: "truncate-end" }))}
|
|
300
|
+
${problems.length > SHOWN && indented("more", t("import.more", { count: problems.length - SHOWN }), { dimColor: true })}
|
|
301
|
+
<//>
|
|
302
|
+
`}
|
|
303
|
+
${plan.read.media > 0 && html`<${Text} dimColor>${t("import.mediaLeft", { count: plan.read.media })}<//>`}
|
|
304
|
+
${plan.read.ignored.length > 0 && html`<${Text} dimColor>${t("import.ignored", { count: plan.read.ignored.length, lines: plan.read.ignored.slice(0, 5).join(", ") + (plan.read.ignored.length > 5 ? "…" : "") })}<//>`}
|
|
305
|
+
${plan.read.anki && !plan.read.html && html`<${Text} color=${theme.warn}>${t("import.ankiNoHtml")}<//>`}
|
|
306
|
+
${!counts.new && !counts.changed && html`<${Box} marginTop=${1}><${Text}>${t("import.nothing")}<//><//>`}
|
|
307
|
+
<${Box} marginTop=${1}>
|
|
308
|
+
${step === "saving"
|
|
309
|
+
? html`<${Text} dimColor>${t("importScreen.saving")}<//>`
|
|
310
|
+
: html`<${Choice} options=${options} selected=${Math.min(selected, options.length - 1)} onMove=${setSelected} onPick=${settled((i) => (options[i].id === "cancel" ? onCancel() : save(options[i].id === "both")))} onCancel=${back} />`}
|
|
311
|
+
<//>
|
|
312
|
+
<//>
|
|
313
|
+
`,
|
|
314
|
+
choiceHints("back")
|
|
315
|
+
);
|
|
316
|
+
}
|