create-pmos 0.427.0 → 0.429.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +25 -25
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/board-programs-test.js +16 -2
- package/workspace/briefing-premium-board-test.js +27 -22
- package/workspace/briefing-premium-insights-test.js +81 -60
- package/workspace/briefing-premium-metrics-test.js +5 -3
- package/workspace/briefing-premium-sources-test.js +5 -5
- package/workspace/briefing-premium-test.js +7 -5
- package/workspace/changelog.json +24 -0
- package/workspace/ev-everywhere-test.js +2 -2
- package/workspace/guide/briefing-premium.md +4 -2
- package/workspace/guide/home.md +34 -7
- package/workspace/guide/index.md +1 -0
- package/workspace/guide/metric-drafts.md +48 -0
- package/workspace/guide/programs.md +1 -0
- package/workspace/home-other-product-test.js +12 -2
- package/workspace/intel-report-ui-test.js +189 -0
- package/workspace/lib/board-metrics-premium.js +1 -1
- package/workspace/lib/headless.js +15 -2
- package/workspace/lib/insights-premium.js +5 -1
- package/workspace/lib/insights-records.js +14 -5
- package/workspace/lib/intel-report.js +419 -0
- package/workspace/lib/metric-draft-runs.js +193 -0
- package/workspace/lib/metric-drafts.js +231 -0
- package/workspace/lib/metrics-cli.js +104 -0
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/report-setups.js +29 -13
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-insights-premium.js +2 -2
- package/workspace/lib/routes-insights-records.js +13 -5
- package/workspace/lib/routes-meeting-material.js +22 -1
- package/workspace/lib/routes-metric-drafts.js +141 -0
- package/workspace/lib/routes-phone-day.js +13 -2
- package/workspace/lib/routes-report-setups.js +92 -3
- package/workspace/lib/routes-viewer.js +5 -2
- package/workspace/lib/settings-store.js +14 -0
- package/workspace/metric-drafts-ui-test.js +209 -0
- package/workspace/milestone-pins-test.js +13 -0
- package/workspace/milestone-suggest-test.js +10 -4
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +40 -13
- package/workspace/premium-phone-card-test.js +8 -5
- package/workspace/premium-rec-tab-test.js +8 -0
- package/workspace/premium-vw-item-test.js +7 -3
- package/workspace/premium-vw-jira-test.js +2 -1
- package/workspace/program-charter-test.js +1 -1
- package/workspace/program-leave-test.js +2 -2
- package/workspace/program-order-test.js +3 -2
- package/workspace/program-panel-test.js +2 -1
- package/workspace/public/pm/bd-acts.js +23 -29
- package/workspace/public/pm/bd-ini-panel.js +90 -32
- package/workspace/public/pm/bd-pin-card.css +4 -4
- package/workspace/public/pm/bd-pin-card.js +4 -1
- package/workspace/public/pm/bd-prog-panel.js +9 -4
- package/workspace/public/pm/bd-span.js +22 -12
- package/workspace/public/pm/cozy-aud.css +1 -1
- package/workspace/public/pm/cozy-board.css +256 -256
- package/workspace/public/pm/cozy-ev.css +45 -45
- package/workspace/public/pm/cozy-evmodel.js +1 -1
- package/workspace/public/pm/cozy-home-rows.css +23 -23
- package/workspace/public/pm/cozy-home.css +207 -207
- package/workspace/public/pm/cozy-insights.css +207 -108
- package/workspace/public/pm/cozy-live-pill.css +5 -5
- package/workspace/public/pm/cozy-mtg-present.css +23 -23
- package/workspace/public/pm/cozy-nav.js +1 -1
- package/workspace/public/pm/cozy-news.js +2 -2
- package/workspace/public/pm/cozy-panel.css +29 -29
- package/workspace/public/pm/cozy-pick.css +5 -5
- package/workspace/public/pm/cozy-rec-now.css +20 -20
- package/workspace/public/pm/cozy-rec-present.css +11 -11
- package/workspace/public/pm/cozy-rec-tab.css +13 -13
- package/workspace/public/pm/cozy-rec-tab.js +12 -3
- package/workspace/public/pm/cozy-settings.js +1 -1
- package/workspace/public/pm/cozy-steps.css +9 -9
- package/workspace/public/pm/cozy-today.css +107 -71
- package/workspace/public/pm/cozy-viewer.css +7 -7
- package/workspace/public/pm/cozy-viewer.js +157 -23
- package/workspace/public/pm/cozy-vw-mtg.css +81 -81
- package/workspace/public/pm/cozy-vw-rp.css +53 -53
- package/workspace/public/pm/cozy-vw-shell.css +34 -21
- package/workspace/public/pm/cozy-vw.css +117 -117
- package/workspace/public/pm/cozy-xv.css +11 -11
- package/workspace/public/pm/cozy.css +18 -15
- package/workspace/public/pm/hi-pop.css +82 -0
- package/workspace/public/pm/hi-pop.js +65 -0
- package/workspace/public/pm/home-app.js +83 -28
- package/workspace/public/pm/home-day.js +131 -26
- package/workspace/public/pm/home-ini.css +38 -108
- package/workspace/public/pm/home-ini.js +50 -68
- package/workspace/public/pm/home-line.css +7 -7
- package/workspace/public/pm/home-list.js +41 -4
- package/workspace/public/pm/home-phone-card.js +18 -15
- package/workspace/public/pm/home-today.js +18 -7
- package/workspace/public/pm/ini-more.js +67 -0
- package/workspace/public/pm/ini-view-model.js +3 -2
- package/workspace/public/pm/ini-view.css +104 -102
- package/workspace/public/pm/ini-view.js +16 -8
- package/workspace/public/pm/loose-props.css +13 -13
- package/workspace/public/pm/metric-drafts.css +82 -0
- package/workspace/public/pm/metric-drafts.js +165 -0
- package/workspace/public/pm/ms-suggest.css +8 -8
- package/workspace/public/pm/order-model.js +85 -0
- package/workspace/public/pm/ov-view.css +12 -12
- package/workspace/public/pm/premium-board.js +57 -11
- package/workspace/public/pm/premium-chart-tab.js +6 -6
- package/workspace/public/pm/premium-insights.js +306 -105
- package/workspace/public/pm/premium-report-intel.css +56 -0
- package/workspace/public/pm/premium-report-intel.js +232 -0
- package/workspace/public/pm/premium-shell.js +2 -2
- package/workspace/public/pm/premium-vw-file.js +2 -2
- package/workspace/public/pm/premium-vw-item.js +3 -1
- package/workspace/public/pm/premium-vw-jira.js +2 -0
- package/workspace/public/pm/premium.css +127 -128
- package/workspace/public/pm/prog-order.css +6 -6
- package/workspace/public/pm/prog-order.js +15 -2
- package/workspace/public/pm/program-charter.css +23 -23
- package/workspace/public/pm/rp-parts.js +2 -2
- package/workspace/public/pm/sort-order.css +17 -0
- package/workspace/public/pm/sort-order.js +108 -0
- package/workspace/public/pm/split-merge.css +15 -15
- package/workspace/public/pm/task-card.css +21 -21
- package/workspace/public/pm/tk-tasks.css +37 -37
- package/workspace/public/pm/tk-view.css +6 -6
- package/workspace/public/pm/tk-view.js +3 -2
- package/workspace/public/pm/wf-page.css +28 -28
- package/workspace/public/pm/wf-page.js +1 -1
- package/workspace/public/premium-board.html +1 -0
- package/workspace/public/premium-intelligence.html +82 -0
- package/workspace/server.js +38 -3
- package/workspace/skills/metric-draft.skill +47 -0
- package/workspace/sort-order-test.js +201 -0
- package/workspace/stage-card-test.js +1 -0
- package/workspace/task-card-test.js +1 -1
- package/workspace/test-lists/intel-report-ui.json +5 -0
- package/workspace/test-lists/intel-report.json +9 -0
- package/workspace/test-lists/metric-drafts-ui.json +5 -0
- package/workspace/test-lists/metric-drafts.json +9 -0
- package/workspace/test-lists/sort-order.json +6 -0
- package/workspace/test-lists/viewer-trail.json +5 -0
- package/workspace/test-run.js +3 -0
- package/workspace/tk-tasks-test.js +5 -3
- package/workspace/viewer-trail-test.js +145 -0
- package/workspace/public/premium-insights.html +0 -81
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
.cz .veil { background: rgba(42,46,53,.22); -webkit-backdrop-filter: none; backdrop-filter: none; }
|
|
38
38
|
.cz .dlg { background: var(--card-solid); border: 1px solid var(--hair); border-radius: 28px; box-shadow: 0 30px 70px -36px rgba(42,46,53,.28), 0 2px 6px rgba(42,46,53,.06);
|
|
39
39
|
-webkit-backdrop-filter: none; backdrop-filter: none; color: var(--ink); }
|
|
40
|
-
.cz .dlg .dhead h2 { font-size:
|
|
41
|
-
.cz .dlg .dsub { font-size:
|
|
42
|
-
.cz .dlg .label, .cz .dlg #dEye { font: 700
|
|
40
|
+
.cz .dlg .dhead h2 { font-size: var(--fs-5); line-height: 1.25; font-weight: 800; letter-spacing: -.01em; }
|
|
41
|
+
.cz .dlg .dsub { font-size: var(--fs-2); color: var(--ink-3); }
|
|
42
|
+
.cz .dlg .label, .cz .dlg #dEye { font: 700 var(--fs-2) var(--sans); letter-spacing: 0; text-transform: none; color: var(--ink-3); }
|
|
43
43
|
.cz .dlg .dx2 { background: transparent; border-radius: 999px; color: var(--ink-2); }
|
|
44
44
|
.cz .dlg .dx2:hover { background: var(--well); }
|
|
45
45
|
.cz .dlg .dx2[aria-pressed="true"] { background: var(--spot); color: var(--ember-ink); }
|
|
@@ -89,9 +89,9 @@
|
|
|
89
89
|
.cz .jbar{border-radius:14px}
|
|
90
90
|
.cz .jbtn{border-radius:999px;font-weight:700}
|
|
91
91
|
.cz .jtk{border-radius:20px;box-shadow:none}
|
|
92
|
-
.cz .jtk h1{font-size:
|
|
92
|
+
.cz .jtk h1{font-size:var(--fs-5);font-weight:800;letter-spacing:-.01em}
|
|
93
93
|
.cz .jtk h3{font-weight:800}
|
|
94
|
-
.cz .jst{border-radius:999px;text-transform:none;letter-spacing:0;font-weight:800;font-size:
|
|
94
|
+
.cz .jst{border-radius:999px;text-transform:none;letter-spacing:0;font-weight:800;font-size:var(--fs-2)}
|
|
95
95
|
.cz .jst.doing{background:var(--spot);color:var(--ember-ink)}
|
|
96
96
|
.cz .jchip{border-radius:999px;font-weight:700}
|
|
97
97
|
.cz .jpts{border-radius:999px}
|
|
@@ -99,8 +99,8 @@
|
|
|
99
99
|
.cz .jcrd{border-radius:14px}
|
|
100
100
|
.cz .jcol{border-radius:16px}
|
|
101
101
|
|
|
102
|
-
.cz .jfd dt { font-size:
|
|
103
|
-
.cz .jfd dd { font-size:
|
|
102
|
+
.cz .jfd dt { font-size: var(--fs-1); font-weight: 800; }
|
|
103
|
+
.cz .jfd dd { font-size: var(--fs-3); font-weight: 700; }
|
|
104
104
|
|
|
105
105
|
/* Every view: Nunito headings at 800, bold at 700, as Viewer.dc.html, Meeting.dc.html and ReportPanel.dc.html set them */
|
|
106
106
|
.cz .dlg .obody h1, .cz .dlg .obody h2, .cz .dlg .obody h3, .cz .dlg .obody h4 { font-family: var(--sans); font-weight: 800; letter-spacing: -.01em; }
|
|
@@ -44,13 +44,22 @@
|
|
|
44
44
|
* 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.
|
|
45
45
|
* id optional; current() returns it, so a caller can tell whether its item is the one shown
|
|
46
46
|
* onClose called once when this item leaves the card (Close, Escape, close(), or another open())
|
|
47
|
-
* close() · back() · isOpen() · current() → { id, kind, title, url } | null · body() → the body element or null
|
|
47
|
+
* close() · back() · forward() · isOpen() · current() → { id, kind, title, url } | null · body() → the body element or null
|
|
48
48
|
* 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
|
|
49
49
|
* rows through a module that does not know it is a drill-in: Home's initiative page, canvas HbCDrill)
|
|
50
50
|
* Overlay (canvas HbCNarrow): a host marked data-cz-vw-overlay keeps its list when there is no room beside the chat; the Viewer then
|
|
51
51
|
* lies over the chat (body.cz-vw-over) instead of folding the list to a rail. Open wide still folds it.
|
|
52
|
+
* One trail (feedback batch 14 item 7, canvas Exploring · Navigation NvADesk, NvAPhone, NvAPhoneTrail, NvAFlow):
|
|
53
|
+
* - a press inside the Viewer keeps the item shown behind the one it opens (a drill-in), as back: true and drill() do; a press on the page
|
|
54
|
+
* outside starts a new trail; fresh: true always starts one. Opening the item shown again (the same id) draws it again in its place.
|
|
55
|
+
* - ← goes one step back, and its name says where ("Back to PSLE Landing Page"); at the trail's first item a desk shows no ←, a phone's
|
|
56
|
+
* ← closes. → shows only after a back, and any new open drops it. Hover ← or → (desk) or hold it (phone): the trail, newest first,
|
|
57
|
+
* ending at the page it started on; a press jumps there.
|
|
58
|
+
* - every step is a browser history entry ({ czvw: { s, i } }), so the browser's Back and Forward and a phone's back swipe walk the same
|
|
59
|
+
* trail; Back at the first item closes the Viewer. Close (×, Escape, close()) takes the trail's entries off again, so Back never
|
|
60
|
+
* lands on a closed item. A page writes its own address with replaceUrl(url), which waits while the history is still moving.
|
|
52
61
|
* placeholder(featureName, { kind?, icon? }) opens the card with czPlaceholder(featureName) in it (cozy-placeholder.js)
|
|
53
|
-
* onChange(fn) → fn({ open, id, kind, title }) after each open and close; document also gets the event 'cz-viewer' with the same detail.
|
|
62
|
+
* onChange(fn) → fn({ open, id, kind, title, via }) after each open and close (via 'history' when the browser's Back closed it); document also gets the event 'cz-viewer' with the same detail.
|
|
54
63
|
* czSummary({ line, tone, right, text, meta, primary, also, extra }) → the summary card's markup: one line of state, the words, one quiet meta
|
|
55
64
|
* line and ONE primary press ({ label, act } → data-czs-act="<act>", or { label, href }). tone 'you' (blue dot), 'warn' (amber), 'live' (red).
|
|
56
65
|
* also: [{ act, label, icon }] quiet icon-only presses after the primary (the Done check of a task). second: { label, act } one quiet
|
|
@@ -87,7 +96,7 @@ const P = {
|
|
|
87
96
|
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',
|
|
88
97
|
wide: 'M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7', side: 'M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7',
|
|
89
98
|
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',
|
|
90
|
-
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',
|
|
99
|
+
fwd: 'M10 6l6 6-6 6', home: 'M4 11l8-7 8 7v9H4z', 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',
|
|
91
100
|
};
|
|
92
101
|
export const PHONE = 760;
|
|
93
102
|
const NARROW = 1100, MIN = 420, CHAT = 360, RAIL = 64, MAXF = 0.7, W2 = 760, FLOAT = 560;
|
|
@@ -102,7 +111,7 @@ const isPhone = () => typeof innerWidth === 'number' && innerWidth <= PHONE;
|
|
|
102
111
|
const onHome = () => typeof document !== 'undefined' && !!document.body && document.body.classList.contains('cz-home');
|
|
103
112
|
const kindKey = (k) => String(k || 'item').trim().toLowerCase().replace(/^file · .*/, 'file').replace(/[^a-z0-9]+/g, '-').slice(0, 40) || 'item';
|
|
104
113
|
|
|
105
|
-
const V = { el: null, cur: null, back: null, subs: [], stack: [], wide: false, rail: false, w: 0, drill: false, over: false };
|
|
114
|
+
const V = { el: null, cur: null, back: null, subs: [], stack: [], fwd: [], wide: false, rail: false, w: 0, drill: false, over: false };
|
|
106
115
|
|
|
107
116
|
/** "PRD" over "PRD", or "File · plans/x.md" over "x.md": the kind is left out when it only repeats the title */
|
|
108
117
|
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); };
|
|
@@ -115,7 +124,8 @@ function renHtml(o) {
|
|
|
115
124
|
return `<form class="cz-vw-ren" data-cz-vw-ren data-esc-layer><input id="czVwTitle" type="text" value="${esc(o.renValue != null ? o.renValue : o.title || '')}" maxlength="${max}" aria-label="Name" autocomplete="off"${o.renBusy ? ' disabled' : ''}>`
|
|
116
125
|
+ `<button type="submit" class="cz-vw-sv" aria-label="Save the name" title="Save (Enter). Esc cancels."${o.renBusy ? ' disabled' : ''}>${svg('M5 12.5l4.5 4.5L19 7.5', 16, 2.2)}</button></form>` + j + err;
|
|
117
126
|
}
|
|
118
|
-
/** The header's markup for one item; pure, so a unit test can read it. o.canBack: ← is drawn
|
|
127
|
+
/** The header's markup for one item; pure, so a unit test can read it. o.canBack: ← is drawn (o.backTo names where it goes); o.fwdTo: → is
|
|
128
|
+
* drawn after a back; o.isWide: ⤢ reads "Back to the side". */
|
|
119
129
|
export function headHtml(it) {
|
|
120
130
|
const o = it || {};
|
|
121
131
|
const phone = !!o.phone;
|
|
@@ -128,7 +138,8 @@ export function headHtml(it) {
|
|
|
128
138
|
: `<button type="button" class="cz-vw-ib" data-cz-vw="press" data-cz-vw-p="${esc(x.act)}" aria-label="${esc(x.label)}" title="${esc(x.label)}">${svg(path(x.icon), 18)}</button>`).join('');
|
|
129
139
|
const sub = o.sub ? `<p class="cz-vw-sub">${esc(o.sub)}</p>` : '';
|
|
130
140
|
const chip = o.chip && (o.chip.n > 0 || o.chip.looking) ? `<button type="button" class="cz-vw-chip${o.chip.looking ? ' live' : ''}" data-cz-vw="chip" aria-haspopup="dialog" aria-label="${esc(o.chip.label || 'Claude proposes ' + o.chip.n + '. Open')}" title="${esc(o.chip.label || 'Claude proposes')}">${svg(ICONS.spark, 13, 2)}${o.chip.n > 0 ? `<b>${esc(o.chip.n)}</b>` : ''}</button>` : '';
|
|
131
|
-
return (o.canBack || phone ? ib('back', o.canBack ? 'Back' : 'Close the viewer', P.back) : '')
|
|
141
|
+
return (o.canBack || phone ? ib('back', o.canBack ? (o.backTo ? 'Back to ' + o.backTo : 'Back') : 'Close the viewer', P.back) : '')
|
|
142
|
+
+ (o.fwdTo ? ib('fwd', 'Forward to ' + o.fwdTo, P.fwd) : '')
|
|
132
143
|
+ (o.check ? `<button type="button" class="cz-vw-tile cz-vw-chk s-${esc(o.check.state || 'todo')}" data-cz-vw="press" data-cz-vw-p="check" aria-label="${esc(o.check.label || 'Mark done')}" title="${esc(o.check.title || o.check.label || 'Mark done')}"${o.check.disabled ? ' disabled' : ''}><span class="bx"></span></button>`
|
|
133
144
|
: `<span class="cz-vw-tile" aria-hidden="true">${svg(path(o.icon), 17)}</span>`)
|
|
134
145
|
+ (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title${chip ? ' has-chip' : ''}" 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>` : chip ? `<span class="cz-vw-tt">${esc(o.title || '')}</span>` : esc(o.title || '')}${chip}</h3>${sub}</div>`)
|
|
@@ -362,7 +373,8 @@ function mount() {
|
|
|
362
373
|
const b = e.target.closest('[data-cz-vw]'); if (!b || b.disabled || !el.querySelector('.cz-vw-hd').contains(b)) return;
|
|
363
374
|
const a = b.dataset.czVw;
|
|
364
375
|
if (a === 'close') guarded(close, b);
|
|
365
|
-
else if (a === 'back') guarded(() => { if (V.stack.length)
|
|
376
|
+
else if (a === 'back') { if (!held(b)) guarded(() => { if (V.stack.length) step(-1); else close(); }, b); }
|
|
377
|
+
else if (a === 'fwd') { if (!held(b)) guarded(() => step(1), b); }
|
|
366
378
|
else if (a === 'press') { if (V.cur && typeof V.cur.onPress === 'function') V.cur.onPress(b.dataset.czVwP, b); }
|
|
367
379
|
else if (a === 'more') moreMenu(b);
|
|
368
380
|
else if (a === 'chip') { if (V.cur && V.cur.chip && typeof V.cur.chip.on === 'function') V.cur.chip.on(b); }
|
|
@@ -370,6 +382,7 @@ function mount() {
|
|
|
370
382
|
else if (a === 'wide') wide();
|
|
371
383
|
else if (a === 'discuss') discuss();
|
|
372
384
|
});
|
|
385
|
+
holdable(el);
|
|
373
386
|
el.addEventListener('submit', (e) => { if (e.target.closest('[data-cz-vw-ren]')) { e.preventDefault(); saveRename(); } });
|
|
374
387
|
el.addEventListener('keydown', (e) => { if (e.key === 'Escape' && e.target.closest('[data-cz-vw-ren]')) { e.preventDefault(); e.stopPropagation(); endRename(); } });
|
|
375
388
|
el.addEventListener('input', (e) => { if (e.target.id === 'czVwTitle' && V.cur && V.cur.renaming) V.cur.renValue = e.target.value; });
|
|
@@ -389,7 +402,7 @@ function place(el) {
|
|
|
389
402
|
else { if (el.parentNode !== document.body) document.body.appendChild(el); el.classList.add('cz-vw-float'); }
|
|
390
403
|
}
|
|
391
404
|
function emit() {
|
|
392
|
-
const d = { open: !!V.cur, id: V.cur ? V.cur.id : null, kind: V.cur ? V.cur.kind : null, title: V.cur ? V.cur.title : null };
|
|
405
|
+
const d = { open: !!V.cur, id: V.cur ? V.cur.id : null, kind: V.cur ? V.cur.kind : null, title: V.cur ? V.cur.title : null, via: V.cur ? '' : V.via || '' }; // via 'history': the browser's Back closed it
|
|
393
406
|
document.body.classList.toggle('cz-vw-on', d.open);
|
|
394
407
|
V.subs.forEach((f) => { try { f(d); } catch { /* a listener's fault stays its own */ } });
|
|
395
408
|
document.dispatchEvent(new CustomEvent('cz-viewer', { detail: d }));
|
|
@@ -408,7 +421,8 @@ function redraw() {
|
|
|
408
421
|
if (!V.el || !V.cur) return;
|
|
409
422
|
V.ph = isPhone();
|
|
410
423
|
const hd = V.el.querySelector('.cz-vw-hd');
|
|
411
|
-
|
|
424
|
+
const bk = V.stack[V.stack.length - 1], fw = V.fwd[V.fwd.length - 1];
|
|
425
|
+
hd.innerHTML = headHtml({ ...V.cur, canBack: V.stack.length > 0, backTo: bk ? bk.title || '' : '', fwdTo: fw ? fw.title || 'the next item' : '', isWide: V.wide || V.rail, phone: V.ph, home: onHome() });
|
|
412
426
|
hd.classList.toggle('cz-vw-renon', !!V.cur.renaming);
|
|
413
427
|
}
|
|
414
428
|
|
|
@@ -464,14 +478,24 @@ export function open(it) {
|
|
|
464
478
|
}
|
|
465
479
|
const el = mount(); place(el);
|
|
466
480
|
if (!V.cur) { const ae = document.activeElement; V.back = ae && ae !== document.body && !el.contains(ae) ? ae : null; }
|
|
467
|
-
|
|
468
|
-
V.
|
|
481
|
+
const was = isOpen(), pos = V.stack.length, how = stepOf(o);
|
|
482
|
+
if (how === 'nav') { V.stack = o._trail.stack; V.fwd = o._trail.fwd; }
|
|
483
|
+
else if (how === 'drill') { V.stack.push(V.cur.args); V.fwd = []; hq({ push: 1, s: H.s, i: V.stack.length }); }
|
|
484
|
+
else if (how === 'new') {
|
|
485
|
+
// a press starts a trail on its own entry; an open no press led to (the page drew it, or Back from another page restored it) takes the
|
|
486
|
+
// page's entry, so Back from it leaves the page as before. A new trail from a press takes the place of a pressed one.
|
|
487
|
+
const auto = !(H.press && Date.now() - H.press.t < 10000) || H.adopt, wasAuto = H.auto;
|
|
488
|
+
V.stack = []; V.fwd = []; H.s = serial(); H.auto = auto && !(was && !wasAuto);
|
|
489
|
+
if (was && pos) hq({ go: -pos }); // back to where this trail started
|
|
490
|
+
if ((was && !(wasAuto && !auto)) || (!was && auto)) hq({ s: H.s, i: 0, auto: H.auto }); else hq({ push: 1, s: H.s, i: 0 });
|
|
491
|
+
}
|
|
492
|
+
V.drill = false; H.adopt = false;
|
|
469
493
|
const sameKind = V.cur && kindKey(V.cur.kind) === kindKey(o.kind);
|
|
470
494
|
leave();
|
|
471
495
|
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, discussHome: !!o.discussHome, add: o.add || null, sub: o.sub || '', check: o.check || null, presses: o.presses || null, chip: o.chip && (o.chip.n > 0 || o.chip.looking) ? o.chip : null, onPress: o.onPress, guard: o.guard, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, args: o };
|
|
472
496
|
el.setAttribute('aria-label', 'Viewer: ' + (o.kind || o.title || 'item'));
|
|
473
497
|
redraw();
|
|
474
|
-
|
|
498
|
+
el.querySelectorAll('.cz-vw-menu,.cz-vw-trail').forEach((m) => m.remove());
|
|
475
499
|
const body = el.querySelector('.cz-vw-body');
|
|
476
500
|
body.innerHTML = ''; body.scrollTop = 0;
|
|
477
501
|
body.className = 'cz-vw-body'; body.onclick = null; body.oninput = null; body.onchange = null; body.onkeydown = null; // what one item's render added to the body does not reach the next
|
|
@@ -485,21 +509,30 @@ export function open(it) {
|
|
|
485
509
|
}
|
|
486
510
|
/** The next open() is a drill-in: the item shown now stays behind it, and ← comes back to it. Nothing open: nothing to keep. */
|
|
487
511
|
export function drill() { V.drill = isOpen(); }
|
|
488
|
-
/** ← : the item that was shown before this
|
|
489
|
-
export function back() {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
512
|
+
/** ← : the item that was shown before this one, drawn again. With nothing behind, ← closes. */
|
|
513
|
+
export function back() { if (!V.stack.length) { close(); return null; } return step(-1); }
|
|
514
|
+
/** → : after a back, the item that was shown after this one. Nothing ahead: nothing happens. */
|
|
515
|
+
export function forward() { return V.fwd.length ? step(1) : null; }
|
|
516
|
+
/** The trail for the tests and the trail list: { back: [titles, nearest first], here, ahead: [titles, nearest first] }. */
|
|
517
|
+
export function trail() {
|
|
518
|
+
const t = (a) => (a && a.title) || '';
|
|
519
|
+
return { back: V.stack.map(t).reverse(), here: V.cur ? V.cur.title : null, ahead: V.fwd.map(t).reverse() };
|
|
520
|
+
}
|
|
521
|
+
/** Close the Viewer. Focus goes back to what had it before the Viewer opened. The list comes back from the rail. o.quiet: the browser
|
|
522
|
+
* already left the trail (its Back at the first item), so the history is not moved again. */
|
|
523
|
+
export function close(o = {}) {
|
|
496
524
|
if (!V.el || V.el.hidden) return;
|
|
525
|
+
const pos = V.stack.length;
|
|
497
526
|
leave();
|
|
498
|
-
|
|
527
|
+
// the trail's entries come off, so Back never lands on a closed item; a trail on the page's own entry gives that entry back
|
|
528
|
+
if (!o.quiet && H.s) { if (H.auto) { if (pos) hq({ go: -pos }); hq({ clear: 1 }); } else hq({ go: -(pos + 1) }); }
|
|
529
|
+
H.s = ''; H.auto = false;
|
|
530
|
+
V.via = o.quiet ? 'history' : '';
|
|
531
|
+
V.stack = []; V.fwd = []; V.wide = false; V.drill = false;
|
|
499
532
|
if (V.over) { V.over = false; document.body.classList.remove('cz-vw-over'); }
|
|
500
533
|
V.el.hidden = true;
|
|
501
534
|
V.el.querySelector('.cz-vw-body').innerHTML = '';
|
|
502
|
-
|
|
535
|
+
V.el.querySelectorAll('.cz-vw-menu,.cz-vw-trail').forEach((m) => m.remove());
|
|
503
536
|
setRail(false);
|
|
504
537
|
emit();
|
|
505
538
|
const b = V.back; V.back = null;
|
|
@@ -514,6 +547,103 @@ export function placeholder(featureName, o = {}) {
|
|
|
514
547
|
return open({ id: 'placeholder:' + featureName, kind: o.kind || featureName, title: featureName, icon: o.icon || 'info', render: (el) => czPlaceholder(el, featureName) });
|
|
515
548
|
}
|
|
516
549
|
|
|
550
|
+
/* ── one trail: ← →, the browser's Back and Forward, a phone's back swipe (batch 14 item 7) ── */
|
|
551
|
+
const H = { s: '', n: 0, adopt: false, auto: false, q: [], wait: 0, press: null };
|
|
552
|
+
const canHist = () => typeof history !== 'undefined' && typeof history.pushState === 'function' && typeof location !== 'undefined';
|
|
553
|
+
const serial = () => Date.now().toString(36) + '-' + (++H.n);
|
|
554
|
+
/** How an open moves the trail: 'nav' (← →, a jump), 'keep' (the same item again, a view switch), 'drill' (it keeps the item behind it), 'new'. */
|
|
555
|
+
function stepOf(o) {
|
|
556
|
+
if (o._nav) return 'nav';
|
|
557
|
+
const p = H.press && Date.now() - H.press.t < 10000 ? H.press : null; // the press that led here: an open often waits for a module or a read
|
|
558
|
+
if (o.keep && V.cur) return 'keep';
|
|
559
|
+
if (V.cur && V.cur.args && !o.fresh && (o.back || V.drill)) return 'drill'; // asked for: a view of the same item drills in too (Stage, Documents)
|
|
560
|
+
if (V.cur && o.id != null && V.cur.id === String(o.id) && !(p && !p.inside) && !o.fresh) return 'keep';
|
|
561
|
+
if (V.cur && V.cur.args && !o.fresh && p && p.inside) return 'drill';
|
|
562
|
+
return 'new';
|
|
563
|
+
}
|
|
564
|
+
/** The history follows the trail. A go() waits for its popstate before the next push or replace, so the order holds. */
|
|
565
|
+
function hq(op) { if (!canHist()) return; H.q.push(op); hRun(); }
|
|
566
|
+
function hRun() {
|
|
567
|
+
while (H.q.length && !H.wait) {
|
|
568
|
+
const op = H.q.shift();
|
|
569
|
+
try {
|
|
570
|
+
if (op.go) { const t = H.wait = Date.now(); history.go(op.go); setTimeout(() => { if (H.wait === t) { H.wait = 0; hRun(); } }, 700); }
|
|
571
|
+
else if (op.url != null) history.replaceState(history.state, '', op.url);
|
|
572
|
+
else if (op.clear) { const { czvw, ...rest } = history.state && typeof history.state === 'object' ? history.state : {}; history.replaceState(czvw && Object.keys(rest).length ? rest : czvw ? null : history.state, '', location.href); }
|
|
573
|
+
else if (op.push) history.pushState({ czvw: { s: op.s, i: op.i } }, '', location.href);
|
|
574
|
+
else history.replaceState({ ...(history.state && typeof history.state === 'object' ? history.state : {}), czvw: { s: op.s, i: op.i, ...(op.auto ? { auto: 1 } : {}) } }, '', location.href);
|
|
575
|
+
} catch { H.wait = 0; }
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
/** A page writes its own address here (in place of history.replaceState): it waits while the history is still moving, so it lands on the
|
|
579
|
+
* entry the page shows. */
|
|
580
|
+
export function replaceUrl(url) { if (canHist()) hq({ url: String(url) }); }
|
|
581
|
+
/** n steps along the trail (← is -1, → is 1, the trail list jumps). Past its start the Viewer closes. o.quiet: the browser already moved. */
|
|
582
|
+
function step(n, o = {}) {
|
|
583
|
+
if (!V.cur || !n) return null;
|
|
584
|
+
const seq = [...V.stack, V.cur.args, ...V.fwd.slice().reverse()], at = V.stack.length + n;
|
|
585
|
+
if (at < 0) { close(o); return null; }
|
|
586
|
+
if (at >= seq.length) return null;
|
|
587
|
+
const to = seq[at];
|
|
588
|
+
if (!o.quiet) hq({ go: n });
|
|
589
|
+
return open({ ...to, back: false, keep: false, _asked: true, _nav: true, _trail: { stack: seq.slice(0, at), fwd: seq.slice(at + 1).reverse() } });
|
|
590
|
+
}
|
|
591
|
+
/** The browser moved (Back, Forward, a swipe, a long press on its own ←). An item with unsaved changes asks first: the browser goes back to
|
|
592
|
+
* where it was, and the move runs on Save or Discard. */
|
|
593
|
+
function popped(e) {
|
|
594
|
+
if (H.wait) { H.wait = 0; hRun(); return; } // the history moving after ← → or a close: the Viewer is already there
|
|
595
|
+
const st = e && e.state && e.state.czvw;
|
|
596
|
+
if (!st) { if (isOpen()) follow(-(V.stack.length + 1)); return; } // before the trail: the page as it was
|
|
597
|
+
if (st.s === H.s && isOpen()) { const n = st.i - V.stack.length; if (n) follow(n); return; }
|
|
598
|
+
if (st.auto) { if (isOpen()) follow(-(V.stack.length + 1)); return; } // an item the page drew itself: the page, before this trail
|
|
599
|
+
hq({ go: -1 }); // a closed trail's entry (Forward after a close): nothing to show, so on to the page
|
|
600
|
+
}
|
|
601
|
+
function follow(n) {
|
|
602
|
+
let now = true, ran = false;
|
|
603
|
+
guarded(() => { ran = true; if (now) step(n, { quiet: true }); else step(n); });
|
|
604
|
+
now = false;
|
|
605
|
+
if (!ran) hq({ go: -n });
|
|
606
|
+
}
|
|
607
|
+
/* where a press was: inside the Viewer it drills in, outside it starts a new trail */
|
|
608
|
+
function pressAt(e) { const t = e.target; H.press = { t: Date.now(), inside: !!(V.el && t && t.nodeType === 1 && V.el.contains(t) && !t.closest('.cz-vw-trail')) }; }
|
|
609
|
+
/* the trail list: hover ← or → for a moment (a mouse), or hold it (a touch). It names every step, newest first, and the page it started on. */
|
|
610
|
+
let HOLD = { t: 0, fired: 0 };
|
|
611
|
+
function holdable(el) {
|
|
612
|
+
el.addEventListener('pointerover', (e) => { const b = e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]'); if (!b || e.pointerType === 'touch' || !V.stack.length && !V.fwd.length) return; clearTimeout(HOLD.t); HOLD.t = setTimeout(() => trailMenu(b), 500); });
|
|
613
|
+
el.addEventListener('pointerout', (e) => { if (e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]')) clearTimeout(HOLD.t); });
|
|
614
|
+
el.addEventListener('pointerdown', (e) => { const b = e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]'); if (!b) return; HOLD.fired = 0; if (e.pointerType === 'mouse' || !V.stack.length && !V.fwd.length) return; clearTimeout(HOLD.t); HOLD.t = setTimeout(() => { HOLD.fired = Date.now(); trailMenu(b); }, 500); });
|
|
615
|
+
['pointerup', 'pointercancel'].forEach((k) => el.addEventListener(k, () => clearTimeout(HOLD.t)));
|
|
616
|
+
el.addEventListener('contextmenu', (e) => { if (e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]')) e.preventDefault(); });
|
|
617
|
+
}
|
|
618
|
+
/** A hold that opened the trail list is not also a press. */
|
|
619
|
+
function held() { if (HOLD.fired && Date.now() - HOLD.fired < 800) { HOLD.fired = 0; return true; } return false; }
|
|
620
|
+
const PAGES = { '/premium.html': 'Home', '/premium-board.html': 'Board', '/premium-intelligence.html': 'Intelligence', '/premium-insights.html': 'Intelligence' };
|
|
621
|
+
function trailMenu(b) {
|
|
622
|
+
if (!V.cur || !V.el) return;
|
|
623
|
+
const old = V.el.querySelector('.cz-vw-trail'); if (old) old.remove();
|
|
624
|
+
const seq = [...V.stack, V.cur.args, ...V.fwd.slice().reverse()], here = V.stack.length;
|
|
625
|
+
const row = (it, i) => `<button type="button" role="menuitem" data-cz-vw-go="${i - here}"${i === here ? ' aria-current="page" class="here"' : i > here ? ' class="ahead"' : ''}>`
|
|
626
|
+
+ `<span class="t">${svg(it.check ? ICONS.task : path(it.icon), 15)}</span><span>${esc(it.title || it.kind || 'Item')}</span>${i === here ? '<i class="dot" aria-hidden="true"></i>' : ''}</button>`;
|
|
627
|
+
const m = document.createElement('div');
|
|
628
|
+
m.className = 'cz-vw-trail'; m.setAttribute('role', 'menu'); m.setAttribute('aria-label', 'This trail'); m.dataset.escLayer = '1';
|
|
629
|
+
m.innerHTML = seq.map((it, i) => ({ it, i })).reverse().map(({ it, i }) => row(it, i)).join('')
|
|
630
|
+
+ `<button type="button" role="menuitem" class="pg" data-cz-vw-go="${-(here + 1)}"><span class="t">${svg(P.home, 15)}</span><span>${esc(PAGES[location.pathname] || document.title || 'The page')}</span></button>`;
|
|
631
|
+
const off = () => { m.remove(); document.removeEventListener('pointerdown', away, true); };
|
|
632
|
+
const away = (e) => { if (!m.contains(e.target)) off(); };
|
|
633
|
+
m.addEventListener('click', (e) => { const x = e.target.closest('[data-cz-vw-go]'); if (!x) return; const n = +x.dataset.czVwGo; off(); if (n) guarded(() => step(n), b); });
|
|
634
|
+
m.addEventListener('keydown', (e) => {
|
|
635
|
+
const bs = [...m.querySelectorAll('button')], at = bs.indexOf(document.activeElement);
|
|
636
|
+
if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); off(); b.focus(); }
|
|
637
|
+
else if (e.key === 'ArrowDown' || e.key === 'ArrowUp') { e.preventDefault(); const n = bs[(at + (e.key === 'ArrowDown' ? 1 : -1) + bs.length) % bs.length]; if (n) n.focus(); }
|
|
638
|
+
});
|
|
639
|
+
m.addEventListener('pointerleave', (e) => { if (e.pointerType === 'mouse' && !(e.relatedTarget && b.contains(e.relatedTarget))) off(); });
|
|
640
|
+
V.el.appendChild(m);
|
|
641
|
+
const r = b.getBoundingClientRect(), h = V.el.getBoundingClientRect();
|
|
642
|
+
m.style.left = Math.max(8, r.left - h.left) + 'px'; m.style.top = (r.bottom - h.top + 6) + 'px';
|
|
643
|
+
document.addEventListener('pointerdown', away, true);
|
|
644
|
+
const c = m.querySelector('.here') || m.querySelector('button'); if (c) c.focus({ preventScroll: true });
|
|
645
|
+
}
|
|
646
|
+
|
|
517
647
|
if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') {
|
|
518
648
|
// Escape closes the Viewer first, unless a layer over it (a menu, a confirm) is open: that layer closes first. The listener is on
|
|
519
649
|
// window in the capture phase and is added before premium-shell.js adds its own, so the old dialog does not also close on the same key.
|
|
@@ -522,5 +652,9 @@ if (typeof window !== 'undefined' && typeof window.addEventListener === 'functio
|
|
|
522
652
|
if (document.querySelector('[data-esc-layer]')) return;
|
|
523
653
|
e.preventDefault(); e.stopImmediatePropagation(); guarded(close);
|
|
524
654
|
}, true);
|
|
655
|
+
window.addEventListener('click', pressAt, true);
|
|
656
|
+
window.addEventListener('keydown', (e) => { if (e.key === 'Enter' || e.key === ' ') pressAt(e); }, true);
|
|
657
|
+
window.addEventListener('popstate', popped);
|
|
658
|
+
try { H.adopt = !!(history.state && history.state.czvw); } catch { H.adopt = false; } // back here from another page, or a reload: the first open takes this entry
|
|
525
659
|
}
|
|
526
|
-
if (typeof window !== 'undefined') window.czViewer = { open, close, back, drill, setPresses, setChip, setCheck, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, ICONS };
|
|
660
|
+
if (typeof window !== 'undefined') window.czViewer = { open, close, back, forward, trail, replaceUrl, drill, setPresses, setChip, setCheck, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, ICONS };
|