create-pmos 0.406.0 → 0.408.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 (32) hide show
  1. package/package.json +25 -30
  2. package/payload/KIT-VERSION +2 -2
  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/payload/state/log.md +1 -1
  7. package/workspace/briefing-premium-adddoc-test.js +4 -3
  8. package/workspace/briefing-premium-doc-edit-test.js +3 -5
  9. package/workspace/briefing-premium-initiative-test.js +46 -27
  10. package/workspace/changelog.json +24 -0
  11. package/workspace/guide/home.md +11 -5
  12. package/workspace/home-other-product-test.js +94 -0
  13. package/workspace/package-lock.json +2 -2
  14. package/workspace/package.json +1 -1
  15. package/workspace/premium-board-actions-test.js +2 -2
  16. package/workspace/premium-core-doc-issue-test.js +4 -1
  17. package/workspace/premium-vw-backlog-test.js +3 -3
  18. package/workspace/premium-vw-doc-test.js +4 -6
  19. package/workspace/premium-vw-item-test.js +1 -1
  20. package/workspace/premium-vw-jira-test.js +2 -2
  21. package/workspace/public/pm/bd-prog-panel.js +4 -3
  22. package/workspace/public/pm/cozy-home.css +5 -0
  23. package/workspace/public/pm/cozy-nav.js +4 -0
  24. package/workspace/public/pm/cozy-today.css +2 -0
  25. package/workspace/public/pm/cozy-viewer.js +24 -8
  26. package/workspace/public/pm/home-app.js +138 -62
  27. package/workspace/public/pm/home-ini.css +14 -0
  28. package/workspace/public/pm/home-ini.js +93 -81
  29. package/workspace/public/pm/home-today.js +7 -5
  30. package/workspace/public/premium.html +1 -1
  31. package/workspace/test-lists/briefing-premium.json +3 -1
  32. package/workspace/tk-tasks-test.js +2 -3
@@ -77,11 +77,9 @@ const prop = (o) => Object.assign({ id: 'prop-a', state: 'proposed', prompt: 'ad
77
77
  return send({ ok: false, error: 'not in this test' }, 404);
78
78
  });
79
79
  await page.goto(BASE + '/premium.html?ini=self-serve-v2&ws=w1&theme=' + theme);
80
- await until(() => page.evaluate(() => !!document.querySelector('.hm-r[data-id="f:planning/prd/self-serve-v2-prd.md"]')), 15000);
81
- await until(() => page.evaluate(() => !!document.querySelector('#hmList [data-hi-open="docs"]')), 15000);
82
- if (!(await page.evaluate(() => !!document.querySelector('#hmList [data-hi-open="docs"]').offsetParent))) await page.click('#hmNeeds'); // a phone may show the list in the top bar's sheet
83
- // the initiative's Core documents group (in place of the Files group, premium-uncovered-features InDocs) opens every document in the Viewer
84
- await page.click('#hmList [data-hi-open="docs"]');
80
+ await until(() => page.evaluate(() => !!document.querySelector('#czViewer [data-hi-open="docs"]')), 15000); // the initiative's page (canvas HbC)
81
+ // the page's Documents "Show all N" opens every document in the Viewer
82
+ await page.click('#czViewer [data-hi-open="docs"]');
85
83
  await until(() => page.evaluate(() => !!document.querySelector('#czViewer [data-ov-open="planning/prd/self-serve-v2-prd.md"]')), 15000);
86
84
  await page.click('#czViewer [data-ov-open="planning/prd/self-serve-v2-prd.md"]'); // the PRD opens as a page
87
85
  await until(() => page.evaluate(() => document.querySelector('.vwdoc .cf, .vwdoc .vwempty:not(:empty)') && !/Reading the file/.test(document.querySelector('.vwdoc').textContent)));
@@ -111,7 +109,7 @@ const prop = (o) => Object.assign({ id: 'prop-a', state: 'proposed', prompt: 'ad
111
109
  ok('D9 Links show what it is built from and what uses it, from the document library', /Built from · 1.*Onboarding interviews/.test(await txt(p, V + ' .vwmp')) && /Used by · 1.*Self-serve rubric/.test(await txt(p, V + ' .vwmp')) && /Links 2/.test(await txt(p, V + ' .vwmore')));
112
110
  await p.click(V + ' [data-vd="open:planning/evals/self-serve-v2-rubric.md"]');
113
111
  ok('D9 a linked document opens as a page in the Viewer, in place of this one', await until(() => p.evaluate(() => !!document.querySelector('#czViewer .obody.vw[data-vw="doc:planning/evals/self-serve-v2-rubric.md"]'))));
114
- await p.click('#hmList [data-hi-open="docs"]'); // back to the PRD: Core documents opens it again
112
+ await (async (g) => { const P = '#czViewer:not([hidden]) [data-hi-v="page"]', r = '#hmList [data-hm-sel^="i:"][aria-current="true"]'; for (let i = 0; i < 4 && !(await g.$(P)) && (await g.$('#czViewer:not([hidden]) [data-cz-vw="back"]')); i++) { await g.click('#czViewer [data-cz-vw="back"]'); await g.waitForTimeout(150); } if (await g.$(P)) return; if (await g.$(r)) await g.click(r); else await g.reload(); await g.waitForSelector(P + ' .hi-pgh [data-hi-addtask]', { timeout: 30000 }); })(p); /* ← back to the initiative's page, else its row, else the address again (an initiative the list does not show) */ await p.click('#czViewer [data-hi-open="docs"]'); // back to the PRD: the initiative's row opens its page, and Documents opens it again
115
113
  await until(() => p.evaluate(() => !!document.querySelector('#czViewer [data-ov-open="planning/prd/self-serve-v2-prd.md"]')), 15000);
116
114
  await p.click('#czViewer [data-ov-open="planning/prd/self-serve-v2-prd.md"]');
117
115
  await until(() => p.evaluate(() => !!document.querySelector('#czViewer .obody.vw[data-vw="doc:planning/prd/self-serve-v2-prd.md"] .vwdoc .cf')));
@@ -52,7 +52,7 @@ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
52
52
  return { page, ctx, S };
53
53
  };
54
54
  const viaMore = async (pg, label) => { await pg.click('#czViewer:not([hidden]) [data-cz-vw="more"]'); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer .cz-vw-menu'))); await pg.click(`#czViewer .cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("${label}"))`); }; // the Overview's other views, Open the full record and Sprint sit under ⋯ (XvATasks)
55
- const overview = async (page) => { if (!(await page.locator('.hm-card [data-hm-ov]').isVisible())) await page.click('#hmNeeds'); await page.click('.hm-card [data-hm-ov]'); /* a phone: the initiative card is in the top bar's sheet */ return until(() => page.evaluate(() => !!document.querySelector('#czViewer [data-cz-vw="more"]') && !!document.querySelector('#czViewer [data-ov-tk="task:t1"]'))); };
55
+ const overview = async (page) => { await (async (g) => { const P = '#czViewer:not([hidden]) [data-hi-v="page"]', r = '#hmList [data-hm-sel^="i:"][aria-current="true"]'; for (let i = 0; i < 4 && !(await g.$(P)) && (await g.$('#czViewer:not([hidden]) [data-cz-vw="back"]')); i++) { await g.click('#czViewer [data-cz-vw="back"]'); await g.waitForTimeout(150); } if (await g.$(P)) return; if (await g.$(r)) await g.click(r); else await g.reload(); await g.waitForSelector(P + ' .hi-pgh [data-hi-addtask]', { timeout: 30000 }); })(page); /* ← back to the initiative's page, else its row, else the address again (an initiative the list does not show) */ await page.click('#czViewer .hi-pgh [data-hi-addtask]'); /* the initiative's page (canvas HbC): its + drills into Tasks */ return until(() => page.evaluate(() => !!document.querySelector('#czViewer [data-cz-vw="more"]') && !!document.querySelector('#czViewer [data-ov-tk="task:t1"]'))); };
56
56
  const cur = (page) => page.evaluate(() => { const p = document.querySelector('#czViewer:not([hidden]) .obody.vw'); return { on: p ? p.dataset.vw : null, title: (document.querySelector('#czVwTitle') || {}).textContent || '', n: document.querySelectorAll('#czViewer .obody.vw').length }; });
57
57
  const paneTxt = (page, id) => page.evaluate((k) => { const p = document.querySelector(`#czViewer .obody.vw[data-vw="${CSS.escape(k)}"]`); return p ? p.textContent.replace(/\s+/g, ' ') : ''; }, id);
58
58
  const INI = 'item:ini:self-serve-v2';
@@ -72,7 +72,7 @@ const TICKETS = {
72
72
  const IMODEL = IP.build(IF.facts());
73
73
  // Home's initiative layout (premium-agreed-design): the card's Overview has the Sprint press; the Viewer shows one item at a time
74
74
  const viaMore = async (pg, label) => { await pg.click('#czViewer:not([hidden]) [data-cz-vw="more"]'); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer .cz-vw-menu'))); await pg.click(`#czViewer .cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("${label}"))`); }; // the Overview's other views, Open the full record and Sprint sit under ⋯ (XvATasks)
75
- const overview = async (pg) => { if (!(await pg.locator('.hm-card [data-hm-ov]').isVisible())) await pg.click('#hmNeeds'); await pg.click('.hm-card [data-hm-ov]'); /* a phone: the initiative card is in the top bar's sheet */ return until(() => pg.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v]'))); };
75
+ const overview = async (pg) => { await (async (g) => { const P = '#czViewer:not([hidden]) [data-hi-v="page"]', r = '#hmList [data-hm-sel^="i:"][aria-current="true"]'; for (let i = 0; i < 4 && !(await g.$(P)) && (await g.$('#czViewer:not([hidden]) [data-cz-vw="back"]')); i++) { await g.click('#czViewer [data-cz-vw="back"]'); await g.waitForTimeout(150); } if (await g.$(P)) return; if (await g.$(r)) await g.click(r); else await g.reload(); await g.waitForSelector(P + ' .hi-pgh [data-hi-addtask]', { timeout: 30000 }); })(pg); /* ← back to the initiative's page, else its row, else the address again (an initiative the list does not show) */ await pg.click('#czViewer .hi-pgh [data-hi-addtask]'); /* the initiative's page (canvas HbC): its + drills into Tasks */ return until(() => pg.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v]'))); };
76
76
  const openSprint = async (pg) => { if (!(await pg.$('#czViewer:not([hidden]) [data-hi-v]'))) await overview(pg); /* open() already showed the Overview */ await viaMore(pg, 'Sprint'); };
77
77
  const open = async ({ w = 1280, h = 900, theme = 'light', sprints = SPRINTS, tickets = TICKETS } = {}) => {
78
78
  const ctx = await browser.newContext({ viewport: { width: w, height: h }, colorScheme: theme });
@@ -138,7 +138,7 @@ const TICKETS = {
138
138
  && await p.evaluate(() => [...document.querySelectorAll('#czViewer .obody.vw a[href]')].every((a) => a.href === 'https://acme.atlassian.net/browse/PMOS-142' && a.target === '_blank' && /noopener/.test(a.rel))));
139
139
  await p.click('#czViewer .obody.vw [data-jt="PMOS-152"]');
140
140
  ok('K6 a linked ticket opens in its own tab', !!(await until(async () => { const t = await paneText(p, 'jira:PMOS-152'); return t && /Release to existing workspaces/.test(t) && /No sprint/.test(t); })));
141
- if (!(await p.locator('.hm-card [data-hm-ov]').isVisible())) await p.click('#hmNeeds'); await p.click('.hm-card [data-hm-ov]');
141
+ await (async (g) => { const P = '#czViewer:not([hidden]) [data-hi-v="page"]', r = '#hmList [data-hm-sel^="i:"][aria-current="true"]'; for (let i = 0; i < 4 && !(await g.$(P)) && (await g.$('#czViewer:not([hidden]) [data-cz-vw="back"]')); i++) { await g.click('#czViewer [data-cz-vw="back"]'); await g.waitForTimeout(150); } if (await g.$(P)) return; if (await g.$(r)) await g.click(r); else await g.reload(); await g.waitForSelector(P + ' .hi-pgh [data-hi-addtask]', { timeout: 30000 }); })(p); /* ← back to the initiative's page, else its row, else the address again (an initiative the list does not show) */ await p.click('#czViewer .hi-pgh [data-hi-addtask]'); /* the initiative's page (canvas HbC): its + drills into Tasks */
142
142
  const k7 = await until(() => p.evaluate((t0) => { const m = document.querySelector('#czViewer:not([hidden]) .cz-vw-body'); return m && m.textContent === t0 ? m.textContent : null; }, mainTxt));
143
143
  ok('K7 the Overview comes back with its own facts, as before', !!k7, await p.evaluate(() => ((document.querySelector('#czViewer .cz-vw-body') || {}).textContent || '').slice(0, 300)));
144
144
  ok('K8 the views read the two Jira routes only, and wrote nothing', A.posts.filter((x) => !/thread|note|seen/.test(x)).length === 0 && A.reads.every((r) => /^\/api\/(jira\/tickets|boards\/sprints)\?/.test(r)) && A.reads.some((r) => /jira\/tickets\?.*initiative=self-serve-v2/.test(r)), JSON.stringify([A.posts, A.reads]));
@@ -2,8 +2,9 @@
2
2
  * shell A since the second kit (initiative viewer-shell-a, V9): the shell's header, summary card and folding rows in place of the panel's own
3
3
  * head and tabs. The content is the same. The shell floats at 560 px over the page's right edge and does not push the page.
4
4
  *
5
- * mount(o) once, from premium-board.js. o: { M() the Board model, programs() GET /api/programs' programs, openIni(id, from) the initiative
6
- * of a row of this board, close() what the shell shows for the Board, reload() reads the programs again, say(msg) the toast }
5
+ * mount(o) once, from premium-board.js or home-app.js. o: { M() the Board model, programs() GET /api/programs' programs, openIni(id, from) the
6
+ * initiative of a row of this board, close() what the shell shows for the Board, reload() reads the programs again, say(msg) the
7
+ * toast, drill? true keeps the program behind the initiative it opens, so ← comes back to it (Home, canvas HbCProg) }
7
8
  *
8
9
  * The panel opens on document `bd:program` { id, from? }. A program row of the Board ([data-prog]) and ?program=<id> (Home links there) send
9
10
  * that event through pm/bd-prog.js openProgram, the one path that opens it.
@@ -387,7 +388,7 @@ async function press(b) {
387
388
  else if (a === 'ms' || a === 'itasks') showRow(a);
388
389
  else if (a === 'period') { O._perOpen = !O._perOpen; draw(true); }
389
390
  else if (a === 'per' || a === 'early') { period = b.dataset.per; O._perOpen = false; draw(); const pb = VW.body() && VW.body().querySelector('[data-pp="period"]'); if (pb) pb.focus(); }
390
- else if (a === 'ini') { const id = b.dataset.ini, from = document.querySelector(`#ibBody [data-prog="${CSS.escape(p.id)}"]`); VW.close(); O.openIni(id, from); }
391
+ else if (a === 'ini') { const id = b.dataset.ini, from = document.querySelector(`#ibBody [data-prog="${CSS.escape(p.id)}"]`); if (O.drill) VW.drill(); else VW.close(); O.openIni(id, from); }
391
392
  else if (a === 'add') { adding = true; draw(); const i = VW.body() && VW.body().querySelector('.pp-add input'); if (i) i.focus(); }
392
393
  else if (a === 'charter') openCharter(p);
393
394
  else if (a === 'done') {
@@ -628,3 +628,8 @@ form.hm-box textarea { min-height: 48px; border: 0; background: none; resize: no
628
628
  .hm-moved td { padding: 8px 0; border-bottom: 1px solid var(--cz-hair); }
629
629
  .hm-moved td + td { padding-left: 12px; font-weight: 600; white-space: nowrap; }
630
630
  @media (max-width: 760px) { .hm-kpis { grid-template-columns: 1fr; } }
631
+ /* the list stays when there is no room beside the chat (HbCNarrow): the Viewer lies over the chat, at most the room right of the list */
632
+ @media (min-width: 761px) {
633
+ body.cz-home.cz-vw-over .hm-vw { position: absolute; top: 16px; right: 16px; bottom: 16px; z-index: 5; }
634
+ body.cz-home.cz-vw-over .hm-vw .cz-vw { box-shadow: var(--cz-vlift); }
635
+ }
@@ -9,6 +9,7 @@
9
9
  * Sources pm/cozy-sources.js: what PMOS reads and how old each reading is, in the Viewer
10
10
  * Settings pm/cozy-settings.js: General, Connectors, Workspaces, Updates, What's new
11
11
  * A page with features the design does not draw yet passes opts.more (Home): a quiet "More" row then follows Settings.
12
+ * A page that passes opts.here() runs it when its own place is pressed, in place of a reload (Home: Menu > Home closes the page that is open).
12
13
  * The counts come from GET /api/news-for-you and GET /api/sources, read when the page opens and every two minutes while it is shown.
13
14
  * Nothing here leads to the console, and nothing here writes but the theme (this device).
14
15
  */
@@ -95,6 +96,9 @@ export function mountNav(here, doc = document, opts = {}) {
95
96
  // set() redraws the button's icon, so the pressed icon may be gone from the page by now: only a press still on the page closes the menu
96
97
  doc.addEventListener('click', (e) => { if (!menu.hidden && e.target.isConnected && !w.contains(e.target)) set(false); });
97
98
  menu.addEventListener('click', (e) => {
99
+ // the page you are on, pressed again: a page that passes opts.here goes back to its start without a reload (Home: the list, no page open)
100
+ const a = e.target.closest('a[aria-current="page"]');
101
+ if (a && opts.here && !e.metaKey && !e.ctrlKey && !e.shiftKey) { e.preventDefault(); set(false); opts.here(); return; }
98
102
  const b = e.target.closest('button'); if (!b) return;
99
103
  if (b.dataset.evTheme) { setTheme(b.dataset.evTheme, doc); return; }
100
104
  set(false);
@@ -267,6 +267,8 @@ body.cz-home .hm-lsc { margin: 0 -12px; padding: 0 12px 4px; }
267
267
  .hv-pt { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 44px; padding: 0 6px; border: 0; background: none; color: var(--cz-ink); cursor: pointer; font-family: var(--cz-sans); border-radius: 14px; }
268
268
  .hv-pf { flex: 1; display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-height: 44px; padding: 0 10px 0 6px; border: 0; background: none; cursor: pointer; font-family: var(--cz-sans); border-radius: 14px; }
269
269
  .hv-pf .hv-cv { margin-left: 0; }
270
+ /* the heading whose program or product is open in the Viewer (HbCProg, HbCProduct): its name carries the selection, as a row does */
271
+ .hv-gh.hv-prg.sel .hv-pt { background: var(--cz-bluebg); }
270
272
  .hv-msd { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--cz-ink2); white-space: nowrap; }
271
273
  .hv-msd.late { color: var(--cz-late); }
272
274
  .hv-dm { display: block; width: 8px; height: 8px; border-radius: 2px; transform: rotate(45deg); background: var(--cz-c-6b4fa3); }
@@ -27,10 +27,16 @@
27
27
  * The caller writes the record and says "Renamed" with Undo; the header shows the saved name at once.
28
28
  * true goes to Home with ?about=<kind>:<id>&label=<title>; { href } goes there; fn() runs instead.
29
29
  * back true: keep the item shown now, so ← comes back to it. Without back, opening an item forgets what was behind it.
30
+ * keep true: this item takes the place of the one shown now, and what was behind that one stays behind this one (a view switch)
31
+ * add { label, on(button) }: a quiet + before ⋯ (Home's "New session" on an initiative, canvas HbC). Not drawn on a phone.
30
32
  * render called with the body element to draw into; html is the same as a string. Neither: the body is left empty for the caller.
31
33
  * id optional; current() returns it, so a caller can tell whether its item is the one shown
32
34
  * onClose called once when this item leaves the card (Close, Escape, close(), or another open())
33
35
  * close() · back() · isOpen() · current() → { id, kind, title, url } | null · body() → the body element or null
36
+ * drill() the next open() keeps the item shown now behind it, as back: true does (a page opens a task or a document from its own
37
+ * rows through a module that does not know it is a drill-in: Home's initiative page, canvas HbCDrill)
38
+ * Overlay (canvas HbCNarrow): a host marked data-cz-vw-overlay keeps its list when there is no room beside the chat; the Viewer then
39
+ * lies over the chat (body.cz-vw-over) instead of folding the list to a rail. Open wide still folds it.
34
40
  * placeholder(featureName, { kind?, icon? }) opens the card with czPlaceholder(featureName) in it (cozy-placeholder.js)
35
41
  * onChange(fn) → fn({ open, id, kind, title }) after each open and close; document also gets the event 'cz-viewer' with the same detail.
36
42
  * czSummary({ line, tone, right, text, meta, primary, also, extra }) → the summary card's markup: one line of state, the words, one quiet meta
@@ -66,7 +72,7 @@ export const ICONS = {
66
72
  warn: 'M12 3l9 16H3zM12 10v4M12 17h.01',
67
73
  };
68
74
  const P = {
69
- back: 'M14 6l-6 6 6 6', more: 'M5 12h.01M12 12h.01M19 12h.01', close: 'M6 6l12 12M18 6L6 18',
75
+ add: 'M12 5v14M5 12h14', back: 'M14 6l-6 6 6 6', more: 'M5 12h.01M12 12h.01M19 12h.01', close: 'M6 6l12 12M18 6L6 18',
70
76
  wide: 'M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7', side: 'M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7',
71
77
  chat: 'M5 6.5A2.5 2.5 0 0 1 7.5 4h9A2.5 2.5 0 0 1 19 6.5v7a2.5 2.5 0 0 1-2.5 2.5H11l-4 3.5V16h.5A2.5 2.5 0 0 1 5 13.5z',
72
78
  tab: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6', chev: 'M10 7l5 5-5 5', down: 'M7 10l5 5 5-5', list: 'M3.5 4.5h17v15h-17zM14 4.5v15',
@@ -84,7 +90,7 @@ const isPhone = () => typeof innerWidth === 'number' && innerWidth <= PHONE;
84
90
  const onHome = () => typeof document !== 'undefined' && !!document.body && document.body.classList.contains('cz-home');
85
91
  const kindKey = (k) => String(k || 'item').trim().toLowerCase().replace(/^file · .*/, 'file').replace(/[^a-z0-9]+/g, '-').slice(0, 40) || 'item';
86
92
 
87
- const V = { el: null, cur: null, back: null, subs: [], stack: [], wide: false, rail: false, w: 0 };
93
+ const V = { el: null, cur: null, back: null, subs: [], stack: [], wide: false, rail: false, w: 0, drill: false, over: false };
88
94
 
89
95
  /** "PRD" over "PRD", or "File · plans/x.md" over "x.md": the kind is left out when it only repeats the title */
90
96
  const sameAs = (kind, title) => { const k = String(kind || '').trim().toLowerCase().replace(/^file · /, ''), t = String(title || '').trim().toLowerCase(); return !!t && (k === t || k.split('/').pop() === t || k.split('/').pop().replace(/\.[a-z]+$/, '') === t); };
@@ -104,10 +110,11 @@ export function headHtml(it) {
104
110
  const kind = o.kind && !sameAs(o.kind, o.title) ? `<p class="cz-vw-kind">${esc(o.kind)}</p>` : '';
105
111
  const disc = o.discuss && !o.home ? ib('discuss', 'Discuss in chat', P.chat) : '';
106
112
  const more = typeof o.more === 'function' || (Array.isArray(o.more) && o.more.some((m) => m && !m.sep)) || o.url ? ib('more', 'More', P.more, ' aria-haspopup="menu" aria-expanded="false"') : '';
113
+ const add = o.add && o.add.label && !phone ? ib('add', o.add.label, P.add) : '';
107
114
  return (o.canBack || phone ? ib('back', o.canBack ? 'Back' : 'Close the viewer', P.back) : '')
108
115
  + `<span class="cz-vw-tile" aria-hidden="true">${svg(path(o.icon), 17)}</span>`
109
116
  + (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : esc(o.title || '')}</h3></div>`)
110
- + disc + more
117
+ + disc + add + more
111
118
  + (phone ? '' : ib('wide', o.isWide ? 'Back to the side' : 'Open wide', o.isWide ? P.side : P.wide, ` aria-pressed="${o.isWide ? 'true' : 'false'}"`))
112
119
  + (phone ? '' : `<button type="button" class="cz-vw-ib" data-cz-vw="close" aria-label="Close the viewer" title="Close">${svg(P.close, 18)}</button>`);
113
120
  }
@@ -182,7 +189,7 @@ function room() {
182
189
  const right = inner - (lw ? lw + gap : 0);
183
190
  const side = right - gap - CHAT;
184
191
  const wideMax = Math.min(Math.round(innerWidth * MAXF), inner - (list ? RAIL + gap : 0) - gap - CHAT);
185
- return { float: false, def: Math.max(MIN, Math.round(right / 2)), side, wideMax: Math.max(wideMax, side), hasList: !!list };
192
+ return { float: false, def: Math.max(MIN, Math.round(right / 2)), side, wideMax: Math.max(wideMax, side), hasList: !!list, right };
186
193
  }
187
194
  export const widthOf = (kind) => { const n = parseInt(store.get('cz-vw-w:' + kindKey(kind)) || '', 10); return n > 0 ? n : null; };
188
195
  function setRail(on) {
@@ -223,6 +230,10 @@ function apply(px) {
223
230
  const el = V.el; if (!el) return;
224
231
  if (isPhone()) { el.style.width = ''; el.style.flexBasis = ''; el.classList.remove('cz-vw-w2'); setRail(false); return; }
225
232
  let r = room();
233
+ // a host that keeps its list (Home, HbCNarrow): with no room beside the chat the Viewer lies over the chat, at most the room right of the list
234
+ const over = !r.float && r.hasList && r.side < MIN && !V.wide && !!(el.parentNode && el.parentNode.hasAttribute('data-cz-vw-overlay'));
235
+ if (over !== V.over) { V.over = over; document.body.classList.toggle('cz-vw-over', over); }
236
+ if (over) { setRail(false); r = room(); const w = Math.max(Math.min(MIN, r.right), Math.min(Math.round(px || r.def), r.right)); V.w = w; el.style.width = w + 'px'; el.style.flexBasis = w + 'px'; el.classList.toggle('cz-vw-w2', w >= W2); return; }
226
237
  if (!r.float && r.hasList && r.side < MIN) { setRail(true); r = room(); } // under 1100 px: the list folds as the Viewer opens
227
238
  let w = Math.max(MIN, Math.round(px || r.def));
228
239
  if (!r.float) {
@@ -329,6 +340,7 @@ function mount() {
329
340
  if (a === 'close') close();
330
341
  else if (a === 'back') { if (V.stack.length) back(); else close(); }
331
342
  else if (a === 'more') moreMenu(b);
343
+ else if (a === 'add') { if (V.cur && V.cur.add && typeof V.cur.add.on === 'function') V.cur.add.on(b); }
332
344
  else if (a === 'wide') wide();
333
345
  else if (a === 'discuss') discuss();
334
346
  });
@@ -402,10 +414,11 @@ export function open(it) {
402
414
  const o = it || {};
403
415
  const el = mount(); place(el);
404
416
  if (!V.cur) { const ae = document.activeElement; V.back = ae && ae !== document.body && !el.contains(ae) ? ae : null; }
405
- if (o.back && V.cur && V.cur.args) V.stack.push(V.cur.args); else if (!o._back) V.stack = [];
417
+ if ((o.back || V.drill) && V.cur && V.cur.args) V.stack.push(V.cur.args); else if (!o._back && !o.keep) V.stack = [];
418
+ V.drill = false;
406
419
  const sameKind = V.cur && kindKey(V.cur.kind) === kindKey(o.kind);
407
420
  leave();
408
- V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, args: o };
421
+ V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, add: o.add || null, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, args: o };
409
422
  el.setAttribute('aria-label', 'Viewer: ' + (o.kind || o.title || 'item'));
410
423
  redraw();
411
424
  const m = el.querySelector('.cz-vw-menu'); if (m) m.remove();
@@ -420,6 +433,8 @@ export function open(it) {
420
433
  if (isPhone()) el.focus();
421
434
  return body;
422
435
  }
436
+ /** The next open() is a drill-in: the item shown now stays behind it, and ← comes back to it. Nothing open: nothing to keep. */
437
+ export function drill() { V.drill = isOpen(); }
423
438
  /** ← : the item that was shown before this drill-in, drawn again. With nothing behind, ← closes. */
424
439
  export function back() {
425
440
  const prev = V.stack.pop();
@@ -430,7 +445,8 @@ export function back() {
430
445
  export function close() {
431
446
  if (!V.el || V.el.hidden) return;
432
447
  leave();
433
- V.stack = []; V.wide = false;
448
+ V.stack = []; V.wide = false; V.drill = false;
449
+ if (V.over) { V.over = false; document.body.classList.remove('cz-vw-over'); }
434
450
  V.el.hidden = true;
435
451
  V.el.querySelector('.cz-vw-body').innerHTML = '';
436
452
  const m = V.el.querySelector('.cz-vw-menu'); if (m) m.remove();
@@ -457,4 +473,4 @@ if (typeof window !== 'undefined' && typeof window.addEventListener === 'functio
457
473
  e.preventDefault(); e.stopImmediatePropagation(); close();
458
474
  }, true);
459
475
  }
460
- if (typeof window !== 'undefined') window.czViewer = { open, close, back, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, ICONS };
476
+ if (typeof window !== 'undefined') window.czViewer = { open, close, back, drill, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, ICONS };