@remit/ui 0.0.187 → 0.0.188
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
CHANGED
|
@@ -308,47 +308,6 @@ describe("NavSidebar", () => {
|
|
|
308
308
|
});
|
|
309
309
|
});
|
|
310
310
|
|
|
311
|
-
describe("NavSidebar saved searches", () => {
|
|
312
|
-
it("omits the group when there are no saved searches and no active query", () => {
|
|
313
|
-
const html = renderToString(
|
|
314
|
-
createElement(NavSidebar, {
|
|
315
|
-
accounts,
|
|
316
|
-
selectedNavId: "brief",
|
|
317
|
-
onSelectNav: () => undefined,
|
|
318
|
-
}),
|
|
319
|
-
);
|
|
320
|
-
assert.doesNotMatch(html, /Saved searches/);
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
it("renders every saved search", () => {
|
|
324
|
-
const html = renderToString(
|
|
325
|
-
createElement(NavSidebar, {
|
|
326
|
-
accounts,
|
|
327
|
-
selectedNavId: "brief",
|
|
328
|
-
onSelectNav: () => undefined,
|
|
329
|
-
savedSearches: ["from:alice", "has:attachment invoice"],
|
|
330
|
-
}),
|
|
331
|
-
);
|
|
332
|
-
assert.match(html, /Saved searches/);
|
|
333
|
-
assert.match(html, /from:alice/);
|
|
334
|
-
assert.match(html, /has:attachment invoice/);
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
it("shows a save row for an active, unsaved query", () => {
|
|
338
|
-
const html = renderToString(
|
|
339
|
-
createElement(NavSidebar, {
|
|
340
|
-
accounts,
|
|
341
|
-
selectedNavId: "brief",
|
|
342
|
-
onSelectNav: () => undefined,
|
|
343
|
-
saveableQuery: "from:dhl",
|
|
344
|
-
}),
|
|
345
|
-
);
|
|
346
|
-
assert.match(html, /Saved searches/);
|
|
347
|
-
assert.match(html, /Save/);
|
|
348
|
-
assert.match(html, /from:dhl/);
|
|
349
|
-
});
|
|
350
|
-
});
|
|
351
|
-
|
|
352
311
|
describe("NavSidebar collapse persistence", () => {
|
|
353
312
|
afterEach(() => {
|
|
354
313
|
Reflect.deleteProperty(globalThis, "localStorage");
|
|
@@ -185,21 +185,6 @@ export const LoadError: Story = {
|
|
|
185
185
|
},
|
|
186
186
|
};
|
|
187
187
|
|
|
188
|
-
/**
|
|
189
|
-
* The reserved "Saved searches" group (#428 follow-up): saved queries plus a
|
|
190
|
-
* "Save «query»" row when the active search isn't saved yet.
|
|
191
|
-
*/
|
|
192
|
-
export const WithSavedSearches: Story = {
|
|
193
|
-
args: {
|
|
194
|
-
selectedNavId: "personal-inbox",
|
|
195
|
-
savedSearches: ["from:alice has:attachment", "account:work is:unread"],
|
|
196
|
-
saveableQuery: "in:archive invoice",
|
|
197
|
-
onSelectSavedSearch: () => undefined,
|
|
198
|
-
onRemoveSavedSearch: () => undefined,
|
|
199
|
-
onSaveCurrentSearch: () => undefined,
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
|
-
|
|
203
188
|
/** Each nav row is a real anchor: the linkComponent renders <a href>. */
|
|
204
189
|
export const AsLinks: Story = {
|
|
205
190
|
args: {
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
AlertOctagon,
|
|
4
4
|
Archive,
|
|
5
5
|
BellOff,
|
|
6
|
-
BookmarkPlus,
|
|
7
6
|
CalendarDays,
|
|
8
7
|
ChevronDown,
|
|
9
8
|
ChevronRight,
|
|
@@ -11,12 +10,10 @@ import {
|
|
|
11
10
|
Folder,
|
|
12
11
|
Inbox,
|
|
13
12
|
Mails,
|
|
14
|
-
Search,
|
|
15
13
|
Send,
|
|
16
14
|
Sparkles,
|
|
17
15
|
Star,
|
|
18
16
|
Trash2,
|
|
19
|
-
X,
|
|
20
17
|
} from "lucide-react";
|
|
21
18
|
import type { ReactNode } from "react";
|
|
22
19
|
import { useRef, useState } from "react";
|
|
@@ -231,104 +228,6 @@ export function writeOpen(prefix: string, id: string, open: boolean): void {
|
|
|
231
228
|
export const NAV_FOLDER_OPEN_KEY = FOLDER_OPEN_KEY;
|
|
232
229
|
export const NAV_ACCOUNT_OPEN_KEY = ACCOUNT_OPEN_KEY;
|
|
233
230
|
|
|
234
|
-
/**
|
|
235
|
-
* One row in the "Saved searches" group: a plain query string (local-only MVP
|
|
236
|
-
* — no separate label, see doc/design/flows/06-search.md). Hover reveals a
|
|
237
|
-
* remove control, mirroring `SearchTokenChip`'s dismiss affordance.
|
|
238
|
-
*/
|
|
239
|
-
function SavedSearchRow({
|
|
240
|
-
query,
|
|
241
|
-
onSelect,
|
|
242
|
-
onRemove,
|
|
243
|
-
}: {
|
|
244
|
-
query: string;
|
|
245
|
-
onSelect?: () => void;
|
|
246
|
-
onRemove?: () => void;
|
|
247
|
-
}) {
|
|
248
|
-
return (
|
|
249
|
-
<div className="group flex w-full items-center gap-1 rounded-md pr-1 hover:bg-surface">
|
|
250
|
-
<button
|
|
251
|
-
type="button"
|
|
252
|
-
onClick={onSelect}
|
|
253
|
-
className={cn(
|
|
254
|
-
"flex min-w-0 flex-1 items-center gap-2 px-2 py-1 text-left text-sm text-fg-muted transition-colors hover:text-fg",
|
|
255
|
-
FOCUS_RING,
|
|
256
|
-
)}
|
|
257
|
-
>
|
|
258
|
-
<Search className="size-4 shrink-0 text-fg-subtle" />
|
|
259
|
-
<span className="min-w-0 flex-1 truncate">{query}</span>
|
|
260
|
-
</button>
|
|
261
|
-
{onRemove && (
|
|
262
|
-
<button
|
|
263
|
-
type="button"
|
|
264
|
-
onClick={onRemove}
|
|
265
|
-
aria-label={`Remove saved search: ${query}`}
|
|
266
|
-
className={cn(
|
|
267
|
-
"shrink-0 rounded-full p-1 text-fg-subtle opacity-0 transition-opacity hover:bg-surface-sunken hover:text-fg group-hover:opacity-100 focus-visible:opacity-100",
|
|
268
|
-
FOCUS_RING,
|
|
269
|
-
)}
|
|
270
|
-
>
|
|
271
|
-
<X className="size-3.5" />
|
|
272
|
-
</button>
|
|
273
|
-
)}
|
|
274
|
-
</div>
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* The reserved "Saved searches" group (#428 follow-up): a "Save «query»" row
|
|
280
|
-
* when the active search isn't saved yet, then every saved query as a
|
|
281
|
-
* removable row. Renders nothing when there is neither an active query to
|
|
282
|
-
* save nor any saved searches — an always-empty group would just be noise.
|
|
283
|
-
*/
|
|
284
|
-
function SavedSearchesGroup({
|
|
285
|
-
savedSearches,
|
|
286
|
-
saveableQuery,
|
|
287
|
-
onSelectSavedSearch,
|
|
288
|
-
onRemoveSavedSearch,
|
|
289
|
-
onSaveCurrentSearch,
|
|
290
|
-
}: {
|
|
291
|
-
savedSearches: string[];
|
|
292
|
-
saveableQuery?: string;
|
|
293
|
-
onSelectSavedSearch?: (query: string) => void;
|
|
294
|
-
onRemoveSavedSearch?: (query: string) => void;
|
|
295
|
-
onSaveCurrentSearch?: () => void;
|
|
296
|
-
}) {
|
|
297
|
-
if (savedSearches.length === 0 && !saveableQuery) return null;
|
|
298
|
-
return (
|
|
299
|
-
<div className="mt-3">
|
|
300
|
-
<div className="px-2 pb-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle">
|
|
301
|
-
Saved searches
|
|
302
|
-
</div>
|
|
303
|
-
{saveableQuery && (
|
|
304
|
-
<button
|
|
305
|
-
type="button"
|
|
306
|
-
onClick={onSaveCurrentSearch}
|
|
307
|
-
className={cn(
|
|
308
|
-
"flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-accent transition-colors hover:bg-surface",
|
|
309
|
-
FOCUS_RING,
|
|
310
|
-
)}
|
|
311
|
-
>
|
|
312
|
-
<BookmarkPlus className="size-4 shrink-0" />
|
|
313
|
-
<span className="min-w-0 flex-1 truncate">
|
|
314
|
-
Save “{saveableQuery}”
|
|
315
|
-
</span>
|
|
316
|
-
</button>
|
|
317
|
-
)}
|
|
318
|
-
{savedSearches.map((query) => (
|
|
319
|
-
<SavedSearchRow
|
|
320
|
-
key={query}
|
|
321
|
-
query={query}
|
|
322
|
-
onSelect={() => onSelectSavedSearch?.(query)}
|
|
323
|
-
onRemove={
|
|
324
|
-
onRemoveSavedSearch ? () => onRemoveSavedSearch(query) : undefined
|
|
325
|
-
}
|
|
326
|
-
/>
|
|
327
|
-
))}
|
|
328
|
-
</div>
|
|
329
|
-
);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
231
|
function AccountNav({
|
|
333
232
|
account,
|
|
334
233
|
selectedNavId,
|
|
@@ -565,16 +464,6 @@ export interface NavSidebarProps
|
|
|
565
464
|
* that leads nowhere.
|
|
566
465
|
*/
|
|
567
466
|
calendarNav?: "hidden" | "shown";
|
|
568
|
-
/** Every saved query, most recently saved first. See `SavedSearchesGroup`. */
|
|
569
|
-
savedSearches?: string[];
|
|
570
|
-
/**
|
|
571
|
-
* The active search query, when it's non-empty and not already saved — shows
|
|
572
|
-
* the "Save «query»" row. Omit (or pass an already-saved query) to hide it.
|
|
573
|
-
*/
|
|
574
|
-
saveableQuery?: string;
|
|
575
|
-
onSelectSavedSearch?: (query: string) => void;
|
|
576
|
-
onRemoveSavedSearch?: (query: string) => void;
|
|
577
|
-
onSaveCurrentSearch?: () => void;
|
|
578
467
|
}
|
|
579
468
|
|
|
580
469
|
export function NavSidebar({
|
|
@@ -585,11 +474,6 @@ export function NavSidebar({
|
|
|
585
474
|
variant = "desktop",
|
|
586
475
|
linkComponent,
|
|
587
476
|
calendarNav = "hidden",
|
|
588
|
-
savedSearches = [],
|
|
589
|
-
saveableQuery,
|
|
590
|
-
onSelectSavedSearch,
|
|
591
|
-
onRemoveSavedSearch,
|
|
592
|
-
onSaveCurrentSearch,
|
|
593
477
|
}: NavSidebarProps) {
|
|
594
478
|
const containerRef = useRef<HTMLElement>(null);
|
|
595
479
|
useRovingFocus({ containerRef, itemSelector: NAV_ITEM_SELECTOR });
|
|
@@ -634,14 +518,6 @@ export function NavSidebar({
|
|
|
634
518
|
onClick={() => onSelectNav?.("flagged")}
|
|
635
519
|
/>
|
|
636
520
|
|
|
637
|
-
<SavedSearchesGroup
|
|
638
|
-
savedSearches={savedSearches}
|
|
639
|
-
saveableQuery={saveableQuery}
|
|
640
|
-
onSelectSavedSearch={onSelectSavedSearch}
|
|
641
|
-
onRemoveSavedSearch={onRemoveSavedSearch}
|
|
642
|
-
onSaveCurrentSearch={onSaveCurrentSearch}
|
|
643
|
-
/>
|
|
644
|
-
|
|
645
521
|
{accounts.length === 0 ? (
|
|
646
522
|
<div className="px-2 py-4 text-center text-sm text-fg-muted">
|
|
647
523
|
No accounts configured
|