create-pmos 0.828.0 → 0.830.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 (113) hide show
  1. package/package.json +237 -35
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/board-deliveries-test.js +2 -2
  7. package/workspace/briefing-premium-board-test.js +1 -1
  8. package/workspace/briefing-premium-insights-test.js +1 -1
  9. package/workspace/changelog.json +236 -8
  10. package/workspace/guide/agent-capabilities.md +1 -1
  11. package/workspace/guide/backlog.md +12 -1
  12. package/workspace/guide/cli.md +46 -1
  13. package/workspace/guide/home.md +2 -1
  14. package/workspace/guide/layout.md +1 -0
  15. package/workspace/guide/settings-and-switches.md +1 -0
  16. package/workspace/lib/board-premium.js +1 -0
  17. package/workspace/lib/code-map.js +8 -2
  18. package/workspace/lib/critical-needs.js +162 -0
  19. package/workspace/lib/deps-cli.js +102 -0
  20. package/workspace/lib/engine/boards.js +13 -2
  21. package/workspace/lib/factory-floor.js +16 -8
  22. package/workspace/lib/features.json +17 -13
  23. package/workspace/lib/needs-providers.js +1 -0
  24. package/workspace/lib/page-one-answer.js +86 -0
  25. package/workspace/lib/pages-cli.js +6 -2
  26. package/workspace/lib/people-cli.js +9 -1
  27. package/workspace/lib/people-prep.js +140 -0
  28. package/workspace/lib/pmos-verbs.js +10 -0
  29. package/workspace/lib/print-cli.js +49 -0
  30. package/workspace/lib/print-pdf.js +96 -0
  31. package/workspace/lib/prototype-cli.js +86 -0
  32. package/workspace/lib/report-cli.js +12 -2
  33. package/workspace/lib/report-readers.js +5 -3
  34. package/workspace/lib/review-pack.js +348 -0
  35. package/workspace/lib/review-reasons.js +121 -9
  36. package/workspace/lib/route-modules.js +5 -0
  37. package/workspace/lib/routes-boards.js +25 -2
  38. package/workspace/lib/routes-report-design.js +3 -1
  39. package/workspace/lib/routes-review-pack.js +42 -0
  40. package/workspace/lib/routes-roadmap-ops.js +53 -1
  41. package/workspace/lib/routes-sim-users.js +66 -0
  42. package/workspace/lib/routes-skill-map.js +39 -0
  43. package/workspace/lib/routes-strategy-card.js +13 -6
  44. package/workspace/lib/routes-team-waits.js +24 -0
  45. package/workspace/lib/sim-users.js +329 -0
  46. package/workspace/lib/skill-map.js +199 -0
  47. package/workspace/lib/task-store.js +1 -1
  48. package/workspace/lib/team-cli.js +20 -1
  49. package/workspace/lib/team-waits.js +167 -0
  50. package/workspace/lib/tradeoff-cards.js +258 -0
  51. package/workspace/lib/tradeoff-cli.js +83 -0
  52. package/workspace/package-lock.json +2 -2
  53. package/workspace/package.json +1 -1
  54. package/workspace/public/pm/action-keys.js +1 -0
  55. package/workspace/public/pm/ask-here-ctx.js +25 -1
  56. package/workspace/public/pm/ask-here.css +7 -0
  57. package/workspace/public/pm/ask-here.js +15 -2
  58. package/workspace/public/pm/bd-backlog.css +61 -0
  59. package/workspace/public/pm/bd-backlog.js +99 -7
  60. package/workspace/public/pm/bd-work.js +12 -1
  61. package/workspace/public/pm/code-map.js +15 -4
  62. package/workspace/public/pm/cozy-board.css +5 -1
  63. package/workspace/public/pm/cozy-library.css +5 -0
  64. package/workspace/public/pm/cozy-pop-work.js +4 -1
  65. package/workspace/public/pm/cozy-proto.css +5 -0
  66. package/workspace/public/pm/cozy-proto.js +11 -3
  67. package/workspace/public/pm/cozy-search.js +2 -2
  68. package/workspace/public/pm/cozy-today-app.js +5 -2
  69. package/workspace/public/pm/day-time.js +8 -0
  70. package/workspace/public/pm/factory.js +199 -0
  71. package/workspace/public/pm/home-ini.js +3 -2
  72. package/workspace/public/pm/ini-links.js +2 -1
  73. package/workspace/public/pm/ini-tasks.js +5 -2
  74. package/workspace/public/pm/ini-view-model.js +14 -6
  75. package/workspace/public/pm/ini-view.js +12 -2
  76. package/workspace/public/pm/library-model.js +1 -1
  77. package/workspace/public/pm/page-one-answer.css +18 -0
  78. package/workspace/public/pm/page-one-answer.js +134 -0
  79. package/workspace/public/pm/pop-cap.js +5 -3
  80. package/workspace/public/pm/pop-work-model.js +8 -6
  81. package/workspace/public/pm/portfolio.js +1 -1
  82. package/workspace/public/pm/premium-board.js +23 -6
  83. package/workspace/public/pm/premium-library.js +27 -3
  84. package/workspace/public/pm/premium-report-read.js +11 -2
  85. package/workspace/public/pm/print-pdf.js +191 -0
  86. package/workspace/public/pm/range-pick.css +12 -0
  87. package/workspace/public/pm/range-pick.js +30 -6
  88. package/workspace/public/pm/review-pack.js +47 -0
  89. package/workspace/public/pm/review-reasons.js +19 -5
  90. package/workspace/public/pm/sim-users.js +34 -0
  91. package/workspace/public/pm/skill-map.js +57 -0
  92. package/workspace/public/pm/sort-order.js +3 -0
  93. package/workspace/public/pm/task-card.js +10 -7
  94. package/workspace/public/pm/team-waits.js +56 -0
  95. package/workspace/public/pm/tradeoff-cards.css +27 -0
  96. package/workspace/public/pm/tradeoff-cards.js +183 -0
  97. package/workspace/public/premium-board.html +3 -0
  98. package/workspace/public/today.html +1 -0
  99. package/workspace/run-tests.js +9 -1
  100. package/workspace/test-lists/critical-needs.json +9 -0
  101. package/workspace/test-lists/factory-page-ui.json +9 -0
  102. package/workspace/test-lists/page-one-answer.json +9 -0
  103. package/workspace/test-lists/people-prep.json +9 -0
  104. package/workspace/test-lists/print-pdf.json +9 -0
  105. package/workspace/test-lists/review-pack.json +9 -0
  106. package/workspace/test-lists/sim-users.json +9 -0
  107. package/workspace/test-lists/skill-map.json +9 -0
  108. package/workspace/test-lists/surface-ask-card.json +9 -0
  109. package/workspace/test-lists/task-time-optional.json +9 -0
  110. package/workspace/test-lists/team-waits.json +9 -0
  111. package/workspace/test-lists/tradeoff-cards.json +9 -0
  112. package/workspace/test-lists/voice-files.json +9 -0
  113. package/workspace/test-timings.json +25 -0
@@ -29,6 +29,7 @@
29
29
  * 5 Artefacts: one table: Artefact, Kind, Updated. A core document a gate needs that is not written is a grey row that says which gate. */
30
30
 
31
31
  import { gapsOf } from './cozy-bar.js';
32
+ import { withTime } from './day-time.js'; // a task's optional time on its start and due (task-time-optional)
32
33
  import { provenStatus, NO_SIGNAL } from './status-proof.js';
33
34
  import * as WT from './work-tree.js'; // subtasks: nesting and the roll-up (initiative work-subtasks)
34
35
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
@@ -51,10 +52,10 @@ export function dayText(v, today) {
51
52
  return d.getDate() + ' ' + MON[d.getMonth()] + (d.getFullYear() !== t.getFullYear() ? ' ' + d.getFullYear() : '');
52
53
  }
53
54
  /** A date and, when it has passed and the thing is open, how late: "4 Nov · 14 days late". */
54
- export function dateLate(v, today, open = true) {
55
- const d = day(v), t = today instanceof Date ? today : day(today); if (!d || !t) return { text: dayText(v, t), late: false };
55
+ export function dateLate(v, today, open = true, time = '') {
56
+ const d = day(v), t = today instanceof Date ? today : day(today); if (!d || !t) return { text: withTime(dayText(v, t), time), late: false };
56
57
  const late = open && d < t;
57
- return { text: dayText(v, t) + (late ? ' · ' + plural(between(d, t), 'day', 'days') + ' late' : ''), late };
58
+ return { text: withTime(dayText(v, t), time) + (late ? ' · ' + plural(between(d, t), 'day', 'days') + ' late' : ''), late };
58
59
  }
59
60
 
60
61
  /* ── the timeline ── */
@@ -324,8 +325,8 @@ export function goalName(list, anchor) {
324
325
  }
325
326
 
326
327
  /* ── the work breakdown ── */
327
- function taskRow(x, t) {
328
- const dl = x.end ? dateLate(x.end, t, !x.closed) : { text: x.start ? 'from ' + dayText(x.start, t) : '', late: false };
328
+ export function taskRow(x, t) {
329
+ const dl = x.end ? dateLate(x.end, t, !x.closed, x.due_time) : { text: x.start ? 'from ' + withTime(dayText(x.start, t), x.start_time) : '', late: false };
329
330
  const st = taskStatus(x);
330
331
  return { kind: 'task', uid: x.uid, title: x.title, who: x.owner || '', status: st, date: dl.text, late: dl.late, start: x.start || '', end: x.end || '', since: x.since || '', done: !!x.closed, ms: !!x.ms, jira: !!x.jkey, canCheck: !!x.canCheck,
331
332
  // a Jira ticket's own status name and a move PMOS asked that Jira has not answered (jira-row-edit): the status press moves it in Jira
@@ -333,7 +334,8 @@ function taskRow(x, t) {
333
334
  prog: /progress|review/i.test(st), wont: !!x.wont || st === "Won't do",
334
335
  // subtasks and Jira (initiative work-subtasks): the parent, the chip's key and link, the epic as read, the assignee, a Jira sub-task
335
336
  parent: x.parent || '', ckey: x.ckey || x.jkey || '', jurl: x.jurl || '', ...(x.jepic !== undefined ? { jepic: x.jepic, jepicName: x.jepicName || '' } : {}), jassignee: x.jassignee || '', jtype: x.jtype || '',
336
- ...(x.jsub ? { jsub: true } : {}), ...(x.jsubOf ? { jsubOf: x.jsubOf } : {}), ...(x.priority ? { priority: x.priority } : {}) };
337
+ ...(x.jsub ? { jsub: true } : {}), ...(x.jsubOf ? { jsubOf: x.jsubOf } : {}), ...(x.priority ? { priority: x.priority } : {}),
338
+ ...(x.start_time ? { start_time: x.start_time } : {}), ...(x.due_time ? { due_time: x.due_time } : {}) }; // the optional times (task-time-optional)
337
339
  }
338
340
  /** The tasks of every stage, nested (initiative work-subtasks): the read Jira sub-tasks join as rows under their ticket, and a task that names
339
341
  * a sub-task's key with no parent of its own sits under its ticket's row. → { T: Map uid → node, isChild(x), rx(x) (a parent with its roll-up) } */
@@ -13,7 +13,7 @@ import { productName, whenNames } from './scope-chip.js';
13
13
 
14
14
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
15
15
  const svg = (d, n = 18) => `<svg class="pm-ic" viewBox="0 0 24 24" width="${n}" height="${n}" aria-hidden="true"><path d="${d}"/></svg>`;
16
- const I = { keep: 'M5 12.5l4.5 4.5L19 7.5', later: 'M12 7v5l3 2M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18', undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3', spark: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z' };
16
+ const I = { keep: 'M5 12.5l4.5 4.5L19 7.5', later: 'M6 6l12 12M18 6L6 18', undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3', spark: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z' };
17
17
  const money = (n) => (n == null ? '' : '$' + (n >= 1000 ? (Math.round(n / 100) / 10) + 'k' : n >= 10 ? Math.round(n) : n.toFixed(2)));
18
18
 
19
19
  export function pageHtml(v, o = {}) {
@@ -65,6 +65,7 @@ import * as CM from './changed-mark.js'; // bet A456: the ✦ and Undo on a ro
65
65
  import { setSay } from './cozy-xv.js';
66
66
  import { narrowForm } from './pn-narrow.js';
67
67
  import * as BP2 from './bd-pane.js';
68
+ import * as PA from './page-one-answer.js'; // page-one-answer (A308): Work and Board open with one sentence, what needs you, the rest folded
68
69
  import * as WV from './bd-work.js'; // Work, one view on a desk (slice 4 of the six-place navigation, initiative work-one-view)
69
70
  import * as BK from './bd-backlog.js';
70
71
  import * as PL from './bd-phone-line.js'; // a phone offers List and By stage, no Gantt (board PhIniB)
@@ -72,6 +73,7 @@ import * as ST from './bd-stands.js'; // Where it stands, its Suggestion and t
72
73
  import * as LS from './load-shapes.js'; // the skeleton and the slow-case line while the board is read (page-open-speed, SpD) // the Board as the first panel: fit(), the rows that open beside, the open row's mark
73
74
  import * as STRAT from './bd-strategy.js'; // the product's strategy in five lines above the initiatives (bet A458)
74
75
  import * as PRIN from './bd-principles.js'; // the product's principles drafted from its decisions, below the strategy (bet A352)
76
+ import * as SKM from './skill-map.js'; // the team skill map below the principles (bet A208)
75
77
  import * as CMAP from './code-map.js'; // the product's code map, one box per main part (idea A176)
76
78
  import * as SWN from './cozy-status-when.js'; // the day a status move really happened, in the toast (round 3 point 18)
77
79
  import { pressHold } from './state-glyph.js';
@@ -92,6 +94,7 @@ let readTimer = null;
92
94
  const SKEL = $('#ibBody').innerHTML; // the grey rows the page opens with (premium-board.html), put back if a failure line replaced them
93
95
  LS.slowLine($('#ibBody'), () => M);
94
96
  let readTries = 0; // reads that answered "reading" in a row: the next ask waits longer each time
97
+ const POA = { open: false, more: false }; // page-one-answer: the answer's fold (closed by default) and its "N more"
95
98
  let foldOpen = false; // the Monitor and Evaluate rows under the table
96
99
  let sprintSet = false; // "This sprint" starts on, once, when the board has a sprint
97
100
  const F = { chips: new Set(), q: '', owners: new Set(), cats: new Set(), sprints: new Set() }; // the chip filters, Find and Filter (the workflow is pm/bd-wf.js picked())
@@ -968,7 +971,9 @@ function drawInit() {
968
971
  if (v === 'time') TL.hold(); else TL.forget();
969
972
  // a row with the focus keeps it when the rows are drawn again (the page panel changes form as a Viewer opens or closes beside it)
970
973
  const fe = document.activeElement, fk = fe && body.contains(fe) && fe.matches('[data-key]') ? fe.dataset.key : null;
971
- body.innerHTML = html + phx;
974
+ // page-one-answer (A308): one sentence first, then only what needs you, the rest in one fold (a published copy shows none: it is the PM's own)
975
+ const ans = window.PMOS_READONLY ? '' : PA.answerHtml(PA.boardAnswer(L, { stateOf: (r) => WV.rowState(r), grill: (id) => GR[id], day: PA.dayWord() }), { open: POA.open, more: POA.more, page: v === 'work' ? 'work' : 'board' });
976
+ body.innerHTML = ans + html + phx;
972
977
  LB.sizeBars(body);
973
978
  if (fk) { const n = $$('#ibBody [data-key]').find((x) => x.dataset.key === fk); if (n) n.focus({ preventScroll: true }); }
974
979
  if (v === 'time') TL.mount(body);
@@ -980,6 +985,7 @@ function drawInit() {
980
985
  document.body.dataset.bdView = v;
981
986
  $('#stage').dataset.bdDesk = view; // what fit() measures: the desktop's view, so the narrow form never flips it back and forth
982
987
  markOpen();
988
+ if (M && !window.PMOS_READONLY) PA.reportCalls(v === 'work' ? 'work' : 'board', pmPost, $('#stage'));
983
989
  }
984
990
  PHONE.addEventListener('change', () => { if (M) { drawChips(); drawInit(); } });
985
991
  /** The grouping (PgBoard, PgBoardProduct): programs first (the default) or By product, in the tune sheet (#bdFilter) since UI grill U2.
@@ -1000,6 +1006,13 @@ $('#bdShowing').addEventListener('click', (e) => {
1000
1006
  });
1001
1007
  function setSpan(s) { span = s; store.set(SPAN_KEY, span); drawChips(); drawInit(); }
1002
1008
  $('#ibBody').addEventListener('click', (e) => {
1009
+ // page-one-answer: a Needs you row opens its initiative; the fold and "N more" open in place
1010
+ const pa = e.target.closest('[data-poa]');
1011
+ if (pa) {
1012
+ if (pa.dataset.poa === 'open') { const r = rowOf(pa.dataset.poaKey); if (r) openIni(r, pa); return; }
1013
+ if (pa.dataset.poa === 'fold') POA.open = !POA.open; else if (pa.dataset.poa === 'more') POA.more = true;
1014
+ drawInit(); const n = $('#ibBody [data-poa="fold"]'); if (n && pa.dataset.poa === 'fold') n.focus(); return;
1015
+ }
1003
1016
  if (curView() === 'work') {
1004
1017
  const op = e.target.closest('[data-wkopen]'); if (op) { e.preventDefault(); openIni(rowOf(op.dataset.wkopen), op); return; }
1005
1018
  const sg = e.target.closest('[data-wksug]'); if (sg) { sugPress(sg); return; }
@@ -1201,7 +1214,7 @@ function msPop(anchor, r, ids, sheet) {
1201
1214
  el.className = 'tg-msp' + (sheet ? ' sh' : ''); el.setAttribute('role', 'menu'); el.setAttribute('aria-label', (sheet ? '' : 'Milestones of ') + r.title); el.dataset.escLayer = '';
1202
1215
  el.innerHTML = (sheet ? `<i class="gr" aria-hidden="true"></i><b class="h">${esc(r.title)}</b>` : '') + items.map((x) => x.html).join('');
1203
1216
  document.body.appendChild(el); el.__a = anchor; msEl = el; anchor.setAttribute('aria-expanded', 'true');
1204
- if (!sheet) { const b = anchor.getBoundingClientRect(), w = el.offsetWidth; el.style.left = Math.max(8, Math.min(b.left + b.width / 2 - w / 2, innerWidth - w - 8)) + 'px'; el.style.top = b.bottom + 8 + 'px'; }
1217
+ if (!sheet) { const b = anchor.getBoundingClientRect(), w = el.offsetWidth; el.style.left = Math.max(8, Math.min(b.left + b.width / 2 - w / 2, innerWidth - w - 8)) + 'px'; const h = el.offsetHeight; el.style.top = Math.max(8, b.bottom + 8 + h > innerHeight - 8 ? b.top - h - 8 : b.bottom + 8) + 'px'; }
1205
1218
  el.onclick = (e) => {
1206
1219
  const o = e.target.closest('[data-ms-open]'); if (!o) return;
1207
1220
  const id = o.dataset.msOpen, m = L.find((x) => x.id === id); msClose();
@@ -1225,7 +1238,7 @@ function lanePop(anchor, data, title) {
1225
1238
  el.innerHTML = (title ? `<i class="gr" aria-hidden="true"></i><b class="h">${esc(title)}</b>` : '')
1226
1239
  + L.map((m) => `<button type="button" role="menuitem" class="o" data-ms-ini="${esc(m.k)}"><i class="tg-tm-i${m.s ? ' ' + m.s : ''}" aria-hidden="true"></i><span>${esc(m.n)}<small>${esc(m.t)}</small></span><span class="k${m.s === 'late' ? ' late' : ''}">${esc(md(m.d))}</span></button>`).join('');
1227
1240
  document.body.appendChild(el); el.__a = anchor; msEl = el; anchor.setAttribute('aria-expanded', 'true');
1228
- if (!title) { const b = anchor.getBoundingClientRect(), w = el.offsetWidth; el.style.left = Math.max(8, Math.min(b.left + b.width / 2 - w / 2, innerWidth - w - 8)) + 'px'; el.style.top = b.bottom + 8 + 'px'; }
1241
+ if (!title) { const b = anchor.getBoundingClientRect(), w = el.offsetWidth; el.style.left = Math.max(8, Math.min(b.left + b.width / 2 - w / 2, innerWidth - w - 8)) + 'px'; const h = el.offsetHeight; el.style.top = Math.max(8, b.bottom + 8 + h > innerHeight - 8 ? b.top - h - 8 : b.bottom + 8) + 'px'; }
1229
1242
  el.onclick = (e) => { const o = e.target.closest('[data-ms-ini]'); if (!o) return; msClose(); openIni(rowOf(o.dataset.msIni), anchor); };
1230
1243
  const f = el.querySelector('button'); if (f) f.focus({ preventScroll: true });
1231
1244
  }
@@ -1244,7 +1257,8 @@ function gapPop(anchor, r) {
1244
1257
  el.innerHTML = `<div class="w">${lines.map((t, i) => `<p class="${i ? 's' : ''}">${esc(t)}</p>`).join('')}${sk.map((k) => `<p class="s">${esc(skipWords(k.items))}</p>`).join('')}</div>`
1245
1258
  + (anchor.dataset.ahead ? `<button type="button" class="gp-add" aria-label="${esc('New task, ' + md(d(start)) + ' to ' + md(d(due)))}" title="New task">${'<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg>'}</button>` : '');
1246
1259
  document.body.appendChild(el); el.__a = anchor; msEl = el; anchor.setAttribute('aria-expanded', 'true');
1247
- const bx = anchor.getBoundingClientRect(), w = el.offsetWidth; el.style.left = Math.max(8, Math.min(bx.left + bx.width / 2 - w / 2, innerWidth - w - 8)) + 'px'; el.style.top = bx.bottom + 6 + 'px';
1260
+ const bx = anchor.getBoundingClientRect(), w = el.offsetWidth; el.style.left = Math.max(8, Math.min(bx.left + bx.width / 2 - w / 2, innerWidth - w - 8)) + 'px';
1261
+ const h = el.offsetHeight; el.style.top = Math.max(8, bx.bottom + 6 + h > innerHeight - 8 ? bx.top - h - 6 : bx.bottom + 6) + 'px'; // flips above a row low on the screen
1248
1262
  const add = el.querySelector('.gp-add');
1249
1263
  if (add) { add.onclick = () => { msClose(); BI.openIni(r, anchor, { addTo: '', addDates: { start, due } }); }; add.focus({ preventScroll: true }); }
1250
1264
  }
@@ -1512,6 +1526,7 @@ async function load() {
1512
1526
  LE.loaded({ since, stale: !!r.stale }); // a change still saving stays on the new read; open views (the big Work breakdown) follow it
1513
1527
  STRAT.refresh($('#cStrat'), { ws: M.board.ws || null, board: M.board.id || null, single: !ALL, say });
1514
1528
  PRIN.refresh($('#cPrin'), { ws: M.board.ws || null, single: !ALL, say });
1529
+ SKM.refresh($('#cSkills'), { ws: M.board.ws || null, single: !ALL, say });
1515
1530
  CMAP.mount($('#cCode'), { ws: M.board.ws || null, single: !ALL });
1516
1531
  focusOnce(); taskOnce(); programOnce(); newOnce(); loadOthers(); loadWorkflows();
1517
1532
  if (r.stale) setTimeout(load, 2000); // a press is still being derived: ask again
@@ -1552,8 +1567,8 @@ async function setDates(r, uid, patch) {
1552
1567
  const res = await pmPost('/api/boards/tasks/edit', { ...body, ...patch }).catch(() => null);
1553
1568
  if (!res || res.ok === false) { say(LE.notSaved(res), () => setDates(r, uid, patch), 'Try again'); return; }
1554
1569
  const ms = 'milestone' in patch;
1555
- const back = {}; for (const f of Object.keys(patch)) back[f] = f === 'milestone' ? (res.from && 'milestone' in res.from ? !!res.from.milestone : !patch.milestone) : k ? (f === 'due' ? k.end : k[f]) || '' : res.from && f in res.from ? res.from[f] || '' : ''; // a Jira ticket's days come back in from (batch 11 item 23)
1556
- const words = ms ? (patch.milestone ? 'Milestone' : 'Not a milestone') : 'Dates saved';
1570
+ const back = {}; for (const f of Object.keys(patch)) back[f] = /_time$/.test(f) ? (res.from && res.from[f]) || '' : f === 'milestone' ? (res.from && 'milestone' in res.from ? !!res.from.milestone : !patch.milestone) : k ? (f === 'due' ? k.end : k[f]) || '' : res.from && f in res.from ? res.from[f] || '' : ''; // a Jira ticket's days come back in from (batch 11 item 23)
1571
+ const words = ms ? (patch.milestone ? 'Milestone' : 'Not a milestone') : Object.keys(patch).every((f) => /_time$/.test(f)) ? 'Time saved' : 'Dates saved'; // a time alone (task-time-optional)
1557
1572
  const jd = !k && !ms && res.from && ('start' in res.from || 'due' in res.from); // a Jira ticket's days, kept in PMOS (batch 11 item 23)
1558
1573
  say(words + (k ? ': ' + k.title : jd ? ': ' + uid + ', kept in PMOS' : '') + '.', k || ms || jd ? async () => { const u = await pmPost('/api/boards/tasks/edit', { ...body, ...back }).catch(() => null); say(u && u.ok !== false ? (ms ? 'Put back.' : 'Dates put back.') : (u && u.error) || 'The undo did not land.'); load(); } : undefined);
1559
1574
  load();
@@ -1585,6 +1600,8 @@ const bkApi = () => ({
1585
1600
  scope: () => (M.board.all ? (M.board.products || []).map((p) => ({ ws: p.ws, board: p.id || '', name: p.name })) : [{ ws: M.board.ws || '', board: M.board.id || '', name: M.board.product || M.board.name || '' }]),
1586
1601
  // CLASSIC (lib/classic-board.js) is the test seam of the four Board views: Work and its Backlog switch are not there
1587
1602
  post: pmPost, say, reload: () => load(), readonly: !!window.PMOS_READONLY || CLASSIC,
1603
+ // Work › Factory (factory-page-ui): What the factory is making, the live initiatives by goal and by the stage of their own workflow
1604
+ work: () => (M && M.initiatives ? M.initiatives.list.rows : []).filter((r) => r.track && r.acts).map((r) => ({ id: r.id, goal: wkGoalOf(r), stage: r.acts.stage || '', stages: r.acts.stages || [] })),
1588
1605
  // the Line tab (quiet-rows slice B): a row opens its initiative, as a row of Initiatives does
1589
1606
  openIni: (id, ws) => { const r = (M.rows || []).find((x) => x.id === id && x.track && (!ws || (x.ws || M.board.ws) === ws)); if (r) openIni(r); else say('Open ' + id + ' from Initiatives.'); },
1590
1607
  // the sprint band (pm/bd-sprint.js): Read Jira again is the Board's own; "Make a home" opens New initiative with the theme's name
@@ -29,6 +29,8 @@ import { FAMILIES, GROUPS, STATES, view, counts, passes, matches, aboutText, sta
29
29
  import { openItem } from './library-open.js';
30
30
  import { bindSlash, bindEnterOpen, pressStep } from './library-keys.js'; // D1 and D6: the keys and presses, tested by pressing them (A437)
31
31
  import { STEP, nextShown, moreHtml, totalOf, logMore } from './list-cap.js'; // lists stay short (A455): one step for every long list
32
+ import * as RP from './review-pack.js'; // the monthly review pack (review-pack, job #1910): its parts in the preview, and the share (Issue) press
33
+ import { noteUse } from './use-log.js';
32
34
 
33
35
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
34
36
  const svg = (d, cls = '') => `<svg class="pm-ic${cls ? ' ' + cls : ''}" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
@@ -315,18 +317,23 @@ async function drawPreview() {
315
317
  if (!x || !wide()) { pv.hidden = true; pv.innerHTML = ''; document.body.classList.remove('lb-pv-on'); return; }
316
318
  pv.hidden = false; document.body.classList.add('lb-pv-on');
317
319
  const older = (S.items || []).filter((o) => o.ed && o.ed === x.ed && o.id !== x.id).sort((a, b) => (b.v || 0) - (a.v || 0) || String(when(b)).localeCompare(String(when(a))));
318
- const p = x.open && x.open.doc ? S.peek.get(x.id) : null;
320
+ const p = x.open && x.open.doc && !x.pack ? S.peek.get(x.id) : null;
319
321
  const lines = x.kind === 'meeting' ? x.gist || [] : p && p.head ? p.head : [];
322
+ const pack = x.pack ? RP.packHtml(x) : '';
323
+ if (pack && S.packSeen !== x.id) { S.packSeen = x.id; noteUse('rpOpen'); console.info('[review-pack] preview ' + x.id); }
320
324
  pv.innerHTML = `<div class="head"><span class="lb-mi">${svg(ICON[x.kind] || ICON.doc)}</span><h2 class="pm-h">${esc(x.name)}</h2>`
321
325
  + `<button type="button" class="pm-btn" data-lb-pv-open aria-label="Open ${esc(x.name)}, with the chat about it" title="Open, with the chat about it">${svg(OPEN)}</button>`
326
+ + (x.pack ? RP.shareHtml(x) : '')
322
327
  + `<button type="button" class="pm-btn" data-lb-pv-close aria-label="Close the record" title="Close">${svg(X)}</button></div>`
323
328
  + `<p class="pm-meta lb-pvh">Press again or Enter to open it as the full popup</p>`
324
329
  + `<dl class="pm-field">${field('Kind', x.kindText)}${field('Product', x.product)}${field('About', aboutText(x) || (x.about && x.about.title))}${field('By', x.by)}${stateText({ x, older }) ? `<dt>State</dt><dd><span class="pm-badge${x.state === 'Issued' ? ' blue' : ''}">${esc(stateText({ x, older }))}</span></dd>` : ''}`
325
330
  + `${field(x.kind === 'meeting' ? 'Held' : 'Updated', dayText(when(x)))}${field('Came out of it', x.came)}${field('Title', x.sub)}${field('File', x.path)}</dl>`
326
- + (lines.length ? `<h3 class="pm-meta lb-pvk">First lines</h3><div class="lb-pvl">${lines.map((l) => `<p>${esc(l)}</p>`).join('')}</div>` : x.open && x.open.doc && !p ? '<p class="pm-meta">Reading the first lines…</p>' : '')
331
+ + pack
332
+ + (S.shareMsg && S.shareMsg.id === x.id ? `<p class="pm-meta" role="status">${esc(S.shareMsg.text)}</p>` : '')
333
+ + (pack ? '' : lines.length ? `<h3 class="pm-meta lb-pvk">First lines</h3><div class="lb-pvl">${lines.map((l) => `<p>${esc(l)}</p>`).join('')}</div>` : x.open && x.open.doc && !p ? '<p class="pm-meta">Reading the first lines…</p>' : '')
327
334
  + (p && p.from && p.from.length ? `<h3 class="pm-meta lb-pvk">Linked from</h3><ul>${p.from.map((f) => `<li>${esc(f.title)}</li>`).join('')}</ul>` : '')
328
335
  + (older.length ? `<h3 class="pm-meta lb-pvk">Editions</h3><ul>${older.map((o) => `<li><button type="button" class="lb-nb" data-lb-pv-ed="${esc(o.id)}">${esc(o.name)}${o.v ? ' · v' + o.v : ''}</button> <span class="pm-meta">${esc(dayText(when(o)))}</span></li>`).join('')}</ul>` : '');
329
- if (x.open && x.open.doc && !p) {
336
+ if (x.open && x.open.doc && !p && !x.pack) {
330
337
  const r = await pmGet('/api/library-items/peek?ws=' + encodeURIComponent(x.open.doc.ws) + '&path=' + encodeURIComponent(x.open.doc.path)).catch(() => null);
331
338
  S.peek.set(x.id, r && r.ok ? r : { head: [], from: [] });
332
339
  if (S.pick === x.id) drawPreview();
@@ -381,6 +388,13 @@ async function load() {
381
388
  S.at = Date.now(); S.P = P || S.P;
382
389
  if (r && r.ok) { S.items = r.items || []; nameProducts(S.items); S.programs = r.programs || []; S.error = ''; } else { S.items = S.items || []; S.error = (r && r.error) || 'the server did not answer'; }
383
390
  draw();
391
+ // the monthly review packs (Library › Reports): PMOS drafts a product's pack in the month's last week when it has none, then they join the list
392
+ pmPost('/api/review-packs/due', {}).catch(() => pmGet('/api/review-packs').catch(() => null)).then((k) => {
393
+ if (!k || !k.ok || !Array.isArray(k.items) || !k.items.length) return;
394
+ const have = new Set((S.items || []).map((x) => x.id));
395
+ S.items = [...k.items.filter((x) => !have.has(x.id)), ...(S.items || [])];
396
+ nameProducts(S.items); draw();
397
+ });
384
398
  whenNames().then(() => { nameProducts(S.items); drawFilters(); draw(); }).catch(() => {});
385
399
  }
386
400
 
@@ -459,6 +473,16 @@ pv.onclick = (e) => {
459
473
  let b;
460
474
  if (e.target.closest('[data-lb-pv-close]')) { S.pick = null; draw(); drawPreview(); return; }
461
475
  if (e.target.closest('[data-lb-pv-open]') && x) { openItem(x, { from: 'Library' }); return; }
476
+ if (e.target.closest('[data-rp-share]') && x && x.pack) {
477
+ // Share is the PM's Issue press (POST /api/report/issue): the pack is frozen as it is now. PMOS never shares a pack by itself.
478
+ noteUse('rpShare');
479
+ RP.share(x, pmPost).then((r) => {
480
+ S.shareMsg = { id: x.id, text: r && r.ok ? 'Shared. The pack is issued and frozen as it is now.' : 'Not shared: ' + ((r && r.error) || 'the server did not answer') };
481
+ if (r && r.ok) { x.pack.issued = true; x.state = 'Issued'; }
482
+ drawPreview();
483
+ });
484
+ return;
485
+ }
462
486
  if ((b = e.target.closest('[data-lb-pv-ed]'))) { const o = (S.items || []).find((i) => i.id === b.dataset.lbPvEd); if (o) openItem(o, { from: 'Library' }); }
463
487
  };
464
488
  qBox.addEventListener('input', () => { S.q = qBox.value.trim(); draw(); findByMeaning(); });
@@ -51,6 +51,7 @@
51
51
  * (Read again: a redraft that keeps the notes; Start the next cycle without a template), /api/report-setups/draft (Start the next cycle),
52
52
  * /api/report-design/revert (Go back to it). */
53
53
  import { pmGet, pmPost } from './http.js';
54
+ import * as PR from './print-pdf.js'; // Print or PDF and Send a copy: the one print layout (job #1911, A379)
54
55
  import { open as vOpen, current as vCur, czSections } from './cozy-viewer.js';
55
56
  import * as MP from './premium-mtg-present.js'; // the one presenter window for every kind (canvas note xvPresent)
56
57
  import { presentInRecording } from './cozy-rec-bridge.js'; // while a meeting records, the recording tab presents it (rule 10)
@@ -263,7 +264,7 @@ function dlPop() {
263
264
  const fmt = (k, l) => (k === 'pdf' || k === 'md' ? `<button type="button" class="vz-fmt" data-r="${k}">${l}</button>` : `<a class="vz-fmt" data-r="dl|${k}" href="/api/report-export?${esc(q({ ws: R.ws, path: R.row.path, fmt: k }))}" download>${l}</a>`);
264
265
  return `<div class="vz-pop vz-pop-dl" data-esc-layer="1" role="menu" aria-label="Download"><p class="vz-lab">Download</p>`
265
266
  + `<div class="vz-fmts">${fmt('pptx', 'PPTX')}${fmt('docx', 'DOCX')}${fmt('pdf', 'PDF')}${fmt('xlsx', 'XLSX')}${fmt('csv', 'CSV')}${fmt('md', 'MD')}</div>`
266
- + `<p class="vz-note vz-padmi">Slides as PowerPoint, words as Word or Markdown, tables as Excel or CSV. PDF keeps the look.</p><hr>${mi('print', 'print', 'Print')}</div>`;
267
+ + `<p class="vz-note vz-padmi">Slides as PowerPoint, words as Word or Markdown, tables as Excel or CSV. PDF keeps the look.</p><hr>${mi('print', 'print', 'Print or PDF')}</div>`;
267
268
  }
268
269
  function schedPop() {
269
270
  const k = R.sch, opts = [['weekly', 'Every week'], ['bi-weekly', 'Every 2 weeks'], ['monthly', 'Every month, on the 1st'], ['else', 'Something else: say it in the chat']];
@@ -340,6 +341,7 @@ function sharePop() {
340
341
  return `<div class="vz-pop vz-pop-share" data-esc-layer="1" role="dialog" aria-label="Share">${seg}${body}${foot}</div>`;
341
342
  }
342
343
  function canSend() {
344
+ PR.brandNow(R.ws); // the brand is read before Send a copy is pressed (a share sheet cannot wait)
343
345
  try { return typeof navigator !== 'undefined' && !!navigator.share && !!navigator.canShare && navigator.canShare({ files: [new File([R.text || ''], fileName(), { type: 'text/markdown' })] }); } catch { return false; }
344
346
  }
345
347
  const fileName = () => String(R.row.path).split('/').slice(-2).join('-') || 'report.md';
@@ -956,7 +958,7 @@ async function shareAct(k, v) {
956
958
  S.off = null; if (r && r.ok) { S.list = S.list.filter((x) => x.id !== v); R.shares = sharesOf(S.list, R.row.path); } else S.err = (r && r.error) || 'The link could not be turned off.';
957
959
  return draw();
958
960
  }
959
- if (k === 'shsend') { try { await navigator.share({ files: [new File([R.text || ''], fileName(), { type: 'text/markdown' })], title: R.name }); R.pop = null; draw(); } catch { /* the PM closed the share sheet */ } return; }
961
+ if (k === 'shsend') { try { await navigator.share({ files: [new File([R.W ? docPage() : R.text || ''], R.W ? fileName().replace(/\.md$/i, '') + '.html' : fileName(), { type: R.W ? 'text/html' : 'text/markdown' })], title: R.name }); R.pop = null; draw(); } catch { /* the PM closed the share sheet */ } return; }
960
962
  if (k === 'shmake') {
961
963
  if (S.pw && String(S.pass || '').trim().length < 8) { S.err = 'The password needs at least 8 characters.'; return draw(); }
962
964
  S.busy = true; S.err = ''; draw();
@@ -1041,7 +1043,14 @@ function printHtml() {
1041
1043
  : `<h1>${esc(w.title)}</h1>` + w.sections.map((x) => `<h2>${esc(x.h)}</h2>${slideHtml(x.lines)}`).join('');
1042
1044
  return frameDoc('', inner, R.view === 'deck' ? 'pmos-print pmos-print-deck' : 'pmos-print pmos-print-doc').replace('<head>', '<head><title>' + t + '</title>').replace('</head>', css + '</head>');
1043
1045
  }
1046
+ /** The document view's sections for the one print layout (pm/print-pdf.js, job #1911): Print or PDF and Send a copy use the same page. */
1047
+ function docPrint() {
1048
+ const w = R.W || { title: R.name, sections: [] };
1049
+ return { title: R.name + (R.row.slot ? ' ' + R.row.slot : ''), sections: w.sections.map((x) => ({ h: x.h, html: slideHtml(x.lines) })) };
1050
+ }
1051
+ const docPage = () => { const d = docPrint(); return PR.layoutHtml({ ...d, brand: PR.brandNow(R.ws) }); };
1044
1052
  function printIt() {
1053
+ if (!R.cyc && R.view !== 'deck' && R.W) { const d = docPrint(); PR.printPage('', { title: d.title, ws: R.ws, sections: d.sections }); return; } // Print or PDF (job #1911)
1045
1054
  const w = window.open('', '_blank');
1046
1055
  if (!w) return say('The browser blocked the print window. Allow pop-ups for this page, then press Print again.', 'bad');
1047
1056
  w.document.open(); w.document.write(printHtml()); w.document.close();
@@ -0,0 +1,191 @@
1
+ /* pm/print-pdf.js — Print or PDF: one clean print layout for every report, roadmap and initiative page (initiative print-pdf, job #1911,
2
+ * idea A379; board BatchMoreADS panel 26, agreed by Wawan 2026-11-25). Many stakeholders still read a PDF in email; this is the page they get.
3
+ *
4
+ * layoutHtml({ title, date, brand, sections, html }) PURE → the whole print document. sections: [{ h, html }] (each a section that does
5
+ * not split across pages), or html: one body. Every printed page carries the title (top left), the brand when one is set
6
+ * (top right), the date (bottom left) and "page N of M" (bottom right), through the page's margin boxes; page 1 also
7
+ * opens with the title and the date. Black on white, no shadows, no colour-only marks.
8
+ * cleanHtml(html) PURE → the same markup with no buttons, fields, menus, nav, aside, chat, scripts, styles, frames, comments or on…
9
+ * handlers. A button with words keeps its words as plain text (a task's or stage's name is often a button); an
10
+ * icon-only button goes. Anything marked data-print="skip" goes. A state glyph or a state dot becomes its word
11
+ * (pm/state-glyph.js STATES: On track, At risk, Late …); a dot whose next words already say it is dropped (say it once).
12
+ * dateLine(d) PURE → "25 Nov 2026"
13
+ * brandNow(ws) the brand already read ('' until it is; starts the read), for a press that cannot wait
14
+ * printPage(root, { title, ws, date, sections }) the browser part: cleans root's markup, asks GET /api/print for the product's brand, and prints the
15
+ * layout from a hidden frame that runs no script (sandbox without allow-scripts). The browser's print window offers
16
+ * Save as PDF. Notes the use `print-pdf` (the kill reads it).
17
+ * lib/print-pdf.js loads this module in Node for `pmos print`, so the terminal and the page print the same layout. The UI says PMOS. */
18
+ import { STATES, stateKey } from './state-glyph.js';
19
+
20
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
21
+ // a CSS string: no quote, backslash or line break can end it early
22
+ const cssStr = (s) => '"' + String(s == null ? '' : s).replace(/[\\"]/g, (c) => '\\' + c).replace(/[\r\n\u2028\u2029]+/g, ' ').slice(0, 160) + '"';
23
+ const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
24
+
25
+ export function dateLine(d = new Date()) {
26
+ const t = d instanceof Date ? d : new Date(d);
27
+ if (isNaN(t)) return '';
28
+ return `${t.getDate()} ${MONTHS[t.getMonth()]} ${t.getFullYear()}`;
29
+ }
30
+
31
+ /* ── the layout ── */
32
+ // The frame cannot load the app's stylesheets, so the page is the browser's own black on white (as pm/premium-vw-file.js prints a file):
33
+ // no colour at all, a quieter line by opacity, sizes in the font shorthand.
34
+ export const PRINT_CSS = `
35
+ .pp, .pp * { box-shadow: none !important; text-shadow: none !important; animation: none !important; transition: none !important; }
36
+ :root { color-scheme: light; }
37
+ body.pp { margin: 0; font: 11pt/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
38
+ .pp-head { margin: 0 0 18pt; }
39
+ .pp-head h1 { margin: 0; font: 700 20pt/1.2 system-ui, sans-serif; }
40
+ .pp-date { margin: 4pt 0 0; opacity: .7; }
41
+ .pp-sec { margin: 0 0 14pt; }
42
+ .pp-sec, .pm-block, section, table, tr, li, figure, blockquote, pre { break-inside: avoid; page-break-inside: avoid; }
43
+ h1, h2, h3, h4, h5 { break-after: avoid; page-break-after: avoid; }
44
+ h2 { font: 700 14pt/1.3 system-ui, sans-serif; margin: 0 0 6pt; } h3 { font: 700 12pt/1.3 system-ui, sans-serif; margin: 10pt 0 4pt; }
45
+ p { orphans: 3; widows: 3; }
46
+ table { border-collapse: collapse; width: 100%; } th, td { text-align: left; padding: 3pt 8pt 3pt 0; border-bottom: 0.5pt solid; vertical-align: top; }
47
+ a { color: inherit; text-decoration: none; }
48
+ img, svg, canvas { max-width: 100%; height: auto; }
49
+ .pp-st { font-weight: 600; }
50
+ `;
51
+
52
+ /** The page's margin boxes: title, brand, date and "page N of M" on every printed page. */
53
+ function pageCss(title, date, brand) {
54
+ return `@page { size: A4; margin: 18mm 16mm 20mm;
55
+ @top-left { content: ${cssStr(title)}; font: 9pt system-ui, sans-serif; }
56
+ ${brand ? `@top-right { content: ${cssStr(brand)}; font: 600 9pt system-ui, sans-serif; }` : ''}
57
+ @bottom-left { content: ${cssStr(date)}; font: 9pt system-ui, sans-serif; }
58
+ @bottom-right { content: "page " counter(page) " of " counter(pages); font: 9pt system-ui, sans-serif; }
59
+ }`;
60
+ }
61
+
62
+ export function layoutHtml({ title = '', date = '', brand = '', sections = null, html = '' } = {}) {
63
+ const t = String(title || 'PMOS').trim(), d = String(date || dateLine()).trim(), b = String(brand || '').trim();
64
+ const body = Array.isArray(sections) && sections.length
65
+ ? sections.map((s) => `<section class="pp-sec">${s.h ? `<h2>${esc(s.h)}</h2>` : ''}${cleanHtml(s.html || '')}</section>`).join('\n')
66
+ : `<div class="pp-sec pp-one">${cleanHtml(html || '')}</div>`;
67
+ return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${esc(t)}</title>`
68
+ + `<style>${pageCss(t, d, b)}${PRINT_CSS}</style></head>`
69
+ + `<body class="pp"><header class="pp-head"><h1>${esc(t)}</h1><p class="pp-date">${esc(d)}${b ? ' · ' + esc(b) : ''}</p></header>\n<main>${body}</main></body></html>`;
70
+ }
71
+
72
+ /* ── the clean-up ── */
73
+ const VOID = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'source', 'track', 'wbr']);
74
+ const DROP = new Set(['input', 'select', 'textarea', 'nav', 'aside', 'script', 'style', 'noscript', 'iframe', 'object', 'embed', 'template', 'dialog', 'link', 'meta', 'base', 'audio', 'video']);
75
+ const DROP_ROLE = /^(menu|menubar|toolbar|tablist|search|dialog|alertdialog|tooltip|status)$/i;
76
+ const DROP_CLASS = /(^|\s)(cz-pop[\w-]*|cz-fab|cz-chat[\w-]*|chat[\w-]*|pm-toast[\w-]*|pm-menu|vz-tb|vz-pop[\w-]*|hi-pop[\w-]*|tr-card)(\s|$)/;
77
+
78
+ const attr = (a, n) => { const m = new RegExp('(?:^|\\s)' + n + '\\s*=\\s*("([^"]*)"|\'([^\']*)\'|([^\\s>]+))', 'i').exec(a || ''); return m ? (m[2] ?? m[3] ?? m[4] ?? '') : null; };
79
+ const has = (a, n) => new RegExp('(?:^|\\s)' + n + '(?:\\s*=|\\s|$)', 'i').test(a || '');
80
+ const BLOCK_END = /<\/?(?:p|li|td|th|tr|div|section|h[1-6]|ul|ol|table|br|hr|header|footer|article)\b/i;
81
+ const textOf = (h) => String(h || '').replace(/<[^>]*>/g, ' ').replace(/&nbsp;/g, ' ').replace(/\s+/g, ' ').trim();
82
+
83
+ /** The word a state glyph or dot prints as, or null when the element is not one. */
84
+ function stateWord(tag, a) {
85
+ const cls = attr(a, 'class') || '';
86
+ if (/(^|\s)pm-glyph(\s|$)/.test(cls)) {
87
+ const k = stateKey(attr(a, 'data-state') || '') || stateKey(attr(a, 'aria-label') || '');
88
+ return k ? STATES[k].word : (attr(a, 'aria-label') || '');
89
+ }
90
+ if (/(^|\s)cz-dot(\s|$)/.test(cls)) {
91
+ for (const c of cls.split(/\s+/)) { const k = c !== 'cz-dot' && stateKey(c); if (k) return STATES[k].word; }
92
+ return attr(a, 'aria-label') || attr(a, 'title') || '';
93
+ }
94
+ return null;
95
+ }
96
+
97
+ /** Strip on… handlers, style-less risky attributes and script links from a kept tag. */
98
+ function safeAttrs(a) {
99
+ return String(a || '')
100
+ .replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi, '')
101
+ .replace(/\s+(href|src|xlink:href|action|formaction)\s*=\s*("\s*(javascript|vbscript|data:text\/html)[^"]*"|'\s*(javascript|vbscript|data:text\/html)[^']*'|(javascript|vbscript)[^\s>]*)/gi, '')
102
+ .replace(/\s+(contenteditable|tabindex|draggable|autofocus)(\s*=\s*("[^"]*"|'[^']*'|[^\s>]+))?/gi, '');
103
+ }
104
+
105
+ const TAG_SRC = /<!--[\s\S]*?-->|<!\[CDATA\[[\s\S]*?\]\]>|<!doctype[^>]*>|<\/?([a-zA-Z][\w:-]*)((?:"[^"]*"|'[^']*'|[^'">])*)>/gi;
106
+
107
+ /** Where the element opened at `from` (just after its open tag) ends: the index after its close tag (or the end). */
108
+ function closeOf(html, name, from) {
109
+ const re = new RegExp('<(/?)' + name + '\\b(?:"[^"]*"|\'[^\']*\'|[^\'">])*>', 'gi');
110
+ re.lastIndex = from;
111
+ let depth = 1, m;
112
+ while ((m = re.exec(html))) {
113
+ if (/\/>$/.test(m[0]) && !m[1]) continue;
114
+ depth += m[1] ? -1 : 1;
115
+ if (!depth) return { inner: html.slice(from, m.index), end: re.lastIndex };
116
+ }
117
+ return { inner: html.slice(from), end: html.length };
118
+ }
119
+
120
+ export function cleanHtml(html) {
121
+ const s = String(html || '');
122
+ const TAG = new RegExp(TAG_SRC.source, 'gi'); // one per call: a nested call must not move this one
123
+ let out = '', i = 0, m;
124
+ while ((m = TAG.exec(s))) {
125
+ out += s.slice(i, m.index); i = TAG.lastIndex;
126
+ if (!m[1]) continue; // a comment, CDATA or doctype
127
+ const name = m[1].toLowerCase(), a = m[2] || '', closing = m[0][1] === '/';
128
+ if (closing) { if (!DROP.has(name) && name !== 'button') out += `</${name}>`; continue; }
129
+ const self = VOID.has(name) || /\/\s*$/.test(a);
130
+ const skipAll = () => { if (!self) { const c = closeOf(s, name, i); i = c.end; TAG.lastIndex = c.end; return c.inner; } return ''; };
131
+ const word = stateWord(name, a);
132
+ if (word !== null) {
133
+ skipAll();
134
+ const next = textOf(s.slice(i, i + 400).split(BLOCK_END)[0]).slice(0, 80).toLowerCase(); // the words up to the end of this line
135
+ if (word && !next.includes(word.toLowerCase())) out += `<span class="pp-st">${esc(word)}</span> `;
136
+ continue;
137
+ }
138
+ const role = attr(a, 'role') || '', cls = attr(a, 'class') || '';
139
+ if (DROP.has(name) || attr(a, 'data-print') === 'skip' || has(a, 'hidden') || attr(a, 'aria-hidden') === 'true' && name !== 'svg'
140
+ || DROP_ROLE.test(role) || DROP_CLASS.test(cls) || has(a, 'data-chat')) { skipAll(); continue; }
141
+ if (name === 'button' || role === 'button' || role === 'menuitem') {
142
+ // a button with words keeps its words (a task's name); an icon-only or action button goes
143
+ const inner = skipAll(), words = textOf(cleanHtml(inner));
144
+ if (words && !/(^|\s)pm-btn(\s|$)/.test(cls)) out += `<span>${cleanHtml(inner)}</span>`;
145
+ continue;
146
+ }
147
+ if (name === 'svg' && attr(a, 'aria-hidden') === 'true') { skipAll(); continue; } // an icon
148
+ out += `<${name}${safeAttrs(a)}>`;
149
+ }
150
+ out += s.slice(i);
151
+ return out.replace(/<\/(button|script|style|textarea|select|nav|aside|iframe)>/gi, '').replace(/[ \t]+\n/g, '\n');
152
+ }
153
+
154
+ /* ── the browser part ── */
155
+ let brandCache = null;
156
+ async function brandFor(ws) {
157
+ const k = String(ws || '');
158
+ if (brandCache && brandCache.k === k) return brandCache.v;
159
+ let v = '';
160
+ try { const { pmGet } = await import('./http.js'); const r = await pmGet('/api/print' + (k ? '?ws=' + encodeURIComponent(k) : '')); v = (r && r.ok && r.brand) || ''; } catch { v = ''; }
161
+ brandCache = { k, v };
162
+ return v;
163
+ }
164
+
165
+ /** The brand already read for ws ('' until GET /api/print answers; the call starts the read). For a press that must not wait: a share sheet. */
166
+ export function brandNow(ws) {
167
+ const k = String(ws || '');
168
+ if (brandCache && brandCache.k === k) return brandCache.v;
169
+ if (typeof document !== 'undefined') brandFor(k).catch(() => {});
170
+ return '';
171
+ }
172
+
173
+ /** Print root (an element, or markup) in the layout. Returns the frame, or null outside a browser. */
174
+ export async function printPage(root, { title = '', ws = '', date = '', sections = null } = {}) {
175
+ if (typeof document === 'undefined') return null;
176
+ try { const { noteUse } = await import('./use-log.js'); noteUse('print-pdf'); } catch { /* the use log is optional */ }
177
+ const html = typeof root === 'string' ? root : root && root.innerHTML ? root.innerHTML : '';
178
+ const brand = await brandFor(ws);
179
+ const doc = layoutHtml({ title, date: date || dateLine(), brand, sections, html });
180
+ document.querySelectorAll('iframe.pp-frame').forEach((x) => x.remove());
181
+ const fr = document.createElement('iframe');
182
+ fr.className = 'pp-frame';
183
+ fr.setAttribute('sandbox', 'allow-same-origin allow-modals'); // no allow-scripts: the page prints, nothing in it runs
184
+ fr.setAttribute('aria-hidden', 'true'); fr.tabIndex = -1;
185
+ fr.width = '0'; fr.height = '0'; fr.setAttribute('frameborder', '0'); // out of sight; a hidden frame does not print in every browser
186
+ fr.addEventListener('load', () => { try { fr.contentWindow.focus(); fr.contentWindow.print(); } catch { /* the browser refused: the PM prints again */ } }, { once: true });
187
+ fr.srcdoc = doc;
188
+ document.body.append(fr);
189
+ setTimeout(() => fr.remove(), 120000);
190
+ return fr;
191
+ }
@@ -49,3 +49,15 @@
49
49
  .rp .rp-nav { width: 44px; height: 44px; }
50
50
  .rp .rp-clear { min-height: 44px; }
51
51
  }
52
+ /* the optional time (task-time-optional): a clock press at the foot's end, and a row of time fields above the foot */
53
+ .rp .rp-clock { margin-left: auto; display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: var(--radius-pill); background: none; color: var(--cz-ink2); cursor: pointer; }
54
+ .rp .rp-clock[aria-expanded="true"] { background: var(--cz-bluebg); color: var(--cz-blue); }
55
+ .rp-tm { display: flex; gap: var(--space-8); }
56
+ .rp .rp-tf { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 1px; height: 52px; padding: 6px 10px; border-radius: var(--radius-md); background: var(--cz-well); box-sizing: border-box; }
57
+ .rp .rp-tf small { font-size: var(--fs-badge); font-weight: var(--fw-strong); color: var(--cz-ink3); line-height: var(--lh-badge); }
58
+ .rp .rp-ti { width: 100%; min-width: 0; border: 0; padding: 0; background: none; font: inherit; font-size: var(--fs-body); font-weight: var(--fw-strong); color: var(--cz-ink); line-height: var(--lh-body); outline: 0; font-variant-numeric: tabular-nums; }
59
+ .rp .rp-ti:disabled { color: var(--cz-ink3); }
60
+ .rp .rp-tf:focus-within { box-shadow: inset 0 0 0 2px var(--cz-blue); }
61
+ @media (hover: hover) { .rp .rp-clock:hover { background: var(--cz-well); color: var(--cz-ink); } }
62
+ @media (pointer: coarse), (max-width: 640px) { .rp .rp-clock { width: 44px; height: 44px; } .rp .rp-tf { height: 60px; } }
63
+ .rp .rp-ti::-webkit-calendar-picker-indicator { display: none; } /* the clock press is the one clock; the field takes typed digits */
@@ -9,15 +9,21 @@
9
9
  * Words work as well (bet A488): "friday", "+2w", "in 3 days", "end of month", "end of sprint" (o.sprintEnd). While the PM types, the
10
10
  * message line says the day it read ("Reads as Friday 27 Nov 2026 · Enter saves") before anything is saved; a word form taken logs dateWords.
11
11
  * Keyboard: arrows move a day or a week, Page Up/Down a month, Home/End the week's ends, Enter or Space picks.
12
+ * A time is optional (Wawan 2026-11-25, initiative task-time-optional): where the host offers it (o.time), a clock press beside No date
13
+ * opens a time row, Start time and Due time (a milestone one Time), each saved on its own change as { start_time | due_time: 'HH:MM' or
14
+ * '' }. A set time opens the row by itself. The days never carry the time, so a task with no time picks, saves and reads as before.
12
15
  *
13
- * rangeHtml(s, o) → markup pure, for node tests. s: { start, due, field: 'start'|'due', month: 'YYYY-MM', one, focus }
16
+ * rangeHtml(s, o) → markup pure, for node tests. s: { start, due, field: 'start'|'due', month: 'YYYY-MM', one, focus,
17
+ * time (the host offers a time), timeOpen, start_time, due_time }
14
18
  * o: { today, head (html drawn first), coarse (a phone: the fields do not open the keyboard) }
15
19
  * rangeTap(s, iso) → { patch, field, done } pure: what one tap (or a typed day, or '' for "No date") writes, and what comes next
16
20
  * mountRange(el, o) → { state } draws into el and wires it. o: { start, due, one, field, today, head, sprintEnd (an ISO day, or a function that gives one),
21
+ * time (true: offer the optional time), start_time, due_time,
17
22
  * onPick(patch, done, state) — after each tap; done: the range is complete, the host closes;
18
23
  * onState(state) — after each draw, so a host that redraws can open it where it was }
19
24
  * Its own presses stop at el, so a popup's click handler around it sees only the host's own buttons (a sheet's ✕). */
20
25
  import { dayText, dayLong, parseDay, wordsOnly, localToday } from './cozy-day-pick.js';
26
+ import { isTime } from './day-time.js';
21
27
 
22
28
  const CSS = new URL('./range-pick.css', import.meta.url).href;
23
29
  if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${CSS}"]`)) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = CSS; document.head.appendChild(l); }
@@ -30,7 +36,7 @@ const iso = (n) => new Date(n).toISOString().slice(0, 10);
30
36
  const addDays = (v, n) => iso(ms(v) + n * 864e5);
31
37
  const addMonths = (ym, n) => { const [y, m] = ym.split('-').map(Number); return iso(Date.UTC(y, m - 1 + n, 1)).slice(0, 7); };
32
38
  const svg = (d, s = 16) => `<svg aria-hidden="true" width="${s}" height="${s}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
33
- const ARR = { prev: 'M15 6l-6 6 6 6', next: 'M9 6l6 6-6 6' }, DIA = 'M12 4l8 8-8 8-8-8z';
39
+ const ARR = { prev: 'M15 6l-6 6 6 6', next: 'M9 6l6 6-6 6' }, DIA = 'M12 4l8 8-8 8-8-8z', CLOCK = 'M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0zM12 7v5l3 2';
34
40
 
35
41
  /** The month shown: the one asked for, else the end being picked, else the start, else today's. */
36
42
  const monthOf = (s, today) => (s.month && /^\d{4}-\d{2}$/.test(s.month) ? s.month : String((isDay(s[fieldOf(s)]) && s[fieldOf(s)]) || (isDay(s.start) && s.start) || (isDay(s.due) && s.due) || today).slice(0, 7));
@@ -72,18 +78,24 @@ export function rangeHtml(s, o = {}) {
72
78
  const ends = s.one ? `<div class="rp-ends one">${inp('due', 'Date', svg(DIA, 12))}</div>` : `<div class="rp-ends">${inp('start', 'Start')}${svg(ARR.next, 14)}${inp('due', 'Due')}</div>`;
73
79
  const tom = addDays(today, 1), dow = new Date(ms(today)).getUTCDay(), fri = addDays(today, ((5 - dow + 7) % 7) || 7);
74
80
  const quick = `<div class="rp-qk"><button type="button" data-rp-day="${today}">Today</button><button type="button" data-rp-day="${tom}">Tomorrow</button><button type="button" data-rp-day="${fri}">Fri</button></div>`;
81
+ // the optional time (task-time-optional): a clock press beside No date; the row shows when pressed or when a time is set
82
+ const tOpen = !!s.time && (!!s.timeOpen || isTime(s.start_time) || isTime(s.due_time));
83
+ const tin = (k, label, day) => `<label class="rp-tf"><small>${label}</small><input class="rp-ti" data-rp-tm="${k}" type="time" value="${isTime(s[k]) ? s[k] : ''}" aria-label="${esc(label + (day ? '' : ', pick a day first'))}"${day ? '' : ' disabled'}></label>`;
84
+ const times = tOpen ? `<div class="rp-tm">${s.one ? tin('due_time', 'Time', b) : tin('start_time', 'Start time', a) + tin('due_time', 'Due time', b)}</div>` : '';
85
+ const clock = s.time ? `<button type="button" class="rp-clock" data-rp-time aria-expanded="${tOpen}" aria-label="${tOpen ? 'Time' : 'Add a time'}" title="${tOpen ? 'Time' : 'Add a time'}">${svg(CLOCK, 16)}</button>` : '';
75
86
  return `<div class="rp${s.one ? ' one' : ''}" data-rp>${o.head || ''}${ends}${quick}`
76
87
  + `<div class="rp-mh"><button type="button" class="rp-nav" data-rp-month="${addMonths(ym, -1)}" aria-label="Previous month">${svg(ARR.prev)}</button><b aria-live="polite">${FULL[m - 1]} ${y}</b><button type="button" class="rp-nav" data-rp-month="${addMonths(ym, 1)}" aria-label="Next month">${svg(ARR.next)}</button></div>`
77
88
  + `<div class="rp-g" role="grid" aria-label="${esc(FULL[m - 1] + ' ' + y)}"><div class="rp-row rp-wk" aria-hidden="true"><i>M</i><i>T</i><i>W</i><i>T</i><i>F</i><i>S</i><i>S</i></div>${weeks.join('')}</div>`
78
89
  + `<p class="rp-msg" role="status"${o.msg ? '' : ' hidden'}>${esc(o.msg || '')}</p>`
79
- + `<div class="rp-ft"><button type="button" class="rp-clear" data-rp-clear>No date</button></div></div>`;
90
+ + times + `<div class="rp-ft"><button type="button" class="rp-clear" data-rp-clear>No date</button>${clock}</div></div>`;
80
91
  }
81
92
 
82
93
  const coarse = () => typeof matchMedia === 'function' && matchMedia('(pointer: coarse)').matches;
83
94
 
84
95
  export function mountRange(el, o = {}) {
85
96
  const today = o.today || localToday();
86
- const s = { start: isDay(o.start) && !o.one ? o.start : '', due: isDay(o.due) ? o.due : '', one: !!o.one, field: o.one ? 'due' : o.field === 'due' ? 'due' : 'start', month: o.month || '', focus: '' };
97
+ const s = { start: isDay(o.start) && !o.one ? o.start : '', due: isDay(o.due) ? o.due : '', one: !!o.one, field: o.one ? 'due' : o.field === 'due' ? 'due' : 'start', month: o.month || '', focus: '',
98
+ time: !!o.time, timeOpen: !!o.timeOpen, start_time: isTime(o.start_time) && !o.one ? o.start_time : '', due_time: isTime(o.due_time) ? o.due_time : '' };
87
99
  let msg = '', drawing = false;
88
100
  const draw = (focusDay) => {
89
101
  if (focusDay) { s.focus = focusDay; s.month = focusDay.slice(0, 7); }
@@ -95,6 +107,8 @@ export function mountRange(el, o = {}) {
95
107
  const tap = (v, from) => {
96
108
  const r = rangeTap(s, v);
97
109
  Object.assign(s, r.patch); s.field = r.field; msg = '';
110
+ if (r.patch.start === '') s.start_time = ''; // a day taken out takes its time with it (the server does the same)
111
+ if (r.patch.due === '') s.due_time = '';
98
112
  draw(from === 'grid' && v ? v : null);
99
113
  if (from === 'type' && !r.done) el.querySelector(`[data-rp-end="${s.field}"] .rp-in`)?.focus({ preventScroll: true });
100
114
  if (o.onPick) o.onPick(r.patch, r.done, { ...s });
@@ -109,8 +123,9 @@ export function mountRange(el, o = {}) {
109
123
  el.onclick = (e) => {
110
124
  const b = e.target.closest('button'); if (!b || !el.contains(b) || !b.closest('[data-rp]')) return;
111
125
  const d = b.dataset;
112
- if (d.rpDay == null && d.rpMonth == null && !('rpClear' in d)) return; // the host's own button (a sheet's ✕)
126
+ if (d.rpDay == null && d.rpMonth == null && !('rpClear' in d) && !('rpTime' in d)) return; // the host's own button (a sheet's ✕)
113
127
  e.stopPropagation();
128
+ if ('rpTime' in d) { s.timeOpen = !s.timeOpen; draw(); (el.querySelector('.rp-ti:not([disabled])') || el.querySelector('[data-rp-time]'))?.focus({ preventScroll: true }); return; }
114
129
  if (d.rpMonth) { const next = b.getAttribute('aria-label') === 'Next month'; s.month = d.rpMonth; s.focus = ''; draw(); el.querySelector(next ? '.rp-mh .rp-nav:last-child' : '.rp-mh .rp-nav')?.focus({ preventScroll: true }); return; }
115
130
  if ('rpClear' in d) { tap('', 'clear'); return; }
116
131
  tap(d.rpDay, b.closest('.rp-g') ? 'grid' : 'quick');
@@ -166,7 +181,16 @@ export function mountRange(el, o = {}) {
166
181
  if (btn) { el.querySelectorAll('.rp-g [tabindex="0"]').forEach((x) => x.setAttribute('tabindex', '-1')); btn.setAttribute('tabindex', '0'); btn.focus({ preventScroll: true }); }
167
182
  else draw(to);
168
183
  });
169
- el.addEventListener('change', (e) => { const inp = e.target.closest && e.target.closest('.rp-in'); if (inp) take(inp); });
184
+ el.addEventListener('change', (e) => {
185
+ const inp = e.target.closest && e.target.closest('.rp-in'); if (inp) { take(inp); return; }
186
+ // a time field: saved on its own change, "HH:MM" or '' when it is cleared; the picker stays open
187
+ const ti = e.target.closest && e.target.closest('.rp-ti'); if (!ti || drawing || !ti.isConnected) return;
188
+ const k = ti.dataset.rpTm, v = ti.value ? String(ti.value).slice(0, 5) : '';
189
+ if ((v && !isTime(v)) || v === s[k]) return;
190
+ s[k] = v; s.timeOpen = true;
191
+ if (o.onState) o.onState({ ...s });
192
+ if (o.onPick) o.onPick({ [k]: v }, false, { ...s });
193
+ });
170
194
  draw();
171
195
  return { state: s, focus() { (el.querySelector('.rp-g [tabindex="0"]') || el.querySelector('.rp-in'))?.focus({ preventScroll: true }); } };
172
196
  }