@lotics/ui 12.1.1 → 13.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.
@@ -1,456 +0,0 @@
1
- import { useCallback, useEffect, useMemo, useState } from "react";
2
- import { Pressable, ScrollView, StyleSheet, View } from "react-native";
3
- import { Text } from "@lotics/ui/text";
4
- import { colors, solid, asColorName } from "@lotics/ui/colors";
5
- import { Icon } from "@lotics/ui/icon";
6
- import { CheckCircle } from "@lotics/ui/check_circle";
7
- import { OptionBadge, type OptionValue } from "@lotics/ui/option_badge";
8
- import { SearchInput } from "@lotics/ui/search_input";
9
- import { FilterChip } from "@lotics/ui/filter_chip";
10
- import { OptionList } from "@lotics/ui/option_list";
11
- import { InlineTextInput } from "@lotics/ui/inline_text_input";
12
- import { InlineDatePicker } from "@lotics/ui/inline_date_picker";
13
- import { InlineSelect } from "@lotics/ui/inline_select";
14
- import { Select } from "@lotics/ui/select";
15
- import { CaptureRow } from "@lotics/ui/capture_row";
16
- import { Button } from "@lotics/ui/button";
17
- import { FilesEditor } from "@lotics/ui/files_editor";
18
- import type { DisplayFile } from "@lotics/ui/file_thumbnail";
19
- import { Composer } from "@lotics/ui/composer";
20
- import { AgentRun, type AgentRunItem } from "@lotics/ui/agent_run";
21
- import { Change, ChangeReview, ChangeReviewActions, ChangeReviewHeader, ChangeSummary, type ChangeStatus } from "@lotics/ui/change_review";
22
- import { Dialog, DialogHeader, DialogHeaderTitle, DialogScrollArea, DialogFooter } from "@lotics/ui/dialog";
23
- import { CompletionState } from "@lotics/ui/completion_state";
24
- import { Confidence, type ConfidenceLevel } from "@lotics/ui/confidence";
25
- import { formatDate, toISODate } from "@lotics/ui/format_date";
26
-
27
- type TagOption = { value: string; label: string };
28
-
29
- // ─────────────────────────────────────────────────────────────────────────────
30
- // Template · Task list — the Apple-Reminders shape for PERSONAL lists.
31
- // There's no Task component: a row is composed directly from primitives
32
- // (CheckCircle + an inline-editable title + a quiet meta line), which is the most
33
- // flexible way to build a task surface. Quiet, scannable rows you tick to finish
34
- // and tap to expand in place; the note sits below the title in a light tone. No
35
- // assignee (the list is yours). The sibling tpl_task_board is the Linear columns
36
- // shape for a manager. Tick the ring → done; tap the row → expand; click the title
37
- // → rename in place.
38
- // ─────────────────────────────────────────────────────────────────────────────
39
-
40
- type Status = "todo" | "doing" | "done";
41
- const STATUS: Record<Status, OptionValue> = {
42
- todo: { key: "todo", label: "To do", color: null },
43
- doing: { key: "doing", label: "Doing", color: "amber" },
44
- done: { key: "done", label: "Done", color: "emerald" },
45
- };
46
- const STATUS_OPTIONS = (Object.keys(STATUS) as Status[]).map((s) => ({ value: s, label: STATUS[s].label }));
47
-
48
- const TAGS: Record<string, OptionValue> = {
49
- client: { key: "client", label: "Client", color: "blue" },
50
- design: { key: "design", label: "Design", color: "cyan" },
51
- print: { key: "print", label: "Print", color: "amber" },
52
- urgent: { key: "urgent", label: "Urgent", color: "rose" },
53
- };
54
- const TAG_OPTIONS: TagOption[] = Object.values(TAGS).map((t) => ({ value: String(t.key), label: t.label }));
55
- const tagOf = (k: string): TagOption => ({ value: k, label: TAGS[k]?.label ?? k });
56
- const tagBadge = (t: TagOption): OptionValue => TAGS[t.value] ?? { key: t.value, label: t.label, color: null };
57
- const tagColor = (t: TagOption): string => solid(asColorName(TAGS[t.value]?.color));
58
- const renderTagBadge = (o: { value: string; label?: string }) => <OptionBadge value={tagBadge({ value: o.value, label: o.label ?? o.value })} variant="dot" />;
59
-
60
- interface Task {
61
- id: string;
62
- title: string;
63
- due: string | null;
64
- status: Status;
65
- tags: TagOption[];
66
- note: string;
67
- files: DisplayFile[];
68
- }
69
-
70
- const day = (n: number): string => {
71
- const d = new Date();
72
- d.setDate(d.getDate() + n);
73
- return toISODate(d);
74
- };
75
-
76
- // A self-contained SVG data-URI image so seeds preview offline in the gallery.
77
- const sampleImage = (label: string, fill: string): DisplayFile => ({
78
- id: `seed-${label}`,
79
- filename: `${label}.png`,
80
- mimeType: "image/png",
81
- url: "data:image/svg+xml," + encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="320" height="240"><rect width="320" height="240" fill="${fill}"/><text x="160" y="128" font-family="sans-serif" font-size="22" fill="white" text-anchor="middle">${label}</text></svg>`),
82
- });
83
-
84
- // New attachments map a picked browser File → a DisplayFile (local object URL).
85
- // A host wires its own upload here; the template just previews in place.
86
- let fileSeq = 0;
87
- const toDisplayFiles = (files: File[]): DisplayFile[] =>
88
- files.map((f) => ({ id: `f${++fileSeq}`, filename: f.name, mimeType: f.type || "application/octet-stream", url: URL.createObjectURL(f) }));
89
-
90
- const SEED: Task[] = [
91
- { id: "t1", title: "Send VITTORIA their quote", due: day(-2), status: "doing", tags: [tagOf("client"), tagOf("urgent")], note: "Waiting on production to confirm quantities.", files: [sampleImage("quote-draft", "#3b82f6")] },
92
- { id: "t2", title: "Finalize the gift-box packaging design", due: day(0), status: "doing", tags: [tagOf("design")], note: "", files: [] },
93
- { id: "t3", title: "Sign off the die-cut sample", due: `${day(0)}T15:00`, status: "todo", tags: [tagOf("design"), tagOf("print")], note: "Workshop visit booked for 3pm.", files: [sampleImage("die-cut", "#10b981"), sampleImage("sample-2", "#f59e0b")] },
94
- { id: "t4", title: "Order 300g ivory board stock", due: day(3), status: "todo", tags: [tagOf("print")], note: "", files: [] },
95
- { id: "t5", title: "Schedule the first delivery batch", due: day(9), status: "todo", tags: [], note: "", files: [] },
96
- { id: "t6", title: "Draft the 2026 print contract", due: null, status: "todo", tags: [tagOf("client")], note: "", files: [] },
97
- { id: "t7", title: "Update the Q3 price list", due: day(-5), status: "done", tags: [], note: "Sent to the sales team.", files: [] },
98
- ];
99
-
100
- type Group = "due" | "status";
101
- const GROUP_OPTIONS: { value: Group; label: string }[] = [
102
- { value: "due", label: "Due date" },
103
- { value: "status", label: "Status" },
104
- ];
105
- type SectionKey = "overdue" | "today" | "week" | "later" | "none" | "done" | Status;
106
- const DUE_SECTIONS: { key: SectionKey; label: string }[] = [
107
- { key: "overdue", label: "Overdue" },
108
- { key: "today", label: "Today" },
109
- { key: "week", label: "This week" },
110
- { key: "later", label: "Later" },
111
- { key: "none", label: "No date" },
112
- { key: "done", label: "Done" },
113
- ];
114
- const STATUS_SECTIONS: { key: SectionKey; label: string }[] = [
115
- { key: "todo", label: "To do" },
116
- { key: "doing", label: "Doing" },
117
- { key: "done", label: "Done" },
118
- ];
119
-
120
- function dueBucket(due: string | null): SectionKey {
121
- if (!due) return "none";
122
- const d = due.slice(0, 10);
123
- const today = day(0);
124
- if (d < today) return "overdue";
125
- if (d === today) return "today";
126
- if (d <= day(7)) return "week";
127
- return "later";
128
- }
129
- function dueInfo(due: string | null): { label: string; overdue: boolean } | null {
130
- if (!due) return null;
131
- return { label: formatDate(due, { format: "dayMonth" }), overdue: due.slice(0, 10) < day(0) };
132
- }
133
-
134
- // ── AI · draft tasks from notes — agent proposes, you keep/edit/drop ──────────
135
- type Phase = "idle" | "reading" | "review" | "done";
136
- interface Proposal { id: string; title: string; due: string | null; confidence: ConfidenceLevel; source: string }
137
- const DRAFT_STEPS: { label: string; detail: string }[] = [
138
- { label: "Split the notes into candidate items", detail: "6 lines" },
139
- { label: "Drop greetings and lines that aren't actions", detail: "kept 4" },
140
- { label: "Infer a due date from each phrase", detail: "2 dated · 2 left open" },
141
- ];
142
- const DRAFTED: Proposal[] = [
143
- { id: "d1", title: "Send VITTORIA the revised quote", due: day(1), confidence: "high", source: "“…told VITTORIA they'd have the updated quote by tomorrow.”" },
144
- { id: "d2", title: "Re-check the die-cut sample size with the workshop", due: day(3), confidence: "medium", source: "“…workshop to measure the sample again, maybe Thursday.”" },
145
- { id: "d3", title: "Order 300g ivory board for the gift-box run", due: null, confidence: "high", source: "“…order the ivory stock this week.”" },
146
- { id: "d4", title: "Sit in on the Tet carton press check", due: null, confidence: "low", source: "“…someone should be there for the Tet print run.”" },
147
- ];
148
-
149
- export function TplTasks() {
150
- const [tasks, setTasks] = useState<Task[]>(SEED);
151
- const [group, setGroup] = useState<Group | null>("due"); // null = ungrouped (cleared)
152
- const [expandedIds, setExpandedIds] = useState<Set<string>>(() => new Set());
153
- const toggleExpand = (id: string, open: boolean) =>
154
- setExpandedIds((s) => { const n = new Set(s); if (open) n.add(id); else n.delete(id); return n; });
155
- const [query, setQuery] = useState("");
156
- const [tagFilter, setTagFilter] = useState<string[]>([]);
157
- const [draft, setDraft] = useState("");
158
-
159
- const [draftOpen, setDraftOpen] = useState(false);
160
- const [phase, setPhase] = useState<Phase>("idle");
161
- const [revealed, setRevealed] = useState(0);
162
- const [proposals, setProposals] = useState<Proposal[]>([]);
163
- const [decisions, setDecisions] = useState<Record<string, ChangeStatus>>({});
164
- const [addedCount, setAddedCount] = useState(0);
165
-
166
- const patch = (id: string, next: Partial<Task>) =>
167
- setTasks((ts) => ts.map((t) => (t.id === id ? { ...t, ...next } : t)));
168
- const add = () => {
169
- const title = draft.trim();
170
- if (!title) return;
171
- setTasks((ts) => [...ts, { id: `n${ts.length}-${title.length}`, title, due: null, status: "todo", tags: [], note: "", files: [] }]);
172
- setDraft("");
173
- };
174
- const addFiles = (id: string, picked: File[]) =>
175
- setTasks((ts) => ts.map((t) => (t.id === id ? { ...t, files: [...t.files, ...toDisplayFiles(picked)] } : t)));
176
- const removeFile = (id: string, fileId: string) =>
177
- setTasks((ts) => ts.map((t) => (t.id === id ? { ...t, files: t.files.filter((f) => f.id !== fileId) } : t)));
178
-
179
-
180
- const startDraft = useCallback(() => { setRevealed(0); setPhase("reading"); }, []);
181
- const resetDraft = useCallback(() => { setProposals([]); setDecisions({}); setRevealed(0); setPhase("idle"); }, []);
182
- const closeDraft = useCallback(() => { setDraftOpen(false); resetDraft(); }, [resetDraft]);
183
- const editProposal = useCallback((id: string, p: Partial<Proposal>) =>
184
- setProposals((ps) => ps.map((x) => (x.id === id ? { ...x, ...p } : x))), []);
185
- const decide = useCallback((id: string, status: ChangeStatus | null) =>
186
- setDecisions((dec) => { const n = { ...dec }; if (status) n[id] = status; else delete n[id]; return n; }), []);
187
- const acceptedCount = proposals.filter((p) => decisions[p.id] === "accepted").length;
188
- const addAccepted = useCallback(() => {
189
- const accepted = proposals.filter((p) => decisions[p.id] === "accepted");
190
- setTasks((ts) => [...ts, ...accepted.map((p) => ({ id: `d-${p.id}`, title: p.title, due: p.due, status: "todo" as Status, tags: [], note: "", files: [] }))]);
191
- setAddedCount(accepted.length);
192
- setPhase("done");
193
- }, [proposals, decisions]);
194
-
195
- useEffect(() => {
196
- if (phase !== "reading") return;
197
- if (revealed >= DRAFT_STEPS.length) {
198
- const t = setTimeout(() => { setProposals(DRAFTED); setPhase("review"); }, 850);
199
- return () => clearTimeout(t);
200
- }
201
- const t = setTimeout(() => setRevealed((r) => r + 1), revealed === 0 ? 280 : 680);
202
- return () => clearTimeout(t);
203
- }, [phase, revealed]);
204
-
205
- const runItems: AgentRunItem[] = [
206
- { type: "text", id: "intro", text: "I read your notes and pulled out the work." },
207
- ...DRAFT_STEPS.slice(0, Math.min(revealed + 1, DRAFT_STEPS.length)).map((s, i): AgentRunItem => ({
208
- type: "step", id: `s${i}`, label: s.label, detail: i < revealed ? s.detail : undefined, status: i < revealed ? "done" : "running",
209
- })),
210
- ];
211
- if (revealed >= DRAFT_STEPS.length) {
212
- runItems.push({ type: "text", id: "outro", text: `Drafted ${DRAFTED.length} tasks — keep the ones that look right, edit any before adding.` });
213
- }
214
-
215
- const sections = useMemo(() => {
216
- const q = query.trim().toLowerCase();
217
- const pool = tasks.filter((t) => {
218
- if (q && !(t.title.toLowerCase().includes(q) || t.tags.some((tag) => tag.label.toLowerCase().includes(q)))) return false;
219
- if (tagFilter.length > 0 && !t.tags.some((tag) => tagFilter.includes(tag.value))) return false;
220
- return true;
221
- });
222
- const byDue = (a: Task, b: Task) => (a.due ?? "9999").localeCompare(b.due ?? "9999");
223
- if (!group) {
224
- return [{ key: "all" as SectionKey, label: "", items: [...pool].sort(byDue) }];
225
- }
226
- const defs = group === "due" ? DUE_SECTIONS : STATUS_SECTIONS;
227
- const inBucket = (t: Task, key: SectionKey) =>
228
- group === "due" ? (t.status === "done" ? key === "done" : dueBucket(t.due) === key) : t.status === key;
229
- return defs
230
- .map((s) => ({ ...s, items: pool.filter((t) => inBucket(t, s.key)).sort(byDue) }))
231
- .filter((s) => s.items.length > 0);
232
- }, [tasks, group, query, tagFilter]);
233
-
234
- return (
235
- <>
236
- <ScrollView style={{ flex: 1, backgroundColor: colors.white }} contentContainerStyle={{ paddingVertical: 28, paddingHorizontal: 20, paddingBottom: 96 }}>
237
- <View style={{ maxWidth: 680, width: "100%", alignSelf: "center", gap: 14 }}>
238
- <Text size="xxl" weight="semibold">Tasks</Text>
239
-
240
- <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
241
- <View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 8, flex: 1 }}>
242
- <View style={{ flexGrow: 1, flexBasis: 240, minWidth: 200, maxWidth: 360 }}>
243
- <SearchInput value={query} onChangeText={setQuery} placeholder="Search tasks" accessibilityLabel="Search tasks" />
244
- </View>
245
- <FilterChip label="Group by" summary={group ? GROUP_OPTIONS.find((g) => g.value === group)?.label : undefined} onClear={() => setGroup(null)} clearLabel="Clear grouping">
246
- {({ close }) => <OptionList search={{ mode: "none" }} options={GROUP_OPTIONS} value={group ?? undefined} onValueChange={(v) => v && setGroup(v)} onRequestClose={close} />}
247
- </FilterChip>
248
- <FilterChip
249
- label="Tag"
250
- summary={tagFilter.length > 0 ? <View style={styles.dots}>{tagFilter.map((v) => <View key={v} style={[styles.dot, { backgroundColor: tagColor(tagOf(v)) }]} />)}</View> : undefined}
251
- onClear={() => setTagFilter([])}
252
- clearLabel="Clear tag filter"
253
- >
254
- <OptionList search={{ mode: "none" }} multi options={TAG_OPTIONS} value={tagFilter} onValueChange={setTagFilter} renderOptionContent={(o) => <OptionBadge value={tagBadge({ value: o.value, label: o.label ?? o.value })} variant="dot" />} />
255
- </FilterChip>
256
- </View>
257
- <Button title="Draft from notes" color="primary" onPress={() => setDraftOpen(true)} />
258
- </View>
259
-
260
- {/* Capture — type to add; the submit button lives inside the field on the right. */}
261
- <View style={styles.capture}>
262
- <CaptureRow value={draft} onChangeText={setDraft} onSubmit={add} placeholder="Add a task…" accessibilityLabel="Add a task" />
263
- </View>
264
-
265
- <View>
266
- {sections.map((s) => (
267
- <View key={s.key} style={{ marginBottom: 16 }}>
268
- {s.label ? (
269
- <View style={styles.sectionHead}>
270
- <Text size="xs" weight="semibold" color={s.key === "overdue" ? "danger" : "muted"} style={styles.sectionLabel}>{s.label}</Text>
271
- <Text size="xs" color="muted" tabular>{s.items.length}</Text>
272
- </View>
273
- ) : null}
274
- {s.items.map((t) => {
275
- const open = expandedIds.has(t.id);
276
- const done = t.status === "done";
277
- const d = dueInfo(t.due);
278
- return (
279
- <View key={t.id}>
280
- {/* A row is NOT a single button: the ring, the title, and the expand
281
- affordance are SIBLING controls in a plain View. Wrapping the row in a
282
- Pressable accessibilityRole="button" while nesting CheckCircle +
283
- InlineTextInput (each renders a <button> on web) would put <button>s
284
- inside a <button> — invalid DOM + the inner controls drop out of the
285
- keyboard tab order. So the expand affordance is its own Pressable. */}
286
- <View style={styles.row}>
287
- <CheckCircle checked={done} onChange={(on) => patch(t.id, { status: on ? "done" : "todo" })} accessibilityLabel={t.title} />
288
- <View style={{ flex: 1 }}>
289
- <InlineTextInput background="transparent" value={t.title} onSave={(v) => patch(t.id, { title: v })} struck={done} accessibilityLabel="Title" />
290
- </View>
291
- <Pressable
292
- onPress={() => toggleExpand(t.id, !open)}
293
- accessibilityRole="button"
294
- accessibilityLabel={open ? `Collapse ${t.title}` : `Expand ${t.title}`}
295
- style={({ hovered }: { hovered?: boolean }) => [styles.expand, hovered ? styles.rowHover : null]}
296
- >
297
- <View style={styles.meta}>
298
- {t.files.length > 0 ? (
299
- <View style={styles.clip}>
300
- <Icon name="paperclip" size={13} color={colors.zinc[400]} />
301
- <Text size="xs" color="muted" tabular>{t.files.length}</Text>
302
- </View>
303
- ) : null}
304
- {t.tags.length > 0 ? (
305
- <View style={styles.dots}>{t.tags.map((tag) => <View key={tag.value} style={[styles.dot, { backgroundColor: tagColor(tag) }]} />)}</View>
306
- ) : null}
307
- {d ? <Text size="xs" weight="medium" color={d.overdue && !done ? "danger" : "muted"}>{d.label}</Text> : null}
308
- </View>
309
- <Icon name={open ? "chevron-up" : "chevron-down"} size={16} color={colors.zinc[300]} />
310
- </Pressable>
311
- </View>
312
- {open ? (
313
- <View style={styles.detail}>
314
- <Field label="Due">
315
- <InlineDatePicker background="transparent" value={t.due} optionalTime onSave={(v) => patch(t.id, { due: v })} placeholder="Set a due date" accessibilityLabel="Due date" />
316
- </Field>
317
- <Field label="Status">
318
- <InlineSelect background="transparent" value={t.status} options={STATUS_OPTIONS} onSave={(st) => patch(t.id, { status: st })} renderSelected={(o) => <OptionBadge value={STATUS[o.value as Status]} variant="dot" />} renderOptionContent={(o) => <OptionBadge value={STATUS[o.value as Status]} variant="dot" />} accessibilityLabel="Status" />
319
- </Field>
320
- <Field label="Tags">
321
- <Select multi searchable allowCustom value={t.tags.map((tag) => tag.value)} onValueChange={(next) => patch(t.id, { tags: next.map(tagOf) })} options={TAG_OPTIONS} renderSelected={renderTagBadge} renderOptionContent={renderTagBadge} style={{ borderColor: "transparent" }} placeholder="Add tags" accessibilityLabel="Tags" />
322
- </Field>
323
- <Field label="Note">
324
- <InlineTextInput background="transparent" value={t.note} onSave={(v) => patch(t.id, { note: v })} placeholder="Add a note…" accessibilityLabel="Note" />
325
- </Field>
326
- <Field label="Files" top>
327
- <FilesEditor files={t.files} itemSize={72} onAdd={(picked) => addFiles(t.id, picked)} onRemove={(id) => removeFile(t.id, id)} />
328
- </Field>
329
- </View>
330
- ) : null}
331
- </View>
332
- );
333
- })}
334
- </View>
335
- ))}
336
- </View>
337
- </View>
338
- </ScrollView>
339
-
340
- {/* Draft from notes — Composer → AgentRun → ChangeReview → commit. The review
341
- provider wraps the WHOLE dialog so the `Change`s (scroll area) and the
342
- commit bar (`DialogFooter`) share one review context. */}
343
- <ChangeReview>
344
- <Dialog open={draftOpen} onOpenChange={(o) => { if (!o) closeDraft(); }} maxWidth={620}>
345
- <DialogHeader><DialogHeaderTitle>Draft from notes</DialogHeaderTitle></DialogHeader>
346
- <DialogScrollArea>
347
- {phase === "idle" ? (
348
- <View style={{ gap: 12 }}>
349
- <Text size="sm" color="muted">Paste meeting notes, a brief, or an email. Lotics drafts tasks from it — nothing is added until you review and keep them.</Text>
350
- <Composer onSend={startDraft} placeholder="Paste your notes…" autoFocus sendLabel="Draft tasks" />
351
- </View>
352
- ) : null}
353
- {phase === "reading" ? <AgentRun items={runItems} state={revealed >= DRAFT_STEPS.length ? "done" : "streaming"} /> : null}
354
- {phase === "review" ? (
355
- <View style={{ gap: 8 }}>
356
- <ChangeReviewHeader title="Drafted tasks" />
357
- <Text size="sm" color="muted">{`${proposals.length} from your notes — keep, edit, or drop each. A “Low” mark is worth a glance.`}</Text>
358
- {proposals.map((p) => {
359
- const status = decisions[p.id] ?? "pending";
360
- const kept = status === "accepted";
361
- return (
362
- <Change
363
- key={p.id}
364
- id={p.id}
365
- status={status}
366
- onAccept={() => decide(p.id, "accepted")}
367
- onReject={() => decide(p.id, "rejected")}
368
- onUndo={() => decide(p.id, null)}
369
- >
370
- <TaskProposal proposal={p} onEdit={editProposal} />
371
- <ChangeSummary>
372
- <Text size="sm" numberOfLines={1} color={kept ? "default" : "muted"} style={kept ? undefined : { textDecorationLine: "line-through" }}>{p.title}</Text>
373
- </ChangeSummary>
374
- </Change>
375
- );
376
- })}
377
- </View>
378
- ) : null}
379
- {phase === "done" ? (
380
- <CompletionState title={`${addedCount} ${addedCount === 1 ? "task" : "tasks"} added`} summary="They're in your list, grouped by due date." />
381
- ) : null}
382
- </DialogScrollArea>
383
- {phase === "review" ? (
384
- <DialogFooter>
385
- <ChangeReviewActions onApply={addAccepted} onDiscard={resetDraft} applyLabel={`Add ${acceptedCount} ${acceptedCount === 1 ? "task" : "tasks"}`} />
386
- </DialogFooter>
387
- ) : phase === "done" ? (
388
- <DialogFooter>
389
- <Button title="Draft more" color="secondary" onPress={resetDraft} />
390
- <Button title="Done" color="primary" onPress={closeDraft} />
391
- </DialogFooter>
392
- ) : null}
393
- </Dialog>
394
- </ChangeReview>
395
- </>
396
- );
397
- }
398
-
399
- function TaskProposal({ proposal, onEdit }: { proposal: Proposal; onEdit: (id: string, p: Partial<Proposal>) => void }) {
400
- return (
401
- <View style={{ gap: 10 }}>
402
- <View style={{ flexDirection: "row", alignItems: "flex-start", gap: 12 }}>
403
- <View style={{ flex: 1 }}>
404
- <InlineTextInput background="transparent" value={proposal.title} onSave={(v) => onEdit(proposal.id, { title: v })} accessibilityLabel="Task title" />
405
- </View>
406
- <View style={{ paddingTop: 10 }}><Confidence level={proposal.confidence} /></View>
407
- </View>
408
- <View style={{ width: 200 }}>
409
- <InlineDatePicker background="transparent" value={proposal.due} onSave={(v) => onEdit(proposal.id, { due: v })} placeholder="No date" accessibilityLabel="Due date" />
410
- </View>
411
- <View style={styles.source}><Text size="xs" color="muted">{proposal.source}</Text></View>
412
- </View>
413
- );
414
- }
415
-
416
- function Field(props: { label: string; children: React.ReactNode; top?: boolean }) {
417
- return (
418
- <View style={{ flexDirection: "row", alignItems: props.top ? "flex-start" : "center", minHeight: 36 }}>
419
- <Text size="sm" color="muted" style={{ width: 116, paddingTop: props.top ? 8 : 0 }}>{props.label}</Text>
420
- <View style={{ flex: 1 }}>{props.children}</View>
421
- </View>
422
- );
423
- }
424
-
425
- const styles = StyleSheet.create({
426
- row: {
427
- flexDirection: "row",
428
- alignItems: "center",
429
- gap: 12,
430
- minHeight: 44,
431
- paddingHorizontal: 8,
432
- borderRadius: 10,
433
- },
434
- rowHover: { backgroundColor: colors.white },
435
- // The expand affordance — its own button (meta + chevron), sibling to the ring
436
- // and title so no interactive control nests inside another.
437
- // FIXED width so every title cell ends at the same x — the meta content
438
- // (clip count · tag dots · date) varies per row and right-aligns inside;
439
- // without it the title editors read ragged/misaligned across rows.
440
- expand: { flexDirection: "row", alignItems: "center", justifyContent: "flex-end", gap: 10, minHeight: 36, paddingHorizontal: 8, borderRadius: 8, width: 148 },
441
- capture: {
442
- borderBottomWidth: 1,
443
- borderBottomColor: colors.zinc[100],
444
- paddingBottom: 6,
445
- },
446
-
447
- sectionHead: { flexDirection: "row", alignItems: "center", gap: 8, paddingBottom: 6 },
448
- sectionLabel: { letterSpacing: 0.3, textTransform: "uppercase" },
449
- meta: { flexDirection: "row", alignItems: "center", justifyContent: "flex-end", gap: 10, flex: 1 },
450
- clip: { flexDirection: "row", alignItems: "center", gap: 2 },
451
- dots: { flexDirection: "row", alignItems: "center", gap: 4 },
452
- dot: { width: 8, height: 8, borderRadius: 999 },
453
- // ring (20) + gap (12) + the title's 8 inset → labels line up with the title text
454
- detail: { paddingLeft: 48, paddingRight: 8, paddingTop: 2, paddingBottom: 14, gap: 8 },
455
- source: { borderLeftWidth: 2, borderLeftColor: colors.zinc[200], paddingLeft: 10 },
456
- });
@@ -1,140 +0,0 @@
1
- import { useState } from "react";
2
- import { View, StyleSheet } from "react-native";
3
- import { Icon } from "./icon";
4
- import { Text } from "./text";
5
- import { colors } from "./colors";
6
- import { Popover, PopoverTrigger, PopoverContent } from "./popover";
7
- import { OptionList } from "./option_list";
8
- import type { PickerOption } from "./picker";
9
- import { ActivityIndicator } from "./activity_indicator";
10
- import { Badge } from "./badge";
11
- import { type InlineEditBackground, InlineEditView } from "./inline_edit";
12
- import { useLoticsLocale } from "./locale";
13
-
14
- export interface InlineTagSelectProps<T extends string> {
15
- /** The selected tag values. */
16
- value: T[];
17
- /** Commits the NEW SET when the picker closes (only if it changed). Throwing
18
- * surfaces the inline error, like every inline editor. */
19
- onSave: (next: T[]) => void | Promise<void>;
20
- options: PickerOption<T>[];
21
- /** The resting render of ONE selected tag (an `OptionBadge` dot, a `Chip`).
22
- * Defaults to a plain zinc `Badge` of the label. */
23
- renderTag?: (option: PickerOption<T>) => React.ReactNode;
24
- /** Rich row content in the dropdown. Falls back to `renderTag`, then label. */
25
- renderOptionContent?: (option: PickerOption<T>) => React.ReactNode;
26
- placeholder?: string;
27
- disabled?: boolean;
28
- accessibilityLabel?: string;
29
- /** Resting surface — "tint" (default, the zinc-50 chip) or "transparent". */
30
- background?: InlineEditBackground;
31
- /** Show an in-menu search box; default false. */
32
- searchable?: boolean;
33
- }
34
-
35
- /**
36
- * The inline-editable MULTI select — the tag-field member of the `Inline*`
37
- * family (`InlineSelect` picks one; this holds a set). At rest the selected
38
- * tags render as badges inside the standard inline chip; clicking floats a
39
- * multi `OptionList` (checkbox rows) in a popover, toggles edit a local draft,
40
- * and CLOSING the popover commits the new set in one `onSave` — the blur-commit
41
- * contract of the inline family, applied to a set.
42
- */
43
- export function InlineTagSelect<T extends string>(props: InlineTagSelectProps<T>) {
44
- const {
45
- value, onSave, options, renderTag, renderOptionContent, placeholder, disabled, accessibilityLabel, background, searchable = false,
46
- } = props;
47
- const labels = useLoticsLocale().inline;
48
- const [open, setOpenState] = useState(false);
49
- const [draft, setDraft] = useState<T[]>(value);
50
- const [saving, setSaving] = useState(false);
51
- const [error, setError] = useState<string | null>(null);
52
-
53
- const commit = async (next: T[]) => {
54
- const changed = next.length !== value.length || next.some((v) => !value.includes(v));
55
- if (!changed) return;
56
- setSaving(true);
57
- setError(null);
58
- try {
59
- await onSave(next);
60
- } catch (e) {
61
- setError(e instanceof Error && e.message ? e.message : labels.saveError);
62
- } finally {
63
- setSaving(false);
64
- }
65
- };
66
-
67
- const setOpen = (next: boolean) => {
68
- if (next) {
69
- setDraft(value);
70
- setOpenState(true);
71
- return;
72
- }
73
- setOpenState(false);
74
- void commit(draft);
75
- };
76
-
77
- const selected = options.filter((o) => value.includes(o.value));
78
- const tag = (o: PickerOption<T>) => (renderTag ? renderTag(o) : <Badge label={o.label ?? String(o.value)} color="zinc" />);
79
-
80
- return (
81
- <View>
82
- <Popover open={open && !disabled} onOpenChange={setOpen} side="bottom" align="start" inheritTriggerWidth>
83
- <PopoverTrigger>
84
- <InlineEditView
85
- background={background}
86
- display={
87
- selected.length > 0 ? (
88
- <View style={styles.tags}>
89
- {selected.map((o) => (
90
- <View key={o.value}>{tag(o)}</View>
91
- ))}
92
- </View>
93
- ) : (
94
- ""
95
- )
96
- }
97
- placeholder={placeholder}
98
- disabled={disabled}
99
- active={open && !disabled}
100
- accessibilityLabel={accessibilityLabel}
101
- trailing={
102
- saving ? (
103
- <ActivityIndicator size={16} color={colors.zinc[400]} />
104
- ) : (
105
- <Icon name="chevron-down" size={18} color={colors.zinc[400]} />
106
- )
107
- }
108
- />
109
- </PopoverTrigger>
110
- <PopoverContent disableBodyScroll>
111
- <OptionList<T, true>
112
- multi
113
- search={{ mode: searchable ? "internal" : "none" }}
114
- options={options}
115
- value={draft}
116
- onValueChange={setDraft}
117
- onRequestClose={() => setOpen(false)}
118
- renderOptionContent={renderOptionContent ?? renderTag}
119
- />
120
- </PopoverContent>
121
- </Popover>
122
- {error ? (
123
- <Text size="xs" color="danger" style={styles.error}>
124
- {error}
125
- </Text>
126
- ) : null}
127
- </View>
128
- );
129
- }
130
-
131
- const styles = StyleSheet.create({
132
- tags: {
133
- flexDirection: "row",
134
- alignItems: "center",
135
- flexWrap: "wrap",
136
- columnGap: 4,
137
- rowGap: 2,
138
- },
139
- error: { marginTop: 4 },
140
- });