create-pmos 0.635.0 → 0.636.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.
Files changed (150) hide show
  1. package/bin/create-pmos.js +1 -0
  2. package/package.json +14 -20
  3. package/payload/KIT-VERSION +2 -2
  4. package/payload/README.md +37 -113
  5. package/payload/design-system/README.md +98 -0
  6. package/payload/design-system/components/Badge/README.md +16 -0
  7. package/payload/design-system/components/Badge/preview.html +8 -0
  8. package/payload/design-system/components/Button/README.md +20 -0
  9. package/payload/design-system/components/Button/preview.html +8 -0
  10. package/payload/design-system/components/Calendar/README.md +14 -0
  11. package/payload/design-system/components/Calendar/preview.html +11 -0
  12. package/payload/design-system/components/Chart/README.md +24 -0
  13. package/payload/design-system/components/Chart/preview.html +50 -0
  14. package/payload/design-system/components/Conversation/README.md +14 -0
  15. package/payload/design-system/components/Conversation/preview.html +8 -0
  16. package/payload/design-system/components/Detail/README.md +17 -0
  17. package/payload/design-system/components/Detail/preview.html +8 -0
  18. package/payload/design-system/components/Document/README.md +15 -0
  19. package/payload/design-system/components/Document/preview.html +8 -0
  20. package/payload/design-system/components/Event/README.md +13 -0
  21. package/payload/design-system/components/Event/preview.html +8 -0
  22. package/payload/design-system/components/Field/README.md +13 -0
  23. package/payload/design-system/components/Field/preview.html +8 -0
  24. package/payload/design-system/components/Icon/README.md +12 -0
  25. package/payload/design-system/components/Icon/preview.html +8 -0
  26. package/payload/design-system/components/Input/README.md +17 -0
  27. package/payload/design-system/components/Input/preview.html +8 -0
  28. package/payload/design-system/components/List/README.md +21 -0
  29. package/payload/design-system/components/List/preview.html +15 -0
  30. package/payload/design-system/components/ListRow/README.md +19 -0
  31. package/payload/design-system/components/ListRow/preview.html +8 -0
  32. package/payload/design-system/components/MainItem/README.md +13 -0
  33. package/payload/design-system/components/MainItem/preview.html +8 -0
  34. package/payload/design-system/components/MainSide/README.md +12 -0
  35. package/payload/design-system/components/MainSide/preview.html +8 -0
  36. package/payload/design-system/components/Menu/README.md +13 -0
  37. package/payload/design-system/components/Menu/preview.html +8 -0
  38. package/payload/design-system/components/Navigation/README.md +14 -0
  39. package/payload/design-system/components/Navigation/preview.html +8 -0
  40. package/payload/design-system/components/Number/README.md +17 -0
  41. package/payload/design-system/components/Number/preview.html +8 -0
  42. package/payload/design-system/components/Settings/README.md +13 -0
  43. package/payload/design-system/components/Settings/preview.html +10 -0
  44. package/payload/design-system/components/SingleColumn/README.md +12 -0
  45. package/payload/design-system/components/SingleColumn/preview.html +8 -0
  46. package/payload/design-system/components/Stage/README.md +13 -0
  47. package/payload/design-system/components/Stage/preview.html +8 -0
  48. package/payload/design-system/components/Suggestion/README.md +14 -0
  49. package/payload/design-system/components/Suggestion/preview.html +10 -0
  50. package/payload/design-system/components/Summary/README.md +19 -0
  51. package/payload/design-system/components/Summary/preview.html +10 -0
  52. package/payload/design-system/components/Switch/README.md +13 -0
  53. package/payload/design-system/components/Switch/preview.html +10 -0
  54. package/payload/design-system/components/Table/README.md +18 -0
  55. package/payload/design-system/components/Table/preview.html +23 -0
  56. package/payload/design-system/components/Tabs/README.md +13 -0
  57. package/payload/design-system/components/Tabs/preview.html +11 -0
  58. package/payload/design-system/components/Timeline/README.md +15 -0
  59. package/payload/design-system/components/Timeline/preview.html +8 -0
  60. package/payload/design-system/components/Toast/README.md +14 -0
  61. package/payload/design-system/components/Toast/preview.html +8 -0
  62. package/payload/design-system/components/TodayPage/README.md +12 -0
  63. package/payload/design-system/components/TodayPage/preview.html +8 -0
  64. package/payload/design-system/components/bundle.css +126 -0
  65. package/payload/design-system/interactions.md +48 -0
  66. package/payload/design-system/pages.md +34 -0
  67. package/payload/design-system/tokens.css +9 -0
  68. package/payload/design-system/tokens.json +339 -0
  69. package/payload/planning/evals/eval-calibration.md +1 -1
  70. package/payload/planning/okrs/health-budgets.md +1 -1
  71. package/payload/state/discoveries.md +1 -1
  72. package/payload/state/log.md +1 -1
  73. package/workspace/changelog.json +13 -0
  74. package/workspace/ci-checks.sh +3 -0
  75. package/workspace/design-system/README.md +98 -0
  76. package/workspace/design-system/components/Badge/README.md +16 -0
  77. package/workspace/design-system/components/Badge/preview.html +8 -0
  78. package/workspace/design-system/components/Button/README.md +20 -0
  79. package/workspace/design-system/components/Button/preview.html +8 -0
  80. package/workspace/design-system/components/Calendar/README.md +14 -0
  81. package/workspace/design-system/components/Calendar/preview.html +11 -0
  82. package/workspace/design-system/components/Chart/README.md +24 -0
  83. package/workspace/design-system/components/Chart/preview.html +50 -0
  84. package/workspace/design-system/components/Conversation/README.md +14 -0
  85. package/workspace/design-system/components/Conversation/preview.html +8 -0
  86. package/workspace/design-system/components/Detail/README.md +17 -0
  87. package/workspace/design-system/components/Detail/preview.html +8 -0
  88. package/workspace/design-system/components/Document/README.md +15 -0
  89. package/workspace/design-system/components/Document/preview.html +8 -0
  90. package/workspace/design-system/components/Event/README.md +13 -0
  91. package/workspace/design-system/components/Event/preview.html +8 -0
  92. package/workspace/design-system/components/Field/README.md +13 -0
  93. package/workspace/design-system/components/Field/preview.html +8 -0
  94. package/workspace/design-system/components/Icon/README.md +12 -0
  95. package/workspace/design-system/components/Icon/preview.html +8 -0
  96. package/workspace/design-system/components/Input/README.md +17 -0
  97. package/workspace/design-system/components/Input/preview.html +8 -0
  98. package/workspace/design-system/components/List/README.md +21 -0
  99. package/workspace/design-system/components/List/preview.html +15 -0
  100. package/workspace/design-system/components/ListRow/README.md +19 -0
  101. package/workspace/design-system/components/ListRow/preview.html +8 -0
  102. package/workspace/design-system/components/MainItem/README.md +13 -0
  103. package/workspace/design-system/components/MainItem/preview.html +8 -0
  104. package/workspace/design-system/components/MainSide/README.md +12 -0
  105. package/workspace/design-system/components/MainSide/preview.html +8 -0
  106. package/workspace/design-system/components/Menu/README.md +13 -0
  107. package/workspace/design-system/components/Menu/preview.html +8 -0
  108. package/workspace/design-system/components/Navigation/README.md +14 -0
  109. package/workspace/design-system/components/Navigation/preview.html +8 -0
  110. package/workspace/design-system/components/Number/README.md +17 -0
  111. package/workspace/design-system/components/Number/preview.html +8 -0
  112. package/workspace/design-system/components/Settings/README.md +13 -0
  113. package/workspace/design-system/components/Settings/preview.html +10 -0
  114. package/workspace/design-system/components/SingleColumn/README.md +12 -0
  115. package/workspace/design-system/components/SingleColumn/preview.html +8 -0
  116. package/workspace/design-system/components/Stage/README.md +13 -0
  117. package/workspace/design-system/components/Stage/preview.html +8 -0
  118. package/workspace/design-system/components/Suggestion/README.md +14 -0
  119. package/workspace/design-system/components/Suggestion/preview.html +10 -0
  120. package/workspace/design-system/components/Summary/README.md +19 -0
  121. package/workspace/design-system/components/Summary/preview.html +10 -0
  122. package/workspace/design-system/components/Switch/README.md +13 -0
  123. package/workspace/design-system/components/Switch/preview.html +10 -0
  124. package/workspace/design-system/components/Table/README.md +18 -0
  125. package/workspace/design-system/components/Table/preview.html +23 -0
  126. package/workspace/design-system/components/Tabs/README.md +13 -0
  127. package/workspace/design-system/components/Tabs/preview.html +11 -0
  128. package/workspace/design-system/components/Timeline/README.md +15 -0
  129. package/workspace/design-system/components/Timeline/preview.html +8 -0
  130. package/workspace/design-system/components/Toast/README.md +14 -0
  131. package/workspace/design-system/components/Toast/preview.html +8 -0
  132. package/workspace/design-system/components/TodayPage/README.md +12 -0
  133. package/workspace/design-system/components/TodayPage/preview.html +8 -0
  134. package/workspace/design-system/components/bundle.css +126 -0
  135. package/workspace/design-system/interactions.md +48 -0
  136. package/workspace/design-system/pages.md +34 -0
  137. package/workspace/design-system/tokens.css +9 -0
  138. package/workspace/design-system/tokens.json +339 -0
  139. package/workspace/guide/agent-capabilities.md +2 -2
  140. package/workspace/guide/layout.md +6 -0
  141. package/workspace/lib/design-system.js +145 -0
  142. package/workspace/lib/idle-lab-engine.js +5 -1
  143. package/workspace/lib/live-round.js +15 -1
  144. package/workspace/package-lock.json +2 -2
  145. package/workspace/package.json +1 -1
  146. package/workspace/public/pm/komorebi.css +145 -0
  147. package/workspace/public/pm/komorebi.js +240 -0
  148. package/workspace/run-tests.js +6 -1
  149. package/workspace/test-lists/design-system.json +9 -0
  150. package/workspace/test-lists/komorebi.json +9 -0
@@ -22,7 +22,7 @@
22
22
  * new THREE headless runs in parallel, one specimen each (origin `live-round:<ws>:<ini>:<run>:<A|B|C>`, headless kind `live-round`:
23
23
  * Read and Glob, and Write only in the run's own folder <runtime>/idle-lab/specimens/<round>/<key>/). Files group `prototyped`.
24
24
  * feedback ONE run on the base specimen (it reads the earlier file). Files group `improved`, `changed` = the PM's sentence.
25
- * Each run gets a per-product scaffold (scaffoldOf: the product's tokens.css and the head of its components.css, else PMOS's own), the
25
+ * Each run gets a per-product scaffold (scaffoldOf: the PMOS design system, lib/design-system.js, the product's copy first; else the product's tokens.css and the head of its components.css), the
26
26
  * initiative's name, description and Intent, and the viewport pin (dry run finding a: 2 of 9 ran wider than the phone and were cut off).
27
27
  * NO TIME LIMIT (Wawan 2026-11-18: "No need limit, but need a visual guidance of the progression"). The run writes progress.json
28
28
  * ({ now, done, total }) at each step; the Viewer shows it with the time so far and a Stop press (stop()). Only a run that writes
@@ -62,6 +62,7 @@ const PR = require('./proposals.js');
62
62
  const LAB = require('./idle-lab.js');
63
63
  const E = require('./idle-lab-engine.js');
64
64
  const RULES = require('./prototype-rules.js');
65
+ const DS = require('./design-system.js');
65
66
 
66
67
  const JOB = 'live-round';
67
68
  const ORIGIN = 'live-round';
@@ -223,6 +224,18 @@ const stripComments = (css) => String(css || '').replace(/\/\*[\s\S]*?\*\//g, ''
223
224
  /** The product's token sheet and the head of its component sheet, the first folder that has them (dry run finding b: assemble from what
224
225
  * exists). roots: folders to look in, the product's first, PMOS's own last. → { css, from: [paths] } */
225
226
  function scaffoldOf(roots) {
227
+ // the PMOS design system first (Wawan 2026-11-19: "when a user create a prototype on PMOS, it also use a proper design system that is
228
+ // provided by the PMOS"): the product's copy of it (pmos/design-system/ from the kit), then the product's own token sheet, then PMOS's own
229
+ const [prod, ...rest] = (roots || []).filter(Boolean);
230
+ const own = DS.scaffoldOf([prod]);
231
+ if (own.css) return own;
232
+ const theirs = tokensOf([prod]);
233
+ if (theirs.css) return theirs;
234
+ const ds = DS.scaffoldOf(rest);
235
+ return ds.css ? ds : tokensOf(rest);
236
+ }
237
+ /** The product's token sheet and the head of its component sheet (the scaffold before the design system). */
238
+ function tokensOf(roots) {
226
239
  const rel = ['public/pm', 'workspace/public/pm', 'src/styles', 'styles', 'public/css', 'css'];
227
240
  for (const r of roots || []) {
228
241
  if (!r) continue;
@@ -292,6 +305,7 @@ function promptOf(o) {
292
305
  `4. ${path.join(dir, 'tweaks.json')} (optional): { "tweaks": [{ "var": "--gap", "label": "Spacing", "min": 4, "max": 32, "step": 1, "unit": "px", "value": 16, "el"? }] }, at most 6, for the custom properties the prototype reads. "el" is the data-el a tweak belongs to; without it, it is for the whole screen.`,
293
306
  `5. ${path.join(dir, 'notes.json')} (optional): { "notes": [{ "text", "screen"?, "el"? }] }, at most 8: what the PM should know that is not part of the design (the format and its size, that the data is sample data, what a placeholder stands for, the other option to compare). PMOS shows them as annotations beside the design. "screen" is the data-screen a note is about, "el" the data-el it points at; without them, it is for the whole prototype.`,
294
307
  'Write nothing else and do not read anything else' + (o.base || (o.refs || []).length ? ' but what is named above.' : '.'));
308
+ if (o.scaffold && o.scaffold.rules) L.push('', o.scaffold.rules);
295
309
  if (o.scaffold && o.scaffold.css) L.push('', 'The stylesheet:', '```css', o.scaffold.css, '```');
296
310
  return L.join('\n');
297
311
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.635.0",
3
+ "version": "0.636.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.635.0",
9
+ "version": "0.636.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.635.0",
3
+ "version": "0.636.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -0,0 +1,145 @@
1
+ /* komorebi.css — the PMOS design system (Komorebi) for the workspace. GENERATED from workspace/design-system/ by lib/design-system.js:
2
+ * do not edit; change the system's files and run `node lib/design-system.js --write`. Every rule is scoped to .pm-ds, so the sheet changes
3
+ * nothing until a page puts class="pm-ds" on its root. The fonts are the self-hosted ones (public/vendor), never a network font. */
4
+ @font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 200 800; font-display: swap; src: url(/vendor/plus-jakarta-sans-var.woff2) format('woff2'); }
5
+ @font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url(/vendor/ibm-plex-mono-400.woff2) format('woff2'); }
6
+ .pm-ds{--ground:#EFE8E3;--ground-morning:#EEF3F8;--ground-afternoon:#F5EEE2;--ground-evening:#EFE8E3;--ground-night:#1B1D21;--card:#FFFFFF;--well:#F4F2EE;--line:rgba(42,46,53,.12);--ink:#2A2E35;--muted:#646A74;--blue:#2F5FB3;--on-blue:#FFFFFF;--blue-tint:#ECF1F8;--leaf:#5F7A45;--leaf-tint:#F2F4F0;--alert:#A4461A;--alert-tint:#F7EEEA;--raise:0 1px 2px rgba(42,46,53,.08), 0 4px 14px -6px rgba(70,80,50,.14);--lift:0 10px 28px -10px rgba(42,46,53,.28);--glow:0 0 0 2px #5F7A45, 0 0 0 5px rgba(95,122,69,.10)}
7
+ .pm-ds.dark, html.dark .pm-ds, :root[data-theme="dark"] .pm-ds{--ground:#1B1D21;--card:#24262B;--well:#1B1D21;--line:rgba(236,238,241,.12);--ink:#ECEEF1;--muted:#9EA4AD;--blue:#6AAAF0;--on-blue:#14161A;--blue-tint:#2A323D;--leaf:#A9C48C;--leaf-tint:#2F3333;--alert:#E8A07A;--alert-tint:#363132;--raise:0 1px 2px rgba(0,0,0,.4), 0 4px 14px -6px rgba(169,196,140,.08);--lift:0 10px 28px -10px rgba(0,0,0,.6);--glow:0 0 0 2px #A9C48C, 0 0 0 5px rgba(169,196,140,.12)}
8
+ .pm-ds{--space-4:4px;--space-8:8px;--space-12:12px;--space-16:16px;--space-24:24px;--space-32:32px;--space-48:48px;--space-64:64px;--radius-sm:6px;--radius-md:10px;--radius-card:16px;--radius-panel:24px;--radius-pill:999px;--duration-quick:120ms;--duration-enter:200ms;--duration-leaf:600ms;--duration-light:20min;--ease-out:cubic-bezier(.2, .7, .2, 1);--ease-drift:cubic-bezier(.4, 0, .2, 1);--font-sans:"Plus Jakarta Sans", system-ui, sans-serif;--font-mono:"IBM Plex Mono", ui-monospace, monospace}
9
+ .pm-ds .title{font-family:var(--font-sans);font-size:26px;line-height:32px;font-weight:600}
10
+ .pm-ds .heading{font-family:var(--font-sans);font-size:18px;line-height:24px;font-weight:600}
11
+ .pm-ds .body{font-family:var(--font-sans);font-size:15px;line-height:24px;font-weight:400}
12
+ .pm-ds .small{font-family:var(--font-sans);font-size:13px;line-height:20px;font-weight:400}
13
+ .pm-ds .code{font-family:var(--font-mono);font-size:13px;line-height:20px;font-weight:400}
14
+ .pm-ds 600&family=IBM+Plex+Mono&display=swap");
15
+ body{margin:0;background:var(--ground);color:var(--ink);font-family:var(--font-sans);font-size:15px;line-height:1.6}
16
+ .pm-ds *{box-sizing:border-box}
17
+ .pm-ds .pm-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
18
+ .pm-ds .pm-meta{font-size:13px;line-height:20px;color:var(--muted)}
19
+ .pm-ds .pm-h{margin:0;font-size:18px;line-height:24px;font-weight:600}
20
+ .pm-ds .pm-h-sm{margin:0;font-size:15px;line-height:24px;font-weight:600}
21
+ .pm-ds .pm-ic{width:16px;height:16px;flex-shrink:0;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
22
+ .pm-ds .pm-btn{width:32px;height:32px;border-radius:var(--radius-sm);border:0;background:none;color:var(--ink);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;flex-shrink:0;transition:background var(--duration-quick) var(--ease-out)}
23
+ .pm-ds .pm-btn:hover{background:var(--well)}
24
+ .pm-ds .pm-btn:focus-visible{outline:none;box-shadow:var(--glow)}
25
+ .pm-ds .pm-btn.primary{background:var(--blue);color:var(--on-blue)}
26
+ .pm-ds .pm-btn.outline{border:1px solid var(--line);background:var(--card)}
27
+ .pm-ds .pm-btn.danger{color:var(--alert)}
28
+ .pm-ds .pm-btn[disabled]{opacity:.4;cursor:default}
29
+ .pm-ds .pm-input{height:40px;border:1px solid var(--line);border-radius:var(--radius-md);background:var(--card);padding:0 12px;font:inherit;color:var(--ink);width:100%}
30
+ .pm-ds .pm-input:focus{outline:none;box-shadow:var(--glow)}
31
+ .pm-ds .pm-badge{display:inline-flex;align-items:center;height:22px;padding:0 8px;border-radius:var(--radius-sm);font-size:13px;font-weight:600;white-space:nowrap;background:var(--well);color:var(--muted)}
32
+ .pm-ds .pm-badge.alert{background:var(--alert-tint);color:var(--alert)}
33
+ .pm-ds .pm-badge.blue{background:var(--blue-tint);color:var(--blue)}
34
+ .pm-ds .pm-count{display:inline-flex;align-items:center;justify-content:center;min-width:20px;height:20px;padding:0 6px;border-radius:var(--radius-pill);background:var(--blue);color:var(--on-blue);font-size:13px}
35
+ .pm-ds .pm-switch{width:40px;height:24px;border-radius:var(--radius-pill);background:var(--line);border:0;position:relative;cursor:pointer;flex-shrink:0}
36
+ .pm-ds .pm-switch::after{content:"";position:absolute;top:3px;left:3px;width:18px;height:18px;border-radius:var(--radius-pill);background:var(--card);box-shadow:var(--raise);transition:left var(--duration-quick) var(--ease-out)}
37
+ .pm-ds .pm-switch[aria-checked="true"]{background:var(--leaf)}
38
+ .pm-ds .pm-switch[aria-checked="true"]::after{left:19px}
39
+ .pm-ds .pm-switch:focus-visible{outline:none;box-shadow:var(--glow)}
40
+ .pm-ds .pm-chip{display:inline-flex;align-items:center;height:22px;padding:0 8px;border-radius:var(--radius-pill);background:var(--well);font-size:13px}
41
+ .pm-ds .pm-kbd{font-family:var(--font-mono);font-size:13px;min-width:24px;height:24px;padding:0 6px;border-radius:var(--radius-sm);border:1px solid var(--line);background:var(--well);display:inline-flex;align-items:center;justify-content:center}
42
+ .pm-ds .pm-li{min-height:56px;border-radius:var(--radius-md);display:flex;align-items:center;gap:12px;padding:6px 8px 6px 14px}
43
+ .pm-ds .pm-li:hover{background:var(--well)}
44
+ .pm-ds .pm-li .t{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
45
+ .pm-ds .pm-li .w{font-size:13px;line-height:20px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
46
+ .pm-ds .pm-li .txt{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.4}
47
+ .pm-ds .pm-li .acts{display:none;gap:2px}
48
+ .pm-ds .pm-li:hover .acts, .pm-ds .pm-li:focus-within .acts{display:flex}
49
+ .pm-ds .pm-li.now{background:var(--leaf-tint);box-shadow:inset 0 0 0 2px var(--leaf)}
50
+ .pm-ds .pm-li.nest{padding-left:38px;min-height:44px}
51
+ .pm-ds .pm-tabs{display:inline-flex;background:var(--well);border-radius:var(--radius-md);padding:3px;gap:2px}
52
+ .pm-ds .pm-tab{height:30px;padding:0 10px;border-radius:var(--radius-sm);border:0;background:none;font:inherit;font-size:13px;font-weight:600;color:var(--muted);cursor:pointer}
53
+ .pm-ds .pm-tab[aria-selected="true"]{background:var(--card);color:var(--ink);box-shadow:var(--raise)}
54
+ .pm-ds .pm-field{display:grid;grid-template-columns:110px 1fr;gap:8px;font-size:13px;line-height:20px}
55
+ .pm-ds .pm-field dt{color:var(--muted)}
56
+ .pm-ds .pm-field dd{margin:0}
57
+ .pm-ds .pm-toast{display:inline-flex;flex-direction:column;background:var(--ink);color:var(--card);border-radius:var(--radius-md);box-shadow:var(--lift);font-size:13px;overflow:hidden}
58
+ .pm-ds .pm-toast .in{display:inline-flex;align-items:center;gap:10px;padding:4px 4px 4px 14px}
59
+ .pm-ds .pm-toast .pm-btn{color:var(--card)}
60
+ .pm-ds .pm-toast .timer{height:2px;background:var(--leaf)}
61
+ .pm-ds .pm-menu{background:var(--card);border-radius:var(--radius-md);box-shadow:var(--lift);padding:4px;min-width:200px;display:flex;flex-direction:column}
62
+ .pm-ds .pm-menu button{height:36px;border:0;background:none;text-align:left;padding:0 10px;border-radius:var(--radius-sm);font:inherit;font-size:13px;color:var(--ink);display:flex;align-items:center;gap:8px;cursor:pointer}
63
+ .pm-ds .pm-menu button:hover{background:var(--well)}
64
+ .pm-ds .pm-sug{display:flex;align-items:center;gap:10px;background:var(--blue-tint);border-radius:var(--radius-md);padding:4px 4px 4px 12px;font-size:13px}
65
+ .pm-ds .pm-sug .say{flex:1}
66
+ .pm-ds .pm-star{color:var(--blue)}
67
+ .pm-ds .pm-ev{border:1px solid var(--line);border-radius:var(--radius-md);background:var(--card);box-shadow:var(--raise);padding:6px 10px;display:flex;flex-direction:column;line-height:1.35;font-size:13px}
68
+ .pm-ds .pm-ev b{font-weight:600}
69
+ .pm-ds .pm-ev.over{background:none;box-shadow:none;border-style:dashed;color:var(--muted)}
70
+ .pm-ds .pm-fold{height:44px;display:flex;align-items:center;gap:8px;padding:0 14px;border:0;border-top:1px dashed var(--line);background:none;width:100%;font:inherit;font-size:13px;font-weight:600;color:var(--muted);text-align:left;cursor:pointer}
71
+ .pm-ds .pm-group{height:32px;display:flex;align-items:center;gap:8px;padding:0 14px;font-size:13px;font-weight:600;background:var(--well);color:var(--muted)}
72
+ .pm-ds .pm-group.now{background:var(--leaf-tint);color:var(--ink)}
73
+ .pm-ds .pm-block{background:var(--card);border:1px solid var(--line);border-radius:var(--radius-card);box-shadow:var(--raise);padding:16px 18px;display:flex;flex-direction:column;gap:12px;min-width:0}
74
+ .pm-ds .pm-block.flat{background:var(--well);box-shadow:none;border-color:transparent}
75
+ .pm-ds .pm-block .head{display:flex;align-items:center;gap:10px}
76
+ .pm-ds .pm-block .head .sp{flex:1}
77
+ .pm-ds .pm-block.list{padding:0;overflow:hidden;gap:0}
78
+ .pm-ds .pm-block.list .head{padding:14px 16px}
79
+ .pm-ds .pm-block.list .rows{padding:0 8px 8px}
80
+ .pm-ds .pm-table{width:100%;border-collapse:collapse;font-size:13px}
81
+ .pm-ds .pm-table th{text-align:left;font-weight:600;color:var(--muted);padding:8px;border-bottom:1px solid var(--line)}
82
+ .pm-ds .pm-table td{padding:8px;border-bottom:1px solid var(--line);vertical-align:middle}
83
+ .pm-ds .pm-table tr:hover td{background:var(--well)}
84
+ .pm-ds .pm-num{font-size:26px;line-height:32px;font-weight:600;font-variant-numeric:tabular-nums}
85
+ .pm-ds .pm-bar{display:flex;height:10px;border-radius:var(--radius-pill);overflow:hidden;background:var(--well)}
86
+ .pm-ds .pm-cal{display:grid;grid-template-columns:repeat(7,1fr);gap:4px;text-align:center;font-size:13px}
87
+ .pm-ds .pm-cal span{height:32px;line-height:32px;border-radius:var(--radius-sm)}
88
+ .pm-ds .pm-cal .today{box-shadow:var(--glow);font-weight:600}
89
+ .pm-ds .pm-cal .has::after{content:"";display:block;width:4px;height:4px;margin:-8px auto 0;border-radius:2px;background:var(--blue)}
90
+ .pm-ds .pm-msg{align-self:flex-end;max-width:75%;background:var(--well);border-radius:var(--radius-md);padding:8px 12px;font-size:13px}
91
+ .pm-ds .pm-said{display:flex;gap:8px;font-size:13px;line-height:20px;max-width:85%}
92
+ .pm-ds .pm-doc{font-size:15px;line-height:26px;max-width:62ch}
93
+ .pm-ds .pm-doc h3{font-size:18px;line-height:24px;margin:0 0 4px}
94
+ .pm-ds .pm-stage{background:var(--well);border-radius:var(--radius-md);aspect-ratio:16/9;display:flex;align-items:center;justify-content:center;color:var(--muted);font-size:13px}
95
+ .pm-ds .pm-set{display:flex;align-items:center;gap:12px;min-height:56px;border-top:1px solid var(--line)}
96
+ .pm-ds .pm-rail{width:92px;background:var(--well);border-radius:var(--radius-panel);padding:8px 0;display:flex;flex-direction:column;align-items:center;gap:4px}
97
+ .pm-ds .pm-rail a{position:relative;width:76px;height:64px;border-radius:var(--radius-card);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;color:var(--ink);text-decoration:none;font-size:13px;font-weight:600}
98
+ .pm-ds .pm-rail a[aria-current="page"]{background:var(--card);box-shadow:var(--glow)}
99
+ .pm-ds .pm-rail .pm-count{position:absolute;top:3px;right:5px}
100
+ .pm-ds .pm-path{display:flex;align-items:center;gap:6px;font-size:13px}
101
+ .pm-ds .pm-path a{color:var(--blue)}
102
+ .pm-ds .pm-motion-enter{animation:pmEnter var(--duration-enter) var(--ease-out) both}
103
+ @keyframes pmEnter{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
104
+ @media (prefers-reduced-motion: reduce) {
105
+ .pm-ds *{animation:none!important;transition:none!important}
106
+ }
107
+ .pm-ds a{color:var(--blue)}
108
+ .pm-ds .pm-tip{position:absolute;pointer-events:none;background:var(--ink);color:var(--card);font-size:13px;line-height:20px;padding:6px 10px;border-radius:var(--radius-md);box-shadow:var(--lift);white-space:nowrap;opacity:0;transform:translateY(4px);transition:opacity var(--duration-quick) var(--ease-out),transform var(--duration-quick) var(--ease-out);z-index:5}
109
+ .pm-ds .pm-tip.on{opacity:1;transform:none}
110
+ .pm-ds .pm-tip b{font-weight:600}
111
+ .pm-ds .pm-chart{position:relative;outline:none;border-radius:var(--radius-md)}
112
+ .pm-ds .pm-chart:focus-visible{box-shadow:var(--glow)}
113
+ .pm-ds .pm-chart .hit{fill:transparent;cursor:pointer}
114
+ .pm-ds .pm-chart .pt{fill:var(--card);stroke:var(--blue);stroke-width:2;transition:r var(--duration-quick)}
115
+ .pm-ds .pm-chart .pt.on{stroke:var(--leaf);stroke-width:3}
116
+ .pm-ds .pm-chart .xh{stroke:var(--line);stroke-width:1;opacity:0}
117
+ .pm-ds .pm-chart .xh.on{opacity:1}
118
+ .pm-ds .pm-chart .series{transition:opacity var(--duration-enter) var(--ease-drift)}
119
+ .pm-ds .pm-chart .series.off{opacity:0}
120
+ .pm-ds .pm-chart path.line{transition:d var(--duration-enter) var(--ease-drift)}
121
+ .pm-ds .pm-leg{display:flex;gap:12px;font-size:13px}
122
+ .pm-ds .pm-leg button{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;padding:2px 6px;border-radius:var(--radius-sm);color:var(--ink)}
123
+ .pm-ds .pm-leg button:hover{background:var(--well)}
124
+ .pm-ds .pm-leg button:focus-visible{box-shadow:var(--glow)}
125
+ .pm-ds .pm-leg button[aria-pressed="false"]{color:var(--muted);text-decoration:line-through}
126
+ .pm-ds .pm-leg i{width:10px;height:3px;border-radius:2px;display:inline-block}
127
+ .pm-ds .pm-pick{margin-top:8px;font-size:13px;color:var(--muted);min-height:20px}
128
+ .pm-ds .pm-pick a{color:var(--blue);font-weight:600}
129
+ .pm-ds .pm-bar span{cursor:pointer;transition:filter var(--duration-quick)}
130
+ .pm-ds .pm-bar span:hover{filter:brightness(1.12)}
131
+ .pm-ds .pm-table th[aria-sort]{cursor:pointer;user-select:none}
132
+ .pm-ds .pm-table th[aria-sort]:hover{color:var(--ink)}
133
+ .pm-ds .pm-table th[aria-sort="ascending"]::after{content:" ↑"}
134
+ .pm-ds .pm-table th[aria-sort="descending"]::after{content:" ↓"}
135
+ .pm-ds .pm-table tr.sel td{background:var(--leaf-tint)}
136
+ .pm-ds .pm-li.gone{opacity:0;transform:translateX(12px);transition:opacity var(--duration-enter) var(--ease-out),transform var(--duration-enter) var(--ease-out)}
137
+ @media (prefers-reduced-motion:reduce) {
138
+ .pm-ds .pm-chart path.line, .pm-ds .pm-li.gone, .pm-ds .pm-tip{transition:none}
139
+ }
140
+ .pm-ds .pm-tip{left:var(--pm-tip-x,0);top:var(--pm-tip-y,0)}
141
+ .pm-ds .pm-leg i.pm-sw-blue{background:var(--blue)}
142
+ .pm-ds .pm-leg i.pm-sw-leaf{background:var(--leaf)}
143
+ .pm-ds .pm-leg i.pm-sw-muted{background:var(--muted)}
144
+ .pm-ds .pm-leg i.pm-sw-alert{background:var(--alert)}
145
+ .pm-ds .pm-chart-head:empty{display:none}
@@ -0,0 +1,240 @@
1
+ /* komorebi.js — how the PMOS design system's parts respond (design-system/interactions.md; Chart and Table READMEs, v4 2026-11-19).
2
+ * The look is pm/komorebi.css; this is the behaviour, the same on every page so people learn it once.
3
+ *
4
+ * chart(el, data, { onPick }) an interactive chart inside el (class pm-chart lives inside):
5
+ * hover or touch → crosshair and a tooltip with the exact value, the date and the change against the plan;
6
+ * click a point → onPick({ range, index, date, value }) opens the items behind it beside the chart, the point stays lit;
7
+ * click a series label → show or hide that series (one always stays); range Tabs → the line redraws in place;
8
+ * keyboard: Left and Right read each point, Enter opens it, Esc clears.
9
+ * data: { answer, unit, ranges: [{ id, label, dates: [], series: [{ id, label, role: 'blue'|'leaf'|'muted'|'alert', values: [], plan? }] }] }
10
+ * A series with plan: true is the one the others are compared with. No data → one quiet line, never an empty chart.
11
+ * table(el, { onOpen, onSelect }) a sortable table (a th with data-k sorts by that column of each row's data-v JSON array);
12
+ * click a row → onOpen(tr), Shift-click picks several → onSelect([tr]).
13
+ *
14
+ * Clicks are delegated from the document (one listener for every part on the page), so the parts carry no handlers of their own and a
15
+ * part drawn later works the same. The pure helpers (geometry, tooltip, keys, sort, legend) are exported for komorebi.test.mjs. */
16
+
17
+ const W = 600, H = 150, BASE = 140, TOP = 10;
18
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
19
+ const ROLE = { blue: 'var(--blue)', leaf: 'var(--leaf)', muted: 'var(--muted)', alert: 'var(--alert)' };
20
+
21
+ /* ── pure ── */
22
+
23
+ /** The x of point i of n across the chart's width. */
24
+ export const xOf = (i, n) => (n < 2 ? W / 2 : (i * W) / (n - 1));
25
+ /** A y scale for every visible series of a range: 0 at the base line, the highest value near the top. */
26
+ export function yScale(series) {
27
+ const max = Math.max(1, ...series.flatMap((s) => s.values.filter((v) => Number.isFinite(v))));
28
+ return (v) => +(BASE - (v / max) * (BASE - TOP)).toFixed(1);
29
+ }
30
+ /** The SVG path of one series. */
31
+ export function pathOf(values, y) {
32
+ return values.map((v, i) => (i ? 'L' : 'M') + xOf(i, values.length).toFixed(1) + ' ' + y(v)).join(' ');
33
+ }
34
+ /** The series the tooltip reads: the first visible one that is not the plan. */
35
+ export const readOf = (range, hidden) => range.series.find((s) => !s.plan && !hidden.has(s.id)) || range.series.find((s) => !hidden.has(s.id));
36
+ /** The tooltip of point i: "<b>13 done</b> · 19 Nov · +4 vs plan". */
37
+ export function tipOf(range, i, { unit = '', hidden = new Set() } = {}) {
38
+ const s = readOf(range, hidden);
39
+ if (!s) return '';
40
+ const v = s.values[i], plan = range.series.find((x) => x.plan && x !== s && !hidden.has(x.id));
41
+ let t = `<b>${esc(v)}${unit ? ' ' + esc(unit) : ''}</b> · ${esc(range.dates[i])}`;
42
+ if (plan && Number.isFinite(plan.values[i])) { const d = v - plan.values[i]; t += ` · ${d >= 0 ? '+' : ''}${d} vs ${esc(plan.label.toLowerCase())}`; }
43
+ return t;
44
+ }
45
+ /** A key on a focused chart → { hov, act }: act is 'pick', 'clear' or null. hov -1 means nothing is read. */
46
+ export function keyOf(key, hov, n) {
47
+ if (!n) return { hov: -1, act: null };
48
+ if (key === 'ArrowRight') return { hov: hov < 0 ? 0 : Math.min(n - 1, hov + 1), act: null };
49
+ if (key === 'ArrowLeft') return { hov: hov < 0 ? n - 1 : Math.max(0, hov - 1), act: null };
50
+ if (key === 'Home') return { hov: 0, act: null };
51
+ if (key === 'End') return { hov: n - 1, act: null };
52
+ if (key === 'Enter' && hov >= 0) return { hov, act: 'pick' };
53
+ if (key === 'Escape') return { hov: -1, act: 'clear' };
54
+ return { hov, act: null };
55
+ }
56
+ /** Show or hide one series; the last one shown stays. → the new hidden set. */
57
+ export function toggleSeries(ids, hidden, id) {
58
+ const next = new Set(hidden);
59
+ if (next.has(id)) next.delete(id);
60
+ else if (ids.filter((x) => !next.has(x)).length > 1) next.add(id);
61
+ return next;
62
+ }
63
+ /** Rows sorted by column k of their values: numbers as numbers, the rest as words. Stable. */
64
+ export function sortRows(rows, k, asc) {
65
+ const val = (r) => (r.v || [])[k];
66
+ return rows.map((r, i) => [r, i]).sort(([a, i], [b, j]) => {
67
+ const x = val(a), y = val(b);
68
+ const nx = x !== '' && x != null && !isNaN(x), ny = y !== '' && y != null && !isNaN(y);
69
+ const c = nx && ny ? Number(x) - Number(y) : String(x == null ? '' : x).localeCompare(String(y == null ? '' : y));
70
+ return (asc ? c : -c) || i - j;
71
+ }).map(([r]) => r);
72
+ }
73
+ /** A heading pressed: its next order. */
74
+ export const nextSort = (cur) => (cur === 'ascending' ? 'descending' : 'ascending');
75
+
76
+ /** The chart's markup: tabs (more than one range), legend (more than one series), the chart, the pick line. Empty → one quiet line. */
77
+ export function chartHtml(data, st) {
78
+ const range = (data.ranges || []).find((r) => r.id === st.range) || (data.ranges || [])[0];
79
+ if (!range || !range.series.length || !range.dates.length) return `<p class="pm-meta">${esc(data.empty || 'Nothing to show yet.')}</p>`;
80
+ const tabs = data.ranges.length > 1
81
+ ? `<div class="pm-tabs" role="tablist" aria-label="Range">${data.ranges.map((r) => `<button type="button" class="pm-tab" role="tab" data-pm-range="${esc(r.id)}" aria-selected="${r.id === range.id}">${esc(r.label)}</button>`).join('')}</div>`
82
+ : '';
83
+ const leg = range.series.length > 1
84
+ ? `<div class="pm-leg">${range.series.map((s) => `<button type="button" data-pm-series="${esc(s.id)}" aria-pressed="${!st.hidden.has(s.id)}"><i class="pm-sw-${esc(s.role || 'blue')}"></i>${esc(s.label)}</button>`).join('')}</div>`
85
+ : '';
86
+ const shown = range.series.filter((s) => !st.hidden.has(s.id)), y = yScale(shown.length ? shown : range.series), n = range.dates.length, w = n > 1 ? W / (n - 1) : W;
87
+ const read = readOf(range, st.hidden);
88
+ const lines = range.series.map((s) => {
89
+ const off = st.hidden.has(s.id) ? ' off' : '', col = ROLE[s.role] || ROLE.blue;
90
+ const pts = s === read ? `<g class="pts">${s.values.map((v, i) => `<circle class="pt${i === st.sel ? ' on' : ''}" cx="${xOf(i, n)}" cy="${y(v)}" r="${i === st.sel || i === st.hov ? 6 : 3.5}"></circle>`).join('')}</g>` : '';
91
+ return `<g class="series${off}" data-s="${esc(s.id)}"><path class="line" d="${pathOf(s.values, y)}" fill="none" stroke="${col}" stroke-width="${s.plan ? 2 : 2.5}"${s.plan ? ' stroke-dasharray="4 4"' : ''} stroke-linejoin="round"></path>${pts}</g>`;
92
+ }).join('');
93
+ const hits = range.dates.map((_, i) => `<rect class="hit" data-pm-i="${i}" x="${xOf(i, n) - w / 2}" y="0" width="${w}" height="${H}"></rect>`).join('');
94
+ const xh = st.hov >= 0 ? xOf(st.hov, n) : 0;
95
+ const pick = st.sel >= 0 && read
96
+ ? `<a href="#" data-pm-open="${st.sel}">${esc(read.values[st.sel])}${data.unit ? ' ' + esc(data.unit) : ''} on ${esc(range.dates[st.sel])}</a> open beside the chart · Esc clears`
97
+ : 'Hover a point for its numbers. Click to open its items.';
98
+ return `<div class="pm-row pm-chart-head">${tabs}</div>${leg}`
99
+ + `<div class="pm-chart" tabindex="0" role="img" aria-label="${esc(data.answer || '')} Use Left and Right to read each point.">`
100
+ + `<svg width="100%" height="${H}" viewBox="0 0 ${W} ${H}" preserveAspectRatio="none" aria-hidden="true"><line x1="0" x2="${W}" y1="${BASE}" y2="${BASE}" stroke="var(--line)"></line>${lines}`
101
+ + `<line class="xh${st.hov >= 0 ? ' on' : ''}" x1="${xh}" x2="${xh}" y1="0" y2="${BASE}"></line><g class="hits">${hits}</g></svg>`
102
+ + `<div class="pm-tip${st.hov >= 0 ? ' on' : ''}" role="status">${st.hov >= 0 ? tipOf(range, st.hov, { unit: data.unit, hidden: st.hidden }) : ''}</div></div>`
103
+ + `<div class="pm-pick">${pick}</div>`;
104
+ }
105
+
106
+ /* ── the DOM ── */
107
+
108
+ const charts = new WeakMap(); // the element → { data, st, onPick }
109
+ const tables = new WeakMap(); // the table → { onOpen, onSelect }
110
+
111
+ function rangeOf(c) { return c.data.ranges.find((r) => r.id === c.st.range) || c.data.ranges[0]; }
112
+ // the first draw (and a change of shape) writes the markup; every later change patches it in place, so the line redraws in
113
+ // duration-enter instead of jumping and the focus stays where it is
114
+ function render(el) {
115
+ const c = charts.get(el); if (!c) return;
116
+ const r = rangeOf(c), shape = r ? c.data.ranges.map((x) => x.id).join('|') + '/' + r.series.map((x) => x.id).join('|') + '/' + r.dates.length : '';
117
+ if (!el.querySelector('.pm-chart') || el.dataset.pmShape !== shape) {
118
+ const focused = el.contains(document.activeElement) && document.activeElement.classList.contains('pm-chart');
119
+ el.innerHTML = chartHtml(c.data, c.st);
120
+ el.dataset.pmShape = shape;
121
+ if (focused) { const f = el.querySelector('.pm-chart'); if (f) f.focus(); }
122
+ } else {
123
+ const fresh = document.createElement('div');
124
+ fresh.innerHTML = chartHtml(c.data, c.st);
125
+ for (const t of el.querySelectorAll('[data-pm-range]')) t.setAttribute('aria-selected', String(t.dataset.pmRange === r.id));
126
+ for (const b of el.querySelectorAll('[data-pm-series]')) b.setAttribute('aria-pressed', String(!c.st.hidden.has(b.dataset.pmSeries)));
127
+ for (const g of el.querySelectorAll('.series')) {
128
+ const ng = fresh.querySelector(`.series[data-s="${g.dataset.s}"]`); if (!ng) continue;
129
+ g.setAttribute('class', ng.getAttribute('class'));
130
+ g.querySelector('path.line').setAttribute('d', ng.querySelector('path.line').getAttribute('d'));
131
+ const pts = g.querySelector('.pts'), npts = ng.querySelector('.pts');
132
+ if (pts && npts) pts.innerHTML = npts.innerHTML; else if (pts) pts.remove(); else if (npts) g.appendChild(npts);
133
+ }
134
+ for (const k of ['.xh', '.hits', '.pm-tip', '.pm-pick']) {
135
+ const a = el.querySelector(k), b = fresh.querySelector(k); if (!a || !b) continue;
136
+ for (const at of [...b.attributes]) a.setAttribute(at.name, at.value);
137
+ a.innerHTML = b.innerHTML;
138
+ }
139
+ el.querySelector('.pm-chart').setAttribute('aria-label', fresh.querySelector('.pm-chart').getAttribute('aria-label'));
140
+ }
141
+ place(el);
142
+ }
143
+ // the tooltip sits above the point and never covers it, inside the chart's width
144
+ function place(el) {
145
+ const c = charts.get(el), tip = el.querySelector('.pm-tip'), box = el.querySelector('.pm-chart');
146
+ if (!c || !tip || !box || c.st.hov < 0) return;
147
+ const r = rangeOf(c), n = r.dates.length, bw = box.clientWidth || W, tw = tip.offsetWidth || 190;
148
+ const read = readOf(r, c.st.hidden), y = yScale(r.series.filter((s) => !c.st.hidden.has(s.id)));
149
+ const px = (xOf(c.st.hov, n) / W) * bw;
150
+ tip.style.setProperty('--pm-tip-x', Math.max(0, Math.min(bw - tw, px - tw / 2)) + 'px');
151
+ tip.style.setProperty('--pm-tip-y', Math.max(0, (read ? y(read.values[c.st.hov]) : BASE) - 44) + 'px');
152
+ }
153
+ function hover(el, i) {
154
+ const c = charts.get(el); if (!c || c.st.hov === i) return;
155
+ c.st.hov = i; render(el);
156
+ }
157
+ function choose(el, i) {
158
+ const c = charts.get(el); if (!c) return;
159
+ c.st.sel = i; render(el);
160
+ const r = rangeOf(c), read = readOf(r, c.st.hidden);
161
+ if (i >= 0 && c.onPick) c.onPick({ range: r.id, index: i, date: r.dates[i], value: read ? read.values[i] : null });
162
+ }
163
+
164
+ /** Draw an interactive chart in el. Calling it again with new data redraws in place and keeps the range and the hidden series. */
165
+ export function chart(el, data, { onPick } = {}) {
166
+ const prev = charts.get(el);
167
+ const st = prev ? prev.st : { range: ((data.ranges || [])[0] || {}).id, hidden: new Set(), hov: -1, sel: -1 };
168
+ if (!(data.ranges || []).some((r) => r.id === st.range)) st.range = ((data.ranges || [])[0] || {}).id;
169
+ charts.set(el, { data, st, onPick });
170
+ el.classList.add('pm-chart-box');
171
+ if (!prev) {
172
+ el.addEventListener('mousemove', (e) => { const t = e.target.closest('.hit'); if (t) hover(el, +t.dataset.pmI); });
173
+ el.addEventListener('mouseleave', () => hover(el, -1));
174
+ // phones: press and drag along the chart to scrub, lift to keep the last value shown
175
+ el.addEventListener('touchmove', (e) => {
176
+ const t = e.touches[0], at = t && document.elementFromPoint(t.clientX, t.clientY), h = at && at.closest && at.closest('.hit');
177
+ if (h && el.contains(h)) { hover(el, +h.dataset.pmI); e.preventDefault(); }
178
+ }, { passive: false });
179
+ el.addEventListener('keydown', (e) => {
180
+ if (!e.target.classList.contains('pm-chart')) return;
181
+ const c = charts.get(el), k = keyOf(e.key, c.st.hov, rangeOf(c).dates.length);
182
+ if (k.hov === c.st.hov && !k.act) return;
183
+ e.preventDefault();
184
+ if (k.act === 'clear') { c.st.hov = -1; choose(el, -1); return; }
185
+ hover(el, k.hov);
186
+ if (k.act === 'pick') choose(el, k.hov);
187
+ });
188
+ el.addEventListener('focusout', (e) => { if (!el.contains(e.relatedTarget)) hover(el, -1); });
189
+ }
190
+ render(el);
191
+ return el;
192
+ }
193
+
194
+ /** Make a pm-table sortable and its rows openable and pickable. */
195
+ export function table(el, { onOpen, onSelect } = {}) {
196
+ tables.set(el, { onOpen, onSelect });
197
+ for (const th of el.querySelectorAll('th[data-k]')) if (!th.hasAttribute('aria-sort')) th.setAttribute('aria-sort', 'none');
198
+ for (const th of el.querySelectorAll('th[data-k]')) th.tabIndex = 0;
199
+ return el;
200
+ }
201
+ function sortBy(el, th) {
202
+ const order = nextSort(th.getAttribute('aria-sort'));
203
+ for (const x of el.querySelectorAll('th[data-k]')) x.setAttribute('aria-sort', 'none');
204
+ th.setAttribute('aria-sort', order);
205
+ const tb = el.tBodies[0]; if (!tb) return;
206
+ const rows = [...tb.rows].map((tr) => { let v = []; try { v = JSON.parse(tr.dataset.v || '[]'); } catch { /* a row with no values sorts last */ } return { tr, v }; });
207
+ for (const r of sortRows(rows, +th.dataset.k, order === 'ascending')) tb.appendChild(r.tr);
208
+ }
209
+
210
+ // one listener for every part on the page (none in node, where komorebi.test.mjs reads the pure helpers)
211
+ if (typeof document !== 'undefined') document.addEventListener('click', (e) => {
212
+ const box = e.target.closest('.pm-chart-box');
213
+ if (box && charts.has(box)) {
214
+ const c = charts.get(box);
215
+ const tab = e.target.closest('[data-pm-range]');
216
+ if (tab) { c.st.range = tab.dataset.pmRange; c.st.hov = -1; c.st.sel = -1; render(box); return; }
217
+ const leg = e.target.closest('[data-pm-series]');
218
+ if (leg) { c.st.hidden = toggleSeries(rangeOf(c).series.map((s) => s.id), c.st.hidden, leg.dataset.pmSeries); render(box); return; }
219
+ const open = e.target.closest('[data-pm-open]');
220
+ if (open) { e.preventDefault(); choose(box, +open.dataset.pmOpen); return; }
221
+ const hit = e.target.closest('.hit');
222
+ if (hit) { choose(box, +hit.dataset.pmI); return; }
223
+ }
224
+ const tbl = e.target.closest('table.pm-table');
225
+ if (tbl && tables.has(tbl)) {
226
+ const t = tables.get(tbl), th = e.target.closest('th[data-k]');
227
+ if (th) { sortBy(tbl, th); return; }
228
+ const tr = e.target.closest('tbody tr');
229
+ if (!tr) return;
230
+ if (!e.shiftKey) for (const x of tbl.tBodies[0].rows) if (x !== tr) x.classList.remove('sel');
231
+ tr.classList.toggle('sel');
232
+ const picked = [...tbl.querySelectorAll('tbody tr.sel')];
233
+ if (picked.length > 1 && t.onSelect) t.onSelect(picked);
234
+ else if (picked.length === 1 && t.onOpen) t.onOpen(tr);
235
+ }
236
+ });
237
+ if (typeof document !== 'undefined') document.addEventListener('keydown', (e) => {
238
+ const th = e.target.closest && e.target.closest('table.pm-table th[data-k]');
239
+ if (th && (e.key === 'Enter' || e.key === ' ') && tables.has(th.closest('table'))) { e.preventDefault(); sortBy(th.closest('table'), th); }
240
+ });
@@ -154,7 +154,8 @@ const WIDE = new Set([
154
154
  * the 60 workspace commits before 2026-10-23 ran the whole browser group. traceChanges() follows a change along the edges
155
155
  * a suite depends on, and falls back to every suite wherever it cannot tell. The rule, by kind of file:
156
156
  *
157
- * - A suite: that suite. A WIDE file: every suite. Prose (guide/, docs/, *.md) and test-timings.json: nothing.
157
+ * - A suite: that suite. A WIDE file: every suite. Prose (guide/, docs/, *.md) and test-timings.json: nothing. A file under
158
+ * design-system/ (data that lib/design-system.js reads): the suites that name design-system.
158
159
  * - public/, and a lib/ file the server hands to the browser as /lib/<name>.js: the pages that load the file, read from
159
160
  * the import graph of each public/*.html (static and dynamic imports and every '/pm/…' or './…' string, comments
160
161
  * removed, so it reads MORE edges than the browser follows, never fewer), then every browser suite that opens one of
@@ -678,6 +679,10 @@ function traceChanges(changes, ctx) {
678
679
  }
679
680
  if (/^(guide|docs)\/|\.md$/.test(f)) continue; // prose: no suite asserts on it except guide.test.js, a unit suite
680
681
  if (f === 'test-timings.json') continue; // run order only: no suite reads it
682
+ if (/^design-system\//.test(f)) { // the design system's files are data: lib/design-system.js reads them, and the suites that name the folder check them
683
+ for (const s of list) if ((get(s) || '').includes('design-system')) picked.add(s);
684
+ continue;
685
+ }
681
686
  if (/^skills\/[^/]+\.skill$/.test(f) && get(f) != null) {
682
687
  // a built-in skill is prose an agent reads: a suite reads it by its name, or loads the whole folder
683
688
  nameHits(f).forEach((s) => picked.add(s));
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "The PMOS UI design system (2026-11-19): the generated workspace sheet, the prototype scaffold and the kit copy (lib/design-system.js). Pure file reads, no server.",
3
+ "modules": [
4
+ "design-system.test.js"
5
+ ],
6
+ "seconds": {
7
+ "design-system.test.js": 1
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "The design system's parts respond (pm/komorebi.js): chart tooltip, keys, legend and ranges, table sort. Pure, in node, no browser.",
3
+ "modules": [
4
+ "komorebi.test.mjs"
5
+ ],
6
+ "seconds": {
7
+ "komorebi.test.mjs": 1
8
+ }
9
+ }