@seikika/astro-report 0.0.0-stage → 0.1.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.
- package/LICENSE +9 -0
- package/README.md +32 -2
- package/integration.d.mts +13 -0
- package/integration.mjs +44 -0
- package/package.json +57 -3
- package/src/ReportApp.vue +220 -0
- package/src/ReportContent.vue +13 -0
- package/src/ReportView.vue +88 -0
- package/src/layouts/DefaultLayout.astro +17 -0
- package/src/lib/bars.ts +290 -0
- package/src/lib/basis.ts +157 -0
- package/src/lib/campaigns.ts +410 -0
- package/src/lib/compare.ts +204 -0
- package/src/lib/dom.ts +43 -0
- package/src/lib/kinds.ts +84 -0
- package/src/lib/levels.ts +61 -0
- package/src/lib/rings.ts +244 -0
- package/src/lib/routes.ts +118 -0
- package/src/lib/rules.ts +143 -0
- package/src/lib/status.ts +150 -0
- package/src/lib/summary.ts +231 -0
- package/src/lib/text.ts +57 -0
- package/src/lib/tracks.ts +264 -0
- package/src/lib/words.ts +72 -0
- package/src/report-view.ts +37 -0
- package/src/report.astro +27 -0
- package/src/report.css +359 -0
- package/src/types.ts +141 -0
- package/src/views/campaigns.ts +265 -0
- package/src/views/catalog.ts +456 -0
- package/src/views/compare.ts +676 -0
- package/src/views/entity.ts +443 -0
- package/src/views/overview.ts +639 -0
- package/src/views/rule.ts +153 -0
- package/src/views/scorecards.ts +947 -0
- package/src/views/tracks.ts +294 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 The Seikika authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @seikika/astro-report
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An Astro integration for publishing the box's catalog and scorecard snapshots. It takes the `report.json` produced by `seikika report -o web --out <directory>`, renders the report in Vue, and shares the portal's presentation components. GitHub Pages and the Seikika CLI build the same Astro integration.
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
// astro.config.mjs
|
|
7
|
+
import { defineConfig } from 'astro/config';
|
|
8
|
+
import seikikaReport from '@seikika/astro-report';
|
|
9
|
+
|
|
10
|
+
export default defineConfig({
|
|
11
|
+
integrations: [
|
|
12
|
+
seikikaReport({
|
|
13
|
+
data: new URL('./generated/report.json', import.meta.url),
|
|
14
|
+
path: '/report',
|
|
15
|
+
}),
|
|
16
|
+
],
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Install the integration in an Astro project with Vue. The integration adds the Astro Vue renderer when the project has not already configured it. Use the optional `layout` URL to supply your own Astro document template with a `title` prop and a default slot. The package exports `@seikika/astro-report/default-layout.astro` for reuse. `aliases` can preserve existing report URLs, including links to an entity, scorecard, or rule.
|
|
21
|
+
|
|
22
|
+
Every reader can inspect a published snapshot. Use report data approved for the site's audience. A live Seikika portal shapes its reads using the viewer's authorization.
|
|
23
|
+
|
|
24
|
+
From the repository root:
|
|
25
|
+
|
|
26
|
+
- `pnpm build` refreshes the Rust-embedded Astro portal and offline report.
|
|
27
|
+
- `pnpm check` checks the shared components, hosted pages, report, and package catalog.
|
|
28
|
+
- `pnpm storybook` opens the shared component and page stories.
|
|
29
|
+
- `pnpm storybook:build` builds the static Storybook.
|
|
30
|
+
- `pnpm storybook:probe` checks all stories for runtime errors, mobile overflow, and serious accessibility violations across light and dark themes.
|
|
31
|
+
- `pnpm docs:build` includes the report and Storybook in the docs artifact.
|
|
32
|
+
|
|
33
|
+
Fixtures in `fixtures/` come from Seikika for Seikika, the OpenFGA portal, and the repository starter. Run `pnpm --filter @seikika/astro-report fixtures` to regenerate them with the pinned Seikika tooling.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AstroIntegration } from "astro";
|
|
2
|
+
|
|
3
|
+
interface SeikikaReportOptions {
|
|
4
|
+
/** File produced by seikika report -o web. Publish only data your readers may see. */
|
|
5
|
+
data: string | URL;
|
|
6
|
+
/** Defaults to /report. */
|
|
7
|
+
path?: string;
|
|
8
|
+
aliases?: string[];
|
|
9
|
+
/** An Astro document layout with a default slot. */
|
|
10
|
+
layout?: string | URL;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default function seikikaReport(options: SeikikaReportOptions): AstroIntegration;
|
package/integration.mjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { isAbsolute, resolve } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import vue from "@astrojs/vue";
|
|
4
|
+
|
|
5
|
+
const entry = fileURLToPath(new URL("./src/report.astro", import.meta.url));
|
|
6
|
+
const defaultLayout = fileURLToPath(new URL("./src/layouts/DefaultLayout.astro", import.meta.url));
|
|
7
|
+
const virtual = "virtual:seikika-report";
|
|
8
|
+
|
|
9
|
+
export default function seikikaReport({ data, path = "/report", aliases = [], layout } = {}) {
|
|
10
|
+
if (!data) throw new TypeError("seikikaReport requires a report JSON file");
|
|
11
|
+
const localPath = (file) => file instanceof URL ? fileURLToPath(file) : isAbsolute(file) ? file : resolve(file);
|
|
12
|
+
const dataFile = localPath(data);
|
|
13
|
+
const layoutFile = layout ? localPath(layout) : defaultLayout;
|
|
14
|
+
const routes = [...new Set([path, ...aliases])];
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
name: "@seikika/astro-report",
|
|
18
|
+
hooks: {
|
|
19
|
+
"astro:config:setup": ({ config, injectRoute, updateConfig }) => {
|
|
20
|
+
for (const pattern of routes) injectRoute({ pattern, entrypoint: entry });
|
|
21
|
+
const integrations = config.integrations.some(integration => integration.name === "@astrojs/vue") ? [] : [vue()];
|
|
22
|
+
updateConfig({
|
|
23
|
+
integrations,
|
|
24
|
+
vite: {
|
|
25
|
+
resolve: { alias: {
|
|
26
|
+
"@astrojs/vue/client.js": fileURLToPath(import.meta.resolve("@astrojs/vue/client.js")),
|
|
27
|
+
"@astrojs/vue/server.js": fileURLToPath(import.meta.resolve("@astrojs/vue/server.js")),
|
|
28
|
+
} },
|
|
29
|
+
plugins: [{
|
|
30
|
+
name: "seikika-report-options",
|
|
31
|
+
resolveId(id) { if (id === virtual) return "\0" + virtual; },
|
|
32
|
+
load(id) {
|
|
33
|
+
if (id !== "\0" + virtual) return;
|
|
34
|
+
this.addWatchFile(dataFile);
|
|
35
|
+
return "export { default as Layout } from " + JSON.stringify(layoutFile) +
|
|
36
|
+
"; export const dataFile = " + JSON.stringify(dataFile) + ";";
|
|
37
|
+
},
|
|
38
|
+
}],
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seikika/astro-report",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Astro integration for publishing Seikika catalog and scorecard snapshots.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/seikika/seikika.git",
|
|
13
|
+
"directory": "report-ui"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"integration.mjs",
|
|
20
|
+
"integration.d.mts",
|
|
21
|
+
"src"
|
|
22
|
+
],
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./integration.d.mts",
|
|
26
|
+
"default": "./integration.mjs"
|
|
27
|
+
},
|
|
28
|
+
"./page.astro": "./src/report.astro",
|
|
29
|
+
"./default-layout.astro": "./src/layouts/DefaultLayout.astro"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@astrojs/vue": "7.1.6",
|
|
33
|
+
"@seikika/ui": "^0.1.0"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"astro": "^7.0.0",
|
|
37
|
+
"vue": "^3.5.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@storybook/vue3-vite": "10.6.8",
|
|
41
|
+
"@vitejs/plugin-vue": "^6.0.0",
|
|
42
|
+
"astro": "7.4.13",
|
|
43
|
+
"axe-core": "4.14.1",
|
|
44
|
+
"playwright": "1.65.1",
|
|
45
|
+
"storybook": "10.6.8",
|
|
46
|
+
"typescript": "5.9.3",
|
|
47
|
+
"vite": "8.3.8",
|
|
48
|
+
"vue": "^3.5.0",
|
|
49
|
+
"vue-tsc": "^3.0.0"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"check": "vue-tsc --noEmit",
|
|
53
|
+
"build": "astro build && node scripts/embed.mjs",
|
|
54
|
+
"fixtures": "scripts/fixtures.sh",
|
|
55
|
+
"storybook": "storybook dev -p 6006 --no-open",
|
|
56
|
+
"build-storybook": "storybook build -o storybook-static --quiet",
|
|
57
|
+
"probe": "node scripts/probe.mjs storybook-static",
|
|
58
|
+
"smoke": "node scripts/smoke.mjs"
|
|
59
|
+
}
|
|
6
60
|
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from "vue";
|
|
3
|
+
import PageFrame from "@seikika/ui/components/PageFrame.vue";
|
|
4
|
+
import PageHeader from "@seikika/ui/components/PageHeader.vue";
|
|
5
|
+
import "@seikika/ui/theme.css";
|
|
6
|
+
import "./report.css";
|
|
7
|
+
import type { ReportData } from "./types";
|
|
8
|
+
import { boxLogo } from "./lib/bars";
|
|
9
|
+
import { aliasLevels } from "./lib/levels";
|
|
10
|
+
import { parseHash, trackByPath } from "./lib/routes";
|
|
11
|
+
import { registerIds } from "./lib/rings";
|
|
12
|
+
import { ruleTitles } from "./lib/rules";
|
|
13
|
+
import { campaignNamesSorted, summarize } from "./lib/summary";
|
|
14
|
+
import { tracksSorted } from "./lib/tracks";
|
|
15
|
+
import { fmt, plural } from "./lib/words";
|
|
16
|
+
import ReportContent from "./ReportContent.vue";
|
|
17
|
+
import ReportView from "./ReportView.vue";
|
|
18
|
+
|
|
19
|
+
const props = defineProps<{ data: ReportData; initialRoute?: string }>();
|
|
20
|
+
const hash = ref(props.initialRoute === undefined ? location.hash : "#" + props.initialRoute);
|
|
21
|
+
const content = ref<HTMLElement>();
|
|
22
|
+
const navigation = ref<HTMLElement>();
|
|
23
|
+
const tooltip = ref<HTMLElement>();
|
|
24
|
+
const tip = ref("");
|
|
25
|
+
const tipPosition = ref({ left: "", top: "" });
|
|
26
|
+
let tipTrigger: Element | undefined;
|
|
27
|
+
let tipTimer: ReturnType<typeof setTimeout> | undefined;
|
|
28
|
+
let scrollTimer: ReturnType<typeof setTimeout> | undefined;
|
|
29
|
+
let tabFocus = false;
|
|
30
|
+
let lastHash: string | undefined;
|
|
31
|
+
|
|
32
|
+
watch(() => props.data, data => {
|
|
33
|
+
aliasLevels(data);
|
|
34
|
+
ruleTitles(data);
|
|
35
|
+
registerIds(Object.values(data.catalog ?? {}).flat());
|
|
36
|
+
}, { immediate: true, flush: "sync" });
|
|
37
|
+
const summary = computed(() => summarize(props.data));
|
|
38
|
+
const route = computed(() => {
|
|
39
|
+
const value = parseHash(hash.value);
|
|
40
|
+
if (value.mode === "tracks" && value.name) value.name = trackByPath(props.data, value.name);
|
|
41
|
+
return value;
|
|
42
|
+
});
|
|
43
|
+
const active = computed(() => {
|
|
44
|
+
const current = route.value;
|
|
45
|
+
if (current.mode === "missing") return null;
|
|
46
|
+
if (current.bare && !props.data.scorecards[current.name ?? ""]) return null;
|
|
47
|
+
if (current.mode === "entity") return "catalog";
|
|
48
|
+
if (current.mode === "campaign") return "campaigns";
|
|
49
|
+
if (current.mode === "rule" || current.mode === "scorecard") return "scorecards";
|
|
50
|
+
return current.mode;
|
|
51
|
+
});
|
|
52
|
+
const comparisons = computed(() => Object.keys(props.data.comparisons ?? {}).length);
|
|
53
|
+
const levelCards = computed(() => summary.value.rows.filter(row => !row.compare).length);
|
|
54
|
+
const tabs = computed(() => {
|
|
55
|
+
const tracks = tracksSorted(props.data, summary.value).length;
|
|
56
|
+
const campaigns = campaignNamesSorted(props.data).length;
|
|
57
|
+
return [
|
|
58
|
+
{ id: "overview", label: "Overview" },
|
|
59
|
+
...(tracks ? [{ id: "tracks", label: "Tracks", count: tracks }] : []),
|
|
60
|
+
{ id: "catalog", label: "Catalog", count: summary.value.entityCount },
|
|
61
|
+
...(campaigns || active.value === "campaigns" ? [{ id: "campaigns", label: "Campaigns", count: campaigns }] : []),
|
|
62
|
+
{ id: "scorecards", label: "Scorecards", count: levelCards.value },
|
|
63
|
+
...(comparisons.value ? [{ id: "compare", label: "Compare", count: comparisons.value }] : []),
|
|
64
|
+
];
|
|
65
|
+
});
|
|
66
|
+
const columns = computed(() => tabs.value.length <= 3 ? tabs.value.length : tabs.value.length === 4 ? 2 : 3);
|
|
67
|
+
const portal = computed(() => props.data.portal || "Seikika report");
|
|
68
|
+
|
|
69
|
+
function rememberScroll() {
|
|
70
|
+
clearTimeout(scrollTimer);
|
|
71
|
+
if (props.initialRoute === undefined) history.replaceState({ ...history.state, y: scrollY }, "");
|
|
72
|
+
}
|
|
73
|
+
function hideTip() {
|
|
74
|
+
clearTimeout(tipTimer);
|
|
75
|
+
tipTrigger = undefined;
|
|
76
|
+
tip.value = "";
|
|
77
|
+
}
|
|
78
|
+
function onScroll() {
|
|
79
|
+
hideTip();
|
|
80
|
+
clearTimeout(scrollTimer);
|
|
81
|
+
scrollTimer = setTimeout(rememberScroll, 200);
|
|
82
|
+
}
|
|
83
|
+
function syncHash() {
|
|
84
|
+
clearTimeout(scrollTimer);
|
|
85
|
+
hideTip();
|
|
86
|
+
hash.value = location.hash;
|
|
87
|
+
}
|
|
88
|
+
function go(path: string) {
|
|
89
|
+
if (props.initialRoute === undefined) location.hash = path;
|
|
90
|
+
else {
|
|
91
|
+
history.replaceState(null, "", "#" + path);
|
|
92
|
+
syncHash();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function selectTab(event: MouseEvent, path: string) {
|
|
96
|
+
tabFocus = event.currentTarget === document.activeElement;
|
|
97
|
+
go(path);
|
|
98
|
+
}
|
|
99
|
+
function arrow(event: KeyboardEvent) {
|
|
100
|
+
const keys = ["ArrowLeft", "ArrowRight", "Home", "End"];
|
|
101
|
+
if (!keys.includes(event.key)) return;
|
|
102
|
+
const buttons = [...(navigation.value?.querySelectorAll<HTMLButtonElement>('[role="tab"]') ?? [])];
|
|
103
|
+
if (!buttons.length) return;
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
const index = buttons.findIndex(button => button === document.activeElement);
|
|
106
|
+
const change = index + (event.key === "ArrowLeft" ? -1 : 1);
|
|
107
|
+
const to = event.key === "Home" ? 0 : event.key === "End" ? buttons.length - 1 : (change + buttons.length) % buttons.length;
|
|
108
|
+
tabFocus = true;
|
|
109
|
+
go(tabs.value[to].id);
|
|
110
|
+
}
|
|
111
|
+
function scrollTabs() {
|
|
112
|
+
const nav = navigation.value;
|
|
113
|
+
if (!nav) return;
|
|
114
|
+
nav.classList.toggle("more", nav.scrollLeft + nav.clientWidth < nav.scrollWidth - 4);
|
|
115
|
+
nav.classList.toggle("less", nav.scrollLeft > 4);
|
|
116
|
+
}
|
|
117
|
+
async function ready() {
|
|
118
|
+
await nextTick();
|
|
119
|
+
const view = content.value;
|
|
120
|
+
if (!view) return;
|
|
121
|
+
const selected = navigation.value?.querySelector<HTMLElement>('[aria-selected="true"]');
|
|
122
|
+
const headings = view.querySelectorAll<HTMLElement>("h2");
|
|
123
|
+
const target = view.querySelector<HTMLElement>("[data-focus]");
|
|
124
|
+
const heading = target?.querySelector<HTMLElement>("h2") ?? ((route.value.name || route.value.kind) ? headings[1] : null) ?? headings[0];
|
|
125
|
+
if (props.initialRoute === undefined) document.title = heading && route.value.mode !== "overview" ? heading.textContent + " · " + portal.value : portal.value;
|
|
126
|
+
if (selected && navigation.value && navigation.value.scrollWidth > navigation.value.clientWidth) {
|
|
127
|
+
const nav = navigation.value;
|
|
128
|
+
nav.scrollLeft += selected.getBoundingClientRect().left - nav.getBoundingClientRect().left - (nav.clientWidth - selected.offsetWidth) / 2;
|
|
129
|
+
}
|
|
130
|
+
scrollTabs();
|
|
131
|
+
|
|
132
|
+
if (props.initialRoute === undefined && hash.value !== lastHash) {
|
|
133
|
+
const y = view.closest(".seikika-report")?.getBoundingClientRect().top ?? 0;
|
|
134
|
+
const top = Math.max(0, y + scrollY);
|
|
135
|
+
if (tabFocus) {
|
|
136
|
+
selected?.focus({ preventScroll: true });
|
|
137
|
+
scrollTo(0, top);
|
|
138
|
+
} else if (lastHash !== undefined && heading) {
|
|
139
|
+
const targetTop = target ? target.getBoundingClientRect().top + scrollY : top;
|
|
140
|
+
scrollTo(0, targetTop - top < innerHeight * .6 ? top : targetTop - 8);
|
|
141
|
+
heading.tabIndex = -1;
|
|
142
|
+
heading.focus({ preventScroll: true });
|
|
143
|
+
}
|
|
144
|
+
if (lastHash !== undefined && typeof history.state?.y === "number") scrollTo(0, history.state.y);
|
|
145
|
+
}
|
|
146
|
+
tabFocus = false;
|
|
147
|
+
lastHash = hash.value;
|
|
148
|
+
}
|
|
149
|
+
async function showTip(event: Event) {
|
|
150
|
+
const trigger = (event.target as Element | null)?.closest<HTMLElement>(".basis[data-tip],abbr.gloss,a.rl[data-tip]");
|
|
151
|
+
if (!trigger?.dataset.tip) return;
|
|
152
|
+
clearTimeout(tipTimer);
|
|
153
|
+
tipTrigger = trigger;
|
|
154
|
+
tip.value = trigger.dataset.tip;
|
|
155
|
+
await nextTick();
|
|
156
|
+
if (!tooltip.value || tipTrigger !== trigger) return;
|
|
157
|
+
const box = trigger.getBoundingClientRect();
|
|
158
|
+
const { offsetWidth, offsetHeight } = tooltip.value;
|
|
159
|
+
tipPosition.value = {
|
|
160
|
+
left: Math.max(12, Math.min(box.left, document.documentElement.clientWidth - 12 - offsetWidth)) + "px",
|
|
161
|
+
top: Math.max(8, box.bottom + offsetHeight + 4 > innerHeight ? box.top - 4 - offsetHeight : box.bottom + 4) + "px",
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function deferHide(event: Event) {
|
|
165
|
+
if (tipTrigger?.contains(event.target as Node) || event.target === tooltip.value) {
|
|
166
|
+
if (event.type === "focusout") hideTip();
|
|
167
|
+
else if (tipTrigger !== document.activeElement) tipTimer = setTimeout(hideTip, 200);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function keepTip() {
|
|
171
|
+
clearTimeout(tipTimer);
|
|
172
|
+
}
|
|
173
|
+
function escapeTip(event: KeyboardEvent) {
|
|
174
|
+
if (event.key === "Escape") hideTip();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
onMounted(() => {
|
|
178
|
+
if (props.initialRoute !== undefined) history.replaceState(null, "", "#" + props.initialRoute);
|
|
179
|
+
window.addEventListener("hashchange", syncHash);
|
|
180
|
+
window.addEventListener("click", rememberScroll, true);
|
|
181
|
+
window.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
|
182
|
+
window.addEventListener("keydown", escapeTip);
|
|
183
|
+
});
|
|
184
|
+
onUnmounted(() => {
|
|
185
|
+
clearTimeout(scrollTimer);
|
|
186
|
+
clearTimeout(tipTimer);
|
|
187
|
+
window.removeEventListener("hashchange", syncHash);
|
|
188
|
+
window.removeEventListener("click", rememberScroll, true);
|
|
189
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
190
|
+
window.removeEventListener("keydown", escapeTip);
|
|
191
|
+
});
|
|
192
|
+
</script>
|
|
193
|
+
|
|
194
|
+
<template>
|
|
195
|
+
<PageFrame class="seikika-report" @mouseover="showTip" @mouseout="deferHide" @focusin="showTip" @focusout="deferHide">
|
|
196
|
+
<button type="button" class="skip" @click="content?.focus()">Skip to content</button>
|
|
197
|
+
<PageHeader :title="portal">
|
|
198
|
+
<template #title><span class="top"><ReportContent as="span" :build="boxLogo" />{{ portal }}</span></template>
|
|
199
|
+
<template #meta>
|
|
200
|
+
<div class="meta">
|
|
201
|
+
{{ plural(summary.entityCount, "entity", "entities") }} tracked ({{ fmt(Object.keys(summary.worst).length) }} scored) ·
|
|
202
|
+
{{ plural(levelCards, "scorecard") }}
|
|
203
|
+
<template v-if="comparisons"> · {{ plural(comparisons, "comparison factor") }}</template>
|
|
204
|
+
{{ data.snapshot ? " · data from snapshot #" + data.snapshot : " · no data collected yet" }}
|
|
205
|
+
</div>
|
|
206
|
+
</template>
|
|
207
|
+
</PageHeader>
|
|
208
|
+
<div ref="navigation" class="modes" role="tablist" aria-label="Report views" :style="{ '--tabcols': columns }" @keydown="arrow" @scroll="scrollTabs">
|
|
209
|
+
<button v-for="tab in tabs" :id="'tab-' + tab.id" :key="tab.id" type="button" role="tab"
|
|
210
|
+
:aria-selected="active === tab.id" aria-controls="report-body"
|
|
211
|
+
:tabindex="active === tab.id || (!active && tab.id === 'overview') ? 0 : -1" @click="selectTab($event, tab.id)">
|
|
212
|
+
{{ tab.label }}<span v-if="tab.count != null" class="count">{{ fmt(tab.count) }}</span>
|
|
213
|
+
</button>
|
|
214
|
+
</div>
|
|
215
|
+
<div id="report-body" ref="content" tabindex="-1" :role="active ? 'tabpanel' : undefined" :aria-labelledby="active ? 'tab-' + active : undefined">
|
|
216
|
+
<ReportView :data="data" :summary="summary" :route="route" @ready="ready" />
|
|
217
|
+
</div>
|
|
218
|
+
<div ref="tooltip" class="ftip" :hidden="!tip" aria-hidden="true" :style="tipPosition" @mouseenter="keepTip">{{ tip }}</div>
|
|
219
|
+
</PageFrame>
|
|
220
|
+
</template>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, watchPostEffect } from "vue";
|
|
3
|
+
|
|
4
|
+
const props = defineProps<{ build: () => Node | Node[] | null; as?: "div" | "span" | "section" }>();
|
|
5
|
+
const element = ref<HTMLElement>();
|
|
6
|
+
watchPostEffect(() => {
|
|
7
|
+
if (!element.value) return;
|
|
8
|
+
const content = props.build();
|
|
9
|
+
element.value.replaceChildren(...(content ? [content].flat() : []));
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template><component :is="as ?? 'div'" ref="element"></component></template>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, shallowRef, watchPostEffect } from "vue";
|
|
3
|
+
import EntityPage from "@seikika/ui/components/EntityPage.vue";
|
|
4
|
+
import ScorecardPage from "@seikika/ui/components/ScorecardPage.vue";
|
|
5
|
+
import { entityOverview } from "@seikika/ui/entity";
|
|
6
|
+
import type { ReportData } from "./types";
|
|
7
|
+
import { kindTitle } from "./lib/kinds";
|
|
8
|
+
import { plural } from "./lib/words";
|
|
9
|
+
import { shortId, title } from "./lib/rings";
|
|
10
|
+
import type { Route } from "./lib/routes";
|
|
11
|
+
import type { Summary } from "./lib/summary";
|
|
12
|
+
import { buildView } from "./report-view";
|
|
13
|
+
import ReportContent from "./ReportContent.vue";
|
|
14
|
+
|
|
15
|
+
const props = defineProps<{ data: ReportData; summary: Summary; route: Route }>();
|
|
16
|
+
const emit = defineEmits<{ ready: [] }>();
|
|
17
|
+
|
|
18
|
+
const entity = computed(() => {
|
|
19
|
+
const id = props.route.id;
|
|
20
|
+
if (props.route.mode !== "entity" || !id || !props.summary.kindOf[id]) return null;
|
|
21
|
+
const overview = entityOverview(id, props.summary.kindOf[id], props.data.entityOverview?.[id]);
|
|
22
|
+
return overview.title === id ? { ...overview, title: shortId(id) } : overview;
|
|
23
|
+
});
|
|
24
|
+
const cardName = computed(() => {
|
|
25
|
+
const name = props.route.name;
|
|
26
|
+
return props.route.mode === "scorecard" && name && props.data.scorecards[name] ? name : null;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const body = shallowRef<Node | Node[]>();
|
|
30
|
+
const headerActions = shallowRef<Node>();
|
|
31
|
+
const breadcrumbs = shallowRef<Node>();
|
|
32
|
+
const sidebar = shallowRef<Node[]>();
|
|
33
|
+
const beforeScorecard = shallowRef<Node[]>();
|
|
34
|
+
const detailClass = shallowRef("");
|
|
35
|
+
|
|
36
|
+
watchPostEffect(() => {
|
|
37
|
+
const content = buildView(props.data, props.summary, props.route);
|
|
38
|
+
sidebar.value = undefined;
|
|
39
|
+
if (entity.value) {
|
|
40
|
+
const heading = content.querySelector(":scope > .ehead");
|
|
41
|
+
headerActions.value = heading?.querySelector(":scope > .elevel") ?? undefined;
|
|
42
|
+
breadcrumbs.value = content.querySelector(":scope > .crumb") ?? undefined;
|
|
43
|
+
breadcrumbs.value?.parentNode?.removeChild(breadcrumbs.value);
|
|
44
|
+
heading?.remove();
|
|
45
|
+
} else if (cardName.value && content.matches(".split")) {
|
|
46
|
+
const [nav, detail] = content.children;
|
|
47
|
+
sidebar.value = [...nav.childNodes];
|
|
48
|
+
beforeScorecard.value = [...detail.querySelectorAll(":scope > .crumb, :scope > .picker")];
|
|
49
|
+
for (const item of beforeScorecard.value) item.parentNode?.removeChild(item);
|
|
50
|
+
detail.querySelector(":scope > .head")?.remove();
|
|
51
|
+
detailClass.value = detail.className;
|
|
52
|
+
body.value = [...detail.childNodes];
|
|
53
|
+
emit("ready");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
body.value = content;
|
|
57
|
+
emit("ready");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const scoreCount = computed(() => {
|
|
61
|
+
const id = entity.value?.id;
|
|
62
|
+
return id ? Object.values(props.data.scores).filter(scores => scores[id]).length : 0;
|
|
63
|
+
});
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<template>
|
|
67
|
+
<EntityPage v-if="entity" :entity="entity" heading="h2" class="view report-entity"
|
|
68
|
+
:owner-href="entity.owner && summary.kindOf[entity.owner] ? '#entity/' + encodeURIComponent(entity.owner) : undefined">
|
|
69
|
+
<template #breadcrumbs><ReportContent v-if="breadcrumbs" :build="() => breadcrumbs ?? null" /></template>
|
|
70
|
+
<template #meta>
|
|
71
|
+
<code v-if="entity.id !== entity.title">{{ entity.id }}</code>
|
|
72
|
+
<div class="sub">{{ kindTitle(data, entity.kind) }} · {{ plural(scoreCount, "scorecard") }}</div>
|
|
73
|
+
</template>
|
|
74
|
+
<template #header-actions><ReportContent v-if="headerActions" :build="() => headerActions ?? null" /></template>
|
|
75
|
+
<ReportContent :build="() => body ?? null" />
|
|
76
|
+
</EntityPage>
|
|
77
|
+
<div v-else-if="cardName && sidebar" class="view split">
|
|
78
|
+
<ReportContent as="section" :build="() => sidebar ?? null" />
|
|
79
|
+
<section :class="detailClass">
|
|
80
|
+
<ReportContent :build="() => beforeScorecard ?? null" />
|
|
81
|
+
<ScorecardPage :title="title(data, cardName)" heading="h2">
|
|
82
|
+
<template #header-actions><code class="sub">{{ cardName }}</code></template>
|
|
83
|
+
<ReportContent :build="() => body ?? null" />
|
|
84
|
+
</ScorecardPage>
|
|
85
|
+
</section>
|
|
86
|
+
</div>
|
|
87
|
+
<ReportContent v-else class="view" :build="() => body ?? null" />
|
|
88
|
+
</template>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
const { title = "Seikika report" } = Astro.props;
|
|
3
|
+
---
|
|
4
|
+
<!doctype html>
|
|
5
|
+
<html lang="en">
|
|
6
|
+
<head>
|
|
7
|
+
<meta charset="utf-8" />
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
9
|
+
<title>{title}</title>
|
|
10
|
+
</head>
|
|
11
|
+
<body class="seikika-ui">
|
|
12
|
+
<slot />
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
15
|
+
<style is:global>
|
|
16
|
+
body.seikika-ui { margin: 0; }
|
|
17
|
+
</style>
|