@remit/ui 0.0.221 → 0.0.223
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 +14 -3
- package/src/components/DropdownMenu.tsx +100 -0
- package/src/components/EmptyState.tsx +11 -0
- package/src/components/ErrorBanner.render.test.ts +107 -0
- package/src/components/ErrorBanner.stories.tsx +132 -0
- package/src/components/ErrorBanner.tsx +122 -0
- package/src/components/ErrorBannerStack.tsx +34 -0
- package/src/components/ErrorState.render.test.ts +82 -0
- package/src/components/ErrorState.tsx +80 -0
- package/src/components/KeyboardShortcutsModal.tsx +111 -0
- package/src/components/account-service-change-dialog.render.test.ts +1 -41
- package/src/components/account-service-choice.render.test.ts +0 -26
- package/src/components/account-service-toggles.render.test.ts +0 -6
- package/src/components/address-display.render.test.ts +1 -38
- package/src/components/address-tag.render.test.ts +0 -11
- package/src/components/agenda-flow.reach.test.ts +0 -8
- package/src/components/agenda-flow.render.test.ts +0 -31
- package/src/components/agenda-panels.render.test.ts +0 -5
- package/src/components/app-shell-slotted.render.test.ts +0 -118
- package/src/components/attachment-list.render.test.ts +41 -24
- package/src/components/attachment-list.stories.tsx +67 -0
- package/src/components/attachment-list.tsx +112 -35
- package/src/components/attendee-row.render.test.ts +0 -41
- package/src/components/attention-dot.stories.tsx +46 -0
- package/src/components/attention-dot.tsx +23 -0
- package/src/components/banner.render.test.ts +0 -7
- package/src/components/bottom-sheet.render.test.ts +0 -42
- package/src/components/brief-section.render.test.ts +0 -13
- package/src/components/brief-sections.keyboard.test.ts +0 -13
- package/src/components/brief-sections.render.test.ts +0 -22
- package/src/components/calendar-clash-strip.render.test.ts +0 -19
- package/src/components/calendar-grid.render.test.ts +0 -79
- package/src/components/calendar-invite-card.render.test.ts +0 -19
- package/src/components/calendar-list.render.test.ts +0 -21
- package/src/components/calendar-slot-offers.render.test.ts +0 -24
- package/src/components/calendar-suggestion-deck.render.test.ts +0 -18
- package/src/components/calendar-toolbar.render.test.ts +1 -53
- package/src/components/category-badge.render.test.ts +1 -24
- package/src/components/compose-action-bar.render.test.ts +0 -5
- package/src/components/compose-attachments.render.test.ts +0 -38
- package/src/components/event-detail.render.test.ts +0 -27
- package/src/components/event-editor.render.test.ts +0 -4
- package/src/components/event-suggestion-card.render.test.ts +0 -61
- package/src/components/event-suggestion-card.zone-gate.test.ts +1 -7
- package/src/components/filter-clause-chip.tsx +1 -60
- package/src/components/filter-rule-editor.create.test.ts +0 -6
- package/src/components/filter-rule-editor.stories.tsx +24 -138
- package/src/components/filter-rule-editor.tsx +7 -93
- package/src/components/filter-rule.render.test.ts +9 -299
- package/src/components/filter-rule.ts +20 -85
- package/src/components/filter-sheet.render.test.ts +0 -7
- package/src/components/folder-manage-actions.render.test.ts +0 -13
- package/src/components/folder-manager.render.test.ts +0 -31
- package/src/components/folder-mutation-dialog.render.test.ts +0 -83
- package/src/components/folder-rename-dialog.render.test.ts +0 -14
- package/src/components/folder-row.render.test.ts +0 -30
- package/src/components/folder-sync-state.test.ts +0 -61
- package/src/components/folder-tree-picker.create.test.ts +0 -30
- package/src/components/folder-tree-picker.render.test.ts +0 -35
- package/src/components/intelligence-calendar-fixtures.ts +0 -2
- package/src/components/intelligence-calendar.render.test.ts +0 -4
- package/src/components/intelligence-panel.render.test.ts +1 -62
- package/src/components/intelligence-panel.stories.tsx +0 -76
- package/src/components/intelligence-panel.tab-strip.test.ts +0 -1
- package/src/components/intelligence-panel.tsx +6 -176
- package/src/components/intelligence-toggle.render.test.ts +0 -5
- package/src/components/isolated-email-frame.render.test.ts +0 -122
- package/src/components/isolated-email-frame.tsx +55 -3
- package/src/components/keyboard-hint-bar.render.test.ts +0 -7
- package/src/components/label-chip.render.test.ts +0 -28
- package/src/components/label-chip.tsx +1 -1
- package/src/components/mail-header.render.test.ts +0 -20
- package/src/components/mcp-connected-apps-page.stories.tsx +58 -0
- package/src/components/mcp-connected-apps-page.tsx +79 -0
- package/src/components/mcp-consent-page.stories.tsx +39 -0
- package/src/components/mcp-consent-page.tsx +47 -0
- package/src/components/mcp-device-page.stories.tsx +57 -0
- package/src/components/mcp-device-page.tsx +107 -0
- package/src/components/mcp-error-notice.stories.tsx +34 -0
- package/src/components/mcp-error-notice.tsx +23 -0
- package/src/components/mcp-error-page.stories.tsx +17 -0
- package/src/components/mcp-error-page.tsx +15 -0
- package/src/components/mcp-fixtures.ts +16 -0
- package/src/components/mcp-login-page.stories.tsx +37 -0
- package/src/components/mcp-login-page.tsx +58 -0
- package/src/components/mcp-page.stories.tsx +27 -0
- package/src/components/mcp-page.tsx +35 -0
- package/src/components/mcp-permission-list.stories.tsx +21 -0
- package/src/components/mcp-permission-list.tsx +22 -0
- package/src/components/message-body-view.render.test.ts +0 -21
- package/src/components/message-list-pane.brief-filter.test.ts +0 -6
- package/src/components/message-list-pane.render.test.ts +0 -54
- package/src/components/message-list-state.render.test.ts +0 -84
- package/src/components/{quarantine-bug-dialog.tsx → message-report-dialog.tsx} +9 -14
- package/src/components/message-row.render.test.ts +1 -98
- package/src/components/mobile-message-action-bar.render.test.ts +0 -59
- package/src/components/mobile-reading-pane.render.test.ts +0 -48
- package/src/components/mobile-reading-pane.stories.tsx +78 -0
- package/src/components/mobile-reading-pane.tsx +55 -41
- package/src/components/mobile-search-view.render.test.ts +0 -16
- package/src/components/mobile-search-view.stories.tsx +8 -11
- package/src/components/mobile-search-view.tsx +1 -1
- package/src/components/nav-sidebar.keyboard.test.ts +0 -8
- package/src/components/nav-sidebar.render.test.ts +2 -133
- package/src/components/new-folder-form.render.test.ts +0 -26
- package/src/components/outbox-row.render.test.ts +0 -9
- package/src/components/pane-layout.render.test.ts +0 -18
- package/src/components/plain-text-editor.mount.test.ts +0 -16
- package/src/components/popover-menu.render.test.ts +0 -11
- package/src/components/progress-bar.render.test.ts +0 -14
- package/src/components/quarantine-report.test.ts +0 -8
- package/src/components/quarantine-section.render.test.ts +16 -13
- package/src/components/quarantine-section.stories.tsx +11 -8
- package/src/components/reading-pane.render.test.ts +2 -106
- package/src/components/reading-pane.stories.tsx +3 -0
- package/src/components/refresh-button.render.test.ts +0 -9
- package/src/components/rescue-from-spam-flow.render.test.ts +0 -24
- package/src/components/rich-text-editor.mount.test.ts +0 -19
- package/src/components/rich-text-image-node.ts +11 -9
- package/src/components/role-appointment-list.render.test.ts +0 -49
- package/src/components/role-appointment-prompt.render.test.ts +0 -79
- package/src/components/row-actions.render.test.ts +0 -34
- package/src/components/search-bar.render.test.ts +0 -44
- package/src/components/search-chip-input.render.test.ts +0 -71
- package/src/components/search-conversion-notice.stories.tsx +0 -6
- package/src/components/search-conversion-notice.tsx +3 -9
- package/src/components/search-conversion.render.test.ts +0 -52
- package/src/components/search-conversion.ts +2 -18
- package/src/components/search-result-row.tsx +5 -26
- package/src/components/search-results.render.test.ts +0 -68
- package/src/components/search-results.stories.tsx +0 -30
- package/src/components/search-results.tsx +1 -1
- package/src/components/security-select.render.test.ts +1 -14
- package/src/components/selection-top-bar.render.test.ts +0 -180
- package/src/components/selection-wizard-fixtures.ts +0 -2
- package/src/components/selection-wizard.render.test.ts +7 -212
- package/src/components/selection-wizard.stories.tsx +24 -164
- package/src/components/selection-wizard.tsx +10 -86
- package/src/components/self-update.render.test.ts +0 -113
- package/src/components/sender-trust-indicator.render.test.ts +0 -30
- package/src/components/shell-top-bar.render.test.ts +0 -31
- package/src/components/shell-top-bar.stories.tsx +7 -0
- package/src/components/shell-top-bar.tsx +11 -2
- package/src/components/slide-panel.render.test.ts +0 -18
- package/src/components/suggest-list.render.test.ts +0 -6
- package/src/components/swipeable-row.gesture.test.ts +85 -40
- package/src/components/swipeable-row.render.test.ts +0 -7
- package/src/components/swipeable-row.stories.tsx +3 -2
- package/src/components/swipeable-row.tsx +65 -144
- package/src/components/sync-warning-fixtures.ts +22 -0
- package/src/components/sync-warning-report.ts +38 -0
- package/src/components/sync-warning-row.tsx +51 -0
- package/src/components/sync-warning-section.render.test.ts +19 -0
- package/src/components/sync-warning-section.stories.tsx +94 -0
- package/src/components/sync-warning-section.tsx +56 -0
- package/src/components/touch-list-body.render.test.ts +0 -29
- package/src/components/wizard.render.test.ts +0 -22
- package/src/filter-presets.test.ts +1 -107
- package/src/index.ts +40 -34
- package/src/lib/compose-language.test.ts +0 -11
- package/src/lib/email-render-treatment.test.ts +0 -21
- package/src/lib/keymap.test.ts +0 -32
- package/src/lib/property-prefill.ts +2 -2
- package/src/lib/search-rule.test.ts +0 -4
- package/src/lib/search-rule.ts +0 -9
- package/src/lib/sender-derivation.ts +3 -5
- package/src/lib/swipe-config.ts +11 -0
- package/src/lib/use-list-cursor.test.ts +0 -7
- package/src/lib/use-list-keyboard.test.ts +0 -14
- package/src/lib/use-long-press.test.ts +53 -36
- package/src/lib/use-long-press.ts +62 -56
- package/src/lib/use-modal-focus.test.ts +0 -20
- package/src/lib/use-selection.hook.test.ts +0 -13
- package/src/lib/use-selection.test.ts +0 -101
- package/src/lib/use-swipe-navigation.test.ts +162 -0
- package/src/lib/use-swipe-navigation.ts +90 -0
- package/src/lib/wizard-steps.test.ts +18 -79
- package/src/lib/wizard-steps.ts +27 -67
- package/src/mcp-pages.ts +36 -0
- package/src/category-presentation.test.ts +0 -76
- package/src/components/account-service-status.render.test.ts +0 -82
- package/src/components/app-password-hint.render.test.ts +0 -23
- package/src/components/app-top-bar.render.test.ts +0 -59
- package/src/components/auth-card.render.test.ts +0 -24
- package/src/components/auth-footer.render.test.ts +0 -17
- package/src/components/auth-hero.render.test.ts +0 -31
- package/src/components/auto-moved-badge.render.test.ts +0 -65
- package/src/components/button.render.test.ts +0 -29
- package/src/components/calendar-event-chip.render.test.ts +0 -67
- package/src/components/calendar-parse-badge.render.test.ts +0 -40
- package/src/components/checkbox.render.test.ts +0 -65
- package/src/components/compose-form-shell.render.test.ts +0 -106
- package/src/components/dialog.render.test.ts +0 -51
- package/src/components/field-label.render.test.ts +0 -16
- package/src/components/mail-action-toolbar.render.test.ts +0 -43
- package/src/components/nav-link-surface.render.test.ts +0 -126
- package/src/components/new-folder-action.render.test.ts +0 -44
- package/src/components/pane-header.render.test.ts +0 -22
- package/src/components/pull-to-refresh.render.test.ts +0 -46
- package/src/components/recurrence-scope-prompt.render.test.ts +0 -36
- package/src/components/rescue-banner.render.test.ts +0 -32
- package/src/components/rescue-candidate-row.render.test.ts +0 -68
- package/src/components/search-token-chip.render.test.ts +0 -42
- package/src/components/self-update-dot.tsx +0 -32
- package/src/components/settings-primitives.render.test.ts +0 -160
- package/src/lib/email-layout-clamp.test.ts +0 -139
- package/src/lib/label-color.test.ts +0 -25
- package/src/lib/semantic-off.ts +0 -20
- package/src/stories-viewport-globals.test.ts +0 -77
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
import { type FullGestureState, useDrag } from "@use-gesture/react";
|
|
1
2
|
import { Check, Mail, MailOpen, Trash2 } from "lucide-react";
|
|
2
3
|
import { useRef, useState } from "react";
|
|
3
4
|
import { mergeProps } from "react-aria";
|
|
4
5
|
import { cn } from "../lib/cn.js";
|
|
5
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
SWIPE_AXIS_THRESHOLD,
|
|
8
|
+
SWIPE_DRAG_CONFIG,
|
|
9
|
+
} from "../lib/swipe-config.js";
|
|
10
|
+
import {
|
|
11
|
+
holdConfig,
|
|
12
|
+
isHold,
|
|
13
|
+
LONG_PRESS_DELAY_MS,
|
|
14
|
+
swallowReleaseClick,
|
|
15
|
+
touchMenuSuppressionProps,
|
|
16
|
+
} from "../lib/use-long-press.js";
|
|
6
17
|
import type { ThreadRowData } from "./app-shell-types.js";
|
|
7
18
|
import { Avatar } from "./avatar.js";
|
|
8
19
|
import {
|
|
@@ -15,38 +26,6 @@ export type SwipePeek = "none" | "leading" | "trailing";
|
|
|
15
26
|
/** Width a peeked row settles at to reveal its action; also the drag distance
|
|
16
27
|
* past which a release commits the peek rather than snapping back. */
|
|
17
28
|
const SWIPE_ACTION_WIDTH = 72;
|
|
18
|
-
/** Movement (px) before a pointer drag claims an axis; below this a press is
|
|
19
|
-
* still a tap / long-press and vertical scroll wins. Claiming an axis only
|
|
20
|
-
* decides what the row tracks — it does not decide the long press. */
|
|
21
|
-
const SWIPE_AXIS_THRESHOLD = 10;
|
|
22
|
-
/**
|
|
23
|
-
* Movement (px) along the claimed axis before a drag takes the gesture away
|
|
24
|
-
* from a still-pending long press.
|
|
25
|
-
*
|
|
26
|
-
* A finger resting on glass for the 500ms hold drifts, and it drifts further
|
|
27
|
-
* than the axis threshold — that threshold is calibrated for a drag starting
|
|
28
|
-
* to track, which has to feel immediate. Killing the press at that distance
|
|
29
|
-
* meant a real hold read as a swipe: the row followed the drift, the press
|
|
30
|
-
* died, and on release the drift was too short to commit a peek, so the
|
|
31
|
-
* gesture produced nothing at all.
|
|
32
|
-
*
|
|
33
|
-
* The escape distance is the commit distance, so the swipe only takes the
|
|
34
|
-
* gesture once it has moved far enough to actually produce a peek. Below it a
|
|
35
|
-
* release snaps back, which is to say the swipe was never worth the press.
|
|
36
|
-
*/
|
|
37
|
-
const LONG_PRESS_ESCAPE = SWIPE_ACTION_WIDTH / 2;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Tags a pointercancel dispatched by this component's own arbitration (see
|
|
41
|
-
* `cancelLongPress` below) so `onPointerCancel` can tell it apart from one
|
|
42
|
-
* react-aria dispatches itself when its own long press fires, or a genuine
|
|
43
|
-
* browser-triggered cancel. Both of those end the gesture and must reset it
|
|
44
|
-
* silently; a tagged one arrives *because* `onPointerMove`/`onPointerUp` is
|
|
45
|
-
* already handling that gesture inline, so `onPointerCancel` must ignore it —
|
|
46
|
-
* otherwise it drops the drag and the release reads as a tap, firing a
|
|
47
|
-
* spurious onOpen/onToggleCheck.
|
|
48
|
-
*/
|
|
49
|
-
const AXIS_CANCEL = "__swipeableRowAxisCancel";
|
|
50
29
|
|
|
51
30
|
function peekOffset(peek: SwipePeek): number {
|
|
52
31
|
if (peek === "leading") return SWIPE_ACTION_WIDTH;
|
|
@@ -88,127 +67,69 @@ export function SwipeableRow({
|
|
|
88
67
|
* "trailing" = delete. */
|
|
89
68
|
onAct: (side: "leading" | "trailing") => void;
|
|
90
69
|
}) {
|
|
91
|
-
const gesture = useRef<{
|
|
92
|
-
startX: number;
|
|
93
|
-
startY: number;
|
|
94
|
-
axis: "none" | "horizontal" | "vertical";
|
|
95
|
-
/** The drag has passed LONG_PRESS_ESCAPE and already cancelled the press. */
|
|
96
|
-
escaped: boolean;
|
|
97
|
-
} | null>(null);
|
|
98
70
|
const [dragX, setDragX] = useState<number | null>(null);
|
|
71
|
+
const dragOffset = useRef<number | null>(null);
|
|
72
|
+
const held = useRef(false);
|
|
99
73
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
onLongPress,
|
|
104
|
-
isDisabled: selectionMode,
|
|
105
|
-
accessibilityDescription: "Select message",
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
// react-aria's usePress has no imperative "cancel" — a synthetic
|
|
109
|
-
// pointercancel is the mechanism it uses itself to abort other pointer
|
|
110
|
-
// consumers when its own long press fires. Reused here in reverse, tagged
|
|
111
|
-
// so onPointerCancel below can recognize it as ours (see AXIS_CANCEL).
|
|
112
|
-
const cancelLongPress = (e: React.PointerEvent) => {
|
|
113
|
-
const event = new PointerEvent("pointercancel", { bubbles: true });
|
|
114
|
-
(event as PointerEvent & Record<string, boolean>)[AXIS_CANCEL] = true;
|
|
115
|
-
e.currentTarget.dispatchEvent(event);
|
|
74
|
+
const trackDrag = (offset: number | null) => {
|
|
75
|
+
dragOffset.current = offset;
|
|
76
|
+
setDragX(offset);
|
|
116
77
|
};
|
|
117
78
|
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (selectionMode) return;
|
|
129
|
-
const g = gesture.current;
|
|
130
|
-
if (!g) return;
|
|
131
|
-
const dx = e.clientX - g.startX;
|
|
132
|
-
const dy = e.clientY - g.startY;
|
|
133
|
-
if (g.axis === "none") {
|
|
134
|
-
if (Math.abs(dy) > SWIPE_AXIS_THRESHOLD && Math.abs(dy) > Math.abs(dx)) {
|
|
135
|
-
// vertical scroll wins: stop tracking the swipe, let the list scroll
|
|
136
|
-
g.axis = "vertical";
|
|
137
|
-
} else if (
|
|
138
|
-
Math.abs(dx) > SWIPE_AXIS_THRESHOLD &&
|
|
139
|
-
Math.abs(dx) > Math.abs(dy)
|
|
140
|
-
) {
|
|
141
|
-
g.axis = "horizontal";
|
|
142
|
-
e.currentTarget.setPointerCapture(e.pointerId);
|
|
79
|
+
const release = (state: FullGestureState<"drag">) => {
|
|
80
|
+
const offset = dragOffset.current;
|
|
81
|
+
const wasHeld = held.current;
|
|
82
|
+
held.current = false;
|
|
83
|
+
trackDrag(null);
|
|
84
|
+
if (state.event.type.endsWith("cancel") || wasHeld) return;
|
|
85
|
+
if (state.tap) {
|
|
86
|
+
if (selectionMode) {
|
|
87
|
+
onToggleCheck();
|
|
88
|
+
return;
|
|
143
89
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const travel = g.axis === "horizontal" ? Math.abs(dx) : Math.abs(dy);
|
|
150
|
-
if (!g.escaped && travel > LONG_PRESS_ESCAPE) {
|
|
151
|
-
g.escaped = true;
|
|
152
|
-
cancelLongPress(e);
|
|
153
|
-
}
|
|
154
|
-
if (g.axis !== "horizontal") return;
|
|
155
|
-
const base = peekOffset(peek);
|
|
156
|
-
const next = Math.max(
|
|
157
|
-
-SWIPE_ACTION_WIDTH,
|
|
158
|
-
Math.min(SWIPE_ACTION_WIDTH, base + dx),
|
|
159
|
-
);
|
|
160
|
-
setDragX(next);
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
const onPointerUp = (e: React.PointerEvent) => {
|
|
164
|
-
const g = gesture.current;
|
|
165
|
-
gesture.current = null;
|
|
166
|
-
const offset = dragX;
|
|
167
|
-
setDragX(null);
|
|
168
|
-
// g is null when the gesture was already consumed (the long press fired,
|
|
169
|
-
// or a real cancel arrived) — those handle themselves, so do nothing.
|
|
170
|
-
if (!g) return;
|
|
171
|
-
// A drag that claimed an axis but never escaped left react-aria's press
|
|
172
|
-
// live, and an unresolved press synthesizes a click on release. The drag
|
|
173
|
-
// was neither a swipe nor a tap, so end the press with it.
|
|
174
|
-
if (g.axis !== "none" && !g.escaped) cancelLongPress(e);
|
|
175
|
-
if (g.axis === "horizontal") {
|
|
176
|
-
if (offset !== null) onPeek(commitPeek(offset));
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
// The list scrolled under the finger; the release is not a tap.
|
|
180
|
-
if (g.axis === "vertical") return;
|
|
181
|
-
// a tap: no axis claimed
|
|
182
|
-
if (selectionMode) {
|
|
183
|
-
onToggleCheck();
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
if (peek !== "none") {
|
|
187
|
-
onPeek("none");
|
|
90
|
+
if (peek !== "none") {
|
|
91
|
+
onPeek("none");
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
onOpen();
|
|
188
95
|
return;
|
|
189
96
|
}
|
|
190
|
-
|
|
97
|
+
if (state.axis !== "x" || selectionMode || offset === null) return;
|
|
98
|
+
onPeek(commitPeek(offset));
|
|
191
99
|
};
|
|
192
100
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
101
|
+
const bind = useDrag(
|
|
102
|
+
(state) => {
|
|
103
|
+
if (!state.down) {
|
|
104
|
+
release(state);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (isHold(state)) {
|
|
108
|
+
if (selectionMode) return;
|
|
109
|
+
held.current = true;
|
|
110
|
+
swallowReleaseClick();
|
|
111
|
+
onLongPress();
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (!state.intentional) return;
|
|
115
|
+
if (selectionMode || held.current || state.axis !== "x") return;
|
|
116
|
+
const travelled = state.values[0] - state.initial[0];
|
|
117
|
+
trackDrag(
|
|
118
|
+
Math.max(
|
|
119
|
+
-SWIPE_ACTION_WIDTH,
|
|
120
|
+
Math.min(SWIPE_ACTION_WIDTH, peekOffset(peek) + travelled),
|
|
121
|
+
),
|
|
122
|
+
);
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
...holdConfig(LONG_PRESS_DELAY_MS),
|
|
126
|
+
tapsThreshold: SWIPE_AXIS_THRESHOLD,
|
|
127
|
+
axisThreshold: SWIPE_DRAG_CONFIG.axisThreshold,
|
|
128
|
+
},
|
|
129
|
+
);
|
|
206
130
|
|
|
207
|
-
const gestureProps = mergeProps(
|
|
208
|
-
|
|
209
|
-
onPointerMove,
|
|
210
|
-
onPointerUp,
|
|
211
|
-
onPointerCancel,
|
|
131
|
+
const gestureProps = mergeProps(bind(), touchMenuSuppressionProps, {
|
|
132
|
+
"aria-description": selectionMode ? undefined : "Select message",
|
|
212
133
|
});
|
|
213
134
|
|
|
214
135
|
const offset = dragX ?? peekOffset(peek);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { SyncWarningEntry } from "./sync-warning-report.js";
|
|
2
|
+
|
|
3
|
+
export const syncWarningDemoEntries: readonly SyncWarningEntry[] = [
|
|
4
|
+
{
|
|
5
|
+
syncWarningId: "w-1",
|
|
6
|
+
uid: 51_002,
|
|
7
|
+
stage: "Body",
|
|
8
|
+
state: "GaveUp",
|
|
9
|
+
attempts: 3,
|
|
10
|
+
createdAt: Date.parse("2026-10-17T08:12:00Z"),
|
|
11
|
+
folderLabel: "Inbox",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
syncWarningId: "w-2",
|
|
15
|
+
uid: 50_874,
|
|
16
|
+
stage: "Header",
|
|
17
|
+
state: "Retrying",
|
|
18
|
+
attempts: 7,
|
|
19
|
+
createdAt: Date.parse("2026-10-16T21:40:00Z"),
|
|
20
|
+
folderLabel: "Receipts",
|
|
21
|
+
},
|
|
22
|
+
];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { SyncWarningStage, SyncWarningState } from "@remit/domain-enums";
|
|
2
|
+
|
|
3
|
+
export interface SyncWarningEntry {
|
|
4
|
+
syncWarningId: string;
|
|
5
|
+
uid: number;
|
|
6
|
+
stage: (typeof SyncWarningStage)[keyof typeof SyncWarningStage];
|
|
7
|
+
state: (typeof SyncWarningState)[keyof typeof SyncWarningState];
|
|
8
|
+
attempts: number;
|
|
9
|
+
createdAt: number;
|
|
10
|
+
folderLabel: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const summaries: Record<SyncWarningEntry["state"], string> = {
|
|
14
|
+
Retrying: "The message could not be synced. Remit tries again every sync.",
|
|
15
|
+
GaveUp: "The message body could not be downloaded. Remit has stopped trying.",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export function syncWarningSummary(entry: SyncWarningEntry): string {
|
|
19
|
+
return summaries[entry.state];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const SYNC_WARNING_REPORT_DISCLAIMER =
|
|
23
|
+
"_No message content, addresses, subject, folder name or error text are included._";
|
|
24
|
+
|
|
25
|
+
export function formatSyncWarningReport(entry: SyncWarningEntry): string {
|
|
26
|
+
return [
|
|
27
|
+
`### Message failed to sync at \`${entry.stage}\``,
|
|
28
|
+
"",
|
|
29
|
+
`- **State**: \`${entry.state}\``,
|
|
30
|
+
`- **Attempts**: ${entry.attempts}`,
|
|
31
|
+
"",
|
|
32
|
+
SYNC_WARNING_REPORT_DISCLAIMER,
|
|
33
|
+
].join("\n");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function syncWarningIssueTitle(entry: SyncWarningEntry): string {
|
|
37
|
+
return `Message failed to sync: ${entry.state} at ${entry.stage}`;
|
|
38
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Bug } from "lucide-react";
|
|
2
|
+
import { Badge } from "./badge.js";
|
|
3
|
+
import { Button } from "./button.js";
|
|
4
|
+
import {
|
|
5
|
+
type SyncWarningEntry,
|
|
6
|
+
syncWarningSummary,
|
|
7
|
+
} from "./sync-warning-report.js";
|
|
8
|
+
|
|
9
|
+
export interface SyncWarningRowProps {
|
|
10
|
+
entry: SyncWarningEntry;
|
|
11
|
+
onReport: (entry: SyncWarningEntry) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function formatCreatedAt(epochMillis: number): string {
|
|
15
|
+
return new Date(epochMillis).toLocaleString(undefined, {
|
|
16
|
+
dateStyle: "medium",
|
|
17
|
+
timeStyle: "short",
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function SyncWarningRow({ entry, onReport }: SyncWarningRowProps) {
|
|
22
|
+
const gaveUp = entry.state === "GaveUp";
|
|
23
|
+
return (
|
|
24
|
+
<li className="flex flex-col gap-2 border-b border-line px-row-inset py-3 last:border-b-0 sm:flex-row sm:items-start sm:justify-between">
|
|
25
|
+
<div className="min-w-0 space-y-1">
|
|
26
|
+
<p className="text-sm text-fg">{syncWarningSummary(entry)}</p>
|
|
27
|
+
<p className="flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-subtle">
|
|
28
|
+
<Badge tone={gaveUp ? "danger" : "warning"}>
|
|
29
|
+
{gaveUp ? "Gave up" : "Retrying"}
|
|
30
|
+
</Badge>
|
|
31
|
+
<span className="truncate">{entry.folderLabel}</span>
|
|
32
|
+
<span aria-hidden>·</span>
|
|
33
|
+
<span>{`uid ${entry.uid}`}</span>
|
|
34
|
+
<span aria-hidden>·</span>
|
|
35
|
+
<span>{`since ${formatCreatedAt(entry.createdAt)}`}</span>
|
|
36
|
+
<span aria-hidden>·</span>
|
|
37
|
+
<span>{`${entry.attempts} attempts`}</span>
|
|
38
|
+
</p>
|
|
39
|
+
</div>
|
|
40
|
+
<Button
|
|
41
|
+
variant="secondary"
|
|
42
|
+
size="sm"
|
|
43
|
+
className="shrink-0"
|
|
44
|
+
icon={<Bug className="size-3.5" />}
|
|
45
|
+
onClick={() => onReport(entry)}
|
|
46
|
+
>
|
|
47
|
+
Cut a bug
|
|
48
|
+
</Button>
|
|
49
|
+
</li>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { describe, it } from "node:test";
|
|
3
|
+
import { createElement } from "react";
|
|
4
|
+
import { renderToString } from "react-dom/server";
|
|
5
|
+
import { syncWarningDemoEntries } from "./sync-warning-fixtures.js";
|
|
6
|
+
import { SyncWarningSection } from "./sync-warning-section.js";
|
|
7
|
+
|
|
8
|
+
describe("SyncWarningSection", () => {
|
|
9
|
+
it("states the total when the list is capped", () => {
|
|
10
|
+
const html = renderToString(
|
|
11
|
+
createElement(SyncWarningSection, {
|
|
12
|
+
entries: syncWarningDemoEntries,
|
|
13
|
+
total: 4812,
|
|
14
|
+
onReport: () => {},
|
|
15
|
+
}),
|
|
16
|
+
);
|
|
17
|
+
assert.match(html, /Showing the 2 newest of 4812/);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { MessageReportDialog } from "./message-report-dialog.js";
|
|
4
|
+
import { syncWarningDemoEntries } from "./sync-warning-fixtures.js";
|
|
5
|
+
import {
|
|
6
|
+
formatSyncWarningReport,
|
|
7
|
+
type SyncWarningEntry,
|
|
8
|
+
} from "./sync-warning-report.js";
|
|
9
|
+
import { SyncWarningRow } from "./sync-warning-row.js";
|
|
10
|
+
import { SyncWarningSection } from "./sync-warning-section.js";
|
|
11
|
+
|
|
12
|
+
const [gaveUp, retrying] = syncWarningDemoEntries;
|
|
13
|
+
|
|
14
|
+
const demoIssueUrl = "https://github.com/remit-mail/reader/issues/new";
|
|
15
|
+
|
|
16
|
+
const meta: Meta<typeof SyncWarningSection> = {
|
|
17
|
+
title: "Design System/Settings/Sync warnings",
|
|
18
|
+
component: SyncWarningSection,
|
|
19
|
+
parameters: { layout: "padded" },
|
|
20
|
+
args: { onReport: () => {} },
|
|
21
|
+
decorators: [
|
|
22
|
+
(Story) => (
|
|
23
|
+
<div className="mx-auto max-w-2xl">
|
|
24
|
+
<Story />
|
|
25
|
+
</div>
|
|
26
|
+
),
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
export default meta;
|
|
30
|
+
|
|
31
|
+
type Story = StoryObj<typeof SyncWarningSection>;
|
|
32
|
+
|
|
33
|
+
export const Empty: Story = {
|
|
34
|
+
args: { entries: [], total: 0 },
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const Mixed: Story = {
|
|
38
|
+
args: {
|
|
39
|
+
entries: syncWarningDemoEntries,
|
|
40
|
+
total: syncWarningDemoEntries.length,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const OverCap: Story = {
|
|
45
|
+
args: { entries: syncWarningDemoEntries, total: 4_812 },
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const GaveUpRow: Story = {
|
|
49
|
+
render: () => (
|
|
50
|
+
<ul className="rounded-sm border border-line bg-surface">
|
|
51
|
+
<SyncWarningRow entry={gaveUp} onReport={() => {}} />
|
|
52
|
+
</ul>
|
|
53
|
+
),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const RetryingRow: Story = {
|
|
57
|
+
render: () => (
|
|
58
|
+
<ul className="rounded-sm border border-line bg-surface">
|
|
59
|
+
<SyncWarningRow entry={retrying} onReport={() => {}} />
|
|
60
|
+
</ul>
|
|
61
|
+
),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const ReportFlow: Story = {
|
|
65
|
+
render: () => {
|
|
66
|
+
const [open, setOpen] = useState<SyncWarningEntry | null>(null);
|
|
67
|
+
return (
|
|
68
|
+
<>
|
|
69
|
+
<SyncWarningSection
|
|
70
|
+
entries={syncWarningDemoEntries}
|
|
71
|
+
total={syncWarningDemoEntries.length}
|
|
72
|
+
onReport={setOpen}
|
|
73
|
+
/>
|
|
74
|
+
<MessageReportDialog
|
|
75
|
+
report={open ? formatSyncWarningReport(open) : null}
|
|
76
|
+
issueUrl={demoIssueUrl}
|
|
77
|
+
onClose={() => setOpen(null)}
|
|
78
|
+
onCopy={() => setOpen(null)}
|
|
79
|
+
/>
|
|
80
|
+
</>
|
|
81
|
+
);
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const Report: Story = {
|
|
86
|
+
render: () => (
|
|
87
|
+
<MessageReportDialog
|
|
88
|
+
report={formatSyncWarningReport(gaveUp)}
|
|
89
|
+
issueUrl={demoIssueUrl}
|
|
90
|
+
onClose={() => {}}
|
|
91
|
+
onCopy={() => {}}
|
|
92
|
+
/>
|
|
93
|
+
),
|
|
94
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { CheckCircle2 } from "lucide-react";
|
|
2
|
+
import type { SyncWarningEntry } from "./sync-warning-report.js";
|
|
3
|
+
import { SyncWarningRow } from "./sync-warning-row.js";
|
|
4
|
+
|
|
5
|
+
export interface SyncWarningSectionProps {
|
|
6
|
+
entries: readonly SyncWarningEntry[];
|
|
7
|
+
total: number;
|
|
8
|
+
onReport: (entry: SyncWarningEntry) => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function SyncWarningSection({
|
|
12
|
+
entries,
|
|
13
|
+
total,
|
|
14
|
+
onReport,
|
|
15
|
+
}: SyncWarningSectionProps) {
|
|
16
|
+
return (
|
|
17
|
+
<section className="space-y-3">
|
|
18
|
+
<header className="space-y-1">
|
|
19
|
+
<h2 className="text-sm font-semibold text-fg">
|
|
20
|
+
Messages that failed to sync
|
|
21
|
+
</h2>
|
|
22
|
+
<p className="text-xs text-fg-muted">
|
|
23
|
+
A message shows here after three failed rounds and leaves on its own
|
|
24
|
+
once it syncs. The rest of the folder keeps syncing.
|
|
25
|
+
</p>
|
|
26
|
+
</header>
|
|
27
|
+
|
|
28
|
+
{entries.length === 0 && (
|
|
29
|
+
<div className="flex items-center gap-2 rounded-sm border border-line bg-surface px-row-inset py-3">
|
|
30
|
+
<CheckCircle2 className="size-4 shrink-0 text-positive" aria-hidden />
|
|
31
|
+
<p className="text-sm text-fg-muted">
|
|
32
|
+
Every message is syncing. Nothing has failed.
|
|
33
|
+
</p>
|
|
34
|
+
</div>
|
|
35
|
+
)}
|
|
36
|
+
|
|
37
|
+
{total > entries.length && (
|
|
38
|
+
<p className="text-xs text-fg-muted">
|
|
39
|
+
{`Showing the ${entries.length} newest of ${total} messages that failed to sync.`}
|
|
40
|
+
</p>
|
|
41
|
+
)}
|
|
42
|
+
|
|
43
|
+
{entries.length > 0 && (
|
|
44
|
+
<ul className="rounded-sm border border-line bg-surface">
|
|
45
|
+
{entries.map((entry) => (
|
|
46
|
+
<SyncWarningRow
|
|
47
|
+
key={entry.syncWarningId}
|
|
48
|
+
entry={entry}
|
|
49
|
+
onReport={onReport}
|
|
50
|
+
/>
|
|
51
|
+
))}
|
|
52
|
+
</ul>
|
|
53
|
+
)}
|
|
54
|
+
</section>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -46,12 +46,6 @@ const baseProps = {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
describe("TouchListBody", () => {
|
|
49
|
-
it("renders the rows", () => {
|
|
50
|
-
const html = renderToString(createElement(TouchListBody, baseProps));
|
|
51
|
-
assert.match(html, /Priya Nair/);
|
|
52
|
-
assert.match(html, /Alex Rivera/);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
49
|
it("shows the refreshing affordance when refreshing", () => {
|
|
56
50
|
const html = renderToString(
|
|
57
51
|
createElement(TouchListBody, { ...baseProps, refreshing: true }),
|
|
@@ -59,33 +53,10 @@ describe("TouchListBody", () => {
|
|
|
59
53
|
assert.match(html, /Checking for new mail/);
|
|
60
54
|
});
|
|
61
55
|
|
|
62
|
-
it("shows pull to refresh when idle and not in selection mode", () => {
|
|
63
|
-
const html = renderToString(createElement(TouchListBody, baseProps));
|
|
64
|
-
assert.match(html, /Pull to refresh/);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("dims and suppresses taps on every row while busy", () => {
|
|
68
|
-
const html = renderToString(
|
|
69
|
-
createElement(TouchListBody, {
|
|
70
|
-
...baseProps,
|
|
71
|
-
selectionMode: true,
|
|
72
|
-
checkedIds: new Set(["t1", "t2"]),
|
|
73
|
-
busy: true,
|
|
74
|
-
}),
|
|
75
|
-
);
|
|
76
|
-
const dimmed = (html.match(/pointer-events-none opacity-50/g) ?? []).length;
|
|
77
|
-
assert.equal(dimmed, 2, "both seeded rows are dimmed");
|
|
78
|
-
});
|
|
79
|
-
|
|
80
56
|
it("hides pull to refresh while busy", () => {
|
|
81
57
|
const html = renderToString(
|
|
82
58
|
createElement(TouchListBody, { ...baseProps, busy: true }),
|
|
83
59
|
);
|
|
84
60
|
assert.doesNotMatch(html, /Pull to refresh/);
|
|
85
61
|
});
|
|
86
|
-
|
|
87
|
-
it("renders rows undimmed when not busy", () => {
|
|
88
|
-
const html = renderToString(createElement(TouchListBody, baseProps));
|
|
89
|
-
assert.doesNotMatch(html, /pointer-events-none/);
|
|
90
|
-
});
|
|
91
62
|
});
|
|
@@ -24,26 +24,4 @@ describe("ConnectorTile coming-soon", () => {
|
|
|
24
24
|
);
|
|
25
25
|
assert.match(html, /<button/, "tile is a pressable button");
|
|
26
26
|
});
|
|
27
|
-
|
|
28
|
-
it("renders a comingSoon tile without a handler as a safe no-op", () => {
|
|
29
|
-
assert.doesNotThrow(() =>
|
|
30
|
-
markup({
|
|
31
|
-
name: "Gmail",
|
|
32
|
-
description: "Sign in with Google.",
|
|
33
|
-
icon: null,
|
|
34
|
-
comingSoon: true,
|
|
35
|
-
}),
|
|
36
|
-
);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("renders a normal tile without coming-soon affordances", () => {
|
|
40
|
-
const html = markup({
|
|
41
|
-
name: "IMAP / SMTP",
|
|
42
|
-
description: "Any provider.",
|
|
43
|
-
icon: null,
|
|
44
|
-
onSelect: () => undefined,
|
|
45
|
-
});
|
|
46
|
-
assert.doesNotMatch(html, /aria-disabled/);
|
|
47
|
-
assert.doesNotMatch(html, />soon</);
|
|
48
|
-
});
|
|
49
27
|
});
|