@loadmap/react 0.2.0 → 0.3.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 +3 -1
- package/dist/index.d.ts +14 -5
- package/dist/index.js +170 -36
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -71,6 +71,8 @@ each limit into a range. Add `scenarios` to compare designs, `growth` to turn mu
|
|
|
71
71
|
a test when headroom is lost. The layout runs in a Web Worker; nothing loads it before the first diagram.
|
|
72
72
|
|
|
73
73
|
`useLoadmap` with `LoadmapRoot`, `Diagram`, `Verdict`, `Limits`, `Controls` and the others builds a page of your own
|
|
74
|
-
layout from the same pieces.
|
|
74
|
+
layout from the same pieces. The diagram's Full screen takes the whole root: inside a `<div className="lm-side">`
|
|
75
|
+
after the `Diagram`, your pieces become the panel beside it; a title, the `Scenarios` and the `Story` stay above
|
|
76
|
+
the diagram, and the rest waits outside.
|
|
75
77
|
|
|
76
78
|
Docs, live examples and the editor: https://jaim3r0jas.github.io/loadmap/ · MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -105,10 +105,15 @@ interface LoadmapController<P = any> {
|
|
|
105
105
|
/** The state behind a loadmap: values, the model's evaluation, the layout and the engine. */
|
|
106
106
|
export declare function useLoadmap<P>(model: Model<P>, view: View$1, o?: LoadmapOptions<P>): LoadmapController<P>;
|
|
107
107
|
/** The architecture: SVG for the structure, a canvas on top for the dots. Expands to full screen. */
|
|
108
|
-
|
|
108
|
+
interface DiagramProps {
|
|
109
109
|
lm: LoadmapController;
|
|
110
110
|
legend?: boolean;
|
|
111
|
-
|
|
111
|
+
/** A click (or Enter) on a box, by its id. Every box is a button then, one without a component too. */
|
|
112
|
+
onNodeClick?: (id: string) => void;
|
|
113
|
+
/** The box drawn as selected, by its id. */
|
|
114
|
+
selected?: string | null;
|
|
115
|
+
}
|
|
116
|
+
export declare function Diagram({ lm, legend, onNodeClick, selected }: DiagramProps): import("react").JSX.Element;
|
|
112
117
|
type Theme = 'auto' | 'light' | 'dark';
|
|
113
118
|
/** What a page (or `@loadmap/export`) can drive from outside. */
|
|
114
119
|
interface LoadmapHandle {
|
|
@@ -152,10 +157,14 @@ interface LoadmapProps<P> extends LoadmapOptions<P> {
|
|
|
152
157
|
headroom?: boolean;
|
|
153
158
|
/** The scenarios side by side, when the model declares two or more. Default true. */
|
|
154
159
|
compare?: boolean;
|
|
160
|
+
/** A click (or Enter) on a box of the diagram, by its id: every box is a button then. */
|
|
161
|
+
onNodeClick?: (id: string) => void;
|
|
162
|
+
/** The box drawn as selected, by its id. */
|
|
163
|
+
selected?: string | null;
|
|
155
164
|
ref?: Ref<LoadmapHandle>;
|
|
156
165
|
}
|
|
157
166
|
/** The whole page piece: scenarios, diagram, verdict, headroom, live meters, limits, controls and assumptions. */
|
|
158
|
-
export declare function Loadmap<P>({ model, view, theme, title, assumptions, headroom, compare, ref, ...o }: LoadmapProps<P>): import("react").JSX.Element;
|
|
167
|
+
export declare function Loadmap<P>({ model, view, theme, title, assumptions, headroom, compare, onNodeClick, selected, ref, ...o }: LoadmapProps<P>): import("react").JSX.Element;
|
|
159
168
|
export declare function handleOf(lm: LoadmapController): LoadmapHandle;
|
|
160
169
|
/** The model's one-sentence answer for the current values, and which capacity to measure when it is unsure. */
|
|
161
170
|
export declare function Verdict({ lm }: {
|
|
@@ -214,7 +223,7 @@ export declare function Story({ lm }: {
|
|
|
214
223
|
lm: LoadmapController;
|
|
215
224
|
}): import("react").JSX.Element | null;
|
|
216
225
|
/** Theme tokens and the layout of every piece. Scoped to `.lm`; override any `--lm-*` token to restyle. */
|
|
217
|
-
export declare const LOADMAP_CSS = "\n.lm { \n --lm-bg: #eef2f5; --lm-surface: #ffffff; --lm-fg: #17212b; --lm-muted: #5d6d7c; --lm-line: #c6d0da;\n --lm-accent: #0b6b8f; --lm-accent-soft: #d6e9f0; --lm-alt: #7a4f9a; --lm-alt-soft: #efe5f6;\n --lm-ok: #2a7f5a; --lm-warn: #b86e00; --lm-drop: #b7392e; --lm-lane: #e3e9ee;\n --lm-s1: #2a78d6; --lm-s2: #eb6834; --lm-s3: #6250d6; --lm-s4: #eda100; color-scheme: light;\n --lm-font: ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --lm-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font: 14px/1.45 var(--lm-font); color: var(--lm-fg); background: var(--lm-bg);\n display: grid; gap: 14px; padding: 16px; min-width: 0; box-sizing: border-box; }\n@media (prefers-color-scheme: dark) { .lm:not([data-theme=\"light\"]) { \n --lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;\n --lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;\n --lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;\n --lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark; } }\n.lm[data-theme=\"dark\"] { \n --lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;\n --lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;\n --lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;\n --lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark; }\n.lm *, .lm *::before, .lm *::after { box-sizing: border-box; }\n.lm h2 { font-size: 1.3rem; font-weight: 600; margin: 0; text-wrap: balance; }\n.lm h3 { font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin: 0; }\n.lm button:focus-visible, .lm input:focus-visible, .lm select:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }\n.lm-card { background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }\n\n.lm-wrap { display: grid; gap: 8px; min-width: 0; position: relative; }\n.lm-wrap:fullscreen { background: var(--lm-bg); padding: 16px; align-content: center; overflow: auto; }\n.lm-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }\n.lm-btn { font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }\n.lm-board { position: relative; background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; overflow: hidden; margin: 0 auto; width: 100%; }\n.lm-wrap:fullscreen .lm-board { width: auto; max-width: 100%; max-height: calc(100vh - 90px); }\n.lm-board svg { display: block; width: 100%; height: auto; font-family: var(--lm-font); }\n.lm-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }\n.lm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--lm-muted); }\n.lm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 5px; }\n\n.lm-verdict { margin: 0; padding: 10px 14px; border-left: 4px solid var(--lm-ok); background: var(--lm-accent-soft); border-radius: 0 6px 6px 0; }\n.lm-verdict[data-tier=\"warn\"] { border-color: var(--lm-warn); }\n.lm-verdict[data-tier=\"over\"] { border-color: var(--lm-drop); }\n.lm-measure { margin: 6px 0 0; padding: 0 14px; font-size: .86rem; color: var(--lm-muted); }\n\n.lm-strip { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 14px; align-items: start; }\n@container (max-width: 860px) { .lm-strip { grid-template-columns: minmax(0, 1fr); } }\n.lm { container-type: inline-size; }\n\n.lm-meters { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }\n.lm-meter { padding: 8px 10px; border-radius: 6px; background: var(--lm-bg); min-width: 0; }\n.lm-meter b { display: block; font: 500 1.15rem var(--lm-mono); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.lm-meter span { font-size: .74rem; color: var(--lm-muted); }\n.lm-meter[data-state=\"warn\"] b { color: var(--lm-warn); } .lm-meter[data-state=\"over\"] b { color: var(--lm-drop); }\n\n.lm-limits { display: grid; gap: 10px; }\n.lm-lim, .lm-scale { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) 10rem; gap: 4px 14px; align-items: center; }\n@container (max-width: 640px) { .lm-lim, .lm-scale { grid-template-columns: minmax(0, 1fr); } .lm-scale > :first-child, .lm-scale > :last-child { display: none; } }\n.lm-lim b { display: block; font-weight: 600; font-size: .88rem; }\n.lm-lim .lm-sub { display: block; font-size: .74rem; color: var(--lm-muted); }\n.lm-tag { font: 600 .64rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; border-radius: 3px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px; }\n.lm-tag[data-kind=\"first\"] { color: var(--lm-surface); background: var(--lm-drop); }\n.lm-tag[data-kind=\"estimated\"] { color: var(--lm-warn); border: 1px solid currentColor; }\n.lm-tag[data-kind=\"range\"] { color: var(--lm-muted); border: 1px solid currentColor; }\n.lm-track { position: relative; height: 16px; background: var(--lm-bg); border-radius: 3px; overflow: hidden; }\n.lm-fill { position: absolute; inset: 0 auto 0 0; background: var(--lm-ok); transition: width .25s ease; }\n.lm-fill[data-state=\"warn\"] { background: var(--lm-warn); } .lm-fill[data-state=\"over\"] { background: var(--lm-drop); }\n.lm-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--lm-fg); opacity: .55; }\n.lm-val { font: 500 .8rem var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-val small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }\n.lm-scale { font: 400 .7rem var(--lm-mono); color: var(--lm-muted); }\n.lm-scale div { position: relative; height: 12px; }\n.lm-scale div span { position: absolute; transform: translateX(-50%); white-space: nowrap; }\n\n.lm-controls label.lm-range { display: grid; gap: 4px; font-size: .84rem; }\n.lm-controls label.lm-range > span { display: flex; justify-content: space-between; gap: 8px; }\n.lm-controls output { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-controls input[type=range] { width: 100%; accent-color: var(--lm-accent); }\n.lm-presets { display: flex; flex-wrap: wrap; gap: 6px; }\n.lm-presets button { font: 500 .76rem var(--lm-font); background: var(--lm-accent-soft); color: var(--lm-fg); border: 1px solid transparent; border-radius: 5px; padding: 5px 10px; cursor: pointer; }\n.lm-presets button[aria-pressed=\"true\"] { border-color: var(--lm-accent); }\n.lm-switch { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 8px; align-items: start; font-size: .84rem; cursor: pointer; }\n.lm-switch input { margin: 3px 0 0; accent-color: var(--lm-accent); }\n.lm-switch small, .lm-select small { grid-column: 2; color: var(--lm-muted); font-size: .74rem; line-height: 1.3; }\n.lm-select { display: grid; gap: 4px; font-size: .84rem; }\n.lm-select select { width: 100%; min-width: 0; font: 400 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 5px; padding: 5px 8px; }\n.lm-off { opacity: .45; cursor: default; }\n\n.lm-facts { margin: 0; padding-left: 1.1em; font-size: .88rem; columns: 2; column-gap: 28px; }\n@container (max-width: 860px) { .lm-facts { columns: 1; } }\n.lm-facts li { margin-bottom: 8px; break-inside: avoid; }\n.lm-prov { font: 600 .66rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; }\n.lm-prov[data-kind=\"measured\"] { color: var(--lm-ok); } .lm-prov[data-kind=\"estimated\"] { color: var(--lm-warn); }\n.lm-prov[data-kind=\"configured\"] { color: var(--lm-accent); }\n\n/* scenario identity colours (s1–s4) are checked for colour-blind separation on both surfaces; text never wears them */\n.lm-scenarios { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }\n.lm-scenarios legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin-right: 6px; padding: 0; }\n.lm-scenarios button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }\n.lm-scenarios button[aria-pressed=\"true\"] { border-color: var(--lm-fg); box-shadow: inset 0 0 0 1px var(--lm-fg); }\n.lm-scenarios i, .lm-table i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }\n.lm-story { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0; min-width: 0; padding: 8px 12px; border: 1px solid var(--lm-line); border-left: 3px solid var(--lm-accent); border-radius: 6px; background: var(--lm-surface); }\n.lm-story legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); padding: 0; }\n.lm-story p { flex: 1 1 240px; margin: 0; font: 400 .9rem/1.4 var(--lm-font); color: var(--lm-fg); }\n.lm-story b { font-weight: 600; color: var(--lm-muted); margin-right: 4px; white-space: nowrap; }\n.lm-story-nav { display: flex; gap: 6px; }\n.lm-story em { color: var(--lm-muted); }\n.lm-story button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }\n.lm-story button[aria-disabled=\"true\"] { opacity: .45; cursor: default; }\n.lm-own { font-size: .78rem; color: var(--lm-muted); }\n.lm-key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; vertical-align: 3px; margin-right: 6px; }\n\n.lm-compare-text { margin: 0; }\n.lm-table-wrap { overflow-x: auto; }\n.lm-table { border-collapse: collapse; width: 100%; font-size: .84rem; }\n.lm-table th, .lm-table td { text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--lm-line); vertical-align: top; }\n.lm-table thead th { font: 600 .7rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; color: var(--lm-muted); }\n.lm-table tbody th { font-weight: 600; white-space: nowrap; }\n.lm-table td { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-table td.lm-text { font-family: var(--lm-font); }\n.lm-table td small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }\n.lm-table tr[aria-current] th { text-decoration: underline; text-underline-offset: 3px; }\n\n.lm-chart { position: relative; min-width: 0; }\n.lm-chart svg { display: block; overflow: visible; }\n.lm-chart:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }\n.lm-axis, .lm-axis text { font: 400 11px var(--lm-mono); fill: var(--lm-muted); }\n.lm-mark { font: 600 11px var(--lm-mono); fill: var(--lm-fg); }\n.lm-tip { position: absolute; z-index: 2; display: grid; gap: 2px; width: max-content; max-width: 17rem; padding: 8px 10px; font-size: .78rem; background: var(--lm-surface); color: var(--lm-fg); border: 1px solid var(--lm-line); border-radius: 6px; box-shadow: 0 4px 14px rgb(0 0 0 / .14); pointer-events: none; }\n.lm-tip strong { font: 600 .82rem var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-tip .lm-sub { color: var(--lm-muted); }\n.lm-nowrap { white-space: nowrap; }\n.lm-node { cursor: pointer; outline: none; }\n.lm-node:focus-visible > :first-child { stroke-width: 3; }\n\n@media (prefers-reduced-motion: reduce) { .lm-fill { transition: none; } }\n";
|
|
226
|
+
export declare const LOADMAP_CSS = "\n.lm { \n --lm-bg: #eef2f5; --lm-surface: #ffffff; --lm-fg: #17212b; --lm-muted: #5d6d7c; --lm-line: #c6d0da;\n --lm-accent: #0b6b8f; --lm-accent-soft: #d6e9f0; --lm-alt: #7a4f9a; --lm-alt-soft: #efe5f6;\n --lm-ok: #2a7f5a; --lm-warn: #b86e00; --lm-drop: #b7392e; --lm-lane: #e3e9ee;\n --lm-s1: #2a78d6; --lm-s2: #eb6834; --lm-s3: #6250d6; --lm-s4: #eda100; color-scheme: light;\n --lm-font: ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --lm-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font: 14px/1.45 var(--lm-font); color: var(--lm-fg); background: var(--lm-bg);\n display: grid; gap: 14px; padding: 16px; min-width: 0; box-sizing: border-box; }\n@media (prefers-color-scheme: dark) { .lm:not([data-theme=\"light\"]) { \n --lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;\n --lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;\n --lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;\n --lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark; } }\n.lm[data-theme=\"dark\"] { \n --lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;\n --lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;\n --lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;\n --lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark; }\n.lm *, .lm *::before, .lm *::after { box-sizing: border-box; }\n.lm h2 { font-size: 1.3rem; font-weight: 600; margin: 0; text-wrap: balance; }\n.lm h3 { font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin: 0; }\n.lm button:focus-visible, .lm input:focus-visible, .lm select:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }\n.lm-card { background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }\n\n.lm-wrap { display: grid; gap: 8px; min-width: 0; position: relative; }\n.lm-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }\n.lm-btn { font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }\n.lm-board { position: relative; background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; overflow: hidden; margin: 0 auto; width: 100%; }\n.lm-board svg { display: block; width: 100%; height: auto; font-family: var(--lm-font); }\n.lm-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }\n.lm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--lm-muted); }\n.lm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 5px; }\n\n/* full screen (the browser's, or a fixed overlay): the diagram as large as fits, beside a panel of the verdict, the\n live meters and the controls; the board's size comes from Diagram (--lm-fit), the load never changes it */\n.lm-side, .lm-ranked { display: contents; }\n.lm[data-full] { height: 100vh; height: 100dvh; padding: 16px; overflow: auto; overscroll-behavior: contain; align-content: start; }\n.lm[data-full=\"overlay\"] { position: fixed; inset: 0; z-index: 2147483000; width: auto; max-width: none; max-height: none; margin: 0; border: 0; }\n.lm[data-full]:has(> .lm-side) { overflow: hidden; grid-template-columns: minmax(0, 1fr) clamp(300px, 24vw, 400px); grid-template-rows: repeat(3, auto) minmax(0, 1fr); row-gap: 0; }\n.lm[data-full]:has(> .lm-side) > :is(h2, .lm-scenarios, .lm-story) { grid-column: 1; margin-bottom: 12px; }\n/* a page of its own keeps the rest outside full screen, as <Loadmap> does */\n.lm[data-full]:has(> .lm-side) > :not(h2, .lm-scenarios, .lm-story, .lm-wrap, .lm-side) { display: none; }\n.lm[data-full] .lm-wrap { height: calc(100dvh - 32px); grid-template-rows: auto auto; align-content: center; }\n.lm[data-full]:has(> .lm-side) > .lm-wrap { grid-column: 1; grid-row: 4; height: auto; min-height: 0; }\n/* left under the bar, so the legend starts where the board does */\n.lm[data-full] .lm-board { width: var(--lm-fit, 100%); margin: 0; align-self: start; justify-self: start; }\n.lm[data-full] > .lm-side { grid-column: 2; grid-row: 1 / -1; display: grid; gap: 14px; align-content: start; min-height: 0; overflow: auto; overscroll-behavior: contain; container-type: inline-size; }\n.lm[data-full] .lm-more { display: none; }\n@media (max-width: 760px) {\n .lm[data-full]:has(> .lm-side) { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(3, auto) minmax(0, 3fr) minmax(0, 2fr); }\n .lm[data-full] > .lm-side { grid-column: 1; grid-row: 5; margin-top: 12px; }\n .lm[data-full] > h2 { display: none; }\n /* a phone keeps the board as wide as the screen and scrolls it: fitted to the height it is too small to read */\n .lm[data-full]:has(> .lm-side) > .lm-wrap { overflow: auto; align-content: start; }\n .lm[data-full] .lm-board { width: 100%; }\n /* the controls first in the short panel: the diagram, the verdict and the meters answer them */\n .lm[data-full] .lm-side > .lm-strip:not(.lm-more) { display: contents; }\n .lm[data-full] .lm-side .lm-controls { order: -1; }\n}\n\n.lm-verdict { margin: 0; padding: 10px 14px; border-left: 4px solid var(--lm-ok); background: var(--lm-accent-soft); border-radius: 0 6px 6px 0; }\n.lm-verdict[data-tier=\"warn\"] { border-color: var(--lm-warn); }\n.lm-verdict[data-tier=\"over\"] { border-color: var(--lm-drop); }\n.lm-measure { margin: 6px 0 0; padding: 0 14px; font-size: .86rem; color: var(--lm-muted); }\n\n.lm-strip { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 14px; align-items: start; }\n@container (max-width: 860px) { .lm-strip { grid-template-columns: minmax(0, 1fr); } }\n.lm { container-type: inline-size; }\n\n.lm-meters { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }\n.lm-meter { padding: 8px 10px; border-radius: 6px; background: var(--lm-bg); min-width: 0; }\n.lm-meter b { display: block; font: 500 1.15rem var(--lm-mono); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.lm-meter span { font-size: .74rem; color: var(--lm-muted); }\n.lm-meter[data-state=\"warn\"] b { color: var(--lm-warn); } .lm-meter[data-state=\"over\"] b { color: var(--lm-drop); }\n\n.lm-limits { display: grid; gap: 10px; }\n.lm-lim, .lm-scale { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) 10rem; gap: 4px 14px; align-items: center; }\n@container (max-width: 640px) { .lm-lim, .lm-scale { grid-template-columns: minmax(0, 1fr); } .lm-scale > :first-child, .lm-scale > :last-child { display: none; } }\n.lm-lim b { display: block; font-weight: 600; font-size: .88rem; }\n.lm-lim .lm-sub { display: block; font-size: .74rem; color: var(--lm-muted); }\n.lm-tag { font: 600 .64rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; border-radius: 3px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px; }\n.lm-tag[data-kind=\"first\"] { color: var(--lm-surface); background: var(--lm-drop); }\n.lm-tag[data-kind=\"estimated\"] { color: var(--lm-warn); border: 1px solid currentColor; }\n.lm-tag[data-kind=\"range\"] { color: var(--lm-muted); border: 1px solid currentColor; }\n.lm-track { position: relative; height: 16px; background: var(--lm-bg); border-radius: 3px; overflow: hidden; }\n.lm-fill { position: absolute; inset: 0 auto 0 0; background: var(--lm-ok); transition: width .25s ease; }\n.lm-fill[data-state=\"warn\"] { background: var(--lm-warn); } .lm-fill[data-state=\"over\"] { background: var(--lm-drop); }\n.lm-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--lm-fg); opacity: .55; }\n.lm-val { font: 500 .8rem var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-val small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }\n.lm-scale { font: 400 .7rem var(--lm-mono); color: var(--lm-muted); }\n.lm-scale div { position: relative; height: 12px; }\n.lm-scale div span { position: absolute; transform: translateX(-50%); white-space: nowrap; }\n\n.lm-controls label.lm-range { display: grid; gap: 4px; font-size: .84rem; }\n.lm-controls label.lm-range > span { display: flex; justify-content: space-between; gap: 8px; }\n.lm-controls output { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-controls input[type=range] { width: 100%; accent-color: var(--lm-accent); }\n.lm-presets { display: flex; flex-wrap: wrap; gap: 6px; }\n.lm-presets button { font: 500 .76rem var(--lm-font); background: var(--lm-accent-soft); color: var(--lm-fg); border: 1px solid transparent; border-radius: 5px; padding: 5px 10px; cursor: pointer; }\n.lm-presets button[aria-pressed=\"true\"] { border-color: var(--lm-accent); }\n.lm-switch { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 8px; align-items: start; font-size: .84rem; cursor: pointer; }\n.lm-switch input { margin: 3px 0 0; accent-color: var(--lm-accent); }\n.lm-switch small, .lm-select small { grid-column: 2; color: var(--lm-muted); font-size: .74rem; line-height: 1.3; }\n.lm-select { display: grid; gap: 4px; font-size: .84rem; }\n.lm-select select { width: 100%; min-width: 0; font: 400 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 5px; padding: 5px 8px; }\n.lm-off { opacity: .45; cursor: default; }\n\n.lm-facts { margin: 0; padding-left: 1.1em; font-size: .88rem; columns: 2; column-gap: 28px; }\n@container (max-width: 860px) { .lm-facts { columns: 1; } }\n.lm-facts li { margin-bottom: 8px; break-inside: avoid; }\n.lm-prov { font: 600 .66rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; }\n.lm-prov[data-kind=\"measured\"] { color: var(--lm-ok); } .lm-prov[data-kind=\"estimated\"] { color: var(--lm-warn); }\n.lm-prov[data-kind=\"configured\"] { color: var(--lm-accent); }\n\n/* scenario identity colours (s1–s4) are checked for colour-blind separation on both surfaces; text never wears them */\n.lm-scenarios { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }\n.lm-scenarios legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin-right: 6px; padding: 0; }\n.lm-scenarios button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }\n.lm-scenarios button[aria-pressed=\"true\"] { border-color: var(--lm-fg); box-shadow: inset 0 0 0 1px var(--lm-fg); }\n.lm-scenarios i, .lm-table i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }\n.lm-story { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0; min-width: 0; padding: 8px 12px; border: 1px solid var(--lm-line); border-left: 3px solid var(--lm-accent); border-radius: 6px; background: var(--lm-surface); }\n.lm-story legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); padding: 0; }\n.lm-story p { flex: 1 1 240px; margin: 0; font: 400 .9rem/1.4 var(--lm-font); color: var(--lm-fg); }\n.lm-story b { font-weight: 600; color: var(--lm-muted); margin-right: 4px; white-space: nowrap; }\n.lm-story-nav { display: flex; gap: 6px; }\n.lm-story em { color: var(--lm-muted); }\n.lm-story button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }\n.lm-story button[aria-disabled=\"true\"] { opacity: .45; cursor: default; }\n.lm-own { font-size: .78rem; color: var(--lm-muted); }\n.lm-key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; vertical-align: 3px; margin-right: 6px; }\n\n.lm-compare-text { margin: 0; }\n.lm-table-wrap { overflow-x: auto; }\n.lm-table { border-collapse: collapse; width: 100%; font-size: .84rem; }\n.lm-table th, .lm-table td { text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--lm-line); vertical-align: top; }\n.lm-table thead th { font: 600 .7rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; color: var(--lm-muted); }\n.lm-table tbody th { font-weight: 600; white-space: nowrap; }\n.lm-table td { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-table td.lm-text { font-family: var(--lm-font); }\n.lm-table td small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }\n.lm-table tr[aria-current] th { text-decoration: underline; text-underline-offset: 3px; }\n\n.lm-chart { position: relative; min-width: 0; }\n.lm-chart svg { display: block; overflow: visible; }\n.lm-chart:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }\n.lm-axis, .lm-axis text { font: 400 11px var(--lm-mono); fill: var(--lm-muted); }\n.lm-mark { font: 600 11px var(--lm-mono); fill: var(--lm-fg); }\n.lm-tip { position: absolute; z-index: 2; display: grid; gap: 2px; width: max-content; max-width: 17rem; padding: 8px 10px; font-size: .78rem; background: var(--lm-surface); color: var(--lm-fg); border: 1px solid var(--lm-line); border-radius: 6px; box-shadow: 0 4px 14px rgb(0 0 0 / .14); pointer-events: none; }\n.lm-tip strong { font: 600 .82rem var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-tip .lm-sub { color: var(--lm-muted); }\n.lm-nowrap { white-space: nowrap; }\n.lm-node { cursor: pointer; outline: none; }\n.lm-node:focus-visible > :first-child { stroke-width: 3; }\n\n@media (prefers-reduced-motion: reduce) { .lm-fill { transition: none; } }\n";
|
|
218
227
|
/** Adds the stylesheet once per document. */
|
|
219
228
|
export declare function injectStyles(doc?: Document): void;
|
|
220
|
-
export { type AnyNodeDef, type ClusterDef, type Dot, type EdgeDef, type Engine, type FlowColor, type FlowView, type Label, type LoadmapController, type LoadmapHandle, type LoadmapOptions, type LoadmapProps, type NodeDef, type PoolDef, type Theme, type View, type ViewDef, cluster, compact, defineView, edge, fitLinear, fmt, multiple, node, pct, pool, secs };
|
|
229
|
+
export { type AnyNodeDef, type ClusterDef, type DiagramProps, type Dot, type EdgeDef, type Engine, type FlowColor, type FlowView, type Label, type LoadmapController, type LoadmapHandle, type LoadmapOptions, type LoadmapProps, type NodeDef, type PoolDef, type Theme, type View, type ViewDef, cluster, compact, defineView, edge, fitLinear, fmt, multiple, node, pct, pool, secs };
|
package/dist/index.js
CHANGED
|
@@ -536,14 +536,20 @@ const tokenColor = (c) => [
|
|
|
536
536
|
"drop",
|
|
537
537
|
"muted"
|
|
538
538
|
].includes(c) ? `var(--lm-${c})` : c;
|
|
539
|
-
|
|
540
|
-
function Diagram({ lm, legend = true }) {
|
|
539
|
+
function Diagram({ lm, legend = true, onNodeClick, selected = null }) {
|
|
541
540
|
const { scene, engine, reducedMotion } = lm;
|
|
541
|
+
const click = useRef(onNodeClick);
|
|
542
|
+
click.current = onNodeClick;
|
|
543
|
+
const [onClick] = useState(() => (id) => click.current?.(id));
|
|
542
544
|
const svgRef = useRef(null);
|
|
543
545
|
const canvasRef = useRef(null);
|
|
544
546
|
const wrapRef = useRef(null);
|
|
547
|
+
const barRef = useRef(null);
|
|
545
548
|
const boardRef = useRef(null);
|
|
546
|
-
const
|
|
549
|
+
const buttonRef = useRef(null);
|
|
550
|
+
const [screen, setScreen] = useState(false);
|
|
551
|
+
const [overlay, setOverlay] = useState(false);
|
|
552
|
+
const full = screen || overlay;
|
|
547
553
|
const [tip, setTip] = useState(null);
|
|
548
554
|
const detailId = useId();
|
|
549
555
|
useEffect(() => {
|
|
@@ -583,13 +589,66 @@ function Diagram({ lm, legend = true }) {
|
|
|
583
589
|
return () => cancelAnimationFrame(raf);
|
|
584
590
|
}, [engine, reducedMotion]);
|
|
585
591
|
useEffect(() => {
|
|
586
|
-
const
|
|
592
|
+
const el = lm.root ?? wrapRef.current;
|
|
593
|
+
const f = () => setScreen(!!el && document.fullscreenElement === el);
|
|
587
594
|
document.addEventListener("fullscreenchange", f);
|
|
588
595
|
return () => document.removeEventListener("fullscreenchange", f);
|
|
589
|
-
}, []);
|
|
596
|
+
}, [lm.root]);
|
|
597
|
+
useEffect(() => {
|
|
598
|
+
const el = lm.root ?? wrapRef.current;
|
|
599
|
+
if (!el || !full) return;
|
|
600
|
+
el.setAttribute("data-full", overlay ? "overlay" : "screen");
|
|
601
|
+
const top = overlay && typeof el.showPopover === "function";
|
|
602
|
+
if (top) {
|
|
603
|
+
el.popover = "manual";
|
|
604
|
+
el.showPopover();
|
|
605
|
+
}
|
|
606
|
+
return () => {
|
|
607
|
+
el.removeAttribute("data-full");
|
|
608
|
+
if (top) {
|
|
609
|
+
el.hidePopover();
|
|
610
|
+
el.removeAttribute("popover");
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
}, [
|
|
614
|
+
lm.root,
|
|
615
|
+
full,
|
|
616
|
+
overlay
|
|
617
|
+
]);
|
|
618
|
+
useEffect(() => {
|
|
619
|
+
if (!overlay) return;
|
|
620
|
+
const f = (e) => e.key === "Escape" && setOverlay(false);
|
|
621
|
+
document.addEventListener("keydown", f);
|
|
622
|
+
return () => document.removeEventListener("keydown", f);
|
|
623
|
+
}, [overlay]);
|
|
624
|
+
const was = useRef(false);
|
|
625
|
+
useEffect(() => {
|
|
626
|
+
if (was.current && !full) buttonRef.current?.focus();
|
|
627
|
+
was.current = full;
|
|
628
|
+
}, [full]);
|
|
629
|
+
useEffect(() => {
|
|
630
|
+
const wrap = wrapRef.current;
|
|
631
|
+
const bar = barRef.current;
|
|
632
|
+
if (!full || !scene || !wrap || !bar) return;
|
|
633
|
+
const fit = () => {
|
|
634
|
+
const h = wrap.clientHeight - bar.offsetHeight - Number.parseFloat(getComputedStyle(wrap).rowGap || "0");
|
|
635
|
+
const w = Math.min(wrap.clientWidth, h * scene.width / scene.height);
|
|
636
|
+
wrap.style.setProperty("--lm-fit", `${Math.max(0, Math.floor(w))}px`);
|
|
637
|
+
};
|
|
638
|
+
const ro = new ResizeObserver(fit);
|
|
639
|
+
ro.observe(wrap);
|
|
640
|
+
ro.observe(bar);
|
|
641
|
+
return () => {
|
|
642
|
+
ro.disconnect();
|
|
643
|
+
wrap.style.removeProperty("--lm-fit");
|
|
644
|
+
};
|
|
645
|
+
}, [full, scene]);
|
|
590
646
|
const toggle = () => {
|
|
591
|
-
|
|
592
|
-
|
|
647
|
+
const el = lm.root ?? wrapRef.current;
|
|
648
|
+
if (overlay) setOverlay(false);
|
|
649
|
+
else if (document.fullscreenElement) document.exitFullscreen().catch(() => {});
|
|
650
|
+
else if (el?.requestFullscreen) el.requestFullscreen().catch(() => setOverlay(true));
|
|
651
|
+
else setOverlay(true);
|
|
593
652
|
};
|
|
594
653
|
return /* @__PURE__ */ jsxs("div", {
|
|
595
654
|
className: "lm-wrap",
|
|
@@ -597,11 +656,13 @@ function Diagram({ lm, legend = true }) {
|
|
|
597
656
|
children: [
|
|
598
657
|
/* @__PURE__ */ jsxs("div", {
|
|
599
658
|
className: "lm-bar",
|
|
659
|
+
ref: barRef,
|
|
600
660
|
children: [legend ? /* @__PURE__ */ jsx(Legend, { lm }) : /* @__PURE__ */ jsx("span", {}), /* @__PURE__ */ jsx("button", {
|
|
601
661
|
type: "button",
|
|
602
662
|
className: "lm-btn",
|
|
603
663
|
onClick: toggle,
|
|
604
664
|
"aria-pressed": full,
|
|
665
|
+
ref: buttonRef,
|
|
605
666
|
children: full ? "✕ Close" : "⤢ Full screen"
|
|
606
667
|
})]
|
|
607
668
|
}),
|
|
@@ -614,7 +675,9 @@ function Diagram({ lm, legend = true }) {
|
|
|
614
675
|
scene,
|
|
615
676
|
svgRef,
|
|
616
677
|
rates: reducedMotion,
|
|
617
|
-
setTip
|
|
678
|
+
setTip,
|
|
679
|
+
onClick: onNodeClick ? onClick : void 0,
|
|
680
|
+
selected
|
|
618
681
|
}), /* @__PURE__ */ jsx("canvas", {
|
|
619
682
|
ref: canvasRef,
|
|
620
683
|
hidden: reducedMotion
|
|
@@ -649,7 +712,7 @@ function componentOf(lm, n) {
|
|
|
649
712
|
return n.stages.map((s) => lm.ev.stages[s]?.component).find(Boolean) ?? n.component ?? void 0;
|
|
650
713
|
}
|
|
651
714
|
/** The SVG. It does not read the detail's state, so a hover re-renders the detail, not every box and edge. */
|
|
652
|
-
const Structure = memo(function Structure({ lm, scene, svgRef, rates, setTip }) {
|
|
715
|
+
const Structure = memo(function Structure({ lm, scene, svgRef, rates, setTip, onClick, selected }) {
|
|
653
716
|
const marker = useId().replace(/:/g, "");
|
|
654
717
|
const { labels, ev } = lm;
|
|
655
718
|
const stateOf = (n) => {
|
|
@@ -659,13 +722,37 @@ const Structure = memo(function Structure({ lm, scene, svgRef, rates, setTip })
|
|
|
659
722
|
const handlers = (n) => {
|
|
660
723
|
const cid = componentOf(lm, n);
|
|
661
724
|
const c = cid ? ev.components[cid] : void 0;
|
|
662
|
-
if (!c) return {};
|
|
663
725
|
const title = labels.nodes[n.id]?.title;
|
|
726
|
+
if (!c) {
|
|
727
|
+
if (!onClick) return {};
|
|
728
|
+
return {
|
|
729
|
+
tabIndex: 0,
|
|
730
|
+
role: "button",
|
|
731
|
+
className: "lm-node",
|
|
732
|
+
"aria-label": title ?? n.id,
|
|
733
|
+
"aria-pressed": selected === n.id,
|
|
734
|
+
onClick: () => onClick(n.id),
|
|
735
|
+
onKeyDown: (e) => {
|
|
736
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
737
|
+
e.preventDefault();
|
|
738
|
+
onClick(n.id);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
const press = () => {
|
|
744
|
+
setTip((t) => t?.pinned && t.id === n.id ? null : {
|
|
745
|
+
id: n.id,
|
|
746
|
+
pinned: true
|
|
747
|
+
});
|
|
748
|
+
onClick?.(n.id);
|
|
749
|
+
};
|
|
664
750
|
return {
|
|
665
751
|
tabIndex: 0,
|
|
666
752
|
role: "button",
|
|
667
753
|
className: "lm-node",
|
|
668
754
|
"aria-label": `${title && title !== c.name ? `${title}, ` : ""}${c.name}: ${c.util == null ? "switched off" : pct$1(c.util)}`,
|
|
755
|
+
...onClick ? { "aria-pressed": selected === n.id } : {},
|
|
669
756
|
onPointerEnter: (e) => e.pointerType === "mouse" && setTip((t) => t?.pinned ? t : {
|
|
670
757
|
id: n.id,
|
|
671
758
|
pinned: false
|
|
@@ -676,18 +763,12 @@ const Structure = memo(function Structure({ lm, scene, svgRef, rates, setTip })
|
|
|
676
763
|
pinned: false
|
|
677
764
|
}),
|
|
678
765
|
onBlur: () => setTip((t) => t?.pinned ? t : null),
|
|
679
|
-
onClick:
|
|
680
|
-
id: n.id,
|
|
681
|
-
pinned: true
|
|
682
|
-
}),
|
|
766
|
+
onClick: press,
|
|
683
767
|
onKeyDown: (e) => {
|
|
684
768
|
if (e.key === "Escape") setTip(null);
|
|
685
769
|
if (e.key === "Enter" || e.key === " ") {
|
|
686
770
|
e.preventDefault();
|
|
687
|
-
|
|
688
|
-
id: n.id,
|
|
689
|
-
pinned: true
|
|
690
|
-
});
|
|
771
|
+
press();
|
|
691
772
|
}
|
|
692
773
|
}
|
|
693
774
|
};
|
|
@@ -728,6 +809,7 @@ const Structure = memo(function Structure({ lm, scene, svgRef, rates, setTip })
|
|
|
728
809
|
sub: labels.nodes[n.id]?.sub,
|
|
729
810
|
lm,
|
|
730
811
|
focused: !!lm.focus && componentOf(lm, n) === lm.focus,
|
|
812
|
+
selected: selected === n.id,
|
|
731
813
|
handlers: handlers(n)
|
|
732
814
|
}, n.id))
|
|
733
815
|
]
|
|
@@ -795,7 +877,7 @@ function Txt({ s, children, anchor = "middle", fill = "currentColor" }) {
|
|
|
795
877
|
children
|
|
796
878
|
});
|
|
797
879
|
}
|
|
798
|
-
function Node({ n, state, title, sub, lm, focused, handlers }) {
|
|
880
|
+
function Node({ n, state, title, sub, lm, focused, selected, handlers }) {
|
|
799
881
|
const stroke = state ? STATE_STROKE[state] : "var(--lm-line)";
|
|
800
882
|
const flows = lm.view.def.flows;
|
|
801
883
|
const st = n.kind === "pool" ? lm.ev.stages[n.stages[0] ?? ""] : void 0;
|
|
@@ -805,6 +887,7 @@ function Node({ n, state, title, sub, lm, focused, handlers }) {
|
|
|
805
887
|
style: { color: "var(--lm-fg)" },
|
|
806
888
|
"data-node": n.id,
|
|
807
889
|
"data-focus": focused || void 0,
|
|
890
|
+
"data-selected": selected || void 0,
|
|
808
891
|
...handlers,
|
|
809
892
|
children: [
|
|
810
893
|
n.shape === "cylinder" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("path", {
|
|
@@ -892,6 +975,17 @@ function Node({ n, state, title, sub, lm, focused, handlers }) {
|
|
|
892
975
|
rx: "1",
|
|
893
976
|
fill: "var(--lm-accent)"
|
|
894
977
|
})] }, s.index)),
|
|
978
|
+
selected && /* @__PURE__ */ jsx("rect", {
|
|
979
|
+
className: "lm-selected",
|
|
980
|
+
x: n.x - 3,
|
|
981
|
+
y: n.y - 3,
|
|
982
|
+
width: n.w + 6,
|
|
983
|
+
height: n.h + 6,
|
|
984
|
+
rx: "8",
|
|
985
|
+
fill: "none",
|
|
986
|
+
stroke: "var(--lm-accent)",
|
|
987
|
+
strokeWidth: "2.5"
|
|
988
|
+
}),
|
|
895
989
|
focused && /* @__PURE__ */ jsx("rect", {
|
|
896
990
|
className: "lm-focus",
|
|
897
991
|
x: n.x - 5,
|
|
@@ -1503,16 +1597,41 @@ const LOADMAP_CSS = `
|
|
|
1503
1597
|
.lm-card { background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }
|
|
1504
1598
|
|
|
1505
1599
|
.lm-wrap { display: grid; gap: 8px; min-width: 0; position: relative; }
|
|
1506
|
-
.lm-wrap:fullscreen { background: var(--lm-bg); padding: 16px; align-content: center; overflow: auto; }
|
|
1507
1600
|
.lm-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
|
|
1508
1601
|
.lm-btn { font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
|
|
1509
1602
|
.lm-board { position: relative; background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; overflow: hidden; margin: 0 auto; width: 100%; }
|
|
1510
|
-
.lm-wrap:fullscreen .lm-board { width: auto; max-width: 100%; max-height: calc(100vh - 90px); }
|
|
1511
1603
|
.lm-board svg { display: block; width: 100%; height: auto; font-family: var(--lm-font); }
|
|
1512
1604
|
.lm-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
|
|
1513
1605
|
.lm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--lm-muted); }
|
|
1514
1606
|
.lm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 5px; }
|
|
1515
1607
|
|
|
1608
|
+
/* full screen (the browser's, or a fixed overlay): the diagram as large as fits, beside a panel of the verdict, the
|
|
1609
|
+
live meters and the controls; the board's size comes from Diagram (--lm-fit), the load never changes it */
|
|
1610
|
+
.lm-side, .lm-ranked { display: contents; }
|
|
1611
|
+
.lm[data-full] { height: 100vh; height: 100dvh; padding: 16px; overflow: auto; overscroll-behavior: contain; align-content: start; }
|
|
1612
|
+
.lm[data-full="overlay"] { position: fixed; inset: 0; z-index: 2147483000; width: auto; max-width: none; max-height: none; margin: 0; border: 0; }
|
|
1613
|
+
.lm[data-full]:has(> .lm-side) { overflow: hidden; grid-template-columns: minmax(0, 1fr) clamp(300px, 24vw, 400px); grid-template-rows: repeat(3, auto) minmax(0, 1fr); row-gap: 0; }
|
|
1614
|
+
.lm[data-full]:has(> .lm-side) > :is(h2, .lm-scenarios, .lm-story) { grid-column: 1; margin-bottom: 12px; }
|
|
1615
|
+
/* a page of its own keeps the rest outside full screen, as <Loadmap> does */
|
|
1616
|
+
.lm[data-full]:has(> .lm-side) > :not(h2, .lm-scenarios, .lm-story, .lm-wrap, .lm-side) { display: none; }
|
|
1617
|
+
.lm[data-full] .lm-wrap { height: calc(100dvh - 32px); grid-template-rows: auto auto; align-content: center; }
|
|
1618
|
+
.lm[data-full]:has(> .lm-side) > .lm-wrap { grid-column: 1; grid-row: 4; height: auto; min-height: 0; }
|
|
1619
|
+
/* left under the bar, so the legend starts where the board does */
|
|
1620
|
+
.lm[data-full] .lm-board { width: var(--lm-fit, 100%); margin: 0; align-self: start; justify-self: start; }
|
|
1621
|
+
.lm[data-full] > .lm-side { grid-column: 2; grid-row: 1 / -1; display: grid; gap: 14px; align-content: start; min-height: 0; overflow: auto; overscroll-behavior: contain; container-type: inline-size; }
|
|
1622
|
+
.lm[data-full] .lm-more { display: none; }
|
|
1623
|
+
@media (max-width: 760px) {
|
|
1624
|
+
.lm[data-full]:has(> .lm-side) { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(3, auto) minmax(0, 3fr) minmax(0, 2fr); }
|
|
1625
|
+
.lm[data-full] > .lm-side { grid-column: 1; grid-row: 5; margin-top: 12px; }
|
|
1626
|
+
.lm[data-full] > h2 { display: none; }
|
|
1627
|
+
/* a phone keeps the board as wide as the screen and scrolls it: fitted to the height it is too small to read */
|
|
1628
|
+
.lm[data-full]:has(> .lm-side) > .lm-wrap { overflow: auto; align-content: start; }
|
|
1629
|
+
.lm[data-full] .lm-board { width: 100%; }
|
|
1630
|
+
/* the controls first in the short panel: the diagram, the verdict and the meters answer them */
|
|
1631
|
+
.lm[data-full] .lm-side > .lm-strip:not(.lm-more) { display: contents; }
|
|
1632
|
+
.lm[data-full] .lm-side .lm-controls { order: -1; }
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1516
1635
|
.lm-verdict { margin: 0; padding: 10px 14px; border-left: 4px solid var(--lm-ok); background: var(--lm-accent-soft); border-radius: 0 6px 6px 0; }
|
|
1517
1636
|
.lm-verdict[data-tier="warn"] { border-color: var(--lm-warn); }
|
|
1518
1637
|
.lm-verdict[data-tier="over"] { border-color: var(--lm-drop); }
|
|
@@ -2065,7 +2184,7 @@ function LoadmapRoot({ lm, theme = "auto", children }) {
|
|
|
2065
2184
|
});
|
|
2066
2185
|
}
|
|
2067
2186
|
/** The whole page piece: scenarios, diagram, verdict, headroom, live meters, limits, controls and assumptions. */
|
|
2068
|
-
function Loadmap({ model, view, theme, title, assumptions, headroom = true, compare = true, ref, ...o }) {
|
|
2187
|
+
function Loadmap({ model, view, theme, title, assumptions, headroom = true, compare = true, onNodeClick, selected, ref, ...o }) {
|
|
2069
2188
|
const lm = useLoadmap(model, view, o);
|
|
2070
2189
|
useImperativeHandle(ref, () => handleOf(lm), [lm]);
|
|
2071
2190
|
const side = compare && model.scenarios.length > 1;
|
|
@@ -2076,22 +2195,37 @@ function Loadmap({ model, view, theme, title, assumptions, headroom = true, comp
|
|
|
2076
2195
|
title !== false && /* @__PURE__ */ jsx("h2", { children: title ?? model.title }),
|
|
2077
2196
|
/* @__PURE__ */ jsx(Scenarios, { lm }),
|
|
2078
2197
|
/* @__PURE__ */ jsx(Story, { lm }),
|
|
2079
|
-
/* @__PURE__ */ jsx(Diagram, {
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
children: [headroom && /* @__PURE__ */ jsx(HeadroomChart, { lm }), side && /* @__PURE__ */ jsx(Compare, { lm })]
|
|
2198
|
+
/* @__PURE__ */ jsx(Diagram, {
|
|
2199
|
+
lm,
|
|
2200
|
+
onNodeClick,
|
|
2201
|
+
selected
|
|
2084
2202
|
}),
|
|
2085
2203
|
/* @__PURE__ */ jsxs("div", {
|
|
2086
|
-
className: "lm-
|
|
2087
|
-
children: [
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2204
|
+
className: "lm-side",
|
|
2205
|
+
children: [
|
|
2206
|
+
/* @__PURE__ */ jsx(Verdict, { lm }),
|
|
2207
|
+
(headroom || side) && /* @__PURE__ */ jsxs("div", {
|
|
2208
|
+
className: headroom && side ? "lm-more lm-strip" : "lm-more",
|
|
2209
|
+
children: [headroom && /* @__PURE__ */ jsx(HeadroomChart, { lm }), side && /* @__PURE__ */ jsx(Compare, { lm })]
|
|
2210
|
+
}),
|
|
2211
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2212
|
+
className: "lm-strip",
|
|
2213
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2214
|
+
className: "lm-card",
|
|
2215
|
+
children: [/* @__PURE__ */ jsx(Meters, { lm }), /* @__PURE__ */ jsx("div", {
|
|
2216
|
+
className: "lm-more lm-ranked",
|
|
2217
|
+
children: /* @__PURE__ */ jsx(Limits, { lm })
|
|
2218
|
+
})]
|
|
2219
|
+
}), /* @__PURE__ */ jsx(Controls, { lm })]
|
|
2220
|
+
}),
|
|
2221
|
+
/* @__PURE__ */ jsx("div", {
|
|
2222
|
+
className: "lm-more",
|
|
2223
|
+
children: /* @__PURE__ */ jsx(Assumptions, {
|
|
2224
|
+
lm,
|
|
2225
|
+
extra: assumptions
|
|
2226
|
+
})
|
|
2227
|
+
})
|
|
2228
|
+
]
|
|
2095
2229
|
})
|
|
2096
2230
|
]
|
|
2097
2231
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loadmap/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Interactive capacity models for React: an architecture diagram with moving dots, the limits ranked, the verdict, scenarios and headroom.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"loadmap",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@loadmap/core": "0.
|
|
34
|
-
"@loadmap/sim": "0.
|
|
35
|
-
"@loadmap/layout": "0.
|
|
33
|
+
"@loadmap/core": "0.3.1",
|
|
34
|
+
"@loadmap/sim": "0.3.1",
|
|
35
|
+
"@loadmap/layout": "0.3.1",
|
|
36
36
|
"elkjs": "^0.12.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|