@wtfalch/calendar 0.1.0 → 0.3.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.
@@ -35,7 +35,6 @@ import { EventDetail } from "./EventDetail.js";
35
35
  import { EventEditor } from "./EventEditor.js";
36
36
  import { ShareDialog } from "./ShareDialog.js";
37
37
  import { Toolbar } from "./Toolbar.js";
38
- import { sameAddress } from "./participants.js";
39
38
  const localizer = dayjsLocalizer(dayjs);
40
39
  /** The date in a month cell is `6`, not `06`. react-big-calendar's dayjs
41
40
  * localizer pads by default, and a zero-padded day reads as a code rather
@@ -254,14 +253,23 @@ function useMe(client) {
254
253
  * How the editor asks when a set of people are busy.
255
254
  *
256
255
  * One `resolvePrincipal` per address to turn it into the `principalId`
257
- * `getAvailability` takes, then one availability call each. An address that
258
- * resolves to nobody, or a call that fails, simply has no entry — which the
259
- * ribbon draws as unknown, because that is what it is.
256
+ * `getAvailability` takes — that part is unchanged, `Principal/query` has no
257
+ * batched form here — but then one `getAvailability` call for every resolved
258
+ * principal, not one per address: `getAvailability` now takes the whole set
259
+ * at once and answers a map, the same JMAP-level batching
260
+ * `Principal/getAvailability` always supported (issue #13 Decision; this
261
+ * hook is the "N round trips and the merge lives in the app" the ticket
262
+ * named). An address that resolves to nobody simply has no entry, which the
263
+ * ribbon draws as unknown.
260
264
  *
261
- * **An empty list is not "free".** It is the same answer the server gives for
262
- * never-shared and for shared-then-revoked, measured live and pinned in
263
- * `wire-live-transcript.test.ts`. The ribbon is the place that decides what to
264
- * draw; this function only reports what came back.
265
+ * **An empty answer is not "free".** It is the same answer the server gives
266
+ * for never-shared and for shared-then-revoked, measured live and pinned in
267
+ * `wire-live-transcript.test.ts` — `getAvailability`'s own `'unknown'` kind
268
+ * already folds that in. A failure of the one batched call now costs every
269
+ * address its entry rather than only the addresses that individually failed;
270
+ * that trade only ever turns a real busy reading into an honest "unknown"
271
+ * one, never the other way, so the ribbon's own catch-all (`useEffect` below,
272
+ * `AvailabilityRibbon`) still has the right thing to draw.
265
273
  */
266
274
  function useAvailabilityLookup(client) {
267
275
  return useCallback(async (addresses, day) => {
@@ -270,19 +278,26 @@ function useAvailabilityLookup(client) {
270
278
  const to = new Date(from);
271
279
  to.setDate(to.getDate() + 1);
272
280
  const range = { after: from.toISOString(), before: to.toISOString() };
273
- const answers = new Map();
281
+ const addressByPrincipalId = new Map();
274
282
  await Promise.all(addresses.map(async (address) => {
275
283
  try {
276
284
  const principal = await client.resolvePrincipal(address);
277
- if (!principal)
278
- return;
279
- answers.set(address, await client.getAvailability(principal.accountId, range));
285
+ if (principal)
286
+ addressByPrincipalId.set(principal.accountId, address);
280
287
  }
281
288
  catch {
282
- // No entry, so the band stays unknown. A failure to ask is one
289
+ // No entry, so the band stays unknown. A failed resolve is one
283
290
  // more way of not being able to see somebody.
284
291
  }
285
292
  }));
293
+ const answers = new Map();
294
+ if (addressByPrincipalId.size > 0) {
295
+ const results = await client.getAvailability([...addressByPrincipalId.keys()], range);
296
+ for (const [principalId, address] of addressByPrincipalId) {
297
+ const result = results.get(principalId);
298
+ answers.set(address, result?.kind === 'known' ? result.periods : undefined);
299
+ }
300
+ }
286
301
  return answers;
287
302
  }, [client]);
288
303
  }
@@ -396,24 +411,18 @@ export function Calendar({ client, location, onNavigate, account, onError, now,
396
411
  /**
397
412
  * Answer an invite.
398
413
  *
399
- * Always with `sendSchedulingMessages: true`, and not by the person's
400
- * choice: an RSVP nobody is told about is not an RSVP. That is the opposite
401
- * of the editor's Save, where telling people is the separate decision --
402
- * here the telling *is* the act.
403
- *
404
- * The patch addresses the viewer's own participant entry by its map key.
405
- * Those keys are assigned by `wire.ts` (`p0`, `p1`, ...) and are never part
406
- * of the contract, so the key is looked up by address rather than assumed.
414
+ * `client.respond`, not `updateEvent` -- the organiser's verb (#11). Always
415
+ * with `sendSchedulingMessages: true`, and not by the person's choice: an
416
+ * RSVP nobody is told about is not an RSVP. That is the opposite of the
417
+ * editor's Save, where telling people is the separate decision -- here the
418
+ * telling *is* the act.
407
419
  */
408
420
  const respond = useCallback(async (answer) => {
409
- if (selected === undefined || me === undefined)
421
+ if (selected === undefined)
410
422
  return;
411
- const participants = (selected.participants ?? []).map((person) => sameAddress(person.calendarAddress, me)
412
- ? { ...person, participationStatus: answer }
413
- : person);
414
- await client.updateEvent(selected.id, { participants }, { sendSchedulingMessages: true });
423
+ await client.respond(selected.id, answer, { sendSchedulingMessages: true });
415
424
  reload();
416
- }, [client, me, reload, selected]);
425
+ }, [client, reload, selected]);
417
426
  const empty = !loading && !error && gridEvents.length === 0;
418
427
  const detail = selected !== undefined ? (_jsx(EventDetail, { event: selected, me: me, onEdit: () => setEditing({ event: selected, start: undefined }), onRespond: respond, onClose: closeDetail })) : null;
419
428
  /** The phone day view's own picker: the week around `current.date`, tapping
@@ -9,6 +9,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
9
  */
10
10
  import { Button, Icon, Identity, Pill } from '@wtfalch/design';
11
11
  import { useState } from 'react';
12
+ import { eventToIcs } from "../ics.js";
12
13
  import { parseDurationMs } from "../wire.js";
13
14
  import { STATUS_TONE, STATUS_WORD, addressOf, sameAddress } from "./participants.js";
14
15
  /** The three answers a person can give, in the order a person weighs them.
@@ -35,6 +36,26 @@ function formatWhen(event) {
35
36
  return `${date}, ${time(start)}`;
36
37
  return `${date}, ${time(start)} to ${time(new Date(start.getTime() + ms))}`;
37
38
  }
39
+ /** A filesystem-safe `.ics` filename built from the title -- strips the
40
+ * characters no common filesystem accepts, and falls back to a generic
41
+ * name for a title that is empty or entirely such characters (wtfalch/calendar#28). */
42
+ function icsFilename(title) {
43
+ const cleaned = title.replace(/[\\/:*?"<>|]/g, '-').trim();
44
+ return `${cleaned === '' ? 'event' : cleaned}.ics`;
45
+ }
46
+ /** Hands the browser a `.ics` file the way a native "Save As" would: a blob
47
+ * URL, a link nobody sees, one click, then the URL is freed. There is no
48
+ * server round trip -- the export is built entirely from the event this
49
+ * pane already has (wtfalch/calendar#28). */
50
+ function downloadIcs(event) {
51
+ const blob = new Blob([eventToIcs(event)], { type: 'text/calendar;charset=utf-8' });
52
+ const url = URL.createObjectURL(blob);
53
+ const link = document.createElement('a');
54
+ link.href = url;
55
+ link.download = icsFilename(event.title);
56
+ link.click();
57
+ URL.revokeObjectURL(url);
58
+ }
38
59
  /**
39
60
  * What the pane says about repetition.
40
61
  *
@@ -84,7 +105,7 @@ export function EventDetail({ event, me, onEdit, onRespond, onClose }) {
84
105
  setAnswering(null);
85
106
  }
86
107
  };
87
- return (_jsxs("article", { className: "wtcal-detail", "aria-label": event.title, children: [_jsxs("header", { className: "wtcal-detail-head", children: [_jsx("h2", { className: "wtcal-detail-title", children: event.title }), _jsx(Button, { kind: "ghost", size: "sm", iconOnly: true, "aria-label": "Close event details", onPress: onClose, children: _jsx(Icon, { name: "close", size: "sm" }) })] }), _jsx("p", { className: "wtcal-detail-when", children: formatWhen(event) }), repeat !== null && _jsx("p", { className: "wtcal-detail-repeat", children: repeat }), invited && onRespond !== undefined && (_jsxs("section", { className: "wtcal-rsvp", "aria-label": "Your answer", children: [_jsx("h3", { className: "wtcal-detail-label", children: "Are you going?" }), _jsx("div", { className: "wtcal-rsvp-answers", children: ANSWERS.map((answer) => {
108
+ return (_jsxs("article", { className: "wtcal-detail", "aria-label": event.title, children: [_jsxs("header", { className: "wtcal-detail-head", children: [_jsx("h2", { className: "wtcal-detail-title", children: event.title }), _jsxs("div", { className: "wtcal-detail-head-actions", children: [_jsx(Button, { kind: "ghost", size: "sm", iconOnly: true, "aria-label": "Download as .ics", onPress: () => downloadIcs(event), children: _jsx(Icon, { name: "download", size: "sm" }) }), _jsx(Button, { kind: "ghost", size: "sm", iconOnly: true, "aria-label": "Close event details", onPress: onClose, children: _jsx(Icon, { name: "close", size: "sm" }) })] })] }), _jsx("p", { className: "wtcal-detail-when", children: formatWhen(event) }), repeat !== null && _jsx("p", { className: "wtcal-detail-repeat", children: repeat }), invited && onRespond !== undefined && (_jsxs("section", { className: "wtcal-rsvp", "aria-label": "Your answer", children: [_jsx("h3", { className: "wtcal-detail-label", children: "Are you going?" }), _jsx("div", { className: "wtcal-rsvp-answers", children: ANSWERS.map((answer) => {
88
109
  const chosen = mine?.participationStatus === answer.value;
89
110
  return (_jsx(Button, { kind: chosen ? 'primary' : 'default', "aria-pressed": chosen, busy: answering === answer.value, disabled: answering !== null, onPress: () => void respond(answer.value), children: answer.label }, answer.value));
90
111
  }) }), _jsx("p", { className: "wtcal-rsvp-note", children: "The organiser is told either way." }), failure !== null && (_jsx("p", { className: "wtcal-failure", role: "alert", children: failure }))] })), event.status === 'cancelled' && _jsx(Pill, { tone: "bad", children: "Cancelled" }), event.status === 'tentative' && _jsx(Pill, { tone: "warn", children: "Tentative" }), event.location !== undefined && (_jsxs("section", { className: "wtcal-detail-section", children: [_jsx("h3", { className: "wtcal-detail-label", children: "Where" }), _jsx("p", { className: "wtcal-detail-text", children: event.location })] })), event.description !== undefined && (_jsxs("section", { className: "wtcal-detail-section", children: [_jsx("h3", { className: "wtcal-detail-label", children: "Notes" }), _jsx("p", { className: "wtcal-detail-text", children: event.description })] })), participants.length > 0 && (_jsxs("section", { className: "wtcal-detail-section", children: [_jsxs("h3", { className: "wtcal-detail-label", children: [participants.length, " invited"] }), _jsx("ul", { className: "wtcal-detail-people", children: participants.map((participant) => (_jsx("li", { children: _jsx(Identity, { kind: "line", size: "sm", name: participant.name ?? null, address: addressOf(participant), aside: participant.participationStatus !== undefined && (_jsx(Pill, { quiet: true, tone: STATUS_TONE[participant.participationStatus], children: STATUS_WORD[participant.participationStatus] })) }) }, participant.calendarAddress))) })] })), _jsx("footer", { className: "wtcal-detail-actions", children: _jsx(Button, { kind: "primary", onPress: onEdit, children: "Edit event" }) })] }));
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  /**
3
3
  * The event editor: create, edit and delete a person's own events, recurring
4
4
  * included (MSG-055, https://github.com/wtfalch/messaging/issues/158).
@@ -33,6 +33,33 @@ const FREQUENCIES = [
33
33
  { value: 'monthly', label: 'Every month' },
34
34
  { value: 'yearly', label: 'Every year' },
35
35
  ];
36
+ /** Singular/plural noun for the "every N ___" interval field (wtfalch/calendar#30). */
37
+ const INTERVAL_UNIT = {
38
+ daily: ['day', 'days'],
39
+ weekly: ['week', 'weeks'],
40
+ monthly: ['month', 'months'],
41
+ yearly: ['year', 'years'],
42
+ };
43
+ /** Two-letter RFC 5545 weekday codes, Monday first -- `CalendarRecurrenceRule.byDay`'s
44
+ * own `day` values (wtfalch/calendar#30). Only offered for a weekly rule: a
45
+ * bare weekday on a daily/monthly/yearly rule is a different, unrelated
46
+ * RFC 8984 shape this ticket's evidence never asked for. */
47
+ const WEEKDAYS = [
48
+ { value: 'mo', label: 'Mo' },
49
+ { value: 'tu', label: 'Tu' },
50
+ { value: 'we', label: 'We' },
51
+ { value: 'th', label: 'Th' },
52
+ { value: 'fr', label: 'Fr' },
53
+ { value: 'sa', label: 'Sa' },
54
+ { value: 'su', label: 'Su' },
55
+ ];
56
+ function recurrenceEndOf(rule) {
57
+ if (rule?.until !== undefined)
58
+ return 'on';
59
+ if (rule?.count !== undefined)
60
+ return 'after';
61
+ return 'never';
62
+ }
36
63
  const DURATIONS = [
37
64
  { value: 'PT15M', label: '15 minutes' },
38
65
  { value: 'PT30M', label: '30 minutes' },
@@ -77,6 +104,16 @@ export function EventEditor({ event, initialStart, now, calendarId, compact, onS
77
104
  const [location, setLocation] = useState(event?.location ?? '');
78
105
  const [description, setDescription] = useState(event?.description ?? '');
79
106
  const [frequency, setFrequency] = useState(event?.recurrenceRule?.frequency ?? '');
107
+ // Named `recurrenceInterval`, not `interval`: the setter would otherwise be
108
+ // `setInterval`, shadowing the timer function of the same name.
109
+ const [recurrenceInterval, setRecurrenceInterval] = useState(event?.recurrenceRule?.interval ?? 1);
110
+ const [byDay, setByDay] = useState((event?.recurrenceRule?.byDay ?? []).map((day) => day.day));
111
+ const [recurrenceEnd, setRecurrenceEnd] = useState(recurrenceEndOf(event?.recurrenceRule));
112
+ // `until` here is a plain `YYYY-MM-DD` for the date input, not the wire's
113
+ // own local date-time -- `draft`'s own memo appends the end-of-day time
114
+ // when it builds the rule.
115
+ const [until, setUntil] = useState(event?.recurrenceRule?.until?.slice(0, 10) ?? '');
116
+ const [count, setCount] = useState(event?.recurrenceRule?.count ?? 5);
80
117
  const [participants, setParticipants] = useState(event?.participants ?? []);
81
118
  const [invitee, setInvitee] = useState('');
82
119
  /** Off, always, whatever the event already has on it. Sending is a decision
@@ -99,11 +136,30 @@ export function EventEditor({ event, initialStart, now, calendarId, compact, onS
99
136
  duration,
100
137
  isAllDay,
101
138
  location: location.trim() === '' ? undefined : location.trim(),
102
- recurrenceRule: frequency === '' ? undefined : { frequency, interval: 1 },
139
+ recurrenceRule: frequency === ''
140
+ ? undefined
141
+ : {
142
+ frequency,
143
+ interval: recurrenceInterval,
144
+ // `byDay` only makes sense once a week's worth of days exist to
145
+ // choose from -- a stale weekday picked while the frequency was
146
+ // 'weekly' must not leak onto a monthly/yearly rule when the
147
+ // person switches it without clearing the picker.
148
+ ...(frequency === 'weekly' && byDay.length > 0
149
+ ? { byDay: byDay.map((day) => ({ day })) }
150
+ : {}),
151
+ // The date input gives a bare day; the wire's `until` is
152
+ // inclusive, so end-of-day is what actually keeps that day's
153
+ // own occurrence in the series.
154
+ ...(recurrenceEnd === 'on' && until !== '' ? { until: `${until}T23:59:59` } : {}),
155
+ ...(recurrenceEnd === 'after' ? { count } : {}),
156
+ },
103
157
  participants: participants.length === 0 ? undefined : participants,
104
158
  status: event?.status ?? 'confirmed',
105
159
  }), [
160
+ byDay,
106
161
  calendarId,
162
+ count,
107
163
  description,
108
164
  duration,
109
165
  event,
@@ -111,9 +167,15 @@ export function EventEditor({ event, initialStart, now, calendarId, compact, onS
111
167
  isAllDay,
112
168
  location,
113
169
  participants,
170
+ recurrenceEnd,
171
+ recurrenceInterval,
114
172
  start,
115
173
  title,
174
+ until,
116
175
  ]);
176
+ const toggleWeekday = useCallback((day, on) => {
177
+ setByDay((current) => (on ? [...current, day] : current.filter((d) => d !== day)));
178
+ }, []);
117
179
  /** Somebody typed an address and meant it. Duplicates are dropped rather
118
180
  * than refused: adding a person already on the list is not an error, it is
119
181
  * just nothing. */
@@ -176,7 +238,7 @@ export function EventEditor({ event, initialStart, now, calendarId, compact, onS
176
238
  // began 3px before it ended -- the circle sat on the last letter.
177
239
  // The prop is the system's own answer to that, and the only thing
178
240
  // it changes is the body's right padding.
179
- _jsx(Checkbox, { tile: true, label: "Email everyone", checked: notify, onChange: setNotify, disabled: busy })), _jsx("span", { className: "wtcal-editor-spacer" }), _jsx(Button, { kind: "ghost", onPress: onClose, disabled: busy, children: "Cancel" }), _jsx(Button, { kind: "primary", busy: busy, disabled: titleMissing, onPress: () => attempt('save'), children: creating ? 'Create event' : 'Save changes' })] }), children: _jsxs("div", { className: compact ? 'wtcal-editor is-compact' : 'wtcal-editor', children: [_jsx(Field, { label: "Title", required: true, children: (wiring) => (_jsx(Input, { ...wiring, block: true, size: "lg", value: title, placeholder: "What is this meeting?", onChange: (e) => setTitle(e.target.value) })) }), _jsxs("div", { className: "wtcal-editor-row", children: [_jsx(Field, { label: isAllDay ? 'Day' : 'Starts', children: (wiring) => (_jsx(Input, { ...wiring, block: true, type: isAllDay ? 'date' : 'datetime-local', value: isAllDay ? start.slice(0, 10) : start, onChange: (e) => setStart(isAllDay ? `${e.target.value}T00:00` : e.target.value) })) }), !isAllDay && (_jsx(Field, { label: "For", children: (wiring) => (_jsx(Select, { ...wiring, block: true, value: duration, onChange: (e) => setDuration(e.target.value), children: durationOptions(duration).map((option) => (_jsx("option", { value: option.value, children: option.label }, option.value))) })) }))] }), !isAllDay && (_jsx(AvailabilityRibbon, { participants: participants, start: new Date(start), durationMinutes: (parseDurationMs(duration) ?? 3_600_000) / 60_000, lookup: availability })), _jsx(Checkbox, { label: "All day", checked: isAllDay, onChange: setIsAllDay }), _jsx(Field, { label: "Repeats", children: (wiring) => (_jsx(Select, { ...wiring, block: true, value: frequency, onChange: (e) => setFrequency(e.target.value), children: FREQUENCIES.map((option) => (_jsx("option", { value: option.value, children: option.label }, option.value))) })) }), _jsx(Field, { label: "Who", hint: "An email address. They are added to the event, not mailed yet.", children: (wiring) => (_jsxs("div", { className: "wtcal-invitee-add", children: [_jsx(Input, { ...wiring, block: true, type: "email", value: invitee, placeholder: "someone@example.org", onChange: (e) => setInvitee(e.target.value),
241
+ _jsx(Checkbox, { tile: true, label: "Email everyone", checked: notify, onChange: setNotify, disabled: busy })), _jsx("span", { className: "wtcal-editor-spacer" }), _jsx(Button, { kind: "ghost", onPress: onClose, disabled: busy, children: "Cancel" }), _jsx(Button, { kind: "primary", busy: busy, disabled: titleMissing, onPress: () => attempt('save'), children: creating ? 'Create event' : 'Save changes' })] }), children: _jsxs("div", { className: compact ? 'wtcal-editor is-compact' : 'wtcal-editor', children: [_jsx(Field, { label: "Title", required: true, children: (wiring) => (_jsx(Input, { ...wiring, block: true, size: "lg", value: title, placeholder: "What is this meeting?", onChange: (e) => setTitle(e.target.value) })) }), _jsxs("div", { className: "wtcal-editor-row", children: [_jsx(Field, { label: isAllDay ? 'Day' : 'Starts', children: (wiring) => (_jsx(Input, { ...wiring, block: true, type: isAllDay ? 'date' : 'datetime-local', value: isAllDay ? start.slice(0, 10) : start, onChange: (e) => setStart(isAllDay ? `${e.target.value}T00:00` : e.target.value) })) }), !isAllDay && (_jsx(Field, { label: "For", children: (wiring) => (_jsx(Select, { ...wiring, block: true, value: duration, onChange: (e) => setDuration(e.target.value), children: durationOptions(duration).map((option) => (_jsx("option", { value: option.value, children: option.label }, option.value))) })) }))] }), !isAllDay && (_jsx(AvailabilityRibbon, { participants: participants, start: new Date(start), durationMinutes: (parseDurationMs(duration) ?? 3_600_000) / 60_000, lookup: availability })), _jsx(Checkbox, { label: "All day", checked: isAllDay, onChange: setIsAllDay }), _jsx(Field, { label: "Repeats", children: (wiring) => (_jsx(Select, { ...wiring, block: true, value: frequency, onChange: (e) => setFrequency(e.target.value), children: FREQUENCIES.map((option) => (_jsx("option", { value: option.value, children: option.label }, option.value))) })) }), frequency !== '' && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "wtcal-editor-row", children: [_jsx(Field, { label: `Every (${INTERVAL_UNIT[frequency][recurrenceInterval === 1 ? 0 : 1]})`, children: (wiring) => (_jsx(Input, { ...wiring, block: true, type: "number", min: 1, value: recurrenceInterval, onChange: (e) => setRecurrenceInterval(Math.max(1, Number(e.target.value) || 1)) })) }), _jsx(Field, { label: "Ends", children: (wiring) => (_jsxs(Select, { ...wiring, block: true, value: recurrenceEnd, onChange: (e) => setRecurrenceEnd(e.target.value), children: [_jsx("option", { value: "never", children: "Never" }), _jsx("option", { value: "on", children: "On a date" }), _jsx("option", { value: "after", children: "After a number of times" })] })) })] }), frequency === 'weekly' && (_jsx(Field, { label: "On", hint: "Which day of the week.", children: () => (_jsx("div", { className: "wtcal-weekdays", children: WEEKDAYS.map((day) => (_jsx(Checkbox, { tile: true, label: day.label, checked: byDay.includes(day.value), onChange: (on) => toggleWeekday(day.value, on) }, day.value))) })) })), recurrenceEnd === 'on' && (_jsx(Field, { label: "End date", children: (wiring) => (_jsx(Input, { ...wiring, block: true, type: "date", value: until, onChange: (e) => setUntil(e.target.value) })) })), recurrenceEnd === 'after' && (_jsx(Field, { label: "Number of times", children: (wiring) => (_jsx(Input, { ...wiring, block: true, type: "number", min: 1, value: count, onChange: (e) => setCount(Math.max(1, Number(e.target.value) || 1)) })) }))] })), _jsx(Field, { label: "Who", hint: "An email address. They are added to the event, not mailed yet.", children: (wiring) => (_jsxs("div", { className: "wtcal-invitee-add", children: [_jsx(Input, { ...wiring, block: true, type: "email", value: invitee, placeholder: "someone@example.org", onChange: (e) => setInvitee(e.target.value),
180
242
  // Enter adds a person; without this it submits nothing and
181
243
  // the address the person typed disappears on Save.
182
244
  onKeyDown: (e) => {