@remit/ui 0.0.211 → 0.0.213
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-invite-card.render.test.ts +1 -0
- package/src/components/calendar-invite-card.stories.tsx +5 -0
- package/src/components/calendar-invite-card.tsx +2 -2
- package/src/components/calendar-types.ts +0 -50
- package/src/components/intelligence-panel-calendar.stories.tsx +18 -2
- package/src/index.ts +1 -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,227 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { AgendaComposer, AgendaPhraseField } from "./agenda-composer.js";
|
|
4
|
-
import type {
|
|
5
|
-
AgendaParse,
|
|
6
|
-
CalendarDescriptor,
|
|
7
|
-
ChoicePicks,
|
|
8
|
-
EventDraft,
|
|
9
|
-
} from "./calendar-types.js";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Correcting the machine happens before the event exists. The sentence is read
|
|
13
|
-
* back with the words each part came from, and where it has two honest
|
|
14
|
-
* readings the composer asks rather than choosing.
|
|
15
|
-
*/
|
|
16
|
-
const meta: Meta<typeof AgendaComposer> = {
|
|
17
|
-
title: "Playground/Proposed/Calendar/Agenda composer",
|
|
18
|
-
tags: ["proposed"],
|
|
19
|
-
component: AgendaComposer,
|
|
20
|
-
parameters: { layout: "padded" },
|
|
21
|
-
decorators: [
|
|
22
|
-
(Story) => (
|
|
23
|
-
<div className="max-w-96">
|
|
24
|
-
<Story />
|
|
25
|
-
</div>
|
|
26
|
-
),
|
|
27
|
-
],
|
|
28
|
-
};
|
|
29
|
-
export default meta;
|
|
30
|
-
|
|
31
|
-
type Story = StoryObj<typeof AgendaComposer>;
|
|
32
|
-
|
|
33
|
-
const calendars: CalendarDescriptor[] = [
|
|
34
|
-
{
|
|
35
|
-
id: "work",
|
|
36
|
-
accountId: "a1",
|
|
37
|
-
accountLabel: "Work",
|
|
38
|
-
name: "Northwind",
|
|
39
|
-
color: "cal-1",
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
id: "personal",
|
|
43
|
-
accountId: "a2",
|
|
44
|
-
accountLabel: "Personal",
|
|
45
|
-
name: "Family",
|
|
46
|
-
color: "cal-3",
|
|
47
|
-
},
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
const draft: EventDraft = {
|
|
51
|
-
title: "Lunch with Jane",
|
|
52
|
-
date: "2026-06-12",
|
|
53
|
-
startTime: "13:00",
|
|
54
|
-
endDate: "2026-06-12",
|
|
55
|
-
endTime: "14:00",
|
|
56
|
-
allDay: false,
|
|
57
|
-
calendarId: "work",
|
|
58
|
-
location: "",
|
|
59
|
-
guests: "Jane",
|
|
60
|
-
notes: "",
|
|
61
|
-
repeat: "",
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const parse: AgendaParse = {
|
|
65
|
-
title: "Lunch with Jane",
|
|
66
|
-
date: "2026-06-12",
|
|
67
|
-
dateText: "friday",
|
|
68
|
-
startTime: "13:00",
|
|
69
|
-
startTimeText: "1pm",
|
|
70
|
-
endTime: "14:00",
|
|
71
|
-
durationMinutes: 60,
|
|
72
|
-
durationText: "",
|
|
73
|
-
attendees: ["Jane"],
|
|
74
|
-
attendeesText: "with Jane",
|
|
75
|
-
location: "",
|
|
76
|
-
locationText: "",
|
|
77
|
-
repeat: "",
|
|
78
|
-
repeatText: "",
|
|
79
|
-
assumptions: ["An hour long, because the sentence never said."],
|
|
80
|
-
unresolved: [],
|
|
81
|
-
choices: [],
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const repeating: AgendaParse = {
|
|
85
|
-
...parse,
|
|
86
|
-
title: "Standup",
|
|
87
|
-
startTime: "09:30",
|
|
88
|
-
endTime: "09:45",
|
|
89
|
-
startTimeText: "9:30",
|
|
90
|
-
dateText: "every weekday",
|
|
91
|
-
repeat: "Every weekday",
|
|
92
|
-
repeatText: "every weekday",
|
|
93
|
-
attendees: [],
|
|
94
|
-
attendeesText: "",
|
|
95
|
-
assumptions: ["Fifteen minutes, because the sentence never said."],
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const ambiguous: AgendaParse = {
|
|
99
|
-
...parse,
|
|
100
|
-
title: "Coffee with Marcus",
|
|
101
|
-
startTime: "08:00",
|
|
102
|
-
startTimeText: "at 8",
|
|
103
|
-
endTime: "09:00",
|
|
104
|
-
attendees: ["Marcus"],
|
|
105
|
-
attendeesText: "with Marcus",
|
|
106
|
-
unresolved: ["No place given."],
|
|
107
|
-
choices: [
|
|
108
|
-
{
|
|
109
|
-
id: "which_eight",
|
|
110
|
-
question: "Eight in the morning or eight at night?",
|
|
111
|
-
source: "at 8",
|
|
112
|
-
options: [
|
|
113
|
-
{ id: "am", label: "08:00", date: "", startTime: "08:00" },
|
|
114
|
-
{ id: "pm", label: "20:00", date: "", startTime: "20:00" },
|
|
115
|
-
],
|
|
116
|
-
chosenId: "am",
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
const base = {
|
|
122
|
-
onPhraseChange: () => {},
|
|
123
|
-
picks: {} as ChoicePicks,
|
|
124
|
-
onPick: () => {},
|
|
125
|
-
draft,
|
|
126
|
-
onDraftChange: () => {},
|
|
127
|
-
calendars,
|
|
128
|
-
expanded: false,
|
|
129
|
-
onToggleExpanded: () => {},
|
|
130
|
-
onSave: () => {},
|
|
131
|
-
onCancel: () => {},
|
|
132
|
-
onOpen: () => {},
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
/** The field on its own — where the composer starts every time. */
|
|
136
|
-
export const FieldOnly: Story = {
|
|
137
|
-
render: () => (
|
|
138
|
-
<AgendaPhraseField
|
|
139
|
-
phrase=""
|
|
140
|
-
onPhraseChange={() => {}}
|
|
141
|
-
onOpen={() => {}}
|
|
142
|
-
onCommit={() => {}}
|
|
143
|
-
/>
|
|
144
|
-
),
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
/** A sentence that read cleanly, with the reading shown back above the form. */
|
|
148
|
-
export const Read: Story = {
|
|
149
|
-
args: {
|
|
150
|
-
...base,
|
|
151
|
-
phrase: "lunch with Jane friday 1pm",
|
|
152
|
-
parse,
|
|
153
|
-
open: true,
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
/** A rule the sentence carried, named as a rule rather than as one morning. */
|
|
158
|
-
export const Repeating: Story = {
|
|
159
|
-
args: {
|
|
160
|
-
...base,
|
|
161
|
-
phrase: "standup every weekday 9:30",
|
|
162
|
-
parse: repeating,
|
|
163
|
-
draft: { ...draft, title: "Standup", repeat: "Every weekday" },
|
|
164
|
-
open: true,
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
/** Two honest readings: the question is a control, and the answer is one tap. */
|
|
169
|
-
export const Ambiguous: Story = {
|
|
170
|
-
args: {
|
|
171
|
-
...base,
|
|
172
|
-
phrase: "coffee with Marcus at 8",
|
|
173
|
-
parse: ambiguous,
|
|
174
|
-
draft: { ...draft, title: "Coffee with Marcus", startTime: "08:00" },
|
|
175
|
-
open: true,
|
|
176
|
-
},
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
/** Folded away until there is something to correct. */
|
|
180
|
-
export const Folded: Story = {
|
|
181
|
-
args: {
|
|
182
|
-
...base,
|
|
183
|
-
phrase: "lunch with Jane friday 1pm",
|
|
184
|
-
parse,
|
|
185
|
-
open: false,
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
/** Grown for a phone, where the form is the whole screen. */
|
|
190
|
-
export const Touch: Story = {
|
|
191
|
-
args: {
|
|
192
|
-
...base,
|
|
193
|
-
phrase: "coffee with Marcus at 8",
|
|
194
|
-
parse: ambiguous,
|
|
195
|
-
open: true,
|
|
196
|
-
touch: true,
|
|
197
|
-
},
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
/** Answering the question moves the reading; nothing is settled behind you. */
|
|
201
|
-
export const Interactive: Story = {
|
|
202
|
-
render: () => {
|
|
203
|
-
const [picks, setPicks] = useState<ChoicePicks>({});
|
|
204
|
-
const [phrase, setPhrase] = useState("coffee with Marcus at 8");
|
|
205
|
-
const [open, setOpen] = useState(true);
|
|
206
|
-
const [expanded, setExpanded] = useState(false);
|
|
207
|
-
const [current, setCurrent] = useState(draft);
|
|
208
|
-
return (
|
|
209
|
-
<AgendaComposer
|
|
210
|
-
{...base}
|
|
211
|
-
phrase={phrase}
|
|
212
|
-
onPhraseChange={setPhrase}
|
|
213
|
-
parse={ambiguous}
|
|
214
|
-
picks={picks}
|
|
215
|
-
onPick={(choiceId, optionId) =>
|
|
216
|
-
setPicks((previous) => ({ ...previous, [choiceId]: optionId }))
|
|
217
|
-
}
|
|
218
|
-
draft={current}
|
|
219
|
-
onDraftChange={setCurrent}
|
|
220
|
-
expanded={expanded}
|
|
221
|
-
onToggleExpanded={() => setExpanded((value) => !value)}
|
|
222
|
-
open={open}
|
|
223
|
-
onOpen={() => setOpen(true)}
|
|
224
|
-
/>
|
|
225
|
-
);
|
|
226
|
-
},
|
|
227
|
-
};
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typing is the create path here, so the field is on screen at all times and
|
|
3
|
-
* the form is downstream of it.
|
|
4
|
-
*
|
|
5
|
-
* Every keystroke re-reads the sentence and writes the reading straight into
|
|
6
|
-
* the fields underneath, attributed to the words it came from. Where the
|
|
7
|
-
* sentence has two honest readings — which Friday, eight in the morning or
|
|
8
|
-
* eight at night — the reader asks instead of choosing, and the answer is one
|
|
9
|
-
* tap. Correcting the machine happens before the event exists.
|
|
10
|
-
*/
|
|
11
|
-
import { AlertTriangle, Info, Wand2 } from "lucide-react";
|
|
12
|
-
import { formatShortDay } from "../lib/agenda-time.js";
|
|
13
|
-
import { cn } from "../lib/cn.js";
|
|
14
|
-
import type {
|
|
15
|
-
AgendaParse,
|
|
16
|
-
CalendarDescriptor,
|
|
17
|
-
ChoicePicks,
|
|
18
|
-
EventDraft,
|
|
19
|
-
} from "./calendar-types.js";
|
|
20
|
-
import { EventEditor } from "./event-editor.js";
|
|
21
|
-
|
|
22
|
-
export interface AgendaComposerProps {
|
|
23
|
-
phrase: string;
|
|
24
|
-
onPhraseChange: (phrase: string) => void;
|
|
25
|
-
parse: AgendaParse;
|
|
26
|
-
picks: ChoicePicks;
|
|
27
|
-
onPick: (choiceId: string, optionId: string) => void;
|
|
28
|
-
draft: EventDraft;
|
|
29
|
-
onDraftChange: (draft: EventDraft) => void;
|
|
30
|
-
calendars: CalendarDescriptor[];
|
|
31
|
-
expanded: boolean;
|
|
32
|
-
onToggleExpanded: () => void;
|
|
33
|
-
onSave: () => void;
|
|
34
|
-
onCancel: () => void;
|
|
35
|
-
saveLabel?: string;
|
|
36
|
-
/** The rule belongs to the series; an edit scoped to one instance reads it back. */
|
|
37
|
-
repeatEditable?: boolean;
|
|
38
|
-
/** Opens the custom-rule editor from the repeat picker. */
|
|
39
|
-
onCustomRepeat?: () => void;
|
|
40
|
-
/** The form is folded away until there is something to correct. */
|
|
41
|
-
open: boolean;
|
|
42
|
-
onOpen: () => void;
|
|
43
|
-
placeholder?: string;
|
|
44
|
-
touch?: boolean;
|
|
45
|
-
className?: string;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface AgendaPhraseFieldProps {
|
|
49
|
-
phrase: string;
|
|
50
|
-
onPhraseChange: (phrase: string) => void;
|
|
51
|
-
/** Focus or a keystroke unfolds the form under the field. */
|
|
52
|
-
onOpen: () => void;
|
|
53
|
-
onCommit: () => void;
|
|
54
|
-
placeholder?: string;
|
|
55
|
-
touch?: boolean;
|
|
56
|
-
className?: string;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function AgendaPhraseField({
|
|
60
|
-
phrase,
|
|
61
|
-
onPhraseChange,
|
|
62
|
-
onOpen,
|
|
63
|
-
onCommit,
|
|
64
|
-
placeholder = "lunch with Jane friday 1pm",
|
|
65
|
-
touch,
|
|
66
|
-
className,
|
|
67
|
-
}: AgendaPhraseFieldProps) {
|
|
68
|
-
return (
|
|
69
|
-
<div
|
|
70
|
-
className={cn(
|
|
71
|
-
"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",
|
|
72
|
-
touch ? "min-h-11" : "h-9",
|
|
73
|
-
className,
|
|
74
|
-
)}
|
|
75
|
-
>
|
|
76
|
-
<Wand2 className="size-4 shrink-0 text-fg-subtle" aria-hidden />
|
|
77
|
-
<input
|
|
78
|
-
value={phrase}
|
|
79
|
-
aria-label="Describe the event"
|
|
80
|
-
placeholder={placeholder}
|
|
81
|
-
onFocus={onOpen}
|
|
82
|
-
onChange={(event) => {
|
|
83
|
-
onOpen();
|
|
84
|
-
onPhraseChange(event.target.value);
|
|
85
|
-
}}
|
|
86
|
-
onKeyDown={(event) => {
|
|
87
|
-
if (event.key === "Enter") onCommit();
|
|
88
|
-
}}
|
|
89
|
-
className="min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-subtle"
|
|
90
|
-
/>
|
|
91
|
-
</div>
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function AgendaComposer({
|
|
96
|
-
phrase,
|
|
97
|
-
onPhraseChange,
|
|
98
|
-
parse,
|
|
99
|
-
picks,
|
|
100
|
-
onPick,
|
|
101
|
-
draft,
|
|
102
|
-
onDraftChange,
|
|
103
|
-
calendars,
|
|
104
|
-
expanded,
|
|
105
|
-
onToggleExpanded,
|
|
106
|
-
onSave,
|
|
107
|
-
onCancel,
|
|
108
|
-
saveLabel = "Add",
|
|
109
|
-
repeatEditable,
|
|
110
|
-
onCustomRepeat,
|
|
111
|
-
open,
|
|
112
|
-
onOpen,
|
|
113
|
-
placeholder = "lunch with Jane friday 1pm",
|
|
114
|
-
touch,
|
|
115
|
-
className,
|
|
116
|
-
}: AgendaComposerProps) {
|
|
117
|
-
return (
|
|
118
|
-
<div className={cn("flex flex-col gap-2", className)}>
|
|
119
|
-
<AgendaPhraseField
|
|
120
|
-
phrase={phrase}
|
|
121
|
-
onPhraseChange={onPhraseChange}
|
|
122
|
-
onOpen={onOpen}
|
|
123
|
-
onCommit={onSave}
|
|
124
|
-
placeholder={placeholder}
|
|
125
|
-
touch={touch}
|
|
126
|
-
/>
|
|
127
|
-
|
|
128
|
-
{open && (
|
|
129
|
-
<EventEditor
|
|
130
|
-
draft={draft}
|
|
131
|
-
onChange={onDraftChange}
|
|
132
|
-
calendars={calendars}
|
|
133
|
-
expanded={expanded}
|
|
134
|
-
onToggleExpanded={onToggleExpanded}
|
|
135
|
-
onSave={onSave}
|
|
136
|
-
onCancel={onCancel}
|
|
137
|
-
saveLabel={saveLabel}
|
|
138
|
-
repeatEditable={repeatEditable}
|
|
139
|
-
guestsEditable
|
|
140
|
-
onCustomRepeat={onCustomRepeat}
|
|
141
|
-
touch={touch}
|
|
142
|
-
header={
|
|
143
|
-
phrase.trim() === "" ? undefined : (
|
|
144
|
-
<PhraseReading
|
|
145
|
-
parse={parse}
|
|
146
|
-
picks={picks}
|
|
147
|
-
onPick={onPick}
|
|
148
|
-
touch={touch}
|
|
149
|
-
/>
|
|
150
|
-
)
|
|
151
|
-
}
|
|
152
|
-
/>
|
|
153
|
-
)}
|
|
154
|
-
</div>
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export function PhraseReading({
|
|
159
|
-
parse,
|
|
160
|
-
picks,
|
|
161
|
-
onPick,
|
|
162
|
-
touch,
|
|
163
|
-
}: {
|
|
164
|
-
parse: AgendaParse;
|
|
165
|
-
picks: ChoicePicks;
|
|
166
|
-
onPick: (choiceId: string, optionId: string) => void;
|
|
167
|
-
touch?: boolean;
|
|
168
|
-
}) {
|
|
169
|
-
const when =
|
|
170
|
-
parse.startTime === ""
|
|
171
|
-
? formatShortDay(parse.date)
|
|
172
|
-
: `${formatShortDay(parse.date)} ${parse.startTime} – ${parse.endTime}`;
|
|
173
|
-
|
|
174
|
-
return (
|
|
175
|
-
<div className="flex flex-col gap-1 rounded-md border border-line bg-surface px-2.5 py-2">
|
|
176
|
-
<Reading
|
|
177
|
-
label="What"
|
|
178
|
-
value={parse.title === "" ? "—" : parse.title}
|
|
179
|
-
source=""
|
|
180
|
-
/>
|
|
181
|
-
<Reading
|
|
182
|
-
label="When"
|
|
183
|
-
value={when}
|
|
184
|
-
source={[parse.dateText, parse.startTimeText]
|
|
185
|
-
.filter((part) => part !== "")
|
|
186
|
-
.join(" ")}
|
|
187
|
-
/>
|
|
188
|
-
{parse.repeat !== "" && (
|
|
189
|
-
<Reading
|
|
190
|
-
label="Repeat"
|
|
191
|
-
value={parse.repeat}
|
|
192
|
-
source={parse.repeatText}
|
|
193
|
-
/>
|
|
194
|
-
)}
|
|
195
|
-
{parse.attendees.length > 0 && (
|
|
196
|
-
<Reading
|
|
197
|
-
label="Who"
|
|
198
|
-
value={parse.attendees.join(", ")}
|
|
199
|
-
source={parse.attendeesText}
|
|
200
|
-
/>
|
|
201
|
-
)}
|
|
202
|
-
{parse.location !== "" && (
|
|
203
|
-
<Reading
|
|
204
|
-
label="Where"
|
|
205
|
-
value={parse.location}
|
|
206
|
-
source={parse.locationText}
|
|
207
|
-
/>
|
|
208
|
-
)}
|
|
209
|
-
|
|
210
|
-
{parse.choices.map((choice) => (
|
|
211
|
-
<div
|
|
212
|
-
key={choice.id}
|
|
213
|
-
className="mt-1 flex flex-wrap items-center gap-1.5 rounded-md border border-warning/50 bg-warning-soft/30 px-2 py-1.5"
|
|
214
|
-
>
|
|
215
|
-
<AlertTriangle className="size-3 shrink-0 text-warning" aria-hidden />
|
|
216
|
-
<span className="text-2xs text-warning">{choice.question}</span>
|
|
217
|
-
{choice.options.map((option) => {
|
|
218
|
-
const chosen = (picks[choice.id] ?? choice.chosenId) === option.id;
|
|
219
|
-
return (
|
|
220
|
-
<button
|
|
221
|
-
key={option.id}
|
|
222
|
-
type="button"
|
|
223
|
-
aria-pressed={chosen}
|
|
224
|
-
onClick={() => onPick(choice.id, option.id)}
|
|
225
|
-
className={cn(
|
|
226
|
-
"rounded-full border px-2 text-2xs outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring",
|
|
227
|
-
touch ? "min-h-9" : "h-6",
|
|
228
|
-
chosen
|
|
229
|
-
? "border-warning bg-warning-soft font-medium text-warning"
|
|
230
|
-
: "border-line text-fg-muted hover:border-line-strong hover:text-fg",
|
|
231
|
-
)}
|
|
232
|
-
>
|
|
233
|
-
{option.label}
|
|
234
|
-
</button>
|
|
235
|
-
);
|
|
236
|
-
})}
|
|
237
|
-
</div>
|
|
238
|
-
))}
|
|
239
|
-
|
|
240
|
-
{parse.assumptions.map((note) => (
|
|
241
|
-
<p
|
|
242
|
-
key={note}
|
|
243
|
-
className="flex items-center gap-1.5 text-2xs text-fg-subtle"
|
|
244
|
-
>
|
|
245
|
-
<Info className="size-3 shrink-0" aria-hidden />
|
|
246
|
-
{note}
|
|
247
|
-
</p>
|
|
248
|
-
))}
|
|
249
|
-
{parse.unresolved.map((note) => (
|
|
250
|
-
<p
|
|
251
|
-
key={note}
|
|
252
|
-
className="flex items-center gap-1.5 text-2xs text-warning"
|
|
253
|
-
>
|
|
254
|
-
<AlertTriangle className="size-3 shrink-0" aria-hidden />
|
|
255
|
-
{note}
|
|
256
|
-
</p>
|
|
257
|
-
))}
|
|
258
|
-
</div>
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function Reading({
|
|
263
|
-
label,
|
|
264
|
-
value,
|
|
265
|
-
source,
|
|
266
|
-
}: {
|
|
267
|
-
label: string;
|
|
268
|
-
value: string;
|
|
269
|
-
source: string;
|
|
270
|
-
}) {
|
|
271
|
-
return (
|
|
272
|
-
<div className="flex min-w-0 items-baseline gap-1.5">
|
|
273
|
-
<span className="w-12 shrink-0 text-2xs uppercase tracking-wider text-fg-subtle">
|
|
274
|
-
{label}
|
|
275
|
-
</span>
|
|
276
|
-
<span className="truncate text-xs font-medium text-fg">{value}</span>
|
|
277
|
-
{source !== "" && (
|
|
278
|
-
<span className="shrink-0 rounded-xs bg-accent-2-soft px-1 text-2xs text-accent-2">
|
|
279
|
-
{source}
|
|
280
|
-
</span>
|
|
281
|
-
)}
|
|
282
|
-
</div>
|
|
283
|
-
);
|
|
284
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import {
|
|
4
|
-
type CustomRecurrence,
|
|
5
|
-
defaultCustomRecurrence,
|
|
6
|
-
defaultEndDate,
|
|
7
|
-
formatCustomRecurrence,
|
|
8
|
-
} from "../lib/recurrence.js";
|
|
9
|
-
import { CustomRecurrenceEditor } from "./custom-recurrence.js";
|
|
10
|
-
|
|
11
|
-
const DATE = "2026-06-09";
|
|
12
|
-
const START = "09:15";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The rule the derived choices cannot express. Every part of it is a control —
|
|
16
|
-
* how often, which days, when it stops — and what comes out is the same
|
|
17
|
-
* sentence the picker reads back. Nobody types an RRULE and nobody is shown
|
|
18
|
-
* one; the line under each story is what the event would carry.
|
|
19
|
-
*/
|
|
20
|
-
const meta: Meta<typeof CustomRecurrenceEditor> = {
|
|
21
|
-
title: "Design System/Calendar/Custom recurrence",
|
|
22
|
-
tags: ["proposed"],
|
|
23
|
-
component: CustomRecurrenceEditor,
|
|
24
|
-
parameters: { layout: "padded" },
|
|
25
|
-
};
|
|
26
|
-
export default meta;
|
|
27
|
-
|
|
28
|
-
type Story = StoryObj<typeof CustomRecurrenceEditor>;
|
|
29
|
-
|
|
30
|
-
function Editor({ seed, touch }: { seed: CustomRecurrence; touch?: boolean }) {
|
|
31
|
-
const [rule, setRule] = useState(seed);
|
|
32
|
-
return (
|
|
33
|
-
<div className="flex max-w-sm flex-col gap-4 rounded-lg border border-line bg-surface p-5">
|
|
34
|
-
<h3 className="text-lg font-semibold text-fg">Custom recurrence</h3>
|
|
35
|
-
<CustomRecurrenceEditor
|
|
36
|
-
value={rule}
|
|
37
|
-
onChange={setRule}
|
|
38
|
-
date={DATE}
|
|
39
|
-
suggestedEndDate={defaultEndDate(DATE)}
|
|
40
|
-
touch={touch}
|
|
41
|
-
/>
|
|
42
|
-
<p className="border-t border-line pt-3 text-sm text-fg-muted">
|
|
43
|
-
{formatCustomRecurrence(rule, DATE, START)}
|
|
44
|
-
</p>
|
|
45
|
-
</div>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** What it opens as: every week, on the day the event already sits on. */
|
|
50
|
-
export const Weekly: Story = {
|
|
51
|
-
render: () => <Editor seed={defaultCustomRecurrence(DATE)} />,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Two days a week, fortnightly, until October. None of that is expressible as
|
|
56
|
-
* a choice derived from a date, which is the whole reason this exists.
|
|
57
|
-
*/
|
|
58
|
-
export const EveryOtherWeekUntilOctober: Story = {
|
|
59
|
-
name: "Every other week, until October",
|
|
60
|
-
render: () => (
|
|
61
|
-
<Editor
|
|
62
|
-
seed={{
|
|
63
|
-
interval: 2,
|
|
64
|
-
unit: "week",
|
|
65
|
-
weekdays: [1, 4],
|
|
66
|
-
monthlyMode: "dayOfMonth",
|
|
67
|
-
ends: { kind: "onDate", date: "2026-10-03" },
|
|
68
|
-
}}
|
|
69
|
-
/>
|
|
70
|
-
),
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* A monthly rule means two different things about the same date — the ninth,
|
|
75
|
-
* or the second Tuesday — and which one is meant is never derivable. So it is
|
|
76
|
-
* asked rather than assumed.
|
|
77
|
-
*/
|
|
78
|
-
export const MonthlyReadTwoWays: Story = {
|
|
79
|
-
name: "Monthly, read two ways",
|
|
80
|
-
render: () => (
|
|
81
|
-
<Editor
|
|
82
|
-
seed={{
|
|
83
|
-
...defaultCustomRecurrence(DATE),
|
|
84
|
-
unit: "month",
|
|
85
|
-
monthlyMode: "weekdayOfMonth",
|
|
86
|
-
}}
|
|
87
|
-
/>
|
|
88
|
-
),
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
/** An ending counted rather than dated: thirteen times and then it stops. */
|
|
92
|
-
export const EndsAfterCount: Story = {
|
|
93
|
-
name: "Ends after a count",
|
|
94
|
-
render: () => (
|
|
95
|
-
<Editor
|
|
96
|
-
seed={{
|
|
97
|
-
...defaultCustomRecurrence(DATE),
|
|
98
|
-
ends: { kind: "afterCount", count: 13 },
|
|
99
|
-
}}
|
|
100
|
-
/>
|
|
101
|
-
),
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
/** The same controls at thumb size, as the phone step renders them. */
|
|
105
|
-
export const Touch: Story = {
|
|
106
|
-
render: () => <Editor seed={defaultCustomRecurrence(DATE)} touch />,
|
|
107
|
-
};
|