@haatlabs-core/ui 0.18.5 → 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 (59) 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/client/usage-css.d.ts +1 -1
  5. package/dist/client/usage-css.js +8 -8
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/layout/layout-css.d.ts +1 -1
  10. package/dist/layout/layout-css.js +10 -10
  11. package/dist/notifications/NotificationBell.d.ts +12 -0
  12. package/dist/notifications/NotificationBell.js +94 -0
  13. package/dist/notifications/NotificationBell.js.map +1 -0
  14. package/dist/notifications/NotificationInbox.d.ts +23 -0
  15. package/dist/notifications/NotificationInbox.js +92 -0
  16. package/dist/notifications/NotificationInbox.js.map +1 -0
  17. package/dist/notifications/NotificationPreferences.d.ts +10 -0
  18. package/dist/notifications/NotificationPreferences.js +135 -0
  19. package/dist/notifications/NotificationPreferences.js.map +1 -0
  20. package/dist/notifications/notifications-css.d.ts +6 -0
  21. package/dist/notifications/notifications-css.js +62 -0
  22. package/dist/notifications/notifications-css.js.map +1 -0
  23. package/dist/notifications/types.d.ts +80 -0
  24. package/dist/notifications/types.js +12 -0
  25. package/dist/notifications/types.js.map +1 -0
  26. package/dist/notifications/use-notification-stream.d.ts +15 -0
  27. package/dist/notifications/use-notification-stream.js +123 -0
  28. package/dist/notifications/use-notification-stream.js.map +1 -0
  29. package/dist/shell/Account.d.ts +24 -0
  30. package/dist/shell/Account.js +48 -0
  31. package/dist/shell/Account.js.map +1 -0
  32. package/dist/shell/AppShell.d.ts +10 -7
  33. package/dist/shell/AppShell.js +104 -16
  34. package/dist/shell/AppShell.js.map +1 -1
  35. package/dist/shell/ShellSearch.d.ts +6 -2
  36. package/dist/shell/ShellSearch.js +3 -3
  37. package/dist/shell/ShellSearch.js.map +1 -1
  38. package/dist/shell/ShortcutsDialog.d.ts +11 -0
  39. package/dist/shell/ShortcutsDialog.js +26 -0
  40. package/dist/shell/ShortcutsDialog.js.map +1 -0
  41. package/dist/shell/nav.d.ts +2 -0
  42. package/dist/shell/nav.js.map +1 -1
  43. package/dist/shell/shell-css.d.ts +1 -1
  44. package/dist/shell/shell-css.js +55 -16
  45. package/dist/shell/shell-css.js.map +1 -1
  46. package/dist/shell/shortcuts.d.ts +22 -0
  47. package/dist/shell/shortcuts.js +48 -0
  48. package/dist/shell/shortcuts.js.map +1 -0
  49. package/dist/shell/sidebar-state.d.ts +5 -0
  50. package/dist/shell/sidebar-state.js +38 -0
  51. package/dist/shell/sidebar-state.js.map +1 -0
  52. package/dist/theme/ThemeStyles.js +2 -1
  53. package/dist/theme/ThemeStyles.js.map +1 -1
  54. package/dist/theme/ThemeSwitch.d.ts +5 -0
  55. package/dist/theme/ThemeSwitch.js +12 -0
  56. package/dist/theme/ThemeSwitch.js.map +1 -1
  57. package/dist/theme/tokens.js +4 -4
  58. package/dist/theme/tokens.js.map +1 -1
  59. package/package.json +4 -4
@@ -9,3 +9,11 @@ export { ApiError, OkSchema, cookieCredentials, createTransport, readCookie } fr
9
9
  export type { CredentialStrategy, Method, Transport } from './transport.js';
10
10
  export { UsagePage } from './UsagePage.js';
11
11
  export type { BillingClient, PaymentProvider, PlanData, PlanListData, UsageData, } from './UsagePage.js';
12
+ export { NotificationBell } from '../notifications/NotificationBell.js';
13
+ export { NotificationInbox } from '../notifications/NotificationInbox.js';
14
+ export { NotificationPreferences } from '../notifications/NotificationPreferences.js';
15
+ export { NOTIFICATIONS_CSS } from '../notifications/notifications-css.js';
16
+ export { useNotificationStream } from '../notifications/use-notification-stream.js';
17
+ export type { NotificationStreamState } from '../notifications/use-notification-stream.js';
18
+ export { isAppPath } from '../notifications/types.js';
19
+ export type { NotificationChannel, NotificationChannelState, NotificationItemData, NotificationPreferenceChange, NotificationPreferenceData, NotificationStreamEvent, NotificationsClient, PreferencesData, } from '../notifications/types.js';
@@ -5,4 +5,10 @@ export { SIGN_IN_CSS } from './sign-in-styles.js';
5
5
  export { createQueryClient, isUnauthorized, shouldRetry } from './query-client.js';
6
6
  export { ApiError, OkSchema, cookieCredentials, createTransport, readCookie } from './transport.js';
7
7
  export { UsagePage } from './UsagePage.js';
8
+ export { NotificationBell } from '../notifications/NotificationBell.js';
9
+ export { NotificationInbox } from '../notifications/NotificationInbox.js';
10
+ export { NotificationPreferences } from '../notifications/NotificationPreferences.js';
11
+ export { NOTIFICATIONS_CSS } from '../notifications/notifications-css.js';
12
+ export { useNotificationStream } from '../notifications/use-notification-stream.js';
13
+ export { isAppPath } from '../notifications/types.js';
8
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEpG,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEpG,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAQ3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAEpF,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC"}
@@ -2,4 +2,4 @@
2
2
  * The plans-and-usage page (UsagePage), on the theme tokens. Scoped to `.hl-usage` so it
3
3
  * never restyles an app's own pages, whose class names it shares.
4
4
  */
5
- export declare const USAGE_CSS = "\n.hl-usage h1 { margin: 0; font-size: clamp(24px, 3vw, 30px); font-weight: 800; letter-spacing: -0.02em; }\n.hl-usage h2 { margin: 0; font-size: 16px; font-weight: 700; }\n.hl-usage .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }\n.hl-usage .row.spread { justify-content: space-between; align-items: flex-end; }\n.hl-usage .muted { color: var(--hl-muted); font-size: 14px; }\n.hl-usage .mono { font-family: var(--hl-mono); font-size: 14px; }\n.hl-usage .eyebrow { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--hl-muted); }\n.hl-usage .panel { background: var(--hl-surface); border: 1px solid var(--hl-border); border-radius: var(--hl-radius-card); padding: 20px; display: flex; flex-direction: column; gap: 14px; }\n.hl-usage .notice { padding: 12px 16px; border-radius: var(--hl-radius-control); background: var(--hl-amber-bg); border: 1px solid var(--hl-amber-border); color: var(--hl-amber-text); font-size: 14px; }\n.hl-usage button, .hl-usage .button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 14px; border-radius: var(--hl-radius-control); border: 1px solid var(--hl-border); background: var(--hl-surface); color: var(--hl-text); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }\n.hl-usage button:hover:not(:disabled) { border-color: var(--hl-accent); }\n.hl-usage button.primary { background: var(--hl-accent); border-color: var(--hl-accent); color: var(--hl-on-accent); }\n.hl-usage button.strong { border-color: var(--hl-text); }\n.hl-usage button:disabled { opacity: .55; cursor: not-allowed; }\n.hl-usage .pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; background: var(--hl-faint); color: var(--hl-muted); font-size: 12px; font-weight: 700; white-space: nowrap; }\n.hl-usage .pill.done { background: var(--hl-accent-soft); color: var(--hl-accent-text); }\n.hl-usage .pill.failed { background: var(--hl-faint); color: var(--hl-danger); }\n.hl-usage .plan-card { background: var(--hl-panel); color: var(--hl-panel-text); border-radius: var(--hl-radius-card); padding: 18px 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 32px; }\n.hl-usage .plan-card .eyebrow { color: var(--hl-panel-muted); }\n.hl-usage .plan-card strong { font-size: 22px; letter-spacing: -0.02em; }\n.hl-usage .plan-card p { max-width: 380px; color: var(--hl-panel-soft); font-size: 14px; }\n.hl-usage .meter { display: block; height: 8px; min-width: 160px; margin-top: 8px; background: var(--hl-faint); border-radius: 999px; overflow: hidden; }\n.hl-usage .meter > span { display: block; height: 100%; background: var(--hl-accent); border-radius: 999px; }\n.hl-usage .meter.full > span { background: var(--hl-danger); }\n.hl-usage .table-box { background: var(--hl-surface); border: 1px solid var(--hl-border); border-radius: var(--hl-radius-card); overflow-x: auto; }\n.hl-usage table { width: 100%; min-width: 640px; border-collapse: collapse; color: var(--hl-text); }\n.hl-usage th, .hl-usage td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--hl-border); vertical-align: middle; }\n.hl-usage table.compare { min-width: 780px; table-layout: fixed; }\n.hl-usage table.compare td, .hl-usage table.compare th { text-align: center; padding-left: 8px; padding-right: 8px; }\n.hl-usage table.compare tr > :first-child { width: 170px; text-align: left; padding-left: 16px; }\n.hl-usage table.compare tbody th { color: var(--hl-muted); font-weight: 500; }\n.hl-usage table.compare thead th { padding: 14px 10px 12px; font-size: 14px; font-weight: 400; vertical-align: top; }\n.hl-usage table.compare thead th > span { display: block; }\n.hl-usage table.compare thead th > .pill { display: inline-flex; margin-top: 8px; }\n.hl-usage table.compare .plan-name { font-size: 16px; font-weight: 700; }\n.hl-usage table.compare .price { margin-top: 6px; font-size: 13px; color: var(--hl-muted); }\n.hl-usage table.compare .corner { color: var(--hl-muted); font-size: 13px; vertical-align: bottom; }\n.hl-usage table.compare tbody td { font-family: var(--hl-mono); font-size: 13px; overflow-wrap: anywhere; }\n.hl-usage table.compare .current { background: var(--hl-accent-soft); }\n.hl-usage table.compare thead .current { box-shadow: inset 0 3px 0 var(--hl-accent); }\n.hl-usage table.compare tfoot td { padding: 12px 8px 16px; border-bottom: 0; vertical-align: top; }\n.hl-usage table.compare tfoot button { width: 100%; padding: 0 8px; font-size: 14px; white-space: nowrap; }\n.hl-usage table.compare tfoot button + button { margin-top: 8px; }\n";
5
+ export declare const USAGE_CSS = "\n.hl-usage h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }\n.hl-usage h2 { margin: 0; font-size: 14px; font-weight: 700; }\n.hl-usage .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }\n.hl-usage .row.spread { justify-content: space-between; align-items: flex-end; }\n.hl-usage .muted { color: var(--hl-muted); font-size: 13px; }\n.hl-usage .mono { font-family: var(--hl-mono); font-size: 13px; }\n.hl-usage .eyebrow { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--hl-muted); }\n.hl-usage .panel { background: var(--hl-surface); border: 1px solid var(--hl-border); border-radius: var(--hl-radius-card); padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }\n.hl-usage .notice { padding: 12px 16px; border-radius: var(--hl-radius-control); background: var(--hl-amber-bg); border: 1px solid var(--hl-amber-border); color: var(--hl-amber-text); font-size: 14px; }\n.hl-usage button, .hl-usage .button { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 0 12px; border-radius: var(--hl-radius-control); border: 1px solid var(--hl-border); background: var(--hl-surface); color: var(--hl-text); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }\n.hl-usage button:hover:not(:disabled) { border-color: var(--hl-accent); }\n.hl-usage button.primary { background: var(--hl-accent); border-color: var(--hl-accent); color: var(--hl-on-accent); }\n.hl-usage button.strong { border-color: var(--hl-text); }\n.hl-usage button:disabled { opacity: .55; cursor: not-allowed; }\n.hl-usage .pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; background: var(--hl-faint); color: var(--hl-muted); font-size: 12px; font-weight: 700; white-space: nowrap; }\n.hl-usage .pill.done { background: var(--hl-accent-soft); color: var(--hl-accent-text); }\n.hl-usage .pill.failed { background: var(--hl-faint); color: var(--hl-danger); }\n.hl-usage .plan-card { background: var(--hl-panel); color: var(--hl-panel-text); border-radius: var(--hl-radius-card); padding: 18px 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 32px; }\n.hl-usage .plan-card .eyebrow { color: var(--hl-panel-muted); }\n.hl-usage .plan-card strong { font-size: 20px; letter-spacing: -0.02em; }\n.hl-usage .plan-card p { max-width: 380px; color: var(--hl-panel-soft); font-size: 14px; }\n.hl-usage .meter { display: block; height: 8px; min-width: 160px; margin-top: 8px; background: var(--hl-faint); border-radius: 999px; overflow: hidden; }\n.hl-usage .meter > span { display: block; height: 100%; background: var(--hl-accent); border-radius: 999px; }\n.hl-usage .meter.full > span { background: var(--hl-danger); }\n.hl-usage .table-box { background: var(--hl-surface); border: 1px solid var(--hl-border); border-radius: var(--hl-radius-card); overflow-x: auto; }\n.hl-usage table { width: 100%; min-width: 640px; border-collapse: collapse; color: var(--hl-text); }\n.hl-usage th, .hl-usage td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--hl-border); vertical-align: middle; }\n.hl-usage table.compare { min-width: 780px; table-layout: fixed; }\n.hl-usage table.compare td, .hl-usage table.compare th { text-align: center; padding-left: 8px; padding-right: 8px; }\n.hl-usage table.compare tr > :first-child { width: 170px; text-align: left; padding-left: 16px; }\n.hl-usage table.compare tbody th { color: var(--hl-muted); font-weight: 500; }\n.hl-usage table.compare thead th { padding: 14px 10px 12px; font-size: 14px; font-weight: 400; vertical-align: top; }\n.hl-usage table.compare thead th > span { display: block; }\n.hl-usage table.compare thead th > .pill { display: inline-flex; margin-top: 8px; }\n.hl-usage table.compare .plan-name { font-size: 16px; font-weight: 700; }\n.hl-usage table.compare .price { margin-top: 6px; font-size: 13px; color: var(--hl-muted); }\n.hl-usage table.compare .corner { color: var(--hl-muted); font-size: 13px; vertical-align: bottom; }\n.hl-usage table.compare tbody td { font-family: var(--hl-mono); font-size: 13px; overflow-wrap: anywhere; }\n.hl-usage table.compare .current { background: var(--hl-accent-soft); }\n.hl-usage table.compare thead .current { box-shadow: inset 0 3px 0 var(--hl-accent); }\n.hl-usage table.compare tfoot td { padding: 12px 8px 16px; border-bottom: 0; vertical-align: top; }\n.hl-usage table.compare tfoot button { width: 100%; padding: 0 8px; font-size: 14px; white-space: nowrap; }\n.hl-usage table.compare tfoot button + button { margin-top: 8px; }\n";
@@ -3,16 +3,16 @@
3
3
  * never restyles an app's own pages, whose class names it shares.
4
4
  */
5
5
  export const USAGE_CSS = `
6
- .hl-usage h1 { margin: 0; font-size: clamp(24px, 3vw, 30px); font-weight: 800; letter-spacing: -0.02em; }
7
- .hl-usage h2 { margin: 0; font-size: 16px; font-weight: 700; }
6
+ .hl-usage h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
7
+ .hl-usage h2 { margin: 0; font-size: 14px; font-weight: 700; }
8
8
  .hl-usage .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
9
9
  .hl-usage .row.spread { justify-content: space-between; align-items: flex-end; }
10
- .hl-usage .muted { color: var(--hl-muted); font-size: 14px; }
11
- .hl-usage .mono { font-family: var(--hl-mono); font-size: 14px; }
10
+ .hl-usage .muted { color: var(--hl-muted); font-size: 13px; }
11
+ .hl-usage .mono { font-family: var(--hl-mono); font-size: 13px; }
12
12
  .hl-usage .eyebrow { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--hl-muted); }
13
- .hl-usage .panel { background: var(--hl-surface); border: 1px solid var(--hl-border); border-radius: var(--hl-radius-card); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
13
+ .hl-usage .panel { background: var(--hl-surface); border: 1px solid var(--hl-border); border-radius: var(--hl-radius-card); padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
14
14
  .hl-usage .notice { padding: 12px 16px; border-radius: var(--hl-radius-control); background: var(--hl-amber-bg); border: 1px solid var(--hl-amber-border); color: var(--hl-amber-text); font-size: 14px; }
15
- .hl-usage button, .hl-usage .button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 14px; border-radius: var(--hl-radius-control); border: 1px solid var(--hl-border); background: var(--hl-surface); color: var(--hl-text); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
15
+ .hl-usage button, .hl-usage .button { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 0 12px; border-radius: var(--hl-radius-control); border: 1px solid var(--hl-border); background: var(--hl-surface); color: var(--hl-text); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
16
16
  .hl-usage button:hover:not(:disabled) { border-color: var(--hl-accent); }
17
17
  .hl-usage button.primary { background: var(--hl-accent); border-color: var(--hl-accent); color: var(--hl-on-accent); }
18
18
  .hl-usage button.strong { border-color: var(--hl-text); }
@@ -22,14 +22,14 @@ export const USAGE_CSS = `
22
22
  .hl-usage .pill.failed { background: var(--hl-faint); color: var(--hl-danger); }
23
23
  .hl-usage .plan-card { background: var(--hl-panel); color: var(--hl-panel-text); border-radius: var(--hl-radius-card); padding: 18px 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 32px; }
24
24
  .hl-usage .plan-card .eyebrow { color: var(--hl-panel-muted); }
25
- .hl-usage .plan-card strong { font-size: 22px; letter-spacing: -0.02em; }
25
+ .hl-usage .plan-card strong { font-size: 20px; letter-spacing: -0.02em; }
26
26
  .hl-usage .plan-card p { max-width: 380px; color: var(--hl-panel-soft); font-size: 14px; }
27
27
  .hl-usage .meter { display: block; height: 8px; min-width: 160px; margin-top: 8px; background: var(--hl-faint); border-radius: 999px; overflow: hidden; }
28
28
  .hl-usage .meter > span { display: block; height: 100%; background: var(--hl-accent); border-radius: 999px; }
29
29
  .hl-usage .meter.full > span { background: var(--hl-danger); }
30
30
  .hl-usage .table-box { background: var(--hl-surface); border: 1px solid var(--hl-border); border-radius: var(--hl-radius-card); overflow-x: auto; }
31
31
  .hl-usage table { width: 100%; min-width: 640px; border-collapse: collapse; color: var(--hl-text); }
32
- .hl-usage th, .hl-usage td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--hl-border); vertical-align: middle; }
32
+ .hl-usage th, .hl-usage td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--hl-border); vertical-align: middle; }
33
33
  .hl-usage table.compare { min-width: 780px; table-layout: fixed; }
34
34
  .hl-usage table.compare td, .hl-usage table.compare th { text-align: center; padding-left: 8px; padding-right: 8px; }
35
35
  .hl-usage table.compare tr > :first-child { width: 170px; text-align: left; padding-left: 16px; }
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ export { ThemeStyles } from './theme/ThemeStyles.js';
9
9
  export { contrastRatio } from './theme/contrast.js';
10
10
  export { THEME_BOOT_SCRIPT, THEME_STORAGE_KEY, applyThemeChoice, readThemeChoice, useTheme, } from './theme/theme-choice.js';
11
11
  export type { ThemeChoice } from './theme/theme-choice.js';
12
- export { ThemeSwitch } from './theme/ThemeSwitch.js';
12
+ export { ThemeCycle, ThemeSwitch } from './theme/ThemeSwitch.js';
13
13
  export { AppShell } from './shell/AppShell.js';
14
14
  export type { ShellAccount } from './shell/AppShell.js';
15
15
  export { flattenNav } from './shell/nav.js';
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ export { ACCENTS, NEUTRALS, themeCss } from './theme/tokens.js';
7
7
  export { ThemeStyles } from './theme/ThemeStyles.js';
8
8
  export { contrastRatio } from './theme/contrast.js';
9
9
  export { THEME_BOOT_SCRIPT, THEME_STORAGE_KEY, applyThemeChoice, readThemeChoice, useTheme, } from './theme/theme-choice.js';
10
- export { ThemeSwitch } from './theme/ThemeSwitch.js';
10
+ export { ThemeCycle, ThemeSwitch } from './theme/ThemeSwitch.js';
11
11
  export { AppShell } from './shell/AppShell.js';
12
12
  export { flattenNav } from './shell/nav.js';
13
13
  export { ShellSearch } from './shell/ShellSearch.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,QAAQ,GACT,MAA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AgB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1,2 +1,2 @@
1
1
  /** The layout pieces' look, on the theme tokens only. */
2
- export declare const LAYOUT_CSS = "\n.hl-muted { color: var(--hl-muted); font-size: 14px; }\n.hl-page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 24px; margin-bottom: 16px; }\n.hl-page-header h1 { margin: 0; font-size: clamp(24px, 3vw, 30px); line-height: 1.15; font-weight: 800; letter-spacing: -0.03em; }\n.hl-page-header p { margin: 6px 0 0; color: var(--hl-muted); }\n.hl-page-header__actions { display: flex; flex-wrap: wrap; gap: 8px; }\n.hl-card { padding: 20px; border-radius: var(--hl-radius-card); background: var(--hl-surface); border: 1px solid var(--hl-border); display: flex; flex-direction: column; gap: 12px; min-width: 0; }\n.hl-card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }\n.hl-card__head h2 { margin: 0; font-size: 16px; font-weight: 700; }\n.hl-card__head a { font-weight: 700; text-decoration: none; }\n.hl-callout { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 12px 16px; border-radius: 16px; background: var(--hl-amber-bg); border: 1px solid var(--hl-amber-border); color: var(--hl-amber-text); }\n.hl-callout__text { flex: 1 1 320px; display: flex; flex-direction: column; }\n.hl-callout a, .hl-callout button { min-height: 38px; display: inline-flex; align-items: center; padding: 0 16px; border: 0; border-radius: var(--hl-radius-control); background: var(--hl-accent); color: #FFFFFF; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }\n.hl-checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }\n.hl-checklist li { display: flex; gap: 12px; align-items: flex-start; }\n.hl-checklist__text { min-width: 0; flex: 1; }\n.hl-check { width: 24px; height: 24px; flex: none; box-sizing: border-box; border-radius: 999px; border: 2px solid var(--hl-border); display: grid; place-items: center; }\n.hl-check--done { border: 0; background: var(--hl-accent); color: #FFFFFF; }\n.hl-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--hl-border); background: var(--hl-surface); color: var(--hl-text); font-weight: 700; text-decoration: none; }\n.hl-chip:hover { border-color: var(--hl-accent); }\n";
2
+ export declare const LAYOUT_CSS = "\n.hl-muted { color: var(--hl-muted); font-size: 13px; }\n.hl-page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 24px; margin-bottom: 14px; }\n.hl-page-header h1 { margin: 0; font-size: 22px; line-height: 1.2; font-weight: 800; letter-spacing: -0.03em; }\n.hl-page-header p { margin: 2px 0 0; color: var(--hl-muted); }\n.hl-page-header__actions { display: flex; flex-wrap: wrap; gap: 8px; }\n.hl-card { padding: 14px 16px; border-radius: var(--hl-radius-card); background: var(--hl-surface); border: 1px solid var(--hl-border); display: flex; flex-direction: column; gap: 10px; min-width: 0; }\n.hl-card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }\n.hl-card__head h2 { margin: 0; font-size: 14px; font-weight: 700; }\n.hl-card__head a { font-weight: 700; text-decoration: none; }\n.hl-callout { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 10px 14px; border-radius: var(--hl-radius-card); background: var(--hl-amber-bg); border: 1px solid var(--hl-amber-border); color: var(--hl-amber-text); }\n.hl-callout__text { flex: 1 1 320px; display: flex; flex-direction: column; }\n.hl-callout a, .hl-callout button { min-height: 32px; display: inline-flex; align-items: center; padding: 0 12px; border: 0; border-radius: var(--hl-radius-control); background: var(--hl-accent); color: #FFFFFF; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }\n.hl-checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }\n.hl-checklist li { display: flex; gap: 12px; align-items: flex-start; }\n.hl-checklist__text { min-width: 0; flex: 1; }\n.hl-check { width: 24px; height: 24px; flex: none; box-sizing: border-box; border-radius: 999px; border: 2px solid var(--hl-border); display: grid; place-items: center; }\n.hl-check--done { border: 0; background: var(--hl-accent); color: #FFFFFF; }\n.hl-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--hl-border); background: var(--hl-surface); color: var(--hl-text); font-weight: 700; text-decoration: none; }\n.hl-chip:hover { border-color: var(--hl-accent); }\n";
@@ -1,23 +1,23 @@
1
1
  /** The layout pieces' look, on the theme tokens only. */
2
2
  export const LAYOUT_CSS = `
3
- .hl-muted { color: var(--hl-muted); font-size: 14px; }
4
- .hl-page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 24px; margin-bottom: 16px; }
5
- .hl-page-header h1 { margin: 0; font-size: clamp(24px, 3vw, 30px); line-height: 1.15; font-weight: 800; letter-spacing: -0.03em; }
6
- .hl-page-header p { margin: 6px 0 0; color: var(--hl-muted); }
3
+ .hl-muted { color: var(--hl-muted); font-size: 13px; }
4
+ .hl-page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 24px; margin-bottom: 14px; }
5
+ .hl-page-header h1 { margin: 0; font-size: 22px; line-height: 1.2; font-weight: 800; letter-spacing: -0.03em; }
6
+ .hl-page-header p { margin: 2px 0 0; color: var(--hl-muted); }
7
7
  .hl-page-header__actions { display: flex; flex-wrap: wrap; gap: 8px; }
8
- .hl-card { padding: 20px; border-radius: var(--hl-radius-card); background: var(--hl-surface); border: 1px solid var(--hl-border); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
8
+ .hl-card { padding: 14px 16px; border-radius: var(--hl-radius-card); background: var(--hl-surface); border: 1px solid var(--hl-border); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
9
9
  .hl-card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
10
- .hl-card__head h2 { margin: 0; font-size: 16px; font-weight: 700; }
10
+ .hl-card__head h2 { margin: 0; font-size: 14px; font-weight: 700; }
11
11
  .hl-card__head a { font-weight: 700; text-decoration: none; }
12
- .hl-callout { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 12px 16px; border-radius: 16px; background: var(--hl-amber-bg); border: 1px solid var(--hl-amber-border); color: var(--hl-amber-text); }
12
+ .hl-callout { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 10px 14px; border-radius: var(--hl-radius-card); background: var(--hl-amber-bg); border: 1px solid var(--hl-amber-border); color: var(--hl-amber-text); }
13
13
  .hl-callout__text { flex: 1 1 320px; display: flex; flex-direction: column; }
14
- .hl-callout a, .hl-callout button { min-height: 38px; display: inline-flex; align-items: center; padding: 0 16px; border: 0; border-radius: var(--hl-radius-control); background: var(--hl-accent); color: #FFFFFF; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
15
- .hl-checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
14
+ .hl-callout a, .hl-callout button { min-height: 32px; display: inline-flex; align-items: center; padding: 0 12px; border: 0; border-radius: var(--hl-radius-control); background: var(--hl-accent); color: #FFFFFF; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
15
+ .hl-checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
16
16
  .hl-checklist li { display: flex; gap: 12px; align-items: flex-start; }
17
17
  .hl-checklist__text { min-width: 0; flex: 1; }
18
18
  .hl-check { width: 24px; height: 24px; flex: none; box-sizing: border-box; border-radius: 999px; border: 2px solid var(--hl-border); display: grid; place-items: center; }
19
19
  .hl-check--done { border: 0; background: var(--hl-accent); color: #FFFFFF; }
20
- .hl-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--hl-border); background: var(--hl-surface); color: var(--hl-text); font-weight: 700; text-decoration: none; }
20
+ .hl-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--hl-border); background: var(--hl-surface); color: var(--hl-text); font-weight: 700; text-decoration: none; }
21
21
  .hl-chip:hover { border-color: var(--hl-accent); }
22
22
  `;
23
23
  //# sourceMappingURL=layout-css.js.map
@@ -0,0 +1,12 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { NotificationsClient } from './types.js';
3
+ /**
4
+ * The top bar's bell: the unread count, live, and a popover with the 10 newest, "Mark all
5
+ * read" and "See all". `onOpenItem` gets an item's link, only when it is an app path, and
6
+ * `inboxPath` for "See all".
7
+ */
8
+ export declare function NotificationBell(props: {
9
+ client: NotificationsClient;
10
+ onOpenItem: (link: string) => void;
11
+ inboxPath?: string;
12
+ }): ReactElement;
@@ -0,0 +1,94 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { EmptyState } from '../EmptyState.js';
4
+ import { Loading } from '../Loading.js';
5
+ import { LoadError, NotificationRow, openNotification } from './NotificationInbox.js';
6
+ import { useNotificationStream } from './use-notification-stream.js';
7
+ /** How many items the popover shows. */
8
+ const NEWEST = 10;
9
+ const MAX_BADGE = 99;
10
+ const badgeText = (unread) => unread > MAX_BADGE ? `${String(MAX_BADGE)}+` : String(unread);
11
+ /**
12
+ * The top bar's bell: the unread count, live, and a popover with the 10 newest, "Mark all
13
+ * read" and "See all". `onOpenItem` gets an item's link, only when it is an app path, and
14
+ * `inboxPath` for "See all".
15
+ */
16
+ export function NotificationBell(props) {
17
+ const { client, onOpenItem, inboxPath = '/notifications' } = props;
18
+ const { unread, latest, setUnread } = useNotificationStream(client);
19
+ const [open, setOpen] = useState(false);
20
+ const [listed, setListed] = useState(null);
21
+ const [failed, setFailed] = useState(false);
22
+ const [reloads, setReloads] = useState(0);
23
+ const [markFailed, setMarkFailed] = useState(false);
24
+ const [readIds, setReadIds] = useState(() => new Set());
25
+ const root = useRef(null);
26
+ const button = useRef(null);
27
+ const panel = useRef(null);
28
+ const close = () => {
29
+ setOpen(false);
30
+ button.current?.focus();
31
+ };
32
+ useEffect(() => {
33
+ if (!open)
34
+ return;
35
+ let live = true;
36
+ setListed(null);
37
+ setFailed(false);
38
+ client.list({}).then((page) => {
39
+ if (live)
40
+ setListed(page.items);
41
+ }, () => {
42
+ if (live)
43
+ setFailed(true);
44
+ });
45
+ panel.current?.focus();
46
+ const onPointer = (event) => {
47
+ if (root.current && !root.current.contains(event.target)) {
48
+ setOpen(false);
49
+ button.current?.focus();
50
+ }
51
+ };
52
+ document.addEventListener('pointerdown', onPointer);
53
+ return () => {
54
+ live = false;
55
+ document.removeEventListener('pointerdown', onPointer);
56
+ };
57
+ }, [open, client, reloads]);
58
+ // Streamed items first (they are newer), then the page, without repeats.
59
+ const seen = new Set();
60
+ const items = [...latest, ...(listed ?? [])]
61
+ .filter((item) => !seen.has(item.id) && Boolean(seen.add(item.id)))
62
+ .slice(0, NEWEST);
63
+ const isRead = (item) => item.readAt !== null || readIds.has(item.id);
64
+ const openItem = (item) => {
65
+ setReadIds((ids) => new Set(ids).add(item.id));
66
+ setOpen(false);
67
+ openNotification(client, item, isRead(item), onOpenItem, setUnread);
68
+ };
69
+ const markAll = () => {
70
+ setMarkFailed(false);
71
+ client.markAllRead().then((count) => {
72
+ setUnread(count);
73
+ setReadIds((ids) => new Set([...ids, ...items.map((item) => item.id)]));
74
+ }, () => setMarkFailed(true));
75
+ };
76
+ // Focus moving to something else on the page closes it; focus lost to nowhere (a button
77
+ // that went disabled, the window) does not.
78
+ const onBlur = (event) => {
79
+ const next = event.relatedTarget;
80
+ if (next instanceof Node && !event.currentTarget.contains(next))
81
+ setOpen(false);
82
+ };
83
+ const onKeyDown = (event) => {
84
+ if (event.key === 'Escape') {
85
+ event.stopPropagation();
86
+ close();
87
+ }
88
+ };
89
+ return (_jsxs("div", { className: "hl-notify", ref: root, onKeyDown: open ? onKeyDown : undefined, onBlur: open ? onBlur : undefined, children: [_jsxs("button", { ref: button, type: "button", className: "hl-notify__bell", "aria-label": unread > 0 ? `Notifications, ${String(unread)} unread` : 'Notifications', "aria-expanded": open, "aria-haspopup": "dialog", onClick: () => (open ? close() : setOpen(true)), children: [_jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", "aria-hidden": "true", children: [_jsx("path", { d: "M6 8a6 6 0 1 1 12 0c0 7 3 9 3 9H3s3-2 3-9" }), _jsx("path", { d: "M10.3 21a1.94 1.94 0 0 0 3.4 0" })] }), unread > 0 && (_jsx("span", { className: "hl-notify__badge", "aria-hidden": "true", children: badgeText(unread) }))] }), open && (_jsxs("div", { ref: panel, role: "dialog", "aria-label": "Notifications", className: "hl-notify__popover", tabIndex: -1, children: [_jsxs("div", { className: "hl-notify__head", children: [_jsx("strong", { children: "Notifications" }), _jsx("button", { type: "button", className: "hl-notify__action", disabled: unread === 0 && items.every(isRead), onClick: markAll, children: "Mark all read" })] }), failed && _jsx(LoadError, { what: "notifications", onRetry: () => setReloads((n) => n + 1) }), markFailed && (_jsx("p", { role: "alert", className: "hl-notify__error", children: "Couldn\u2019t mark them read. Try again." })), listed === null && !failed && latest.length === 0 && (_jsx(Loading, { label: "Loading notifications" })), listed !== null && items.length === 0 && _jsx(EmptyState, { title: "Nothing here yet" }), items.length > 0 && (_jsx("ul", { className: "hl-notify__list", children: items.map((item) => (_jsx(NotificationRow, { item: item, read: isRead(item), onOpen: () => openItem(item) }, item.id))) })), _jsx("div", { className: "hl-notify__foot", children: _jsx("button", { type: "button", className: "hl-notify__action", onClick: () => {
90
+ setOpen(false);
91
+ onOpenItem(inboxPath);
92
+ }, children: "See all" }) })] }))] }));
93
+ }
94
+ //# sourceMappingURL=NotificationBell.js.map
@@ -0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KAAC,OAAO,IAAC,KAAK,EAAC,uBAAuB,GAAG,CAC1C,EACA,MAAM,KAAK,IAAI,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAC,UAAU,IAAC,KAAK,EAAC,kBAAkB,GAAG,EAChF,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CACnB,aAAI,SAAS,EAAC,iBAAiB,YAC5B,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,KAAC,eAAe,IAEd,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EAClB,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAHvB,IAAI,CAAC,EAAE,CAIZ,CACH,CAAC,GACC,CACN,EACD,cAAK,SAAS,EAAC,iBAAiB,YAC9B,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,mBAAmB,EAC7B,OAAO,EAAE,GAAG,EAAE;gCACZ,OAAO,CAAC,KAAK,CAAC,CAAC;gCACf,UAAU,CAAC,SAAS,CAAC,CAAC;4BACxB,CAAC,wBAGM,GACL,IACF,CACP,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { NotificationItemData, NotificationsClient } from './types.js';
3
+ /** A load error, with a button that tries again. */
4
+ export declare function LoadError(props: {
5
+ what: string;
6
+ onRetry: () => void;
7
+ }): ReactElement;
8
+ /**
9
+ * Marks the item read (when it is unread) and opens its link, only when the link is an app
10
+ * path: a link from anywhere else is never followed (`https:`, `//host`, `javascript:`).
11
+ */
12
+ export declare function openNotification(client: NotificationsClient, item: NotificationItemData, read: boolean, onOpenItem: (link: string) => void, onUnread: (unread: number) => void): void;
13
+ /** One item, as a button: it never renders the link itself. */
14
+ export declare function NotificationRow(props: {
15
+ item: NotificationItemData;
16
+ read: boolean;
17
+ onOpen: () => void;
18
+ }): ReactElement;
19
+ /** The full inbox page: All or Unread, newest first, a page at a time. */
20
+ export declare function NotificationInbox(props: {
21
+ client: NotificationsClient;
22
+ onOpenItem: (link: string) => void;
23
+ }): ReactElement;
@@ -0,0 +1,92 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { EmptyState } from '../EmptyState.js';
4
+ import { Loading } from '../Loading.js';
5
+ import { isAppPath } from './types.js';
6
+ const when = new Intl.DateTimeFormat('en-GB', { dateStyle: 'medium', timeStyle: 'short' });
7
+ /** The time, or nothing for a date that does not parse. */
8
+ const shown = (iso) => {
9
+ const date = new Date(iso);
10
+ return Number.isNaN(date.getTime()) ? '' : when.format(date);
11
+ };
12
+ /** A load error, with a button that tries again. */
13
+ export function LoadError(props) {
14
+ return (_jsxs("p", { role: "alert", className: "hl-notify__error", children: ["Couldn\u2019t load ", props.what, ".", _jsx("button", { type: "button", className: "hl-notify__action", onClick: props.onRetry, children: "Try again" })] }));
15
+ }
16
+ /**
17
+ * Marks the item read (when it is unread) and opens its link, only when the link is an app
18
+ * path: a link from anywhere else is never followed (`https:`, `//host`, `javascript:`).
19
+ */
20
+ export function openNotification(client, item, read, onOpenItem, onUnread) {
21
+ if (!read)
22
+ client.markRead([item.id]).then(onUnread, () => undefined);
23
+ if (item.link !== null && isAppPath(item.link))
24
+ onOpenItem(item.link);
25
+ }
26
+ /** One item, as a button: it never renders the link itself. */
27
+ export function NotificationRow(props) {
28
+ const { item, read } = props;
29
+ return (_jsx("li", { className: read ? 'hl-notify__item' : 'hl-notify__item hl-notify__item--unread', children: _jsxs("button", { type: "button", className: "hl-notify__open", onClick: props.onOpen, children: [!read && _jsx("span", { className: "hl-notify__sr", children: "Unread: " }), _jsx("strong", { children: item.title }), item.body && _jsx("span", { className: "hl-notify__body", children: item.body }), _jsx("time", { dateTime: item.createdAt, children: shown(item.createdAt) })] }) }));
30
+ }
31
+ /** The full inbox page: All or Unread, newest first, a page at a time. */
32
+ export function NotificationInbox(props) {
33
+ const { client, onOpenItem } = props;
34
+ const [filter, setFilter] = useState('all');
35
+ const [items, setItems] = useState(null);
36
+ const [cursor, setCursor] = useState(null);
37
+ const [loadingMore, setLoadingMore] = useState(false);
38
+ const [failed, setFailed] = useState(false);
39
+ const [readIds, setReadIds] = useState(() => new Set());
40
+ const [reloads, setReloads] = useState(0);
41
+ // Which filter's pages are showing: a page that arrives after the filter changed is dropped.
42
+ const generation = useRef(0);
43
+ const query = (next) => ({
44
+ ...(filter === 'unread' ? { unread: true } : {}),
45
+ ...(next === undefined ? {} : { cursor: next }),
46
+ });
47
+ useEffect(() => {
48
+ let live = true;
49
+ generation.current += 1;
50
+ setItems(null);
51
+ setFailed(false);
52
+ client
53
+ .list(filter === 'unread' ? { unread: true } : {})
54
+ .then((page) => {
55
+ if (!live)
56
+ return;
57
+ setItems(page.items);
58
+ setCursor(page.nextCursor);
59
+ })
60
+ .catch(() => {
61
+ if (live)
62
+ setFailed(true);
63
+ });
64
+ return () => {
65
+ live = false;
66
+ };
67
+ }, [client, filter, reloads]);
68
+ const loadMore = () => {
69
+ if (cursor === null)
70
+ return;
71
+ const asked = generation.current;
72
+ setLoadingMore(true);
73
+ setFailed(false);
74
+ client
75
+ .list(query(cursor))
76
+ .then((page) => {
77
+ if (asked !== generation.current)
78
+ return;
79
+ setItems((current) => [...(current ?? []), ...page.items]);
80
+ setCursor(page.nextCursor);
81
+ })
82
+ .catch(() => setFailed(true))
83
+ .finally(() => setLoadingMore(false));
84
+ };
85
+ const isRead = (item) => item.readAt !== null || readIds.has(item.id);
86
+ const open = (item) => {
87
+ setReadIds((ids) => new Set(ids).add(item.id));
88
+ openNotification(client, item, isRead(item), onOpenItem, () => undefined);
89
+ };
90
+ return (_jsxs("div", { className: "hl-notify-page", children: [_jsx("div", { role: "group", "aria-label": "Show", className: "hl-notify__segments", children: ['all', 'unread'].map((value) => (_jsx("button", { type: "button", "aria-pressed": filter === value, onClick: () => setFilter(value), children: value === 'all' ? 'All' : 'Unread' }, value))) }), failed && (_jsx(LoadError, { what: "notifications", onRetry: () => (items === null ? setReloads((n) => n + 1) : loadMore()) })), items === null && !failed && _jsx(Loading, { label: "Loading notifications", rows: 4 }), items?.length === 0 && _jsx(EmptyState, { title: "Nothing here yet" }), items && items.length > 0 && (_jsx("ul", { className: "hl-notify__list", children: items.map((item) => (_jsx(NotificationRow, { item: item, read: isRead(item), onOpen: () => open(item) }, item.id))) })), cursor !== null && items !== null && (_jsx("button", { type: "button", className: "hl-notify__more", disabled: loadingMore, onClick: loadMore, children: "Load more" }))] }));
91
+ }
92
+ //# sourceMappingURL=NotificationInbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationInbox.js","sourceRoot":"","sources":["../../src/notifications/NotificationInbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;AAC3F,2DAA2D;AAC3D,MAAM,KAAK,GAAG,CAAC,GAAW,EAAU,EAAE;IACpC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC,CAAC;AAEF,oDAAoD;AACpD,MAAM,UAAU,SAAS,CAAC,KAA4C;IACpE,OAAO,CACL,aAAG,IAAI,E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H,EACA,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,IAAI,KAAC,OAAO,IAAC,KAAK,EAAC,uBAAuB,EAAC,IAAI,EAAE,CAAC,GAAI,EAC/E,KAAK,EAAE,MAAM,KAAK,CAAC,IAAI,KAAC,UAAU,IAAC,KAAK,EAAC,kBAAkB,GAAG,EAC9D,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAC5B,aAAI,SAAS,EAAC,iBAAiB,YAC5B,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,KAAC,eAAe,IAEd,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EAClB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAHnB,IAAI,CAAC,EAAE,CAIZ,CACH,CAAC,GACC,CACN,EACA,MAAM,KAAK,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,CACpC,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,iBAAiB,EAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,0BAEjF,CACV,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { NotificationsClient } from './types.js';
3
+ /**
4
+ * Which notifications go by email and push, per event, grouped. Each switch saves at once;
5
+ * a failed save puts it back and says so. A locked switch (a required event's email) is off
6
+ * limits. The inbox gets every event whatever is chosen here.
7
+ */
8
+ export declare function NotificationPreferences(props: {
9
+ client: NotificationsClient;
10
+ }): ReactElement;
@@ -0,0 +1,135 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { Loading } from '../Loading.js';
4
+ import { LoadError } from './NotificationInbox.js';
5
+ const CHANNELS = [
6
+ { channel: 'email', label: 'Email' },
7
+ { channel: 'push', label: 'Push' },
8
+ ];
9
+ /** What a device that cannot ask for push says instead of the button. */
10
+ const PUSH_UNAVAILABLE = {
11
+ embedded: 'Push isn’t available inside Shopify — turn it on from the dashboard',
12
+ 'needs-install': 'Add this site to your Home Screen to get push',
13
+ unsupported: 'This browser can’t get push notifications',
14
+ };
15
+ const ENABLE_RESULT = {
16
+ subscribed: 'Push is on for this device',
17
+ denied: 'Push is blocked for this site — allow notifications in the browser’s settings',
18
+ ...PUSH_UNAVAILABLE,
19
+ };
20
+ /** The preferences with one event's channel changed, every other cell as it was. */
21
+ function withCell(data, event, channel, change) {
22
+ return {
23
+ events: data.events.map((row) => row.event === event
24
+ ? {
25
+ ...row,
26
+ channels: { ...row.channels, [channel]: { ...row.channels[channel], ...change } },
27
+ }
28
+ : row),
29
+ };
30
+ }
31
+ /** The events by group, in the order the app lists them. */
32
+ function groups(events) {
33
+ const out = [];
34
+ for (const row of events) {
35
+ const last = out.find(([group]) => group === row.group);
36
+ if (last)
37
+ last[1].push(row);
38
+ else
39
+ out.push([row.group, [row]]);
40
+ }
41
+ return out;
42
+ }
43
+ /** Push on this device: the button, or why this device cannot have it. */
44
+ function DevicePush({ push }) {
45
+ const [support] = useState(() => push.support());
46
+ const [state, setState] = useState({
47
+ busy: false,
48
+ });
49
+ useEffect(() => {
50
+ if (support !== 'supported' || !push.isSubscribed)
51
+ return;
52
+ let live = true;
53
+ push.isSubscribed().then((subscribed) => {
54
+ // A click since then knows better than this first look.
55
+ if (live && subscribed)
56
+ setState((current) => current.busy || current.result ? current : { busy: false, result: 'subscribed' });
57
+ },
58
+ // Not known: the button offers to enable, which is safe to press again.
59
+ () => undefined);
60
+ return () => {
61
+ live = false;
62
+ };
63
+ }, [push, support]);
64
+ const unavailable = PUSH_UNAVAILABLE[support] ??
65
+ (support === 'supported' ? undefined : PUSH_UNAVAILABLE.unsupported);
66
+ if (unavailable)
67
+ return _jsx("p", { className: "hl-notify__note", children: unavailable });
68
+ const enable = () => {
69
+ setState({ busy: true });
70
+ push.enable().then((result) => setState({ busy: false, result }), () => setState({ busy: false, failed: true }));
71
+ };
72
+ const disable = () => {
73
+ setState({ busy: true, result: 'subscribed' });
74
+ push.disable().then(() => setState({ busy: false }), () => setState({ busy: false, result: 'subscribed', failed: true }));
75
+ };
76
+ const on = state.result === 'subscribed';
77
+ return (_jsxs("div", { className: "hl-notify__device", children: [_jsx("button", { type: "button", className: "hl-notify__action", disabled: state.busy, onClick: on ? disable : enable, children: on ? 'Turn off push on this device' : 'Enable push on this device' }), state.result && _jsx("span", { className: "hl-notify__note", children: ENABLE_RESULT[state.result] }), state.failed && (_jsx("span", { role: "alert", className: "hl-notify__error", children: "Couldn\u2019t change push on this device. Try again." }))] }));
78
+ }
79
+ /**
80
+ * Which notifications go by email and push, per event, grouped. Each switch saves at once;
81
+ * a failed save puts it back and says so. A locked switch (a required event's email) is off
82
+ * limits. The inbox gets every event whatever is chosen here.
83
+ */
84
+ export function NotificationPreferences(props) {
85
+ const { client } = props;
86
+ const [data, setData] = useState(null);
87
+ const [loadFailed, setLoadFailed] = useState(false);
88
+ const [saveFailed, setSaveFailed] = useState(false);
89
+ const [reloads, setReloads] = useState(0);
90
+ // The newest save per cell (`event:channel`): an older answer never undoes a newer toggle,
91
+ // and each answer only sets its own cell, so saves of other cells in flight stay as shown.
92
+ const newest = useRef({});
93
+ useEffect(() => {
94
+ let live = true;
95
+ setLoadFailed(false);
96
+ client.preferences().then((loaded) => {
97
+ if (live)
98
+ setData(loaded);
99
+ }, () => {
100
+ if (live)
101
+ setLoadFailed(true);
102
+ });
103
+ return () => {
104
+ live = false;
105
+ };
106
+ }, [client, reloads]);
107
+ const toggle = (event, channel, on) => {
108
+ const cell = `${event}:${channel}`;
109
+ const save = (newest.current[cell] ?? 0) + 1;
110
+ newest.current[cell] = save;
111
+ setSaveFailed(false);
112
+ setData((current) => current && withCell(current, event, channel, { on }));
113
+ client.setPreferences([{ event, channel, on }]).then((saved) => {
114
+ if (newest.current[cell] !== save)
115
+ return;
116
+ const state = saved.events.find((row) => row.event === event)?.channels[channel];
117
+ if (state)
118
+ setData((current) => current && withCell(current, event, channel, state));
119
+ }, () => {
120
+ if (newest.current[cell] !== save)
121
+ return;
122
+ setData((current) => current && withCell(current, event, channel, { on: !on }));
123
+ setSaveFailed(true);
124
+ });
125
+ };
126
+ if (loadFailed)
127
+ return (_jsx("div", { className: "hl-notify-prefs", children: _jsx(LoadError, { what: "your notification settings", onRetry: () => setReloads((n) => n + 1) }) }));
128
+ if (!data)
129
+ return _jsx(Loading, { label: "Loading notification settings", rows: 3 });
130
+ return (_jsxs("div", { className: "hl-notify-prefs", children: [saveFailed && (_jsx("p", { role: "alert", className: "hl-notify__error", children: "Couldn\u2019t save that change, so it\u2019s back as it was. Try again." })), _jsx("div", { className: "hl-notify__table-box", children: _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: "Notification" }), CHANNELS.map(({ channel, label }) => (_jsx("th", { scope: "col", children: label }, channel)))] }) }), groups(data.events).map(([group, rows]) => (_jsxs("tbody", { children: [_jsx("tr", { children: _jsx("th", { scope: "rowgroup", colSpan: 3, className: "hl-notify__group", children: group }) }), rows.map((row) => (_jsxs("tr", { children: [_jsx("th", { scope: "row", children: row.label }), CHANNELS.map(({ channel, label }) => {
131
+ const state = row.channels[channel];
132
+ return (_jsx("td", { children: _jsxs("span", { className: "hl-notify__cell", children: [_jsx("input", { type: "checkbox", role: "switch", className: "hl-notify__switch", "aria-label": `${label} for ${row.label}`, checked: state.on, disabled: state.locked, onChange: (e) => toggle(row.event, channel, e.target.checked) }), state.locked && _jsx("span", { className: "hl-notify__required", children: "Required" })] }) }, channel));
133
+ })] }, row.event)))] }, group)))] }) }), client.push && _jsx(DevicePush, { push: client.push })] }));
134
+ }
135
+ //# sourceMappingURL=NotificationPreferences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationPreferences.js","sourceRoot":"","sources":["../../src/notifications/NotificationPreferences.tsx"],"names":[],"mappings":";AAAA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