create-pmos 0.655.0 → 0.657.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.
@@ -1,66 +1,65 @@
1
- /* cozy-goals.css — Goals' own layout (initiative goals-place, slice 9; boards 8, 13, 31, 32, 33), on the PMOS design system.
2
- * The look is the system's parts (pm/komorebi.css, scope .pm-ds: pm-block, pm-table, pm-sug, pm-menu, pm-btn, pm-chip, pm-badge); this file only
3
- * places them and names no colour, size or radius of its own: every colour, space, radius and shadow is a system token (design-system/ui/README.md) and every type size a role token, the same 26/18/15/13 scale. The shared shell
4
- * (cozy.css: the panel, the rail) is not restyled here. The popup pages (pm/goals-open.js) use the popup's .pw classes (cozy-pop-work.css);
5
- * their few extra rules are at the end. */
1
+ /* cozy-goals.css — Goals' own layout, rebuilt from design system blocks (initiative goals-ds-page; board GoalsDS on Exploring 3, page "pages").
2
+ * The look is the system's parts (pm/komorebi.css, scope .pm-ds: pm-path, pm-chip, pm-block, pm-sug x, pm-num, pm-tabs, pm-table, pm-group,
3
+ * pm-badge, pm-menu, pm-btn); this file only places them and names no colour, size or radius of its own: every colour, space, radius and shadow
4
+ * is a system token (design-system/ui/README.md). The shared shell (cozy.css: the panel, the rail) is not restyled here. The popup pages
5
+ * (pm/goals-open.js) use the popup's .pw classes (cozy-pop-work.css); their few extra rules are at the end. */
6
6
  .gl-page .vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
7
7
  .gl { display: flex; flex-direction: column; gap: var(--space-16); color: var(--ink); }
8
- .gl-bar { min-height: 44px; flex-wrap: nowrap; }
9
- .gl-ttl { margin-right: var(--space-4); }
8
+ .gl-bar { min-height: 44px; flex-wrap: nowrap; gap: var(--space-12); }
10
9
  .gl-sp { flex: 1; }
11
- .gl-per { gap: 6px; white-space: nowrap; }
12
10
  .gl-per[hidden] { display: none; }
13
- .gl-per .pm-ic { width: 14px; height: 14px; }
14
- .gl-pers { color: var(--muted); }
15
11
  #glMore .pm-ic { stroke-width: 3; }
16
12
  .gl-mw { position: relative; display: inline-flex; }
17
- .gl-fdot { position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: var(--radius-pill); background: var(--blue); }
18
13
  .gl-menu { position: absolute; top: 100%; right: 0; z-index: 30; margin-top: var(--space-4); }
19
14
  .gl-menu[hidden] { display: none; }
20
15
  .gl-menu button[aria-checked="true"] { font-weight: var(--fw-strong); }
21
16
  .gl-menu button[aria-checked="true"]::after { content: "✓"; margin-left: auto; color: var(--blue); }
22
- .gl-p { display: flex; flex-direction: column; gap: var(--space-12); }
17
+
18
+ /* one column of blocks (GoalsDS: single column, 1080 wide at most) */
19
+ .gl-col { width: 100%; max-width: 1080px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--space-16); }
20
+ #glBody, .gl-p { display: flex; flex-direction: column; gap: var(--space-16); }
23
21
  .gl-p + .gl-p { margin-top: var(--space-16); }
24
22
  .gl-m0 { margin: 0; }
25
- .gl-al { color: var(--alert); }
26
-
27
- /* the hierarchy: one pm-table; an objective's name, levers and initiatives span its key results' rows */
28
- .gl-tb { overflow-x: auto; }
29
- .gl-tb .pm-table { font-size: var(--fs-row); }
30
- .gl-tb .pm-table thead th { font-size: var(--fs-meta); white-space: nowrap; background: var(--well); }
31
- .gl-tb .pm-table tbody + tbody tr.gl-first > * { border-top: 1px solid var(--line); }
32
- .gl-tb .pm-table td, .gl-tb .pm-table tbody th { vertical-align: top; padding-top: 12px; padding-bottom: 12px; }
33
- .gl-tb .pm-table tr:hover td { background: none; }
34
- .gl-tb .pm-table th.gl-obj { width: 120px; text-align: left; font-weight: var(--fw-regular); color: var(--ink); padding-top: 12px; }
35
- .gl-obj > *, .gl-lv > div > *, .gl-wide > * { display: block; }
36
- .gl-obj .pm-badge { display: inline-flex; margin-top: var(--space-4); }
37
- .gl-lv > div + div { margin-top: var(--space-8); }
38
- .gl-lv b, .gl-wide b, .gl-obj b { font-weight: var(--fw-strong); }
39
- .gl-act { width: 128px; white-space: nowrap; }
40
- .gl-left { width: 84px; white-space: nowrap; }
41
- .gl-lv { width: 18%; }
42
- .gl-in { width: 24%; }
43
- .gl-inis { display: flex; flex-direction: column; gap: var(--space-4); }
44
- /* a key result and an initiative are buttons inside their cell: the row hover of the system, the system's focus ring */
45
- .gl-hit { all: unset; box-sizing: border-box; width: 100%; display: flex; flex-direction: column; gap: 2px; padding: var(--space-4) var(--space-8); margin: calc(-1 * var(--space-4)) calc(-1 * var(--space-8)); border-radius: var(--radius-md); cursor: pointer; transition: background var(--duration-quick) var(--ease-out); }
46
- .gl-hit:hover { background: var(--well); }
47
- .gl-hit:focus-visible { box-shadow: var(--glow); }
48
- .gl-hit b { font-weight: var(--fw-strong); }
49
- .gl-hit > .pm-meta { display: flex; align-items: center; gap: 6px; }
50
- .gl-kr .gl-hit > span:first-child { font-weight: var(--fw-strong); }
51
- .gl-tok { margin-right: 6px; font-weight: var(--fw-regular); }
52
- .gl-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
53
- /* an outcome's check date: a small diamond, alert once it is overdue */
54
- .gl-dm { width: 8px; height: 8px; transform: rotate(45deg); border: 2px solid var(--muted); border-radius: 2px; display: inline-block; flex: none; }
55
- .gl-dm.rd { border-color: var(--alert); }
56
- .gl-n { margin: 0 var(--space-4); }
57
- .gl-n[hidden] { display: none; }
58
- .gl-n a { color: inherit; }
23
+ .gl-al, .gl-al a { color: var(--alert); }
59
24
  .gl-none { padding: var(--space-24) var(--space-16); margin: 0; }
60
25
  .gl-sk { display: flex; flex-direction: column; gap: var(--space-12); }
61
26
  .gl-sk i { display: block; height: 44px; }
62
27
  .gl-sk i:first-child { height: 96px; }
63
28
 
29
+ /* North Star, input, guardrail: Number blocks side by side */
30
+ .gl-nums { display: flex; gap: var(--space-16); align-items: stretch; }
31
+ .gl-nums > .pm-block { flex: 1; min-width: 0; }
32
+ .gl-numr { gap: var(--space-16); flex-wrap: nowrap; }
33
+
34
+ /* Key results: one pm-table, its group rows the system's pm-group */
35
+ .gl-tw { overflow-x: auto; margin: 0 calc(-1 * var(--space-8)); }
36
+ .gl-krs .pm-table td, .gl-krs .pm-table th { white-space: nowrap; }
37
+ .gl-krs .pm-table tr.gl-g td { padding: 0; }
38
+ .gl-krs .pm-table tr.gl-g:hover td { background: none; }
39
+ .gl-krs .pm-group b { color: var(--ink); }
40
+ .gl-krs .pm-group span { font-weight: var(--fw-regular); }
41
+ .gl-kr { padding-left: var(--space-24) !important; }
42
+ .gl-k, .gl-kr a { color: var(--ink); font-weight: var(--fw-strong); text-decoration: none; }
43
+ .gl-k:hover, .gl-kr a:hover, .gl-mvs a:hover { text-decoration: underline; }
44
+ .gl-k:focus-visible, .gl-mvs a:focus-visible, .gl-stands a:focus-visible { outline: none; box-shadow: var(--glow); border-radius: var(--radius-sm); }
45
+ .gl-mvs { white-space: normal !important; }
46
+ .gl-mvs a { color: var(--ink); text-decoration: none; }
47
+ .gl-now { font-variant-numeric: tabular-nums; }
48
+ .gl-meter { display: inline-block; vertical-align: middle; margin-left: var(--space-8); }
49
+ .gl-lvs > span { display: block; }
50
+ .gl-end { text-align: right; }
51
+ .gl-tn { font-weight: var(--fw-regular); color: var(--muted); }
52
+
53
+ /* the Conversation: the one chat, in a block of its own height */
54
+ .gl-talk[hidden] { display: none; }
55
+ .gl-chat { height: 420px; display: flex; flex-direction: column; min-height: 0; }
56
+ .gl-chat > .pc-chat { flex: 1 1 auto; min-height: 0; }
57
+ .gl-chat > .pc-chat > .hm-reopen { display: none; }
58
+ .gl-chat.away::before { content: "The chat is open in the window beside."; color: var(--muted); font-size: var(--fs-meta); }
59
+ .gl-n { margin: 0 var(--space-4); }
60
+ .gl-n[hidden] { display: none; }
61
+ .gl-n a { color: inherit; }
62
+
64
63
  /* the popup pages (boards 31, 32, 33) */
65
64
  .gl-pg .gl-top p { margin: 4px 0 0; color: var(--muted); }
66
65
  .gl-pg .gl-top.gl-set { border-color: var(--line); }
@@ -79,25 +78,12 @@
79
78
  .gl-sg b { font-weight: var(--fw-strong); }
80
79
  .gl-sg span { font-size: var(--fs-meta); color: var(--muted); }
81
80
 
82
-
83
81
  @media (max-width: 900px) {
84
- .gl-tb .gl-lv, .gl-tb .gl-left { display: none; }
82
+ .gl-nums { flex-direction: column; }
85
83
  }
86
- /* phones: the Table becomes a List (design-system/ui/components/Table): every cell on its own line, the objective as the group heading */
84
+ /* phones: the path wraps; the Table scrolls sideways inside its block; the chat is shorter */
87
85
  @media (max-width: 760px) {
88
86
  .gl-bar { flex-wrap: wrap; }
89
- .gl-ttl, .gl-pers { display: none; }
90
- .gl-tb .pm-table, .gl-tb .pm-table tbody { display: block; }
91
- .gl-tb .pm-table thead { display: none; }
92
- .gl-tb .pm-table tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-12); padding: var(--space-8) var(--space-16); }
93
- .gl-tb .pm-table tbody tr + tr { border-top: 1px solid var(--line); }
94
- .gl-tb .pm-table tbody + tbody { border-top: 1px solid var(--line); }
95
- .gl-tb .pm-table tbody + tbody tr.gl-first > * { border-top: 0; }
96
- .gl-tb .pm-table td, .gl-tb .pm-table tbody th { display: block; border: 0; padding: var(--space-4) 0; }
97
- .gl-tb .pm-table th.gl-obj { flex: 1 1 100%; width: auto; margin: calc(-1 * var(--space-8)) calc(-1 * var(--space-16)) var(--space-4); padding: var(--space-8) var(--space-16); background: var(--well); }
98
- .gl-tb .pm-table th.gl-obj > * { display: inline; margin-right: 6px; }
99
- .gl-tb .gl-kr, .gl-tb .gl-in, .gl-tb .gl-wide { flex: 1 1 100%; width: auto; }
100
- .gl-tb .gl-act, .gl-tb .gl-left { display: inline-block; width: auto; padding: 0; }
101
- .gl-tb .gl-left { display: inline-block; }
102
- .gl-tb .gl-in:empty { display: none; }
87
+ .gl-krs .head { flex-wrap: wrap; }
88
+ .gl-chat { height: 360px; }
103
89
  }
@@ -0,0 +1,207 @@
1
+ /* pm/goals-ds.js — the blocks Goals is built from (initiative goals-ds-page; Exploring 3 page "pages", board GoalsDS; brief
2
+ * design-system/pages-rebuild/brief.md). Built only from PMOS Komorebi parts (workspace/design-system/ui). PURE: no DOM, no fetch, no clock of its
3
+ * own; `today` ('YYYY-MM-DD') comes in. The page (pm/premium-goals.js) passes one product's model and wires the presses by their data- attributes.
4
+ *
5
+ * standsOf(model, today) → [html] Where it stands: the cause, the risk and the next decision point, never counts alone
6
+ * sugOf(model, ns, dismissed) → { kind, key, title, why, will, changes, basis, say } | null the one Suggestion under it
7
+ * numbersOf(model, ns) → [{ role, name, value, at, spark, line, ns? }] North Star, input, guardrail (Number blocks)
8
+ * guessKr(title, F) → { key, token, title, words } | null the key result PMOS thinks an unlinked initiative moves, and why
9
+ * linkSay(ini, guess) → the words Link puts in the Conversation box
10
+ * paceOf(row) → [label, badge tone]
11
+ * tableHtml(p, o) → the Key results Table (pm-table in a pm-block, group rows, tabs, Choose columns)
12
+ * COLS the columns: Key result always, then Now, Pace, Moved by, Check (shown) and Left, Levers (Choose columns)
13
+ *
14
+ * NOTHING HERE MAKES A NUMBER UP (the proven-only rule of pm/goals-model.js). A sentence is made from a field of the model; a key result with
15
+ * no reading says so and what it waits on; a sparkline needs two readings. Zero is silence: nothing to say, no block. */
16
+ import * as GM from './goals-model.js';
17
+ import { sugHtml } from './bd-stands.js';
18
+
19
+ export { sugHtml };
20
+ export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
21
+ export const SV = (d, n = 16, cls = '') => `<svg class="pm-ic${cls ? ' ' + cls : ''}" width="${n}" height="${n}" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
22
+ export const I = {
23
+ star: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z', link: 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1',
24
+ cols: 'M4 7h10M18 7h2M4 17h4M12 17h8M14 5v4M8 15v4', chat: 'M4 5h16v11H9l-5 4z', chev: 'M10 8l4 4-4 4',
25
+ };
26
+ const noun = (n, one, many) => n + ' ' + (n === 1 ? one : many);
27
+ const kr = (ws, k, text) => `<a href="#" data-gl-ws="${esc(ws)}" data-gl-kr="${esc(k.key)}">${esc(text || k.title)}</a>`;
28
+ const ini = (ws, i) => `<a href="#" data-gl-ws="${esc(ws)}" data-gl-ini="${esc(i.id)}"${i.verdict ? ' data-gl-verdict' : ''}>${esc(i.title)}</a>`;
29
+
30
+ /** Every key result row of the file (filter all), with its objective. */
31
+ const rowsOf = (model, today) => GM.tableOf(model, today, 'all').objectives.flatMap((o) => o.krs.map((k) => ({ o, k })));
32
+ /** The initiative records the OKR file names, by id (each carries endAt and status). */
33
+ function recs(model) {
34
+ const by = new Map(), F = model && model.okrFile;
35
+ if (F) for (const o of F.objectives || []) for (const k of o.krs || []) for (const r of k.moves || []) by.set(r.id, r);
36
+ return by;
37
+ }
38
+ /** The work that moves a key result most soon: the open initiative with the nearest end still ahead, else the one most over. */
39
+ function leadWork(model, k, today) {
40
+ const by = recs(model);
41
+ const open = k.moves.map((id) => by.get(id)).filter((r) => r && r.status !== 'done' && r.status !== 'cancelled');
42
+ const ahead = open.filter((r) => r.endAt && GM.daysTo(today, r.endAt) >= 0).sort((a, b) => String(a.endAt).localeCompare(String(b.endAt)));
43
+ if (ahead.length) return { r: ahead[0], ahead: true };
44
+ const over = open.filter((r) => r.endAt).sort((a, b) => String(a.endAt).localeCompare(String(b.endAt)));
45
+ return over.length ? { r: over[0], ahead: false } : null;
46
+ }
47
+
48
+ /* ── Where it stands ──────────────────────────────────────────────────────────────────────────────────────────── */
49
+ export function standsOf(model, today) {
50
+ const F = model && model.okrFile; if (!F) return [];
51
+ const ws = (model.board && model.board.ws) || '';
52
+ const all = rowsOf(model, today), out = [];
53
+ if (!all.length) return [];
54
+ const read = all.filter((x) => x.k.read), pace = read.filter((x) => x.k.dot === 'ok');
55
+ const behind = read.filter((x) => x.k.dot === 'rk' || x.k.dot === 'rd');
56
+ // 1. how many are on pace, said only when something was read (a count of nothing read would say nothing true)
57
+ if (read.length) out.push(`${pace.length} of ${noun(all.length, 'key result', 'key results')} ${pace.length === 1 ? 'is' : 'are'} on pace.`);
58
+ // 2. the behind ones: value, target, time left, and the work that moves it with its date (the cause and the risk)
59
+ for (const { k } of behind.slice(0, 2)) {
60
+ const w = leadWork(model, k, today);
61
+ const work = !w ? '' : w.ahead ? `, and the work that moves it, ${ini(ws, { id: w.r.id, title: w.r.title })}, ships ${esc(GM.mdy(w.r.endAt))}`
62
+ : `, and the work that moves it, ${ini(ws, { id: w.r.id, title: w.r.title })}, is ${esc(noun(-GM.daysTo(today, w.r.endAt), 'day', 'days'))} past its end`;
63
+ const left = k.left ? (k.left === 'today' ? ' with the check today' : /over$/.test(k.left) ? ', ' + esc(k.left) : ' with ' + esc(k.left) + ' left') : '';
64
+ out.push(`${kr(ws, k)} is behind: ${esc(k.act)}${k.target ? ' of ' + esc(k.target) : ''}${left}${work}.`);
65
+ }
66
+ // 3. no reading: the one read before and silent since, else how many wait and on what
67
+ const unread = all.filter((x) => !x.k.read);
68
+ const stale = unread.filter((x) => x.k.lastAt).sort((a, b) => String(a.k.lastAt).localeCompare(String(b.k.lastAt)))[0];
69
+ if (stale) out.push(`${kr(ws, stale.k)} has had no reading since ${esc(GM.mdy(stale.k.lastAt))}, so nobody knows how it is going.`);
70
+ else if (unread.length) {
71
+ const by = new Map(); for (const { k } of unread) if (k.need) by.set(k.need, (by.get(k.need) || 0) + 1);
72
+ const top = [...by.entries()].sort((a, b) => b[1] - a[1])[0];
73
+ const who = unread.length === 1 ? kr(ws, unread[0].k) + ' has' : (unread.length === all.length ? 'No key result has' : noun(unread.length, 'key result has', 'key results have'));
74
+ const wait = !top ? '' : unread.length === 1 ? `: it waits on ${esc(top[0])}` : top[1] === unread.length ? `: they all wait on ${esc(top[0])}` : `: ${top[1]} wait on ${esc(top[0])}`;
75
+ out.push(`${who} ${unread.length === all.length && unread.length > 1 ? 'a reading yet' : 'no reading yet'}${wait}.`);
76
+ }
77
+ // 4. a health budget over its cap
78
+ for (const b of ((model.budgets || []).filter((b) => b && b.reading && b.reading.over)).slice(0, 1)) {
79
+ out.push(`The ${esc(b.id)} health budget is over its cap${typeof b.reading.share === 'number' && typeof b.cap === 'number' ? `: ${Math.round(b.reading.share * 100)}% of the work against ${Math.round(b.cap * 100)}%` : ''}.`);
80
+ }
81
+ // 5. the next decision point: the nearest check still ahead
82
+ const next = all.filter((x) => x.k.due && GM.daysTo(today, x.k.due) >= 0).sort((a, b) => String(a.k.due).localeCompare(String(b.k.due)))[0];
83
+ if (next) {
84
+ const n = GM.daysTo(today, next.k.due), when = n === 0 ? ', today' : n === 1 ? ', tomorrow' : `, in ${noun(n, 'day', 'days')}`;
85
+ const end = F.period && F.period.toAt && next.k.due === F.period.toAt && !all.some((x) => x.k.due && x.k.due !== F.period.toAt);
86
+ out.push(end ? `Every key result is checked when ${esc(F.period.label || 'the period')} ends on ${esc(GM.mdy(next.k.due))}${when}.`
87
+ : `The next check is ${kr(ws, next.k, next.k.token + ' ' + next.k.title)} on ${esc(GM.mdy(next.k.due))}${when}.`);
88
+ }
89
+ return out;
90
+ }
91
+
92
+ /* ── the one Suggestion ───────────────────────────────────────────────────────────────────────────────────────── */
93
+ /** The North Star draft first, else a source to connect (the one that frees the most key results), else drafting a North Star. A kind the PM
94
+ * said No to on this device (dismissed: Set of keys) is passed over. */
95
+ export function sugOf(model, ns, dismissed = new Set()) {
96
+ const F = model && model.okrFile; if (!F) return null;
97
+ const out = [];
98
+ if (ns && ns.state === 'draft') out.push({ kind: 'ns', key: 'ns:' + ns.row, title: 'Set the North Star: ' + ns.title, why: ns.sub,
99
+ will: ['Keep the draft as this product’s North Star measure'], changes: 'Goals shows it as the North Star, and the key results hang from it.', basis: 'PMOS’s draft from your key results' });
100
+ const su = GM.setupOf(model, ns);
101
+ for (const s of (su && su.sources) || []) {
102
+ const toks = s.frees.replace(/^Frees /, ''), n = (toks.match(/,| to /g) || []).length + 1;
103
+ out.push({ kind: 'src', key: 'src:' + s.need, title: 'Connect ' + s.need, why: `${toks} ${n === 1 ? 'has' : 'have'} no reading. Your OKR file names ${s.need} as the source.`,
104
+ will: ['Connect ' + s.need + ' as a source', 'Test one read before it keeps it', 'Read ' + toks + ' from it'], changes: `${toks} get readings, so their pace shows here.`, basis: 'Your OKR file',
105
+ say: `Connect ${s.need} and read ${toks} from it. Test one read before you keep it.` });
106
+ }
107
+ if (ns && ns.state === 'none') out.push({ kind: 'draft', key: 'draft', title: 'Draft a North Star', why: ns.sub,
108
+ will: ['Draft a North Star from your key results', 'Show it here for your tick before it counts'], changes: 'The key results hang from one measure.', basis: 'Your OKR file',
109
+ say: 'Draft a North Star for this product from its key results. I approve it with a tick.' });
110
+ return out.find((s) => !dismissed.has(s.key)) || null;
111
+ }
112
+
113
+ /* ── North Star, input, guardrail ─────────────────────────────────────────────────────────────────────────────── */
114
+ /** A sparkline's points in a 120 × 32 box, from two readings or more; '' with fewer. */
115
+ export function sparkOf(series) {
116
+ const s = (series || []).filter((x) => x && typeof x.v === 'number');
117
+ if (s.length < 2) return '';
118
+ const vs = s.map((x) => x.v), lo = Math.min(...vs), hi = Math.max(...vs), span = hi - lo || 1;
119
+ return s.map((x, i) => `${Math.round((i / (s.length - 1)) * 120)},${Math.round(30 - ((x.v - lo) / span) * 28)}`).join(' ');
120
+ }
121
+ const lineOf = (g) => [g.title + '.', g.targetTxt ? `Target ${g.targetTxt}${g.by ? ' by ' + g.by : ''}.` : '', g.pace && g.pace.sub && g.pace.head !== '—' ? g.pace.sub.replace(/^./, (c) => c.toUpperCase()) + '.' : ''].filter(Boolean).join(' ');
122
+ export function numbersOf(model, ns) {
123
+ const G = ((model && model.goals) || []);
124
+ const one = (role, name) => { const g = G.find((x) => x && x.role === role); return g ? { role, name, value: g.nowTxt || '—', at: (g.reading && g.reading.at) || null, spark: sparkOf(g.series), line: lineOf(g), goal: g.id } : null; };
125
+ const out = [];
126
+ const n = one('north-star', 'North Star');
127
+ if (n) out.push(n); else if (model && model.okrFile && ns) out.push({ role: 'north-star', name: 'North Star', ns });
128
+ for (const [r, name] of [['input', 'Input'], ['guardrail', 'Guardrail']]) { const x = one(r, name); if (x) out.push(x); }
129
+ return out;
130
+ }
131
+
132
+ /* ── an unlinked initiative: the key result PMOS thinks it moves ──────────────────────────────────────────────── */
133
+ const STOP = new Set(['the', 'and', 'for', 'with', 'from', 'into', 'over', 'under', 'that', 'this', 'than', 'more', 'less', 'make', 'new', 'old', 'all', 'one', 'per',
134
+ 'its', 'our', 'your', 'are', 'not', 'off', 'out', 'up', 'down', 'v1', 'v2', 'phase', 'work', 'held', 'least', 'good', 'before', 'after', 'week', 'month']);
135
+ const words = (s) => [...new Set(String(s || '').toLowerCase().replace(/[^a-z0-9 ]+/g, ' ').split(/\s+/).filter((w) => w.length >= 4 && !STOP.has(w)))];
136
+ /** The key result whose words the initiative's title shares most; two words, or one of six letters or more. null when none fits. */
137
+ export function guessKr(title, F) {
138
+ const mine = words(title); if (!mine.length) return null;
139
+ let best = null;
140
+ for (const o of (F && F.objectives) || []) for (const k of o.krs || []) {
141
+ const kw = words(k.title + ' ' + (o.title || '')), hit = mine.filter((w) => kw.includes(w));
142
+ const score = hit.length * 10 + hit.reduce((a, w) => a + w.length, 0);
143
+ if ((hit.length >= 2 || hit.some((w) => w.length >= 6)) && (!best || score > best.score)) best = { key: k.key, token: k.token, title: k.title, words: hit, score };
144
+ }
145
+ return best ? { key: best.key, token: best.token, title: best.title, words: best.words } : null;
146
+ }
147
+ export const linkSay = (i, g) => (g ? `Link ${i.title} to ${g.token} ${g.title}.` : `Which key result does ${i.title} move? Link it, or say a new one.`);
148
+
149
+ /* ── the Key results Table ────────────────────────────────────────────────────────────────────────────────────── */
150
+ export const COLS = Object.freeze([['now', 'Now', true], ['pace', 'Pace', true], ['moved', 'Moved by', true], ['check', 'Check', true], ['left', 'Left', false], ['levers', 'Levers', false]]);
151
+ const PACE = { on: ['On pace', 'blue'], close: ['Behind', 'alert'], behind: ['Behind', 'alert'], broken: ['Off track', 'alert'] };
152
+ export const paceOf = (k) => (k.read ? PACE[k.pace] || ['Read', ''] : ['No reading', '']);
153
+ const badge = ([t, tone]) => `<span class="pm-badge${tone ? ' ' + tone : ''}">${esc(t)}</span>`;
154
+ // the bar is an SVG (its length an attribute, never an inline style: conformance R28-1)
155
+ const bar = (f) => `<svg class="gl-meter" aria-hidden="true" width="90" height="6" viewBox="0 0 90 6"><rect width="90" height="6" rx="3" fill="var(--well)"/><rect width="${Math.round(Math.max(0, Math.min(1, f)) * 90)}" height="6" rx="3" fill="var(--leaf)"/></svg>`;
156
+
157
+ /** p: { ws, name, model, T (tableOf with the tab), counts: { all, slip, unread, pace } }; o: { today, filter, cols: Set, many }. */
158
+ export function tableHtml(p, o) {
159
+ const { model, T, ws } = p, F = model.okrFile, cols = COLS.filter(([k]) => o.cols.has(k)), n = cols.length + 1;
160
+ const by = recs(model);
161
+ const moved = (ids) => ids.map((id) => GM.iniItem(by.get(id) || { id, title: id }, model, o.today))
162
+ .map((i) => `<span class="gl-mv${i.tone ? ' gl-al' : ''}" title="${esc(i.line)}">${ini(ws, i)}</span>`).join(', ');
163
+ const cell = {
164
+ now: (k) => `<td class="gl-now">${k.act ? `<b>${esc(k.act)}</b>` : '<b>—</b>'}${k.target ? ` <span class="pm-meta">of ${esc(k.target)}</span>` : ''}`
165
+ + (k.done !== null && k.done !== undefined ? bar(k.done) : !k.read ? ` <span class="pm-meta">${esc(k.lastAt ? 'last read ' + GM.mdy(k.lastAt) : k.sub)}</span>` : '') + '</td>',
166
+ pace: (k) => `<td>${badge(paceOf(k))}</td>`,
167
+ moved: (k) => `<td class="gl-mvs">${moved(k.moves)}</td>`,
168
+ check: (k) => `<td class="code pm-meta">${esc(k.due ? GM.mdy(k.due) : '')}</td>`,
169
+ left: (k) => `<td class="pm-meta">${esc(k.left)}</td>`,
170
+ levers: (k, ob, i) => `<td class="gl-lvs">${i === 0 ? ob.levers.map((l) => `<span><b>${esc(l.title)}</b> <span class="pm-meta${l.tone ? ' gl-al' : ''}">${esc(l.txt)}</span></span>`).join('') : ''}</td>`,
171
+ };
172
+ const group = (label, sub, extra = '') => `<tr class="gl-g"><td colspan="${n}"><div class="pm-group"><b>${esc(label)}</b><span>${esc(sub)}</span>${extra}</div></td></tr>`;
173
+ let body = '';
174
+ for (const ob of T.objectives) {
175
+ body += group(ob.label + (ob.title ? ' · ' + ob.title : ''), noun(ob.krs.length, 'key result', 'key results'));
176
+ body += ob.krs.map((k, i) => `<tr><td class="gl-kr"><a href="#" class="gl-k" data-gl-ws="${esc(ws)}" data-gl-kr="${esc(k.key)}" title="${esc(k.sub)}">${esc(k.token)} · ${esc(k.title)}</a></td>`
177
+ + cols.map(([c]) => cell[c](k, ob, i)).join('') + '</tr>').join('');
178
+ }
179
+ if (T.budgets.length) {
180
+ body += group('Health budgets', 'work that keeps things running');
181
+ body += T.budgets.map((b) => {
182
+ const c = { now: `<td class="gl-now">${b.share ? `<b>${esc(b.share.replace(/ of .*/, ''))}</b> <span class="pm-meta">of ${esc(b.share.replace(/^.* of /, ''))} at most</span>` : '<span class="pm-meta">no share yet</span>'}</td>`,
183
+ pace: `<td>${b.share ? badge(b.over ? ['Over', 'alert'] : ['Within', 'blue']) : ''}</td>`, moved: `<td class="gl-mvs">${b.items.map((i) => `<span class="gl-mv${i.tone ? ' gl-al' : ''}" title="${esc(i.line)}">${ini(ws, i)}</span>`).join(', ')}</td>`,
184
+ check: '<td></td>', left: '<td></td>', levers: `<td class="pm-meta">${esc(b.covers)}</td>` };
185
+ return `<tr><td class="gl-kr"><b>${esc(b.label)}</b></td>${cols.map(([k]) => c[k]).join('')}</tr>`;
186
+ }).join('');
187
+ }
188
+ if (T.unlinked.length) {
189
+ body += group('Not linked to a key result', noun(T.unlinked.length, 'initiative', 'initiatives'));
190
+ body += T.unlinked.map((i) => {
191
+ const g = guessKr(i.title, F);
192
+ const say = g ? `PMOS thinks it moves ${g.token} (both say ${g.words.join(', ')})` : 'no key result fits yet';
193
+ return `<tr><td class="gl-kr">${ini(ws, i)}</td><td colspan="${Math.max(1, n - 2)}" class="pm-meta">${esc(say)}</td>`
194
+ + `<td class="gl-end"><button type="button" class="pm-btn" data-gl-link="${esc(i.id)}" data-gl-ws="${esc(ws)}" data-gl-say="${esc(linkSay(i, g))}" aria-label="Link to a key result" title="Link to a key result">${SV(I.link)}</button></td></tr>`;
195
+ }).join('');
196
+ }
197
+ const tabs = GM.FILTERS.map(([k, label]) => `<button type="button" class="pm-tab" role="tab" aria-selected="${o.filter === k}" data-gl-f="${k}">${esc(label)}${p.counts[k] ? ` <span class="gl-tn">${p.counts[k]}</span>` : ''}</button>`).join('');
198
+ const head = `<div class="head"><h2 class="pm-h">Key results</h2>${o.many ? `<span class="pm-meta">${esc(p.name)}</span>` : ''}<span class="sp"></span>`
199
+ + `<div class="pm-tabs" role="tablist" aria-label="Show">${tabs}</div>`
200
+ + `<span class="gl-mw"><button type="button" class="pm-btn" data-gl-cols="${esc(ws)}" aria-haspopup="menu" aria-expanded="false" aria-label="Choose columns" title="Choose columns">${SV(I.cols)}</button></span></div>`;
201
+ const none = !T.objectives.length && !T.budgets.length && !T.unlinked.length;
202
+ const label = (GM.FILTERS.find((f) => f[0] === o.filter) || [])[1] || '';
203
+ return `<section class="pm-block gl-krs" aria-label="Key results">${head}`
204
+ + (none ? `<p class="pm-meta gl-m0">No key result is ${esc(label.toLowerCase())} in ${esc(p.name)}.</p>`
205
+ : `<div class="gl-tw"><table class="pm-table" aria-label="Key results of ${esc(p.name)}"><thead><tr><th scope="col">Key result</th>${cols.map(([, h]) => `<th scope="col">${esc(h)}</th>`).join('')}</tr></thead><tbody>${body}</tbody></table></div>`)
206
+ + '</section>';
207
+ }
@@ -25,7 +25,9 @@ export const mdy = (d) => { const t = ms(d); if (t === null) return ''; const x
25
25
  export const daysTo = (a, b) => { const x = ms(a), y = ms(b); return x === null || y === null ? null : Math.round((y - x) / DAY); };
26
26
  const noun = (n, one, many) => n + ' ' + (n === 1 ? one : many);
27
27
 
28
- export const FILTERS = Object.freeze([['all', 'All'], ['slip', 'Slipping'], ['unread', 'Not read'], ['read', 'Read']]);
28
+ /* the Key results tabs (GoalsDS): All, Behind, No reading, On pace. 'read' (every read key result) was the old fourth choice and still filters, so a
29
+ * choice stored on a device before the tabs keeps working. */
30
+ export const FILTERS = Object.freeze([['all', 'All'], ['slip', 'Behind'], ['unread', 'No reading'], ['pace', 'On pace']]);
29
31
 
30
32
  /** "O-A" → "Objective A", "O1" → "Objective 1", "Objective 2" stays. */
31
33
  export function objLabel(token) {
@@ -81,9 +83,14 @@ function krRow(model, o, k, today) {
81
83
  act: read ? g.nowTxt : '', target: g && g.targetTxt ? g.targetTxt : '', tone: dot === 'rk' ? 'risk' : dot === 'rd' ? 'late' : '',
82
84
  left: d === null ? '' : d > 0 ? noun(d, 'day', 'days') : d === 0 ? 'today' : noun(-d, 'day', 'days') + ' over', due,
83
85
  moves: (k.moves || []).map((r) => r.id),
86
+ // GoalsDS: the pace a reading gives (on, close, behind, broken; none with no reading), the share of the way to the target when the record
87
+ // has a start, a target and a reading (lib/insights-premium.js done), and the last reading's day even when it is no longer counted as read
88
+ pace: read ? ((g.reading || {}).dot || 'none') : 'none', done: read && typeof g.done === 'number' ? g.done : null,
89
+ lastAt: (g && g.reading && g.reading.at) || (g && g.lastRead && g.lastRead.day) || null,
84
90
  };
85
91
  }
86
- const passes = (row, filter) => filter === 'slip' ? row.dot === 'rk' || row.dot === 'rd' : filter === 'unread' ? !row.read : filter === 'read' ? row.read : true;
92
+ const passes = (row, filter) => filter === 'slip' ? row.dot === 'rk' || row.dot === 'rd' : filter === 'unread' ? !row.read : filter === 'read' ? row.read
93
+ : filter === 'pace' ? row.read && row.dot === 'ok' : true;
87
94
 
88
95
  /** The outcome promise of an initiative (model.outcomes), by id. */
89
96
  const outcomeOf = (model, id) => ((model && model.outcomes) || []).find((r) => r && r.id === id) || null;