@atolis-hq/corum 0.1.54 → 0.1.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/package.json +4 -2
  2. package/web/app.jsx +107 -18
  3. package/web/style.css +69 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atolis-hq/corum",
3
- "version": "0.1.54",
3
+ "version": "0.1.55",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,7 +20,8 @@
20
20
  "mcp": "node dist/src/mcp/index.js",
21
21
  "mcp:smoke": "npm run build && node scripts/mcp-smoke.mjs",
22
22
  "mcp:write-smoke": "npm run build && node scripts/mcp-write-smoke.mjs",
23
- "web": "node dist/src/web/server.js"
23
+ "web": "node dist/src/web/server.js",
24
+ "test:web": "npm run build && playwright test"
24
25
  },
25
26
  "dependencies": {
26
27
  "@apidevtools/swagger-parser": "^12.1.0",
@@ -34,6 +35,7 @@
34
35
  "yaml": "^2.3.4"
35
36
  },
36
37
  "devDependencies": {
38
+ "@playwright/test": "^1.65.1",
37
39
  "@types/express": "^4.17.25",
38
40
  "@types/node": "^24.0.0",
39
41
  "@types/swagger-parser": "^4.0.3",
package/web/app.jsx CHANGED
@@ -215,12 +215,17 @@ function NavTree({ navTree, templates, activeNodeId, onNode, overlayIndicatorIds
215
215
  }
216
216
 
217
217
  return (
218
- <div className="nav-tree">
218
+ <div className="nav-tree" onKeyDown={event => {
219
+ if ((event.key === 'Enter' || event.key === ' ') && event.target.getAttribute('role') === 'button') {
220
+ event.preventDefault();
221
+ event.target.click();
222
+ }
223
+ }}>
219
224
  {sortedComponents.map(component => {
220
225
  const entries = navTree.get(component);
221
226
  return (
222
227
  <div key={component}>
223
- <div className="nav-section-head" onClick={() => toggleComponent(component)}>
228
+ <div className="nav-section-head" role="button" tabIndex={0} aria-expanded={openComponent === component} onClick={() => toggleComponent(component)}>
224
229
  <span>{component}</span>
225
230
  <Icon name={openComponent === component ? 'chevron-down' : 'chevron-right'} size={12} />
226
231
  </div>
@@ -230,7 +235,7 @@ function NavTree({ navTree, templates, activeNodeId, onNode, overlayIndicatorIds
230
235
  const gOpen = openEntryKeys.has(gKey);
231
236
  return (
232
237
  <div key={entry.groupTemplateName}>
233
- <div className="nav-template-head" onClick={() => toggleEntry(gKey)} style={{ cursor: 'pointer' }}>
238
+ <div className="nav-template-head" role="button" tabIndex={0} aria-expanded={gOpen} onClick={() => toggleEntry(gKey)} style={{ cursor: 'pointer' }}>
234
239
  {entry.icon && (
235
240
  <i
236
241
  className={`fa-solid fa-${entry.icon}`}
@@ -257,6 +262,7 @@ function NavTree({ navTree, templates, activeNodeId, onNode, overlayIndicatorIds
257
262
  <div
258
263
  key={node.id}
259
264
  className={`nav-node-item${isActive ? ' active' : ''}`}
265
+ role="button" tabIndex={0} aria-current={isActive ? 'true' : undefined}
260
266
  onClick={() => onNode(node.id)}
261
267
  title={node.id}
262
268
  style={isActive ? { '--nav-node-active-bg': child.colour } : undefined}
@@ -282,7 +288,7 @@ function NavTree({ navTree, templates, activeNodeId, onNode, overlayIndicatorIds
282
288
  const tOpen = openEntryKeys.has(tKey);
283
289
  return (
284
290
  <div key={entry.templateName}>
285
- <div className="nav-template-head" onClick={() => toggleEntry(tKey)} style={{ cursor: 'pointer' }}>
291
+ <div className="nav-template-head" role="button" tabIndex={0} aria-expanded={tOpen} onClick={() => toggleEntry(tKey)} style={{ cursor: 'pointer' }}>
286
292
  <i
287
293
  className={`fa-solid fa-${template?.ui?.icon ?? 'circle'}`}
288
294
  style={{ fontSize: 12, width: 14, textAlign: 'center', flexShrink: 0 }}
@@ -296,6 +302,7 @@ function NavTree({ navTree, templates, activeNodeId, onNode, overlayIndicatorIds
296
302
  <div key={node.id}>
297
303
  <div
298
304
  className={`nav-node-item${isActive ? ' active' : ''}`}
305
+ role="button" tabIndex={0} aria-current={isActive ? 'true' : undefined}
299
306
  onClick={() => onNode(node.id)}
300
307
  title={node.id}
301
308
  style={isActive ? { '--nav-node-active-bg': colour } : undefined}
@@ -309,6 +316,7 @@ function NavTree({ navTree, templates, activeNodeId, onNode, overlayIndicatorIds
309
316
  <div className="nav-child-group" key={group.label}>
310
317
  <div
311
318
  className="nav-child-head"
319
+ role="button" tabIndex={0} aria-expanded={groupOpen}
312
320
  style={{ cursor: 'pointer' }}
313
321
  onClick={() => setOpenGroupKeys(prev => {
314
322
  const next = new Set(prev);
@@ -327,6 +335,7 @@ function NavTree({ navTree, templates, activeNodeId, onNode, overlayIndicatorIds
327
335
  <div
328
336
  key={child.id}
329
337
  className={`nav-node-item nav-node-child${childIsActive ? ' active' : ''}`}
338
+ role="button" tabIndex={0} aria-current={childIsActive ? 'true' : undefined}
330
339
  onClick={() => onNode(child.id)}
331
340
  title={child.id}
332
341
  style={childIsActive ? { '--nav-node-active-bg': childColour } : undefined}
@@ -979,6 +988,10 @@ function App() {
979
988
  const [loading, setLoading] = useState(true);
980
989
  const [error, setError] = useState(null);
981
990
  const [route, setRoute] = useState(() => parseRoute(window.location.hash));
991
+ const [mobile, setMobile] = useState(() => matchMedia('(max-width: 780px)').matches);
992
+ const retainedNode = React.useRef(null);
993
+ const listPane = React.useRef(null);
994
+ const detailPane = React.useRef(null);
982
995
  const [refreshToken, setRefreshToken] = useState(0);
983
996
  const [gitMode, setGitMode] = useState(false);
984
997
  const [branches, setBranches] = useState([]);
@@ -1066,9 +1079,37 @@ function App() {
1066
1079
  }, [viewingRef, gitMode, refreshGraphData]);
1067
1080
 
1068
1081
  useEffect(() => {
1069
- const handler = () => setRoute(parseRoute(window.location.hash));
1082
+ let previous = parseRoute(window.location.hash);
1083
+ function syncHistory(next) {
1084
+ if (matchMedia('(max-width: 780px)').matches && next.pathname === '/node' && !history.state?.corumDetail) {
1085
+ // Seed a list entry behind direct links and nodes opened from other sections.
1086
+ const hash = location.hash;
1087
+ history.replaceState(null, '', buildRoute({ pathname: '/components', branch: next.branch }));
1088
+ history.pushState({ corumDetail: true }, '', hash);
1089
+ }
1090
+ }
1091
+ syncHistory(previous);
1092
+ const handler = () => {
1093
+ const next = parseRoute(location.hash);
1094
+ if (next.pathname === '/node' && previous.pathname === '/components') {
1095
+ history.replaceState({ corumDetail: true }, '');
1096
+ } else {
1097
+ syncHistory(next);
1098
+ }
1099
+ previous = next;
1100
+ setRoute(next);
1101
+ };
1102
+ const query = matchMedia('(max-width: 780px)');
1103
+ const resize = () => {
1104
+ setMobile(query.matches);
1105
+ syncHistory(parseRoute(location.hash));
1106
+ };
1107
+ query.addEventListener('change', resize);
1070
1108
  window.addEventListener('hashchange', handler);
1071
- return () => window.removeEventListener('hashchange', handler);
1109
+ return () => {
1110
+ window.removeEventListener('hashchange', handler);
1111
+ query.removeEventListener('change', resize);
1112
+ };
1072
1113
  }, []);
1073
1114
 
1074
1115
  useEffect(() => {
@@ -1083,9 +1124,38 @@ function App() {
1083
1124
  }, []);
1084
1125
 
1085
1126
  const activeNodeId = route.pathname === '/node' ? route.params.get('id') : null;
1127
+ if (activeNodeId) retainedNode.current = activeNodeId;
1128
+ const detailOpen = route.pathname === '/node';
1086
1129
  const activeSection = activeNodeId ? 'components' : (route.pathname.slice(1) || 'dashboard');
1087
1130
  const navTree = useMemo(() => buildNavTree(nodes, templates), [nodes, templates]);
1088
1131
  const showTree = (activeSection === 'components' || activeNodeId) && activeSection !== 'graph';
1132
+ useEffect(() => {
1133
+ if (!mobile || !showTree) return;
1134
+ const pane = detailOpen ? detailPane.current : listPane.current;
1135
+ let frame;
1136
+ const observer = new MutationObserver(focusTarget);
1137
+ function focusTarget() {
1138
+ const target = pane?.querySelector(detailOpen ? 'h1' : '.nav-node-item.active');
1139
+ if (!target) return;
1140
+ target.tabIndex = detailOpen ? -1 : 0;
1141
+ target.focus({ preventScroll: true });
1142
+ if (document.activeElement === target) {
1143
+ observer.disconnect();
1144
+ } else {
1145
+ // Visibility may still be changing as the pane starts its transition.
1146
+ cancelAnimationFrame(frame);
1147
+ frame = requestAnimationFrame(focusTarget);
1148
+ }
1149
+ }
1150
+ // Node headings arrive asynchronously after the cluster request.
1151
+ if (pane) observer.observe(pane, { childList: true, subtree: true });
1152
+ focusTarget();
1153
+ return () => {
1154
+ observer.disconnect();
1155
+ cancelAnimationFrame(frame);
1156
+ };
1157
+ }, [mobile, detailOpen, activeNodeId, showTree]);
1158
+
1089
1159
  const activeOverlayRefs = useMemo(() =>
1090
1160
  overlayMode === 'single' ? [] :
1091
1161
  overlayMode === 'consolidated' ? branches.filter(branch => branch.ref !== viewingRef).map(branch => branch.ref) :
@@ -1138,6 +1208,7 @@ function App() {
1138
1208
  } else if (route.pathname === '/node') {
1139
1209
  page = (
1140
1210
  <NodePage
1211
+ key={activeNodeId}
1141
1212
  nodeId={activeNodeId}
1142
1213
  templates={templates}
1143
1214
  onNavigate={handleNode}
@@ -1190,18 +1261,36 @@ function App() {
1190
1261
  }}
1191
1262
  />
1192
1263
  )}
1193
- <div className="main">
1194
- <NavRail activeSection={activeSection} onSection={handleSection} debugMode={debugMode} onDebugMode={handleDebugMode} />
1195
- {showTree && !loading && !error && (
1196
- <NavTree
1197
- navTree={navTree}
1198
- templates={templates}
1199
- activeNodeId={activeNodeId}
1200
- onNode={handleNode}
1201
- overlayIndicatorIds={overlayIndicatorIds}
1202
- />
1203
- )}
1204
- {page}
1264
+ <div className={`main${showTree ? ' master-detail' : ''}${detailOpen ? ' detail-open' : ''}`}>
1265
+ <div
1266
+ className="list-pane" ref={listPane}
1267
+ inert={mobile && showTree && detailOpen ? '' : undefined}
1268
+ aria-hidden={mobile && showTree && detailOpen ? true : undefined}
1269
+ >
1270
+ <NavRail activeSection={activeSection} onSection={handleSection} debugMode={debugMode} onDebugMode={handleDebugMode} />
1271
+ {mobile && showTree && !detailOpen && (loading || error) && page}
1272
+ {showTree && !loading && !error && (
1273
+ <NavTree
1274
+ navTree={navTree}
1275
+ templates={templates}
1276
+ activeNodeId={activeNodeId || retainedNode.current}
1277
+ onNode={handleNode}
1278
+ overlayIndicatorIds={overlayIndicatorIds}
1279
+ />
1280
+ )}
1281
+ </div>
1282
+ <div
1283
+ className="detail-pane" ref={detailPane}
1284
+ inert={mobile && showTree && !detailOpen ? '' : undefined}
1285
+ aria-hidden={mobile && showTree && !detailOpen ? true : undefined}
1286
+ >
1287
+ {showTree && (
1288
+ <button type="button" className="mobile-back" onClick={() => history.back()}>
1289
+ <span aria-hidden="true">←</span> Back to components
1290
+ </button>
1291
+ )}
1292
+ {page}
1293
+ </div>
1205
1294
  </div>
1206
1295
  </>
1207
1296
  );
package/web/style.css CHANGED
@@ -103,6 +103,21 @@ button {
103
103
  min-height: 0;
104
104
  }
105
105
 
106
+ .list-pane {
107
+ display: flex;
108
+ min-height: 0;
109
+ }
110
+ .detail-pane {
111
+ display: flex;
112
+ flex-direction: column;
113
+ flex: 1;
114
+ min-width: 0;
115
+ min-height: 0;
116
+ }
117
+ .mobile-back {
118
+ display: none;
119
+ }
120
+
106
121
  .nav-rail {
107
122
  display: flex;
108
123
  flex-direction: column;
@@ -557,7 +572,9 @@ button {
557
572
 
558
573
  .nav-tree {
559
574
  width: 100%;
560
- max-height: 260px;
575
+ min-width: 0;
576
+ min-height: 0;
577
+ flex: 1;
561
578
  border-right: none;
562
579
  border-bottom: 1px solid var(--rule);
563
580
  }
@@ -1699,3 +1716,54 @@ button {
1699
1716
  border-radius: 50%;
1700
1717
  flex-shrink: 0;
1701
1718
  }
1719
+
1720
+ @media (max-width: 780px) {
1721
+ #root {
1722
+ height: 100dvh;
1723
+ }
1724
+ .list-pane {
1725
+ flex-direction: column;
1726
+ flex-shrink: 0;
1727
+ }
1728
+ .master-detail {
1729
+ position: relative;
1730
+ overflow: hidden;
1731
+ }
1732
+ .master-detail > .list-pane, .master-detail > .detail-pane {
1733
+ position: absolute;
1734
+ inset: 0;
1735
+ width: 100%;
1736
+ background: var(--paper);
1737
+ transition: transform 220ms ease, visibility 220ms;
1738
+ }
1739
+ .master-detail > .detail-pane {
1740
+ transform: translateX(100%);
1741
+ visibility: hidden;
1742
+ }
1743
+ .master-detail.detail-open > .list-pane {
1744
+ transform: translateX(-100%);
1745
+ visibility: hidden;
1746
+ }
1747
+ .master-detail.detail-open > .detail-pane {
1748
+ transform: translateX(0);
1749
+ visibility: visible;
1750
+ }
1751
+ .mobile-back {
1752
+ display: flex;
1753
+ align-items: center;
1754
+ gap: 10px;
1755
+ min-height: 44px;
1756
+ padding: 8px 16px;
1757
+ border: 0;
1758
+ border-bottom: 1px solid var(--rule);
1759
+ background: var(--paper-2);
1760
+ color: var(--ink);
1761
+ cursor: pointer;
1762
+ flex-shrink: 0;
1763
+ }
1764
+ }
1765
+ @media (prefers-reduced-motion: reduce) {
1766
+ .master-detail > .list-pane, .master-detail > .detail-pane {
1767
+ transition: none;
1768
+ }
1769
+ }