@remit/ui 0.0.210 → 0.0.212
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/package.json +1 -1
- package/src/components/agenda-panels.render.test.ts +2 -117
- package/src/components/agenda-panels.stories.tsx +2 -72
- package/src/components/agenda-panels.tsx +3 -253
- package/src/components/calendar-types.ts +0 -50
- package/src/components/intelligence-panel-calendar.stories.tsx +1 -1
- package/src/components/pane-header.render.test.ts +22 -0
- package/src/components/pane-header.stories.tsx +76 -0
- package/src/components/pane-header.tsx +33 -0
- package/src/index.ts +2 -47
- package/src/lib/agenda-time.test.ts +0 -2
- package/src/lib/agenda-time.ts +0 -7
- package/src/lib/event-phrase.test.ts +1 -73
- package/src/lib/event-phrase.ts +0 -217
- package/src/lib/recurrence.ts +0 -3
- package/src/components/agenda-composer.render.test.ts +0 -197
- package/src/components/agenda-composer.stories.tsx +0 -227
- package/src/components/agenda-composer.tsx +0 -284
- package/src/components/custom-recurrence.stories.tsx +0 -107
- package/src/components/custom-recurrence.tsx +0 -411
- package/src/components/event-quick-entry.render.test.ts +0 -40
- package/src/components/event-quick-entry.stories.tsx +0 -57
- package/src/components/event-quick-entry.tsx +0 -159
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { AlertTriangle, Info, Wand2 } from "lucide-react";
|
|
2
|
-
import { cn } from "../lib/cn.js";
|
|
3
|
-
import type { PhraseParse } from "../lib/event-phrase.js";
|
|
4
|
-
|
|
5
|
-
export interface EventQuickEntryProps {
|
|
6
|
-
value: string;
|
|
7
|
-
onChange: (value: string) => void;
|
|
8
|
-
/** The reading of `value`, recomputed by the caller on every keystroke. */
|
|
9
|
-
parse: PhraseParse;
|
|
10
|
-
/** Commits the reading to the form. */
|
|
11
|
-
onCommit: () => void;
|
|
12
|
-
placeholder?: string;
|
|
13
|
-
touch?: boolean;
|
|
14
|
-
className?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface ReadingProps {
|
|
18
|
-
label: string;
|
|
19
|
-
value: string;
|
|
20
|
-
source: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function Reading({ label, value, source }: ReadingProps) {
|
|
24
|
-
return (
|
|
25
|
-
<div className="flex min-w-0 items-baseline gap-1.5">
|
|
26
|
-
<span className="shrink-0 text-2xs uppercase tracking-wider text-fg-subtle">
|
|
27
|
-
{label}
|
|
28
|
-
</span>
|
|
29
|
-
<span className="truncate text-xs font-medium text-fg">{value}</span>
|
|
30
|
-
{source !== "" && (
|
|
31
|
-
<span className="shrink-0 rounded-xs bg-accent-2-soft px-1 text-2xs text-accent-2">
|
|
32
|
-
{source}
|
|
33
|
-
</span>
|
|
34
|
-
)}
|
|
35
|
-
</div>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Typing is the fastest way to make an event, so the field takes a sentence.
|
|
41
|
-
* What it does with the sentence is on screen while you type: every reading is
|
|
42
|
-
* shown next to the words it was taken from, and anything the reader filled in
|
|
43
|
-
* or could not settle is said out loud. Correcting the machine happens before
|
|
44
|
-
* the event exists, not after it is on the grid.
|
|
45
|
-
*/
|
|
46
|
-
export function EventQuickEntry({
|
|
47
|
-
value,
|
|
48
|
-
onChange,
|
|
49
|
-
parse,
|
|
50
|
-
onCommit,
|
|
51
|
-
placeholder = "lunch with Jane friday 1pm",
|
|
52
|
-
touch,
|
|
53
|
-
className,
|
|
54
|
-
}: EventQuickEntryProps) {
|
|
55
|
-
const hasReading = value.trim() !== "";
|
|
56
|
-
const endTime =
|
|
57
|
-
parse.startTime === ""
|
|
58
|
-
? ""
|
|
59
|
-
: ` – ${clockAfter(parse.startTime, parse.durationMinutes)}`;
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<div className={cn("flex flex-col gap-2", className)}>
|
|
63
|
-
<div
|
|
64
|
-
className={cn(
|
|
65
|
-
"flex items-center gap-2 rounded-md border border-line bg-surface-sunken px-3 focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30",
|
|
66
|
-
touch ? "min-h-11" : "h-9",
|
|
67
|
-
)}
|
|
68
|
-
>
|
|
69
|
-
<Wand2 className="size-4 shrink-0 text-fg-subtle" aria-hidden />
|
|
70
|
-
<input
|
|
71
|
-
value={value}
|
|
72
|
-
aria-label="Describe the event"
|
|
73
|
-
placeholder={placeholder}
|
|
74
|
-
onChange={(e) => onChange(e.target.value)}
|
|
75
|
-
onKeyDown={(e) => {
|
|
76
|
-
if (e.key === "Enter") onCommit();
|
|
77
|
-
}}
|
|
78
|
-
className="min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-subtle"
|
|
79
|
-
/>
|
|
80
|
-
</div>
|
|
81
|
-
|
|
82
|
-
{hasReading && (
|
|
83
|
-
<div className="flex flex-col gap-1 rounded-md border border-line bg-surface px-2.5 py-2">
|
|
84
|
-
<Reading
|
|
85
|
-
label="What"
|
|
86
|
-
value={parse.title === "" ? "—" : parse.title}
|
|
87
|
-
source=""
|
|
88
|
-
/>
|
|
89
|
-
<Reading
|
|
90
|
-
label="When"
|
|
91
|
-
value={`${formatDay(parse.date)}${
|
|
92
|
-
parse.startTime === "" ? "" : ` ${parse.startTime}${endTime}`
|
|
93
|
-
}`}
|
|
94
|
-
source={[parse.dateText, parse.startTimeText]
|
|
95
|
-
.filter((part) => part !== "")
|
|
96
|
-
.join(" ")}
|
|
97
|
-
/>
|
|
98
|
-
{parse.durationText !== "" && (
|
|
99
|
-
<Reading
|
|
100
|
-
label="Long"
|
|
101
|
-
value={formatDuration(parse.durationMinutes)}
|
|
102
|
-
source={parse.durationText}
|
|
103
|
-
/>
|
|
104
|
-
)}
|
|
105
|
-
{parse.attendees.length > 0 && (
|
|
106
|
-
<Reading
|
|
107
|
-
label="Who"
|
|
108
|
-
value={parse.attendees.join(", ")}
|
|
109
|
-
source={parse.attendeesText}
|
|
110
|
-
/>
|
|
111
|
-
)}
|
|
112
|
-
{parse.assumptions.map((note) => (
|
|
113
|
-
<p
|
|
114
|
-
key={note}
|
|
115
|
-
className="flex items-center gap-1.5 text-2xs text-fg-subtle"
|
|
116
|
-
>
|
|
117
|
-
<Info className="size-3 shrink-0" aria-hidden />
|
|
118
|
-
{note}
|
|
119
|
-
</p>
|
|
120
|
-
))}
|
|
121
|
-
{parse.unresolved.map((note) => (
|
|
122
|
-
<p
|
|
123
|
-
key={note}
|
|
124
|
-
className="flex items-center gap-1.5 text-2xs text-warning"
|
|
125
|
-
>
|
|
126
|
-
<AlertTriangle className="size-3 shrink-0" aria-hidden />
|
|
127
|
-
{note}
|
|
128
|
-
</p>
|
|
129
|
-
))}
|
|
130
|
-
</div>
|
|
131
|
-
)}
|
|
132
|
-
</div>
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function clockAfter(clock: string, minutes: number): string {
|
|
137
|
-
const [hours, mins] = clock.split(":").map(Number);
|
|
138
|
-
const total = (hours * 60 + mins + minutes) % 1440;
|
|
139
|
-
return `${String(Math.floor(total / 60)).padStart(2, "0")}:${String(
|
|
140
|
-
total % 60,
|
|
141
|
-
).padStart(2, "0")}`;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function formatDay(iso: string): string {
|
|
145
|
-
if (iso === "") return "—";
|
|
146
|
-
const [year, month, day] = iso.split("-").map(Number);
|
|
147
|
-
return new Date(year, month - 1, day).toLocaleDateString("en-GB", {
|
|
148
|
-
weekday: "short",
|
|
149
|
-
day: "numeric",
|
|
150
|
-
month: "short",
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function formatDuration(minutes: number): string {
|
|
155
|
-
if (minutes === 0) return "—";
|
|
156
|
-
if (minutes % 60 === 0) return `${minutes / 60}h`;
|
|
157
|
-
if (minutes < 60) return `${minutes}m`;
|
|
158
|
-
return `${Math.floor(minutes / 60)}h ${minutes % 60}m`;
|
|
159
|
-
}
|