@haatlabs-core/ui 0.19.0 → 0.21.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.
Files changed (53) hide show
  1. package/dist/client/index.d.ts +8 -0
  2. package/dist/client/index.js +6 -0
  3. package/dist/client/index.js.map +1 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/notifications/NotificationBell.d.ts +12 -0
  8. package/dist/notifications/NotificationBell.js +94 -0
  9. package/dist/notifications/NotificationBell.js.map +1 -0
  10. package/dist/notifications/NotificationInbox.d.ts +23 -0
  11. package/dist/notifications/NotificationInbox.js +92 -0
  12. package/dist/notifications/NotificationInbox.js.map +1 -0
  13. package/dist/notifications/NotificationPreferences.d.ts +10 -0
  14. package/dist/notifications/NotificationPreferences.js +135 -0
  15. package/dist/notifications/NotificationPreferences.js.map +1 -0
  16. package/dist/notifications/notifications-css.d.ts +6 -0
  17. package/dist/notifications/notifications-css.js +62 -0
  18. package/dist/notifications/notifications-css.js.map +1 -0
  19. package/dist/notifications/types.d.ts +80 -0
  20. package/dist/notifications/types.js +12 -0
  21. package/dist/notifications/types.js.map +1 -0
  22. package/dist/notifications/use-notification-stream.d.ts +15 -0
  23. package/dist/notifications/use-notification-stream.js +123 -0
  24. package/dist/notifications/use-notification-stream.js.map +1 -0
  25. package/dist/shell/Account.d.ts +24 -0
  26. package/dist/shell/Account.js +48 -0
  27. package/dist/shell/Account.js.map +1 -0
  28. package/dist/shell/AppShell.d.ts +10 -7
  29. package/dist/shell/AppShell.js +104 -16
  30. package/dist/shell/AppShell.js.map +1 -1
  31. package/dist/shell/ShellSearch.d.ts +6 -2
  32. package/dist/shell/ShellSearch.js +3 -3
  33. package/dist/shell/ShellSearch.js.map +1 -1
  34. package/dist/shell/ShortcutsDialog.d.ts +11 -0
  35. package/dist/shell/ShortcutsDialog.js +26 -0
  36. package/dist/shell/ShortcutsDialog.js.map +1 -0
  37. package/dist/shell/nav.d.ts +2 -0
  38. package/dist/shell/nav.js.map +1 -1
  39. package/dist/shell/shell-css.d.ts +1 -1
  40. package/dist/shell/shell-css.js +48 -9
  41. package/dist/shell/shell-css.js.map +1 -1
  42. package/dist/shell/shortcuts.d.ts +22 -0
  43. package/dist/shell/shortcuts.js +48 -0
  44. package/dist/shell/shortcuts.js.map +1 -0
  45. package/dist/shell/sidebar-state.d.ts +5 -0
  46. package/dist/shell/sidebar-state.js +38 -0
  47. package/dist/shell/sidebar-state.js.map +1 -0
  48. package/dist/theme/ThemeStyles.js +2 -1
  49. package/dist/theme/ThemeStyles.js.map +1 -1
  50. package/dist/theme/ThemeSwitch.d.ts +5 -0
  51. package/dist/theme/ThemeSwitch.js +12 -0
  52. package/dist/theme/ThemeSwitch.js.map +1 -1
  53. package/package.json +4 -4
@@ -0,0 +1,80 @@
1
+ /** One inbox item. `link` is an app path, or null. */
2
+ export interface NotificationItemData {
3
+ id: string;
4
+ event: string;
5
+ title: string;
6
+ body: string;
7
+ link: string | null;
8
+ readAt: string | null;
9
+ createdAt: string;
10
+ }
11
+ export type NotificationChannel = 'email' | 'push';
12
+ export interface NotificationChannelState {
13
+ on: boolean;
14
+ /** The person cannot change it (a required event's email). */
15
+ locked: boolean;
16
+ }
17
+ /** One event's row in the preferences. */
18
+ export interface NotificationPreferenceData {
19
+ event: string;
20
+ label: string;
21
+ group: string;
22
+ required: boolean;
23
+ channels: Record<NotificationChannel, NotificationChannelState>;
24
+ }
25
+ /** `GET` and `PUT /notifications/preferences`. */
26
+ export interface PreferencesData {
27
+ events: NotificationPreferenceData[];
28
+ }
29
+ export interface NotificationPreferenceChange {
30
+ event: string;
31
+ channel: NotificationChannel;
32
+ on: boolean;
33
+ }
34
+ /** What the stream sends: the unread count (on connect and after every change), or a new item. */
35
+ export type NotificationStreamEvent = {
36
+ kind: 'unread';
37
+ unread: number;
38
+ } | {
39
+ kind: 'notification';
40
+ item: NotificationItemData;
41
+ };
42
+ /** The notification routes, as the app's API client calls them. */
43
+ export interface NotificationsClient {
44
+ list(q: {
45
+ unread?: boolean;
46
+ cursor?: string;
47
+ }): Promise<{
48
+ items: NotificationItemData[];
49
+ nextCursor: string | null;
50
+ unread?: number;
51
+ }>;
52
+ unreadCount(): Promise<number>;
53
+ /** Marks the caller's items read; resolves to the caller's unread count. */
54
+ markRead(ids: string[]): Promise<number>;
55
+ /** Resolves to the caller's unread count (0). */
56
+ markAllRead(): Promise<number>;
57
+ /**
58
+ * Reads `GET /notifications/stream` until `signal` aborts or the connection ends, calling
59
+ * `onEvent` per event. With fetch streaming, so bearer auth works inside the Shopify frame.
60
+ * Without it, the bell polls the unread count.
61
+ */
62
+ stream?(signal: AbortSignal, onEvent: (e: NotificationStreamEvent) => void): Promise<void>;
63
+ preferences(): Promise<PreferencesData>;
64
+ setPreferences(changes: NotificationPreferenceChange[]): Promise<PreferencesData>;
65
+ /** Push on this device, usually from `@haatlabs-core/notifications/browser`. */
66
+ push?: {
67
+ /** `supported`, `embedded`, `needs-install` or `unsupported`. */
68
+ support(): string;
69
+ /** Asks for permission and subscribes; resolves to `subscribed`, `denied` or why not. */
70
+ enable(): Promise<string>;
71
+ disable(): Promise<void>;
72
+ /** Whether this device already has push on, so the button offers to turn it off. */
73
+ isSubscribed?(): Promise<boolean>;
74
+ };
75
+ }
76
+ /**
77
+ * A link is an in-app path: one leading slash, no spaces or backslashes, at most 512
78
+ * characters. The same rule as `@haatlabs-core/notifications`, copied so the UI does not load it.
79
+ */
80
+ export declare function isAppPath(link: string): boolean;
@@ -0,0 +1,12 @@
1
+ // The notification routes' shapes, as the app's API client hands them over. Local on purpose:
2
+ // the UI does not depend on @haatlabs-core/notifications (as BillingClient does not on nest-billing).
3
+ const APP_PATH = /^\/(?!\/)[^\s\\]*$/;
4
+ const MAX_LINK = 512;
5
+ /**
6
+ * A link is an in-app path: one leading slash, no spaces or backslashes, at most 512
7
+ * characters. The same rule as `@haatlabs-core/notifications`, copied so the UI does not load it.
8
+ */
9
+ export function isAppPath(link) {
10
+ return link.length <= MAX_LINK && APP_PATH.test(link);
11
+ }
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/notifications/types.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,iGAAiG;AA4EjG,MAAM,QAAQ,GAAG,oBAAoB,CAAC;AACtC,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,IAAI,CAAC,MAAM,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { NotificationItemData, NotificationsClient } from './types.js';
2
+ export interface NotificationStreamState {
3
+ unread: number;
4
+ /** Items that arrived on the stream since mount, newest first. */
5
+ latest: NotificationItemData[];
6
+ /** Sets the count after the caller changed it (marking read answers with the new count). */
7
+ setUnread: (unread: number) => void;
8
+ }
9
+ /**
10
+ * The unread count, live. Uses `client.stream` when there is one, reconnecting with backoff;
11
+ * polls `unreadCount` every 60 s without a stream, or after 3 unhealthy attempts in a row (the
12
+ * stream keeps retrying, and polling stops once an attempt stays up 30 s or gets a second event). Everything stops while
13
+ * the page is hidden and catches up when it is shown, and on unmount. Pass a stable client.
14
+ */
15
+ export declare function useNotificationStream(client: NotificationsClient): NotificationStreamState;
@@ -0,0 +1,123 @@
1
+ import { useEffect, useState } from 'react';
2
+ /** Waits before each reconnect after the stream ends: 1 s, 2 s, 5 s, 15 s, then 30 s. */
3
+ const BACKOFF_MS = [1_000, 2_000, 5_000, 15_000, 30_000];
4
+ const POLL_MS = 60_000;
5
+ /** Unhealthy stream attempts in a row before the unread count is polled. */
6
+ const FAILURES_BEFORE_POLLING = 3;
7
+ /** An attempt is healthy once it stays up this long, or a second event comes. */
8
+ const HEALTHY_MS = 30_000;
9
+ /** How many streamed items are kept for the bell. */
10
+ const LATEST = 10;
11
+ const pageHidden = () => typeof document !== 'undefined' && document.hidden;
12
+ /**
13
+ * The unread count, live. Uses `client.stream` when there is one, reconnecting with backoff;
14
+ * polls `unreadCount` every 60 s without a stream, or after 3 unhealthy attempts in a row (the
15
+ * stream keeps retrying, and polling stops once an attempt stays up 30 s or gets a second event). Everything stops while
16
+ * the page is hidden and catches up when it is shown, and on unmount. Pass a stable client.
17
+ */
18
+ export function useNotificationStream(client) {
19
+ const [unread, setUnread] = useState(0);
20
+ const [latest, setLatest] = useState([]);
21
+ useEffect(() => {
22
+ let stopped = false;
23
+ let controller;
24
+ let retry;
25
+ let poll;
26
+ let health;
27
+ let failures = 0;
28
+ const refresh = () => {
29
+ client.unreadCount().then((count) => {
30
+ if (!stopped)
31
+ setUnread(count);
32
+ }, () => undefined);
33
+ };
34
+ const startPolling = () => {
35
+ poll ??= setInterval(refresh, POLL_MS);
36
+ };
37
+ const stopPolling = () => {
38
+ clearInterval(poll);
39
+ poll = undefined;
40
+ };
41
+ const onEvent = (event) => {
42
+ if (event.kind === 'unread')
43
+ setUnread(event.unread);
44
+ else
45
+ setLatest((items) => [event.item, ...items.filter((i) => i.id !== event.item.id)].slice(0, LATEST));
46
+ };
47
+ const connect = () => {
48
+ const stream = client.stream?.bind(client);
49
+ if (stopped || pageHidden() || !stream)
50
+ return;
51
+ const attempt = new AbortController();
52
+ controller = attempt;
53
+ // A server that sends the count and drops at once is not healthy: it still backs off.
54
+ let healthy = false;
55
+ let events = 0;
56
+ const becomeHealthy = () => {
57
+ clearTimeout(health);
58
+ health = undefined;
59
+ if (healthy)
60
+ return;
61
+ healthy = true;
62
+ failures = 0;
63
+ stopPolling();
64
+ };
65
+ health = setTimeout(becomeHealthy, HEALTHY_MS);
66
+ const ended = () => {
67
+ if (stopped || attempt.signal.aborted)
68
+ return;
69
+ controller = undefined;
70
+ clearTimeout(health);
71
+ health = undefined;
72
+ failures = healthy ? 0 : failures + 1;
73
+ if (failures >= FAILURES_BEFORE_POLLING)
74
+ startPolling();
75
+ const wait = BACKOFF_MS[Math.min(Math.max(failures - 1, 0), BACKOFF_MS.length - 1)];
76
+ retry = setTimeout(() => {
77
+ retry = undefined;
78
+ connect();
79
+ }, wait);
80
+ };
81
+ stream(attempt.signal, (event) => {
82
+ if (stopped || attempt.signal.aborted)
83
+ return;
84
+ events += 1;
85
+ if (events >= 2)
86
+ becomeHealthy();
87
+ onEvent(event);
88
+ }).then(ended, ended);
89
+ };
90
+ const pause = () => {
91
+ controller?.abort();
92
+ controller = undefined;
93
+ clearTimeout(retry);
94
+ retry = undefined;
95
+ clearTimeout(health);
96
+ health = undefined;
97
+ stopPolling();
98
+ };
99
+ const resume = () => {
100
+ refresh();
101
+ if (!client.stream || failures >= FAILURES_BEFORE_POLLING)
102
+ startPolling();
103
+ if (!controller && retry === undefined)
104
+ connect();
105
+ };
106
+ const onVisibility = () => {
107
+ if (pageHidden())
108
+ pause();
109
+ else
110
+ resume();
111
+ };
112
+ document.addEventListener('visibilitychange', onVisibility);
113
+ if (!pageHidden())
114
+ resume();
115
+ return () => {
116
+ stopped = true;
117
+ document.removeEventListener('visibilitychange', onVisibility);
118
+ pause();
119
+ };
120
+ }, [client]);
121
+ return { unread, latest, setUnread };
122
+ }
123
+ //# sourceMappingURL=use-notification-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-notification-stream.js","sourceRoot":"","sources":["../../src/notifications/use-notification-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAO5C,yFAAyF;AACzF,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAClE,MAAM,OAAO,GAAG,MAAM,CAAC;AACvB,4EAA4E;AAC5E,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAClC,iFAAiF;AACjF,MAAM,UAAU,GAAG,MAAM,CAAC;AAC1B,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,EAAE;YAC9B,IAAI,UAAU,EAAE;gBAAE,KAAK,EAAE,CAAC;;gBACrB,MAAM,EAAE,CAAC;QAChB,CAAC,CAAC;QAEF,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAC;QAC5D,IAAI,CAAC,UAAU,EAAE;YAAE,MAAM,EAAE,CAAC;QAC5B,OAAO,GAAG,EAAE;YACV,OAAO,GAAG,IAAI,CAAC;YACf,QAAQ,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAC;YAC/D,KAAK,EAAE,CAAC;QACV,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AACvC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { ReactElement } from 'react';
2
+ export interface ShellAccount {
3
+ name: string;
4
+ detail?: string;
5
+ onSignOut: () => void;
6
+ signingOut?: boolean;
7
+ }
8
+ /**
9
+ * The account row's two lines. With a detail (an email under an organization's name) they
10
+ * are the name and the detail; a name that is itself an email splits at its last @, so the
11
+ * part that tells people apart is never cut off by the domain.
12
+ */
13
+ export declare function accountLines(account: Pick<ShellAccount, 'name' | 'detail'>): {
14
+ first: string;
15
+ second: string | undefined;
16
+ };
17
+ /**
18
+ * Who is signed in, as one button that opens a menu with the whole name and email and
19
+ * Sign out. In the collapsed sidebar the button is the avatar alone and the menu opens beside it.
20
+ */
21
+ export declare function Account({ account, compact, }: {
22
+ account: ShellAccount;
23
+ compact?: boolean;
24
+ }): ReactElement;
@@ -0,0 +1,48 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useId, useRef, useState } from 'react';
3
+ /**
4
+ * The account row's two lines. With a detail (an email under an organization's name) they
5
+ * are the name and the detail; a name that is itself an email splits at its last @, so the
6
+ * part that tells people apart is never cut off by the domain.
7
+ */
8
+ export function accountLines(account) {
9
+ if (account.detail)
10
+ return { first: account.name, second: account.detail };
11
+ const at = account.name.lastIndexOf('@');
12
+ if (at > 0 && at < account.name.length - 1)
13
+ return { first: account.name.slice(0, at), second: account.name.slice(at) };
14
+ return { first: account.name, second: undefined };
15
+ }
16
+ const CHEVRONS = (_jsx("svg", { className: "hl-account__chevron", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "M8 10l4-4 4 4M8 14l4 4 4-4" }) }));
17
+ /**
18
+ * Who is signed in, as one button that opens a menu with the whole name and email and
19
+ * Sign out. In the collapsed sidebar the button is the avatar alone and the menu opens beside it.
20
+ */
21
+ export function Account({ account, compact = false, }) {
22
+ const [open, setOpen] = useState(false);
23
+ const root = useRef(null);
24
+ const button = useRef(null);
25
+ const signOut = useRef(null);
26
+ const menuId = useId();
27
+ const { first, second } = accountLines(account);
28
+ useEffect(() => {
29
+ if (!open)
30
+ return;
31
+ signOut.current?.focus();
32
+ const onPointer = (event) => {
33
+ if (!root.current?.contains(event.target))
34
+ setOpen(false);
35
+ };
36
+ document.addEventListener('mousedown', onPointer);
37
+ return () => document.removeEventListener('mousedown', onPointer);
38
+ }, [open]);
39
+ const onKeyDown = (event) => {
40
+ if (event.key !== 'Escape' || !open)
41
+ return;
42
+ event.stopPropagation();
43
+ setOpen(false);
44
+ button.current?.focus();
45
+ };
46
+ return (_jsxs("div", { className: "hl-account", ref: root, onKeyDown: onKeyDown, children: [open && (_jsxs("div", { id: menuId, role: "menu", "aria-label": "Account", className: "hl-account__menu", children: [_jsxs("div", { className: "hl-account__head", children: [_jsx("span", { className: "hl-account__caption", children: "Signed in as" }), _jsx("strong", { className: "hl-account__full", children: account.name }), account.detail && _jsx("span", { className: "hl-account__full", children: account.detail })] }), _jsxs("button", { ref: signOut, type: "button", role: "menuitem", className: "hl-signout", disabled: account.signingOut, onClick: account.onSignOut, children: [_jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "M15 4h3a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-3M10 16l-4-4 4-4M6 12h10" }) }), account.signingOut ? 'Signing out…' : 'Sign out'] })] })), _jsxs("button", { ref: button, type: "button", className: "hl-account__trigger", "aria-haspopup": "menu", "aria-expanded": open, "aria-controls": open ? menuId : undefined, "aria-label": `Account: ${account.name}`, title: compact ? account.name : undefined, onClick: () => setOpen((was) => !was), children: [_jsx("span", { "aria-hidden": "true", className: "hl-avatar", children: account.name.charAt(0).toUpperCase() }), !compact && (_jsxs(_Fragment, { children: [_jsxs("span", { className: "hl-account__text", children: [_jsx("strong", { children: first }), second && _jsx("span", { children: second })] }), CHEVRONS] }))] })] }));
47
+ }
48
+ //# sourceMappingURL=Account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Account.js","sourceRoot":"","sources":["../../src/shell/Account.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAU3D;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,OAA8C;IAIzE,IAAI,OAAO,CAAC,MAAM;QAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;IAC3E,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;QACxC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,O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ACrB,cAAc,EAAC,OAAO,iBACV,MAAM,YAElB,eAAM,CAAC,EAAC,kEAAkE,GAAG,GACzE,EACL,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,UAAU,IAC1C,IACL,CACP,EACD,kBACE,GAAG,EAAE,MAAM,EACX,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,qBAAqB,mBACjB,MAAM,mBACL,IAAI,mBACJ,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,gBAC5B,YAAY,OAAO,CAAC,IAAI,EAAE,EACtC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EACzC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,aAErC,8BAAkB,MAAM,EAAC,SAAS,EAAC,WAAW,YAC3C,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAChC,EACN,CAAC,OAAO,IAAI,CACX,8BACE,gBAAM,SAAS,EAAC,kBAAkB,aAChC,2BAAS,KAAK,GAAU,EACvB,MAAM,IAAI,yBAAO,MAAM,GAAQ,IAC3B,EACN,QAAQ,IACR,CACJ,IACM,IACL,CACP,CAAC;AACJ,CAAC"}
@@ -1,21 +1,24 @@
1
1
  import type { ReactElement, ReactNode } from 'react';
2
+ import type { ShellAccount } from './Account.js';
2
3
  import type { SearchEntry } from './ShellSearch.js';
3
4
  import type { NavGroup } from './nav.js';
4
- export interface ShellAccount {
5
- name: string;
6
- detail?: string;
7
- onSignOut: () => void;
8
- signingOut?: boolean;
9
- }
5
+ export type { ShellAccount } from './Account.js';
10
6
  /**
11
7
  * The dashboards' frame: the sidebar (brand, grouped pages, the theme switch, the account),
12
- * a top bar (search and a status chip) and the page. On a phone the sidebar is a menu.
8
+ * a top bar (search, the notifications slot and a status chip) and the page. On a computer the
9
+ * sidebar collapses to a strip of icons (remembered in this browser); on a phone it is a menu.
10
+ * Keyboard: ⌘K or / search, ⌘B the sidebar, ⇧⌘L the theme, N notifications, G then a letter
11
+ * a page, ? the list of them all (Ctrl for ⌘ off a Mac).
13
12
  */
14
13
  export declare function AppShell(props: {
15
14
  brand: ReactNode;
15
+ /** The logo alone, for the collapsed sidebar; without it the strip shows no logo. */
16
+ brandMark?: ReactNode;
16
17
  nav: NavGroup[];
17
18
  account: ShellAccount;
18
19
  statusChip?: ReactNode;
20
+ /** The notification bell (or anything), in the top bar before the status chip. */
21
+ notifications?: ReactNode;
19
22
  /** Pages the top bar's search finds besides the nav's own. */
20
23
  searchEntries?: SearchEntry[];
21
24
  children: ReactNode;
@@ -1,9 +1,15 @@
1
- import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { Link, useLocation } from 'react-router-dom';
4
- import { ThemeSwitch } from '../theme/ThemeSwitch.js';
4
+ import { useNavigate } from 'react-router-dom';
5
+ import { ThemeCycle, ThemeSwitch, nextTheme } from '../theme/ThemeSwitch.js';
6
+ import { useTheme } from '../theme/theme-choice.js';
7
+ import { Account } from './Account.js';
5
8
  import { ShellSearch } from './ShellSearch.js';
9
+ import { ShortcutsDialog } from './ShortcutsDialog.js';
6
10
  import { flattenNav, isUnder } from './nav.js';
11
+ import { useSidebarCollapsed } from './sidebar-state.js';
12
+ import { GO_WINDOW_MS, goKeys, isMac, isTyping, keyNames } from './shortcuts.js';
7
13
  const NARROW = '(max-width: 899px)';
8
14
  /** Whether the screen is phone-sized: the sidebar becomes a menu. */
9
15
  function useNarrow() {
@@ -21,24 +27,24 @@ function useNarrow() {
21
27
  }, []);
22
28
  return narrow;
23
29
  }
24
- function Items({ items, pathname, current, }) {
25
- return (_jsx("ul", { children: items.map((item) => (_jsxs("li", { children: [_jsxs(Link, { to: item.to, "aria-current": item.to === current ? 'page' : undefined, children: [item.icon, item.label] }), item.children && isUnder(pathname, item.to) && (_jsx(Items, { items: item.children, pathname: pathname, current: current }))] }, item.to))) }));
30
+ function Items({ items, pathname, current, collapsed, }) {
31
+ return (_jsx("ul", { children: items.map((item) => (_jsxs("li", { children: [_jsxs(Link, { to: item.to, "aria-current": item.to === current ? 'page' : undefined, title: collapsed ? item.label : undefined, children: [item.icon ??
32
+ (collapsed && (_jsx("span", { "aria-hidden": "true", className: "hl-nav__initial", children: item.label.charAt(0).toUpperCase() }))), _jsx("span", { className: collapsed ? 'hl-sr-only' : undefined, children: item.label })] }), !collapsed && item.children && isUnder(pathname, item.to) && (_jsx(Items, { items: item.children, pathname: pathname, current: current, collapsed: collapsed }))] }, item.to))) }));
26
33
  }
27
- function Nav({ groups }) {
34
+ function Nav({ groups, collapsed }) {
28
35
  const { pathname } = useLocation();
29
36
  // The open page is the deepest one the address is under: a detail page (/lists/7) marks
30
37
  // its list page, and a page that redirects deeper (/research → /research/x) stays marked.
31
38
  const current = flattenNav(groups)
32
39
  .filter((item) => isUnder(pathname, item.to))
33
40
  .sort((a, b) => b.to.length - a.to.length)[0]?.to;
34
- return (_jsx("nav", { "aria-label": "Main", className: "hl-nav", children: groups.map((group, i) => (_jsxs("div", { children: [group.label && _jsx("p", { className: "hl-nav__group", children: group.label }), _jsx(Items, { items: group.items, pathname: pathname, current: current })] }, group.label ?? `group-${String(i)}`))) }));
35
- }
36
- /** Who is signed in, and Sign out: a plain button, always in view. */
37
- function Account({ account }) {
38
- return (_jsxs("div", { className: "hl-account", children: [_jsxs("div", { className: "hl-account__who", children: [_jsx("span", { "aria-hidden": "true", className: "hl-avatar", children: account.name.charAt(0).toUpperCase() }), _jsxs("span", { className: "hl-account__text", children: [_jsx("strong", { children: account.name }), account.detail && _jsx("span", { children: account.detail })] })] }), _jsx("button", { type: "button", className: "hl-signout", disabled: account.signingOut, onClick: account.onSignOut, children: "Sign out" })] }));
41
+ return (_jsx("nav", { "aria-label": "Main", className: "hl-nav", children: groups.map((group, i) => (_jsxs("div", { children: [group.label &&
42
+ (collapsed ? (i > 0 && _jsx("hr", { className: "hl-nav__divider" })) : (_jsx("p", { className: "hl-nav__group", children: group.label }))), _jsx(Items, { items: group.items, pathname: pathname, current: current, collapsed: collapsed })] }, group.label ?? `group-${String(i)}`))) }));
39
43
  }
44
+ const PANEL_ICON = (opening) => (_jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("rect", { x: "3", y: "4", width: "18", height: "16", rx: "3" }), _jsx("path", { d: opening ? 'M9 4v16M14 10l2 2-2 2' : 'M9 4v16M16 10l-2 2 2 2' })] }));
40
45
  function SidebarBody(props) {
41
- return (_jsxs(_Fragment, { children: [_jsx(Link, { to: "/", className: "hl-brand", children: props.brand }), _jsx(Nav, { groups: props.nav }), _jsxs("div", { className: "hl-sidebar__foot", children: [_jsxs("div", { className: "hl-theme-row", children: [_jsx("span", { children: "Theme" }), _jsx(ThemeSwitch, {})] }), _jsx(Account, { account: props.account })] })] }));
46
+ const collapsed = props.collapse?.collapsed ?? false;
47
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "hl-brand-row", children: [collapsed ? (props.brandMark && (_jsx(Link, { to: "/", className: "hl-brand", "aria-label": "Start page", children: props.brandMark }))) : (_jsx(Link, { to: "/", className: "hl-brand", children: props.brand })), props.collapse && (_jsx("button", { type: "button", className: "hl-sidebar-toggle", "aria-label": collapsed ? 'Expand sidebar' : 'Collapse sidebar', "aria-keyshortcuts": "Meta+B Control+B", title: `${collapsed ? 'Expand' : 'Collapse'} sidebar (${props.collapse.mod}B)`, onClick: props.collapse.toggle, children: PANEL_ICON(collapsed) }))] }), _jsx(Nav, { groups: props.nav, collapsed: collapsed }), _jsxs("div", { className: "hl-sidebar__foot", children: [collapsed ? (_jsx(ThemeCycle, {})) : (_jsxs("div", { className: "hl-theme-row", children: [_jsx("span", { children: "Theme" }), _jsx(ThemeSwitch, {})] })), _jsx(Account, { account: props.account, compact: collapsed })] })] }));
42
48
  }
43
49
  const FOCUSABLE = 'a[href], button:not([disabled]), input, select, textarea, [tabindex]:not([tabindex="-1"])';
44
50
  /** The phone menu: a dialog that keeps focus inside, closes with Escape or on navigation. */
@@ -72,25 +78,107 @@ function MenuDrawer(props) {
72
78
  }
73
79
  /**
74
80
  * The dashboards' frame: the sidebar (brand, grouped pages, the theme switch, the account),
75
- * a top bar (search and a status chip) and the page. On a phone the sidebar is a menu.
81
+ * a top bar (search, the notifications slot and a status chip) and the page. On a computer the
82
+ * sidebar collapses to a strip of icons (remembered in this browser); on a phone it is a menu.
83
+ * Keyboard: ⌘K or / search, ⌘B the sidebar, ⇧⌘L the theme, N notifications, G then a letter
84
+ * a page, ? the list of them all (Ctrl for ⌘ off a Mac).
76
85
  */
77
86
  export function AppShell(props) {
78
87
  const narrow = useNarrow();
79
88
  const [menuOpen, setMenuOpen] = useState(false);
89
+ const [helpOpen, setHelpOpen] = useState(false);
90
+ const [collapsedChoice, toggleCollapsed] = useSidebarCollapsed();
91
+ const collapsed = !narrow && collapsedChoice;
92
+ const { choice, setChoice } = useTheme();
93
+ const navigate = useNavigate();
80
94
  const menuButton = useRef(null);
95
+ const searchInput = useRef(null);
96
+ const topbar = useRef(null);
97
+ const goPressedAt = useRef(0);
98
+ const helpReturn = useRef(null);
99
+ const keys = useMemo(() => keyNames(isMac()), []);
81
100
  const { pathname } = useLocation();
82
101
  const closeMenu = useCallback(() => {
83
102
  setMenuOpen(false);
84
103
  menuButton.current?.focus();
85
104
  }, []);
105
+ const closeHelp = useCallback(() => {
106
+ setHelpOpen(false);
107
+ helpReturn.current?.focus();
108
+ }, []);
86
109
  useEffect(() => {
87
110
  setMenuOpen(false);
88
111
  }, [pathname]);
112
+ const pages = useMemo(() => flattenNav(props.nav), [props.nav]);
113
+ const go = useMemo(() => goKeys(pages), [pages]);
89
114
  const entries = useMemo(() => [
90
- ...flattenNav(props.nav).map((item) => ({ label: item.label, to: item.to })),
115
+ ...pages.map((item) => ({ label: item.label, to: item.to })),
91
116
  ...(props.searchEntries ?? []),
92
- ], [props.nav, props.searchEntries]);
93
- const body = _jsx(SidebarBody, { brand: props.brand, nav: props.nav, account: props.account });
94
- return (_jsxs("div", { className: "hl-shell", children: [_jsx("a", { className: "hl-skip", href: "#main", children: "Skip to the page" }), !narrow && _jsx("aside", { className: "hl-sidebar", children: body }), narrow && menuOpen && _jsx(MenuDrawer, { onClose: closeMenu, children: body }), _jsxs("div", { className: "hl-content", children: [_jsxs("header", { className: "hl-topbar", children: [narrow && (_jsx("button", { ref: menuButton, type: "button", className: "hl-menu-button", "aria-expanded": menuOpen, onClick: () => setMenuOpen(true), children: "Menu" })), _jsx(ShellSearch, { entries: entries }), props.statusChip && _jsx("div", { className: "hl-topbar__end", children: props.statusChip })] }), _jsx("div", { id: "main", className: "hl-main", tabIndex: -1, children: props.children })] })] }));
117
+ ], [pages, props.searchEntries]);
118
+ useEffect(() => {
119
+ const openHelp = () => {
120
+ helpReturn.current = document.activeElement;
121
+ setHelpOpen(true);
122
+ };
123
+ const onKeyDown = (event) => {
124
+ if (event.defaultPrevented || event.isComposing || helpOpen || menuOpen)
125
+ return;
126
+ const key = event.key.toLowerCase();
127
+ const mod = event.metaKey || event.ctrlKey;
128
+ if (mod && !event.altKey) {
129
+ if (key === 'k' && !event.shiftKey) {
130
+ event.preventDefault();
131
+ searchInput.current?.focus();
132
+ }
133
+ else if (key === 'b' && !event.shiftKey && !narrow && !isTyping(event.target)) {
134
+ event.preventDefault();
135
+ toggleCollapsed();
136
+ }
137
+ else if (key === 'l' && event.shiftKey) {
138
+ event.preventDefault();
139
+ setChoice(nextTheme(choice));
140
+ }
141
+ else if (key === '/') {
142
+ event.preventDefault();
143
+ openHelp();
144
+ }
145
+ return;
146
+ }
147
+ if (event.altKey || isTyping(event.target))
148
+ return;
149
+ const pendingGo = Date.now() - goPressedAt.current < GO_WINDOW_MS;
150
+ goPressedAt.current = 0;
151
+ if (pendingGo) {
152
+ const target = go.find((g) => g.key === key);
153
+ if (target) {
154
+ event.preventDefault();
155
+ navigate(target.item.to);
156
+ return;
157
+ }
158
+ }
159
+ if (event.key === '/') {
160
+ event.preventDefault();
161
+ searchInput.current?.focus();
162
+ }
163
+ else if (event.key === '?') {
164
+ event.preventDefault();
165
+ openHelp();
166
+ }
167
+ else if (key === 'g' && !event.shiftKey) {
168
+ goPressedAt.current = Date.now();
169
+ }
170
+ else if (key === 'n' && !event.shiftKey) {
171
+ const bell = topbar.current?.querySelector('.hl-notify__bell[aria-expanded="false"]');
172
+ if (bell) {
173
+ event.preventDefault();
174
+ bell.click();
175
+ }
176
+ }
177
+ };
178
+ window.addEventListener('keydown', onKeyDown);
179
+ return () => window.removeEventListener('keydown', onKeyDown);
180
+ }, [helpOpen, menuOpen, narrow, toggleCollapsed, choice, setChoice, go, navigate]);
181
+ const sidebar = (_jsx(SidebarBody, { brand: props.brand, brandMark: props.brandMark, nav: props.nav, account: props.account, collapse: narrow ? undefined : { collapsed, toggle: toggleCollapsed, mod: keys.mod } }));
182
+ return (_jsxs("div", { className: "hl-shell", children: [_jsx("a", { className: "hl-skip", href: "#main", children: "Skip to the page" }), !narrow && (_jsx("aside", { className: "hl-sidebar", "data-collapsed": collapsed ? '' : undefined, children: sidebar })), narrow && menuOpen && _jsx(MenuDrawer, { onClose: closeMenu, children: sidebar }), _jsxs("div", { className: "hl-content", children: [_jsxs("header", { ref: topbar, className: "hl-topbar", children: [narrow && (_jsx("button", { ref: menuButton, type: "button", className: "hl-menu-button", "aria-expanded": menuOpen, onClick: () => setMenuOpen(true), children: "Menu" })), _jsx(ShellSearch, { entries: entries, inputRef: searchInput, hint: narrow ? undefined : `${keys.mod === '⌘' ? '⌘' : 'Ctrl '}K` }), (props.notifications || props.statusChip) && (_jsxs("div", { className: "hl-topbar__end", children: [props.notifications, props.statusChip] }))] }), _jsx("div", { id: "main", className: "hl-main", tabIndex: -1, children: props.children })] }), helpOpen && (_jsx(ShortcutsDialog, { mod: keys.mod, shift: keys.shift, go: go, canCollapse: !narrow, hasNotifications: Boolean(props.notifications), onClose: closeHelp }))] }));
95
183
  }
96
184
  //# sourceMappingURL=AppShell.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AppShell.js","sourceRoot":"","sources":["../../src/shell/AppShell.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAG/C,MAAM,MAAM,GAAG,oBAAoB,CAAC;AAEpC,qEAAqE;AACrE,SAAS,SAAS;IAChB,MAAM,KAAK,GAAG,GAA0B,EAAE,CACxC,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,UAAU;QACtE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;QAC3B,CAAC,CAAC,IAAI,CAAC;IACX,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,OAAO,IAAI,KAAK,CAAC,CAAC;IACtE,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,IAAI,GAAG,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,MAAM,QAAQ,GAAG,GAAS,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC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AC,QAAQ,EACb,SAAS,EAAC,gBAAgB,mBACX,QAAQ,EACvB,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,qBAGzB,CACV,EACD,KAAC,WAAW,IACV,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,GAAG,GACjE,EACD,CAAC,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAC5C,eAAK,SAAS,EAAC,gBAAgB,aAC5B,KAAK,CAAC,aAAa,EACnB,KAAK,CAAC,UAAU,IACb,CACP,IACM,EAET,cAAK,EAAE,EAAC,MAAM,EAAC,SAAS,EAAC,SAAS,EAAC,QAAQ,EAAE,CAAC,CAAC,YAC5C,KAAK,CAAC,QAAQ,GACX,IACF,EACL,QAAQ,IAAI,CACX,KAAC,eAAe,IACd,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,EAAE,EAAE,EAAE,EACN,WAAW,EAAE,CAAC,MAAM,EACpB,gBAAgB,EAAE,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,EAC9C,OAAO,EAAE,SAAS,GAClB,CACH,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ReactElement } from 'react';
1
+ import type { ReactElement, Ref } from 'react';
2
2
  /** A page the search can find: by its name or any of its keywords. */
3
3
  export interface SearchEntry {
4
4
  label: string;
@@ -6,6 +6,10 @@ export interface SearchEntry {
6
6
  keywords?: string[];
7
7
  }
8
8
  /** The top bar's "Search pages": a combobox that goes to the page picked. */
9
- export declare function ShellSearch({ entries }: {
9
+ export declare function ShellSearch({ entries, inputRef, hint, }: {
10
10
  entries: SearchEntry[];
11
+ /** For the shell's ⌘K and / shortcuts, which focus it. */
12
+ inputRef?: Ref<HTMLInputElement>;
13
+ /** The shortcut shown at the end of the box, such as ⌘K. */
14
+ hint?: string;
11
15
  }): ReactElement;
@@ -3,7 +3,7 @@ import { useId, useMemo, useState } from 'react';
3
3
  import { useNavigate } from 'react-router-dom';
4
4
  const MAX_RESULTS = 8;
5
5
  /** The top bar's "Search pages": a combobox that goes to the page picked. */
6
- export function ShellSearch({ entries }) {
6
+ export function ShellSearch({ entries, inputRef, hint, }) {
7
7
  const navigate = useNavigate();
8
8
  const listId = useId();
9
9
  const [query, setQuery] = useState('');
@@ -43,11 +43,11 @@ export function ShellSearch({ entries }) {
43
43
  setActive(0);
44
44
  }
45
45
  };
46
- return (_jsxs("div", { className: "hl-search", children: [_jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": "true", children: [_jsx("circle", { cx: "11", cy: "11", r: "7" }), _jsx("path", { d: "M20 20l-3.5-3.5" })] }), _jsx("input", { type: "search", role: "combobox", "aria-label": "Search pages", "aria-expanded": open, "aria-controls": listId, "aria-autocomplete": "list", "aria-activedescendant": open && results[active] ? `${listId}-${String(active)}` : undefined, placeholder: "Search pages\u2026", value: query, onChange: (e) => {
46
+ return (_jsxs("div", { className: "hl-search", children: [_jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": "true", children: [_jsx("circle", { cx: "11", cy: "11", r: "7" }), _jsx("path", { d: "M20 20l-3.5-3.5" })] }), _jsx("input", { ref: inputRef, type: "search", role: "combobox", "aria-label": "Search pages", "aria-expanded": open, "aria-controls": listId, "aria-autocomplete": "list", "aria-activedescendant": open && results[active] ? `${listId}-${String(active)}` : undefined, placeholder: "Search pages\u2026", value: query, onChange: (e) => {
47
47
  setQuery(e.target.value);
48
48
  setActive(0);
49
49
  setFocused(true);
50
- }, onKeyDown: onKeyDown, onFocus: () => setFocused(true), onBlur: () => setFocused(false) }), open && (_jsx("ul", { id: listId, role: "listbox", "aria-label": "Pages", className: "hl-search__list", children: results.length === 0 ? (_jsx("li", { role: "option", "aria-disabled": "true", "aria-selected": false, className: "hl-search__empty", children: "No pages match" })) : (results.map((entry, i) => (_jsx("li", { id: `${listId}-${String(i)}`, role: "option", "aria-selected": i === active, onMouseDown: (e) => {
50
+ }, onKeyDown: onKeyDown, onFocus: () => setFocused(true), onBlur: () => setFocused(false) }), hint && !focused && (_jsx("kbd", { className: "hl-search__kbd", "aria-hidden": "true", children: hint })), open && (_jsx("ul", { id: listId, role: "listbox", "aria-label": "Pages", className: "hl-search__list", children: results.length === 0 ? (_jsx("li", { role: "option", "aria-disabled": "true", "aria-selected": false, className: "hl-search__empty", children: "No pages match" })) : (results.map((entry, i) => (_jsx("li", { id: `${listId}-${String(i)}`, role: "option", "aria-selected": i === active, onMouseDown: (e) => {
51
51
  e.preventDefault();
52
52
  go(entry);
53
53
  }, children: entry.label }, entry.to)))) }))] }));