create-pmos 0.634.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.
- package/bin/create-pmos.js +1 -0
- package/package.json +22 -22
- package/payload/KIT-VERSION +2 -2
- package/payload/README.md +37 -113
- package/payload/design-system/README.md +98 -0
- package/payload/design-system/components/Badge/README.md +16 -0
- package/payload/design-system/components/Badge/preview.html +8 -0
- package/payload/design-system/components/Button/README.md +20 -0
- package/payload/design-system/components/Button/preview.html +8 -0
- package/payload/design-system/components/Calendar/README.md +14 -0
- package/payload/design-system/components/Calendar/preview.html +11 -0
- package/payload/design-system/components/Chart/README.md +24 -0
- package/payload/design-system/components/Chart/preview.html +50 -0
- package/payload/design-system/components/Conversation/README.md +14 -0
- package/payload/design-system/components/Conversation/preview.html +8 -0
- package/payload/design-system/components/Detail/README.md +17 -0
- package/payload/design-system/components/Detail/preview.html +8 -0
- package/payload/design-system/components/Document/README.md +15 -0
- package/payload/design-system/components/Document/preview.html +8 -0
- package/payload/design-system/components/Event/README.md +13 -0
- package/payload/design-system/components/Event/preview.html +8 -0
- package/payload/design-system/components/Field/README.md +13 -0
- package/payload/design-system/components/Field/preview.html +8 -0
- package/payload/design-system/components/Icon/README.md +12 -0
- package/payload/design-system/components/Icon/preview.html +8 -0
- package/payload/design-system/components/Input/README.md +17 -0
- package/payload/design-system/components/Input/preview.html +8 -0
- package/payload/design-system/components/List/README.md +21 -0
- package/payload/design-system/components/List/preview.html +15 -0
- package/payload/design-system/components/ListRow/README.md +19 -0
- package/payload/design-system/components/ListRow/preview.html +8 -0
- package/payload/design-system/components/MainItem/README.md +13 -0
- package/payload/design-system/components/MainItem/preview.html +8 -0
- package/payload/design-system/components/MainSide/README.md +12 -0
- package/payload/design-system/components/MainSide/preview.html +8 -0
- package/payload/design-system/components/Menu/README.md +13 -0
- package/payload/design-system/components/Menu/preview.html +8 -0
- package/payload/design-system/components/Navigation/README.md +14 -0
- package/payload/design-system/components/Navigation/preview.html +8 -0
- package/payload/design-system/components/Number/README.md +17 -0
- package/payload/design-system/components/Number/preview.html +8 -0
- package/payload/design-system/components/Settings/README.md +13 -0
- package/payload/design-system/components/Settings/preview.html +10 -0
- package/payload/design-system/components/SingleColumn/README.md +12 -0
- package/payload/design-system/components/SingleColumn/preview.html +8 -0
- package/payload/design-system/components/Stage/README.md +13 -0
- package/payload/design-system/components/Stage/preview.html +8 -0
- package/payload/design-system/components/Suggestion/README.md +14 -0
- package/payload/design-system/components/Suggestion/preview.html +10 -0
- package/payload/design-system/components/Summary/README.md +19 -0
- package/payload/design-system/components/Summary/preview.html +10 -0
- package/payload/design-system/components/Switch/README.md +13 -0
- package/payload/design-system/components/Switch/preview.html +10 -0
- package/payload/design-system/components/Table/README.md +18 -0
- package/payload/design-system/components/Table/preview.html +23 -0
- package/payload/design-system/components/Tabs/README.md +13 -0
- package/payload/design-system/components/Tabs/preview.html +11 -0
- package/payload/design-system/components/Timeline/README.md +15 -0
- package/payload/design-system/components/Timeline/preview.html +8 -0
- package/payload/design-system/components/Toast/README.md +14 -0
- package/payload/design-system/components/Toast/preview.html +8 -0
- package/payload/design-system/components/TodayPage/README.md +12 -0
- package/payload/design-system/components/TodayPage/preview.html +8 -0
- package/payload/design-system/components/bundle.css +126 -0
- package/payload/design-system/interactions.md +48 -0
- package/payload/design-system/pages.md +34 -0
- package/payload/design-system/tokens.css +9 -0
- package/payload/design-system/tokens.json +339 -0
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/workspace/changelog.json +21 -2
- package/workspace/ci-checks.sh +3 -0
- package/workspace/design-system/README.md +98 -0
- package/workspace/design-system/components/Badge/README.md +16 -0
- package/workspace/design-system/components/Badge/preview.html +8 -0
- package/workspace/design-system/components/Button/README.md +20 -0
- package/workspace/design-system/components/Button/preview.html +8 -0
- package/workspace/design-system/components/Calendar/README.md +14 -0
- package/workspace/design-system/components/Calendar/preview.html +11 -0
- package/workspace/design-system/components/Chart/README.md +24 -0
- package/workspace/design-system/components/Chart/preview.html +50 -0
- package/workspace/design-system/components/Conversation/README.md +14 -0
- package/workspace/design-system/components/Conversation/preview.html +8 -0
- package/workspace/design-system/components/Detail/README.md +17 -0
- package/workspace/design-system/components/Detail/preview.html +8 -0
- package/workspace/design-system/components/Document/README.md +15 -0
- package/workspace/design-system/components/Document/preview.html +8 -0
- package/workspace/design-system/components/Event/README.md +13 -0
- package/workspace/design-system/components/Event/preview.html +8 -0
- package/workspace/design-system/components/Field/README.md +13 -0
- package/workspace/design-system/components/Field/preview.html +8 -0
- package/workspace/design-system/components/Icon/README.md +12 -0
- package/workspace/design-system/components/Icon/preview.html +8 -0
- package/workspace/design-system/components/Input/README.md +17 -0
- package/workspace/design-system/components/Input/preview.html +8 -0
- package/workspace/design-system/components/List/README.md +21 -0
- package/workspace/design-system/components/List/preview.html +15 -0
- package/workspace/design-system/components/ListRow/README.md +19 -0
- package/workspace/design-system/components/ListRow/preview.html +8 -0
- package/workspace/design-system/components/MainItem/README.md +13 -0
- package/workspace/design-system/components/MainItem/preview.html +8 -0
- package/workspace/design-system/components/MainSide/README.md +12 -0
- package/workspace/design-system/components/MainSide/preview.html +8 -0
- package/workspace/design-system/components/Menu/README.md +13 -0
- package/workspace/design-system/components/Menu/preview.html +8 -0
- package/workspace/design-system/components/Navigation/README.md +14 -0
- package/workspace/design-system/components/Navigation/preview.html +8 -0
- package/workspace/design-system/components/Number/README.md +17 -0
- package/workspace/design-system/components/Number/preview.html +8 -0
- package/workspace/design-system/components/Settings/README.md +13 -0
- package/workspace/design-system/components/Settings/preview.html +10 -0
- package/workspace/design-system/components/SingleColumn/README.md +12 -0
- package/workspace/design-system/components/SingleColumn/preview.html +8 -0
- package/workspace/design-system/components/Stage/README.md +13 -0
- package/workspace/design-system/components/Stage/preview.html +8 -0
- package/workspace/design-system/components/Suggestion/README.md +14 -0
- package/workspace/design-system/components/Suggestion/preview.html +10 -0
- package/workspace/design-system/components/Summary/README.md +19 -0
- package/workspace/design-system/components/Summary/preview.html +10 -0
- package/workspace/design-system/components/Switch/README.md +13 -0
- package/workspace/design-system/components/Switch/preview.html +10 -0
- package/workspace/design-system/components/Table/README.md +18 -0
- package/workspace/design-system/components/Table/preview.html +23 -0
- package/workspace/design-system/components/Tabs/README.md +13 -0
- package/workspace/design-system/components/Tabs/preview.html +11 -0
- package/workspace/design-system/components/Timeline/README.md +15 -0
- package/workspace/design-system/components/Timeline/preview.html +8 -0
- package/workspace/design-system/components/Toast/README.md +14 -0
- package/workspace/design-system/components/Toast/preview.html +8 -0
- package/workspace/design-system/components/TodayPage/README.md +12 -0
- package/workspace/design-system/components/TodayPage/preview.html +8 -0
- package/workspace/design-system/components/bundle.css +126 -0
- package/workspace/design-system/interactions.md +48 -0
- package/workspace/design-system/pages.md +34 -0
- package/workspace/design-system/tokens.css +9 -0
- package/workspace/design-system/tokens.json +339 -0
- package/workspace/guide/agent-capabilities.md +2 -2
- package/workspace/guide/layout.md +7 -1
- package/workspace/lib/design-system.js +145 -0
- package/workspace/lib/idle-lab-engine.js +5 -1
- package/workspace/lib/live-round.js +15 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-today-model.js +53 -4
- package/workspace/public/pm/komorebi.css +145 -0
- package/workspace/public/pm/komorebi.js +240 -0
- package/workspace/run-tests.js +6 -1
- package/workspace/test-lists/design-system.json +9 -0
- package/workspace/test-lists/komorebi.json +9 -0
|
@@ -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) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[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
|
+
});
|
package/workspace/run-tests.js
CHANGED
|
@@ -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
|
+
}
|