@broberg/app-shell 0.5.0 → 0.7.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.
- package/README.md +52 -0
- package/css/app-shell.css +48 -0
- package/dist/index.cjs +124 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +119 -1
- package/dist/index.d.ts +119 -1
- package/dist/index.js +117 -3
- package/dist/index.js.map +1 -1
- package/dist/preact.cjs +297 -3
- package/dist/preact.cjs.map +1 -1
- package/dist/preact.d.cts +154 -1
- package/dist/preact.d.ts +154 -1
- package/dist/preact.js +288 -4
- package/dist/preact.js.map +1 -1
- package/package.json +3 -1
package/dist/preact.js
CHANGED
|
@@ -224,6 +224,80 @@ function createFetchAccountAdapter(opts = {}) {
|
|
|
224
224
|
removeAvatar: () => call("/profile/avatar/remove", { method: "POST" })
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
|
+
var AnalyticsError = class extends Error {
|
|
228
|
+
constructor(status, code) {
|
|
229
|
+
super(code ? `HTTP ${status} ${code}` : `HTTP ${status}`);
|
|
230
|
+
this.status = status;
|
|
231
|
+
this.code = code;
|
|
232
|
+
this.name = "AnalyticsError";
|
|
233
|
+
}
|
|
234
|
+
status;
|
|
235
|
+
code;
|
|
236
|
+
};
|
|
237
|
+
function analyticsErrorKind(err) {
|
|
238
|
+
return err instanceof AnalyticsError && err.status === 503 && err.code === "analytics_unconfigured" ? "unconfigured" : "unavailable";
|
|
239
|
+
}
|
|
240
|
+
function createFetchAnalyticsAdapter(opts = {}) {
|
|
241
|
+
const url = opts.url ?? "/api/analytics";
|
|
242
|
+
return {
|
|
243
|
+
async load(days) {
|
|
244
|
+
let res;
|
|
245
|
+
try {
|
|
246
|
+
res = await (opts.fetch ?? fetch)(`${url}${url.includes("?") ? "&" : "?"}days=${encodeURIComponent(String(days))}`, {
|
|
247
|
+
credentials: opts.credentials ?? "same-origin",
|
|
248
|
+
headers: { accept: "application/json" }
|
|
249
|
+
});
|
|
250
|
+
} catch {
|
|
251
|
+
throw new AnalyticsError(0);
|
|
252
|
+
}
|
|
253
|
+
const body = await res.json().catch(() => null);
|
|
254
|
+
if (!res.ok) throw new AnalyticsError(res.status, typeof body?.error === "string" ? body.error : void 0);
|
|
255
|
+
const ok = body !== null && typeof body.totals?.visitors === "number" && Array.isArray(body.series) && Array.isArray(body.topPages);
|
|
256
|
+
if (!ok) throw new AnalyticsError(res.status, "bad_response");
|
|
257
|
+
return body;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function copenhagenDay(at = /* @__PURE__ */ new Date()) {
|
|
262
|
+
return new Intl.DateTimeFormat("en-CA", { timeZone: "Europe/Copenhagen", year: "numeric", month: "2-digit", day: "2-digit" }).format(at);
|
|
263
|
+
}
|
|
264
|
+
function fillDays(series, days, now = /* @__PURE__ */ new Date()) {
|
|
265
|
+
const byDay = new Map(series.map((d2) => [d2.day, d2]));
|
|
266
|
+
const [y, m, d] = copenhagenDay(now).split("-").map(Number);
|
|
267
|
+
return Array.from({ length: days }, (_, i) => {
|
|
268
|
+
const day = new Date(Date.UTC(y, m - 1, d - (days - 1 - i))).toISOString().slice(0, 10);
|
|
269
|
+
return byDay.get(day) ?? { day, visitors: 0, pageviews: 0 };
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
function changePct(now, before) {
|
|
273
|
+
return before === 0 ? null : Math.round((now - before) / before * 100);
|
|
274
|
+
}
|
|
275
|
+
var TenantLoadError = class extends Error {
|
|
276
|
+
constructor(status) {
|
|
277
|
+
super(`HTTP ${status}`);
|
|
278
|
+
this.status = status;
|
|
279
|
+
this.name = "TenantLoadError";
|
|
280
|
+
}
|
|
281
|
+
status;
|
|
282
|
+
};
|
|
283
|
+
function createFetchTenantAdapter(opts = {}) {
|
|
284
|
+
return {
|
|
285
|
+
async load() {
|
|
286
|
+
let res;
|
|
287
|
+
try {
|
|
288
|
+
res = await (opts.fetch ?? fetch)(opts.url ?? "/api/me/memberships", { credentials: opts.credentials ?? "same-origin", headers: { accept: "application/json" } });
|
|
289
|
+
} catch {
|
|
290
|
+
throw new TenantLoadError(0);
|
|
291
|
+
}
|
|
292
|
+
const body = await res.json().catch(() => null);
|
|
293
|
+
if (!res.ok) throw new TenantLoadError(res.status);
|
|
294
|
+
if (!Array.isArray(body) || !body.every((r) => r && typeof r.role === "string" && r.tenant && typeof r.tenant.slug === "string")) {
|
|
295
|
+
throw new TenantLoadError(res.status);
|
|
296
|
+
}
|
|
297
|
+
return body;
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
}
|
|
227
301
|
var TEXT = {
|
|
228
302
|
da: {
|
|
229
303
|
openMenu: "\xC5bn menu",
|
|
@@ -271,7 +345,27 @@ var TEXT = {
|
|
|
271
345
|
pictureRemoved: "Billedet er fjernet",
|
|
272
346
|
pictureTooLarge: "Billedet er for stort \u2014 h\xF8jst 2 MB.",
|
|
273
347
|
pictureWrongType: "V\xE6lg et PNG-, JPEG- eller WebP-billede.",
|
|
274
|
-
bidSecurity: "Sikkerhed i Broberg ID"
|
|
348
|
+
bidSecurity: "Sikkerhed i Broberg ID",
|
|
349
|
+
analyticsPeriod: "Periode",
|
|
350
|
+
analyticsDays: "{n} dage",
|
|
351
|
+
analyticsVisitors: "Bes\xF8gende",
|
|
352
|
+
analyticsPageviews: "Sidevisninger",
|
|
353
|
+
analyticsVsPrev: "{pct} % mod forrige periode",
|
|
354
|
+
analyticsNoPrev: "Ingen sammenligning",
|
|
355
|
+
analyticsOverTime: "Sidevisninger pr. dag",
|
|
356
|
+
analyticsTopPages: "Mest bes\xF8gte sider",
|
|
357
|
+
analyticsDay: "Dag",
|
|
358
|
+
analyticsPage: "Side",
|
|
359
|
+
analyticsEmpty: "Ingen bes\xF8g i perioden.",
|
|
360
|
+
analyticsLoading: "Henter tal\u2026",
|
|
361
|
+
analyticsUnconfigured: "Analytics er ikke sat op for denne app.",
|
|
362
|
+
analyticsUnavailable: "Upmetrics svarer ikke lige nu. Pr\xF8v igen om lidt.",
|
|
363
|
+
tenantSwitch: "Skift organisation",
|
|
364
|
+
tenantLoadFailed: "Kunne ikke hente dine organisationer.",
|
|
365
|
+
tenantSwitchFailed: "Kunne ikke skifte organisation. Du er stadig i {name}.",
|
|
366
|
+
tenantRetry: "Pr\xF8v igen",
|
|
367
|
+
tenantSuspended: "lukket",
|
|
368
|
+
tenantActive: "aktiv"
|
|
275
369
|
},
|
|
276
370
|
en: {
|
|
277
371
|
openMenu: "Open menu",
|
|
@@ -319,7 +413,27 @@ var TEXT = {
|
|
|
319
413
|
pictureRemoved: "Picture removed",
|
|
320
414
|
pictureTooLarge: "The picture is too large \u2014 2 MB at most.",
|
|
321
415
|
pictureWrongType: "Choose a PNG, JPEG or WebP image.",
|
|
322
|
-
bidSecurity: "Security in Broberg ID"
|
|
416
|
+
bidSecurity: "Security in Broberg ID",
|
|
417
|
+
analyticsPeriod: "Period",
|
|
418
|
+
analyticsDays: "{n} days",
|
|
419
|
+
analyticsVisitors: "Visitors",
|
|
420
|
+
analyticsPageviews: "Page views",
|
|
421
|
+
analyticsVsPrev: "{pct}% vs previous period",
|
|
422
|
+
analyticsNoPrev: "No comparison",
|
|
423
|
+
analyticsOverTime: "Page views per day",
|
|
424
|
+
analyticsTopPages: "Most visited pages",
|
|
425
|
+
analyticsDay: "Day",
|
|
426
|
+
analyticsPage: "Page",
|
|
427
|
+
analyticsEmpty: "No visits in this period.",
|
|
428
|
+
analyticsLoading: "Loading figures\u2026",
|
|
429
|
+
analyticsUnconfigured: "Analytics is not set up for this app.",
|
|
430
|
+
analyticsUnavailable: "Upmetrics is not answering right now. Try again shortly.",
|
|
431
|
+
tenantSwitch: "Switch organisation",
|
|
432
|
+
tenantLoadFailed: "Could not load your organisations.",
|
|
433
|
+
tenantSwitchFailed: "Could not switch organisation. You are still in {name}.",
|
|
434
|
+
tenantRetry: "Try again",
|
|
435
|
+
tenantSuspended: "suspended",
|
|
436
|
+
tenantActive: "active"
|
|
323
437
|
}
|
|
324
438
|
};
|
|
325
439
|
var MOBILE_QUERY = "(max-width: 767px)";
|
|
@@ -1128,7 +1242,7 @@ function AccountPage({ lang, adapter, reauthHref, onProfileChange }) {
|
|
|
1128
1242
|
/* @__PURE__ */ jsx("button", { type: "button", class: "bas-account__btn is-quiet", onClick: () => setConfirming(false), "data-testid": "account-avatar-remove-cancel", children: t.cancel })
|
|
1129
1243
|
] }) : null
|
|
1130
1244
|
] }),
|
|
1131
|
-
/* @__PURE__ */ jsxs("form", { class: "bas-account__form", onSubmit: onSaveName, children: [
|
|
1245
|
+
/* @__PURE__ */ jsxs("form", { class: "bas-account__form", onSubmit: onSaveName, "data-testid": "account-name-form", children: [
|
|
1132
1246
|
/* @__PURE__ */ jsx("label", { class: "bas-account__label", for: "bas-account-name", children: t.name }),
|
|
1133
1247
|
/* @__PURE__ */ jsxs("div", { class: "bas-account__row", children: [
|
|
1134
1248
|
/* @__PURE__ */ jsx(
|
|
@@ -1155,7 +1269,177 @@ function AccountPage({ lang, adapter, reauthHref, onProfileChange }) {
|
|
|
1155
1269
|
] }) : null
|
|
1156
1270
|
] });
|
|
1157
1271
|
}
|
|
1272
|
+
function AnalyticsPage({ lang, adapter, periods = [7, 30, 90], initialDays }) {
|
|
1273
|
+
const t = TEXT[lang];
|
|
1274
|
+
const api = useMemo(() => adapter ?? createFetchAnalyticsAdapter(), [adapter]);
|
|
1275
|
+
const [days, setDays] = useState(initialDays ?? (periods.includes(30) ? 30 : periods[0]));
|
|
1276
|
+
const [load, setLoad] = useState({ state: "loading" });
|
|
1277
|
+
const locale = lang === "da" ? "da-DK" : "en-GB";
|
|
1278
|
+
const num = (n) => n.toLocaleString(locale);
|
|
1279
|
+
useEffect(() => {
|
|
1280
|
+
let live = true;
|
|
1281
|
+
setLoad({ state: "loading" });
|
|
1282
|
+
api.load(days).then(
|
|
1283
|
+
(data) => live && setLoad({ state: "ok", days, data }),
|
|
1284
|
+
(e) => live && setLoad({ state: "error", reason: analyticsErrorKind(e) })
|
|
1285
|
+
);
|
|
1286
|
+
return () => {
|
|
1287
|
+
live = false;
|
|
1288
|
+
};
|
|
1289
|
+
}, [api, days]);
|
|
1290
|
+
return /* @__PURE__ */ jsxs("section", { class: "bas-analytics", "data-testid": "analytics-page", "aria-busy": load.state === "loading", children: [
|
|
1291
|
+
/* @__PURE__ */ jsx("div", { class: "bas-analytics__periods", role: "group", "aria-label": t.analyticsPeriod, children: periods.map((d) => /* @__PURE__ */ jsx(
|
|
1292
|
+
"button",
|
|
1293
|
+
{
|
|
1294
|
+
type: "button",
|
|
1295
|
+
class: "bas-analytics__period" + (d === days ? " is-active" : ""),
|
|
1296
|
+
"aria-pressed": d === days,
|
|
1297
|
+
onClick: () => setDays(d),
|
|
1298
|
+
"data-testid": `analytics-period-${d}`,
|
|
1299
|
+
children: t.analyticsDays.replace("{n}", String(d))
|
|
1300
|
+
},
|
|
1301
|
+
d
|
|
1302
|
+
)) }),
|
|
1303
|
+
load.state === "loading" ? /* @__PURE__ */ jsx("p", { class: "bas-analytics__muted", "data-testid": "analytics-loading", children: t.analyticsLoading }) : null,
|
|
1304
|
+
load.state === "error" ? /* @__PURE__ */ jsx("p", { class: "bas-analytics__note", role: "alert", "data-testid": "analytics-error", "data-reason": load.reason, children: load.reason === "unconfigured" ? t.analyticsUnconfigured : t.analyticsUnavailable }) : null,
|
|
1305
|
+
load.state === "ok" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1306
|
+
/* @__PURE__ */ jsx("div", { class: "bas-analytics__tiles", children: ["visitors", "pageviews"].map((k) => {
|
|
1307
|
+
const c = changePct(load.data.totals[k], load.data.prev[k]);
|
|
1308
|
+
return /* @__PURE__ */ jsxs("div", { class: "bas-analytics__tile", "data-testid": `analytics-${k}`, children: [
|
|
1309
|
+
/* @__PURE__ */ jsx("div", { class: "bas-analytics__label", children: k === "visitors" ? t.analyticsVisitors : t.analyticsPageviews }),
|
|
1310
|
+
/* @__PURE__ */ jsx("div", { class: "bas-analytics__value", "data-testid": `analytics-${k}-value`, children: num(load.data.totals[k]) }),
|
|
1311
|
+
/* @__PURE__ */ jsx("div", { class: "bas-analytics__muted", "data-testid": `analytics-${k}-change`, children: c === null ? t.analyticsNoPrev : t.analyticsVsPrev.replace("{pct}", `${c > 0 ? "+" : ""}${c}`) })
|
|
1312
|
+
] }, k);
|
|
1313
|
+
}) }),
|
|
1314
|
+
/* @__PURE__ */ jsx(AnalyticsSeries, { data: fillDays(load.data.series, load.days), t, locale, num }),
|
|
1315
|
+
/* @__PURE__ */ jsxs("div", { class: "bas-analytics__card", "data-testid": "analytics-top-pages", children: [
|
|
1316
|
+
/* @__PURE__ */ jsx("h2", { class: "bas-analytics__h", children: t.analyticsTopPages }),
|
|
1317
|
+
load.data.topPages.length === 0 ? /* @__PURE__ */ jsx("p", { class: "bas-analytics__muted", "data-testid": "analytics-top-pages-empty", children: t.analyticsEmpty }) : /* @__PURE__ */ jsx("ol", { class: "bas-analytics__pages", children: load.data.topPages.map((p) => /* @__PURE__ */ jsxs("li", { class: "bas-analytics__page", children: [
|
|
1318
|
+
/* @__PURE__ */ jsx("span", { class: "bas-analytics__path", title: p.value, children: p.value }),
|
|
1319
|
+
/* @__PURE__ */ jsx("span", { class: "bas-analytics__count", children: num(p.count) })
|
|
1320
|
+
] }, p.value)) })
|
|
1321
|
+
] })
|
|
1322
|
+
] }) : null
|
|
1323
|
+
] });
|
|
1324
|
+
}
|
|
1325
|
+
function dayLabel(day, locale) {
|
|
1326
|
+
return (/* @__PURE__ */ new Date(`${day}T12:00:00Z`)).toLocaleDateString(locale, { day: "numeric", month: "short", timeZone: "UTC" });
|
|
1327
|
+
}
|
|
1328
|
+
function AnalyticsSeries({ data, t, locale, num }) {
|
|
1329
|
+
const max = Math.max(1, ...data.map((d) => d.pageviews));
|
|
1330
|
+
const empty = data.every((d) => d.pageviews === 0);
|
|
1331
|
+
return /* @__PURE__ */ jsxs("div", { class: "bas-analytics__card", "data-testid": "analytics-series", children: [
|
|
1332
|
+
/* @__PURE__ */ jsx("h2", { class: "bas-analytics__h", children: t.analyticsOverTime }),
|
|
1333
|
+
empty ? /* @__PURE__ */ jsx("p", { class: "bas-analytics__muted", "data-testid": "analytics-series-empty", children: t.analyticsEmpty }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1334
|
+
/* @__PURE__ */ jsx("div", { class: "bas-analytics__bars", "aria-hidden": "true", children: data.map((d) => /* @__PURE__ */ jsx("div", { class: "bas-analytics__col", title: `${dayLabel(d.day, locale)}: ${num(d.pageviews)}`, "data-day": d.day, children: /* @__PURE__ */ jsx("div", { class: "bas-analytics__bar", style: { height: d.pageviews === 0 ? "0" : `max(2px, ${d.pageviews / max * 100}%)` } }) }, d.day)) }),
|
|
1335
|
+
/* @__PURE__ */ jsxs("div", { class: "bas-analytics__axis", "aria-hidden": "true", children: [
|
|
1336
|
+
/* @__PURE__ */ jsx("span", { children: dayLabel(data[0].day, locale) }),
|
|
1337
|
+
/* @__PURE__ */ jsx("span", { children: dayLabel(data[data.length - 1].day, locale) })
|
|
1338
|
+
] }),
|
|
1339
|
+
/* @__PURE__ */ jsxs("table", { class: "bas-analytics__sr", "data-testid": "analytics-series-table", children: [
|
|
1340
|
+
/* @__PURE__ */ jsx("caption", { children: t.analyticsOverTime }),
|
|
1341
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1342
|
+
/* @__PURE__ */ jsx("th", { scope: "col", children: t.analyticsDay }),
|
|
1343
|
+
/* @__PURE__ */ jsx("th", { scope: "col", children: t.analyticsPageviews })
|
|
1344
|
+
] }) }),
|
|
1345
|
+
/* @__PURE__ */ jsx("tbody", { children: data.map((d) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
1346
|
+
/* @__PURE__ */ jsx("td", { children: dayLabel(d.day, locale) }),
|
|
1347
|
+
/* @__PURE__ */ jsx("td", { children: num(d.pageviews) })
|
|
1348
|
+
] }, d.day)) })
|
|
1349
|
+
] })
|
|
1350
|
+
] })
|
|
1351
|
+
] });
|
|
1352
|
+
}
|
|
1353
|
+
function TenantSwitcher({ lang, activeSlug, adapter, onSwitch }) {
|
|
1354
|
+
const t = TEXT[lang];
|
|
1355
|
+
const api = useMemo(() => adapter ?? createFetchTenantAdapter(), [adapter]);
|
|
1356
|
+
const [rows, setRows] = useState(null);
|
|
1357
|
+
const [loadFailed, setLoadFailed] = useState(false);
|
|
1358
|
+
const [open, setOpen] = useState(false);
|
|
1359
|
+
const [busy, setBusy] = useState(null);
|
|
1360
|
+
const [switchFailed, setSwitchFailed] = useState(false);
|
|
1361
|
+
const root = useRef(null);
|
|
1362
|
+
const load = () => {
|
|
1363
|
+
setLoadFailed(false);
|
|
1364
|
+
api.load().then(setRows, () => setLoadFailed(true));
|
|
1365
|
+
};
|
|
1366
|
+
useEffect(load, [api]);
|
|
1367
|
+
useEffect(() => {
|
|
1368
|
+
if (!open) return;
|
|
1369
|
+
const onDown = (e) => {
|
|
1370
|
+
if (root.current && !root.current.contains(e.target)) setOpen(false);
|
|
1371
|
+
};
|
|
1372
|
+
const onKey = (e) => e.key === "Escape" && setOpen(false);
|
|
1373
|
+
document.addEventListener("mousedown", onDown);
|
|
1374
|
+
document.addEventListener("keydown", onKey);
|
|
1375
|
+
return () => {
|
|
1376
|
+
document.removeEventListener("mousedown", onDown);
|
|
1377
|
+
document.removeEventListener("keydown", onKey);
|
|
1378
|
+
};
|
|
1379
|
+
}, [open]);
|
|
1380
|
+
const active = rows?.find((r) => r.tenant.slug === activeSlug);
|
|
1381
|
+
const label = active?.tenant.name ?? activeSlug;
|
|
1382
|
+
const pick = async (slug) => {
|
|
1383
|
+
if (slug === activeSlug || busy) return;
|
|
1384
|
+
setBusy(slug);
|
|
1385
|
+
setSwitchFailed(false);
|
|
1386
|
+
try {
|
|
1387
|
+
await onSwitch(slug);
|
|
1388
|
+
setOpen(false);
|
|
1389
|
+
} catch {
|
|
1390
|
+
setSwitchFailed(true);
|
|
1391
|
+
} finally {
|
|
1392
|
+
setBusy(null);
|
|
1393
|
+
}
|
|
1394
|
+
};
|
|
1395
|
+
if (rows && rows.length <= 1 && !loadFailed) {
|
|
1396
|
+
return /* @__PURE__ */ jsx("div", { class: "bas-tenant", "data-testid": "tenant-switcher", children: /* @__PURE__ */ jsx("span", { class: "bas-tenant__label", "data-testid": "tenant-switcher-label", children: label }) });
|
|
1397
|
+
}
|
|
1398
|
+
return /* @__PURE__ */ jsxs("div", { class: "bas-tenant", ref: root, "data-testid": "tenant-switcher", children: [
|
|
1399
|
+
/* @__PURE__ */ jsx(
|
|
1400
|
+
"button",
|
|
1401
|
+
{
|
|
1402
|
+
type: "button",
|
|
1403
|
+
class: "bas-tenant__btn" + (open ? " is-open" : ""),
|
|
1404
|
+
"aria-haspopup": "menu",
|
|
1405
|
+
"aria-expanded": open,
|
|
1406
|
+
"aria-label": t.tenantSwitch,
|
|
1407
|
+
onClick: () => setOpen((v) => !v),
|
|
1408
|
+
"data-testid": "tenant-switcher-button",
|
|
1409
|
+
children: /* @__PURE__ */ jsx("span", { class: "bas-tenant__label", "data-testid": "tenant-switcher-label", children: label })
|
|
1410
|
+
}
|
|
1411
|
+
),
|
|
1412
|
+
open ? /* @__PURE__ */ jsxs("div", { class: "bas-menu bas-tenant__menu", role: "menu", "data-testid": "tenant-switcher-menu", children: [
|
|
1413
|
+
loadFailed ? /* @__PURE__ */ jsxs("div", { class: "bas-tenant__note", role: "alert", "data-testid": "tenant-switcher-load-error", children: [
|
|
1414
|
+
/* @__PURE__ */ jsx("span", { children: t.tenantLoadFailed }),
|
|
1415
|
+
/* @__PURE__ */ jsx("button", { type: "button", class: "bas-mi", onClick: load, "data-testid": "tenant-switcher-retry", children: t.tenantRetry })
|
|
1416
|
+
] }) : null,
|
|
1417
|
+
switchFailed ? /* @__PURE__ */ jsx("p", { class: "bas-tenant__note is-error", role: "alert", "data-testid": "tenant-switcher-switch-error", children: t.tenantSwitchFailed.replace("{name}", label) }) : null,
|
|
1418
|
+
(rows ?? []).map((r) => {
|
|
1419
|
+
const isActive = r.tenant.slug === activeSlug;
|
|
1420
|
+
const suspended = r.tenant.status === "suspended";
|
|
1421
|
+
return /* @__PURE__ */ jsxs(
|
|
1422
|
+
"button",
|
|
1423
|
+
{
|
|
1424
|
+
type: "button",
|
|
1425
|
+
role: "menuitemradio",
|
|
1426
|
+
"aria-checked": isActive,
|
|
1427
|
+
class: "bas-mi bas-tenant__item" + (isActive ? " is-active" : ""),
|
|
1428
|
+
disabled: suspended || busy !== null,
|
|
1429
|
+
onClick: () => void pick(r.tenant.slug),
|
|
1430
|
+
"data-testid": `tenant-switcher-item-${r.tenant.slug}`,
|
|
1431
|
+
children: [
|
|
1432
|
+
/* @__PURE__ */ jsx("span", { class: "bas-tenant__name", children: r.tenant.name }),
|
|
1433
|
+
/* @__PURE__ */ jsx("span", { class: "bas-tenant__role", children: suspended ? t.tenantSuspended : isActive ? t.tenantActive : r.role })
|
|
1434
|
+
]
|
|
1435
|
+
},
|
|
1436
|
+
r.tenant.id
|
|
1437
|
+
);
|
|
1438
|
+
})
|
|
1439
|
+
] }) : null
|
|
1440
|
+
] });
|
|
1441
|
+
}
|
|
1158
1442
|
|
|
1159
|
-
export { AVATAR_MAX_BYTES, AVATAR_TYPES, AccountError, AccountPage, AppShell, Avatar, NotificationBell, PageHeader, PageTabs, Sidebar, TEXT, TopBar, UserMenu, accountErrorKind, activeNavLabel, badgeLabel, checkAvatarFile, createFetchAccountAdapter, createFetchNotificationSource, createMemoryNotificationSource, defaultReauthHref, initials, isActivePath, isExternal, readFlag, readSet, relativeTime, safeNavigate, useIsMobile, writeFlag, writeSet };
|
|
1443
|
+
export { AVATAR_MAX_BYTES, AVATAR_TYPES, AccountError, AccountPage, AnalyticsError, AnalyticsPage, AppShell, Avatar, NotificationBell, PageHeader, PageTabs, Sidebar, TEXT, TenantLoadError, TenantSwitcher, TopBar, UserMenu, accountErrorKind, activeNavLabel, analyticsErrorKind, badgeLabel, changePct, checkAvatarFile, copenhagenDay, createFetchAccountAdapter, createFetchAnalyticsAdapter, createFetchNotificationSource, createFetchTenantAdapter, createMemoryNotificationSource, defaultReauthHref, fillDays, initials, isActivePath, isExternal, readFlag, readSet, relativeTime, safeNavigate, useIsMobile, writeFlag, writeSet };
|
|
1160
1444
|
//# sourceMappingURL=preact.js.map
|
|
1161
1445
|
//# sourceMappingURL=preact.js.map
|