@haatlabs-core/extension-ui 0.26.1 → 0.27.1

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.
@@ -0,0 +1,12 @@
1
+ import type { ReactElement, ReactNode } from 'react';
2
+ import type { Status } from '@haatlabs-core/announcements-contracts';
3
+ /**
4
+ * The app's announcements and maintenance in the popup or side panel: read once as it opens
5
+ * (`/api/v1/me/status` signed in, `/api/v1/status` before). During maintenance, a notice in
6
+ * place of the panel; otherwise the alerts above it. A status that cannot be read shows the
7
+ * panel as it is: the panel's own calls will say if the app is down.
8
+ */
9
+ export declare function StatusNotices(props: {
10
+ read: () => Promise<Status>;
11
+ children: ReactNode;
12
+ }): ReactElement;
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { httpsLink } from '@haatlabs-core/announcements-contracts';
4
+ import { Notice } from './ExtensionShell.js';
5
+ const ORDER = { CRITICAL: 0, WARN: 1, INFO: 2 };
6
+ const when = (iso) => {
7
+ if (!iso)
8
+ return null;
9
+ const date = new Date(iso);
10
+ return Number.isNaN(date.getTime())
11
+ ? null
12
+ : new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'short' }).format(date);
13
+ };
14
+ /**
15
+ * The app's announcements and maintenance in the popup or side panel: read once as it opens
16
+ * (`/api/v1/me/status` signed in, `/api/v1/status` before). During maintenance, a notice in
17
+ * place of the panel; otherwise the alerts above it. A status that cannot be read shows the
18
+ * panel as it is: the panel's own calls will say if the app is down.
19
+ */
20
+ export function StatusNotices(props) {
21
+ const [status, setStatus] = useState(null);
22
+ // The latest reader, called once as the panel opens: a parent's new arrow is not a new read.
23
+ const read = useRef(props.read);
24
+ read.current = props.read;
25
+ useEffect(() => {
26
+ let live = true;
27
+ read.current().then((next) => {
28
+ if (live)
29
+ setStatus(next);
30
+ }, () => undefined);
31
+ return () => {
32
+ live = false;
33
+ };
34
+ }, []);
35
+ if (status?.maintenance) {
36
+ const until = when(status.maintenance.until);
37
+ return (_jsx("div", { "data-severity": "CRITICAL", children: _jsxs(Notice, { title: "Down for maintenance", children: [_jsx("p", { children: status.maintenance.message }), until && _jsxs("p", { children: ["Back by ", until, "."] })] }) }));
38
+ }
39
+ const alerts = [...(status?.alerts ?? [])].sort((a, b) => ORDER[a.severity] - ORDER[b.severity] || b.startsAt.localeCompare(a.startsAt));
40
+ return (_jsxs(_Fragment, { children: [alerts.map((a) => (_jsx("div", { "data-severity": a.severity, children: _jsxs(Notice, { title: a.title, children: [_jsx("p", { children: a.body }), httpsLink(a.linkUrl) && (_jsx("a", { href: httpsLink(a.linkUrl) ?? undefined, target: "_blank", rel: "noopener noreferrer", children: a.linkLabel ?? a.linkUrl }))] }) }, a.id))), props.children] }));
41
+ }
42
+ //# sourceMappingURL=StatusNotices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatusNotices.js","sourceRoot":"","sources":["../src/StatusNotices.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,MAAM,KAAK,GAA6B,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAE1E,MAAM,IAAI,GAAG,CAAC,GAAkB,EAAiB,EAAE;IACjD,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACjC,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,IAAI,IAAI,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AAK,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CACxF,CAAC;IACF,OAAO,CACL,8BACG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CACjB,+BAA+B,CAAC,CAAC,QAAQ,YACvC,MAAC,MAAM,IAAC,KAAK,EAAE,CAAC,CAAC,KAAK,aACpB,sBAAI,CAAC,CAAC,IAAI,GAAK,EACd,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CACvB,YAAG,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,SAAS,EAAE,MAAM,EAAC,QAAQ,EAAC,GAAG,EAAC,qBAAqB,YAClF,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,OAAO,GACvB,CACL,IACM,IARD,CAAC,CAAC,EAAE,CASR,CACP,CAAC,EACD,KAAK,CAAC,QAAQ,IACd,CACJ,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { ExtensionShell, Header, Notice, SignInCard } from './ExtensionShell.js';
2
2
  export type { PageAnswer, PageFacts, PageReader, PanelBrand, PanelEnv, PanelTheme, } from './types.js';
3
+ export { StatusNotices } from './StatusNotices.js';
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { ExtensionShell, Header, Notice, SignInCard } from './ExtensionShell.js';
2
+ export { StatusNotices } from './StatusNotices.js';
2
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AASjF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/panel.css CHANGED
@@ -164,3 +164,14 @@ h2 {
164
164
  min-height: 36px;
165
165
  padding: 0 4px;
166
166
  }
167
+
168
+ /* Announcements and maintenance (StatusNotices): red, amber, the accent. */
169
+ [data-severity='CRITICAL'] .notice-card {
170
+ border-left: 4px solid #c62828;
171
+ }
172
+ [data-severity='WARN'] .notice-card {
173
+ border-left: 4px solid #e0a106;
174
+ }
175
+ [data-severity='INFO'] .notice-card {
176
+ border-left: 4px solid var(--accent);
177
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haatlabs-core/extension-ui",
3
- "version": "0.26.1",
3
+ "version": "0.27.1",
4
4
  "description": "A browser extension's side panel: the app's brand, theme, header, notices and sign-in card.",
5
5
  "keywords": [
6
6
  "haatlabs",
@@ -54,8 +54,11 @@
54
54
  "jsdom": "^30.1.2",
55
55
  "react": "^19.3.0",
56
56
  "react-dom": "^19.3.0",
57
- "@haatlabs-core/tsconfig": "0.26.1",
58
- "@haatlabs-core/vitest-config": "0.26.1"
57
+ "@haatlabs-core/vitest-config": "0.27.1",
58
+ "@haatlabs-core/tsconfig": "0.27.1"
59
+ },
60
+ "dependencies": {
61
+ "@haatlabs-core/announcements-contracts": "0.27.1"
59
62
  },
60
63
  "scripts": {
61
64
  "build": "rm -rf dist && tsc -p tsconfig.build.json && cp src/panel.css dist/panel.css",