create-pmos 0.711.0 → 0.713.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 +88 -40
- package/payload/KIT-VERSION +1 -1
- package/payload/design-system/ui/README.md +1 -1
- package/payload/design-system/ui/components/State/README.md +21 -0
- package/payload/design-system/ui/components/State/preview.html +8 -0
- package/payload/design-system/ui/components/bundle.css +12 -0
- package/payload/design-system/ui/interactions.md +2 -0
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/bin/back-place-health.js +70 -0
- package/workspace/changelog.json +87 -2
- package/workspace/design-system/ui/README.md +1 -1
- package/workspace/design-system/ui/components/State/README.md +21 -0
- package/workspace/design-system/ui/components/State/preview.html +8 -0
- package/workspace/design-system/ui/components/bundle.css +12 -0
- package/workspace/design-system/ui/interactions.md +2 -0
- package/workspace/guide/breakdown.md +20 -1
- package/workspace/guide/claude-proposes.md +5 -1
- package/workspace/guide/cli.md +10 -1
- package/workspace/guide/home.md +1 -0
- package/workspace/guide/initiatives-and-next-steps.md +13 -0
- package/workspace/guide/layout.md +10 -3
- package/workspace/guide/routine.md +10 -2
- package/workspace/guide/settings-and-switches.md +4 -0
- package/workspace/lib/briefing-premium-products.js +16 -2
- package/workspace/lib/changed-mark.js +34 -0
- package/workspace/lib/launch-cli.js +43 -5
- package/workspace/lib/launch-tiers.js +143 -0
- package/workspace/lib/needs-providers.js +1 -0
- package/workspace/lib/parked-cli.js +105 -0
- package/workspace/lib/parked-reasons.js +245 -0
- package/workspace/lib/pmos-verbs.js +4 -1
- package/workspace/lib/prefs-sync.js +138 -0
- package/workspace/lib/product-dots.js +60 -0
- package/workspace/lib/route-modules.js +2 -0
- package/workspace/lib/routes-briefing-premium.js +11 -1
- package/workspace/lib/routes-prefs.js +56 -0
- package/workspace/lib/routes-strategy-card.js +53 -0
- package/workspace/lib/routes-use-log.js +24 -3
- package/workspace/lib/routine-sentence.js +250 -0
- package/workspace/lib/strategy-card.js +133 -0
- package/workspace/lib/unused-controls.js +178 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/back-place.js +87 -0
- package/workspace/public/pm/bd-backlog.css +1 -1
- package/workspace/public/pm/bd-backlog.js +9 -3
- package/workspace/public/pm/bd-pop-ds.css +10 -0
- package/workspace/public/pm/bd-pop-ds.js +27 -3
- package/workspace/public/pm/bd-strategy.js +85 -0
- package/workspace/public/pm/bd-views.js +2 -1
- package/workspace/public/pm/changed-mark.css +7 -0
- package/workspace/public/pm/changed-mark.js +117 -0
- package/workspace/public/pm/cozy-home.css +7 -0
- package/workspace/public/pm/cozy-pick.css +12 -0
- package/workspace/public/pm/cozy-pop-work.css +10 -1
- package/workspace/public/pm/cozy-pop-work.js +201 -17
- package/workspace/public/pm/cozy-routine-job.js +50 -7
- package/workspace/public/pm/cozy-routine.css +2 -0
- package/workspace/public/pm/cozy-settings.js +21 -3
- package/workspace/public/pm/cozy-task-pop.css +7 -0
- package/workspace/public/pm/cozy-today-page.css +1 -0
- package/workspace/public/pm/cozy-viewer.css +1 -1
- package/workspace/public/pm/cozy-viewer.js +14 -2
- package/workspace/public/pm/cozy-vw-mtg.css +0 -2
- package/workspace/public/pm/cozy-vw.css +0 -1
- package/workspace/public/pm/home-app.js +21 -1
- package/workspace/public/pm/home-ask.js +19 -1
- package/workspace/public/pm/home-chat.js +16 -3
- package/workspace/public/pm/home-today.js +2 -0
- package/workspace/public/pm/ini-tasks.js +4 -1
- package/workspace/public/pm/komorebi.css +11 -0
- package/workspace/public/pm/prefs-sync.js +111 -0
- package/workspace/public/pm/premium-board.js +20 -2
- package/workspace/public/pm/premium-chart-tab.js +2 -1
- package/workspace/public/pm/premium-mtg-replay.js +4 -3
- package/workspace/public/pm/premium-report-read.js +5 -4
- package/workspace/public/pm/premium-report-tab.js +4 -3
- package/workspace/public/pm/premium-vw-backlog.css +2 -1
- package/workspace/public/pm/premium-vw-backlog.js +4 -3
- package/workspace/public/pm/premium-vw-cal.css +1 -2
- package/workspace/public/pm/premium-vw-cal.js +14 -13
- package/workspace/public/pm/premium-vw-copies.js +3 -2
- package/workspace/public/pm/premium-vw-copy.css +0 -3
- package/workspace/public/pm/premium-vw-mtg.js +12 -11
- package/workspace/public/pm/product-switcher.js +41 -0
- package/workspace/public/pm/report-orders-ui.js +2 -1
- package/workspace/public/pm/rp-parts.js +3 -2
- package/workspace/public/pm/state-blocks.js +36 -0
- package/workspace/public/pm/use-log.js +118 -1
- package/workspace/public/pm/work-select.js +92 -2
- package/workspace/public/pm/work-tree.js +70 -0
- package/workspace/public/premium-aud.html +1 -0
- package/workspace/public/premium-board.html +5 -0
- package/workspace/public/premium-buddy.html +1 -0
- package/workspace/public/premium-events.html +1 -0
- package/workspace/public/premium-goals.html +1 -0
- package/workspace/public/premium-intelligence.html +1 -0
- package/workspace/public/premium-library.html +1 -0
- package/workspace/public/premium-present.html +1 -0
- package/workspace/public/premium-rec.html +1 -0
- package/workspace/public/premium-routine.html +1 -0
- package/workspace/public/premium-viewer.html +1 -0
- package/workspace/public/premium-workflows.html +1 -0
- package/workspace/public/today.html +1 -0
- package/workspace/server.js +20 -0
- package/workspace/test-lists/back-place.json +9 -0
- package/workspace/test-lists/changed-mark.json +9 -0
- package/workspace/test-lists/launch-tiers.json +9 -0
- package/workspace/test-lists/parked-reasons.json +9 -0
- package/workspace/test-lists/prefs-follow-person.json +9 -0
- package/workspace/test-lists/product-switcher-dots.json +9 -0
- package/workspace/test-lists/routine-sentence.json +9 -0
- package/workspace/test-lists/shared-empty-states.json +9 -0
- package/workspace/test-lists/strategy-card.json +9 -0
- package/workspace/test-lists/unused-controls.json +9 -0
- package/workspace/test-lists/work-subtasks-followups.json +9 -0
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
.vbl .bl-p{font:var(--fw-regular) var(--fs-meta)/var(--lh-meta) var(--mono);min-width:24px;text-align:center;padding:1px 6px;border-radius:var(--radius-sm);border:1px solid var(--hair);color:var(--ink-2)}
|
|
25
25
|
.vbl .bl-in{font-size:var(--fs-meta);color:var(--ink-3);max-width:16ch;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:var(--lh-meta);}
|
|
26
26
|
.vbl .bl-why{flex-basis:100%;margin:-6px 0 6px;font-size:var(--fs-meta);color:var(--bad);line-height:var(--lh-meta);}
|
|
27
|
-
.vbl
|
|
27
|
+
.vbl > .pm-state{padding-left:var(--space-12);padding-right:var(--space-12)}
|
|
28
|
+
.vbl .bl-none{margin:0;padding:var(--space-12) 14px;font-size:var(--fs-meta);color:var(--ink-3);line-height:var(--lh-meta);}
|
|
28
29
|
.vbl .bl-f button:focus-visible,.vbl .bl-t:focus-visible{outline:2px solid var(--ember);outline-offset:2px}
|
|
29
30
|
@media (max-width:560px){.vbl .bl-in{display:none}}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* - no rank (the list goes by key), no assignee, no sprint capacity: the readings hold none of them.
|
|
12
12
|
* - read-only: moving a ticket between sprints or ranking it happens in Jira (Jira owns sprint and rank, D88). */
|
|
13
13
|
import { vwOpen, vwStyle } from './premium-viewer.js';
|
|
14
|
+
import * as SB from './state-blocks.js'; // the empty, loading and error states every block has (Komorebi State)
|
|
14
15
|
|
|
15
16
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
16
17
|
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
@@ -48,8 +49,8 @@ function rowHtml(x) {
|
|
|
48
49
|
+ (x.blocked ? `<span class="bl-why">${esc(x.blocked)}</span>` : '') + (x.stale ? '<span class="bl-why">Not in the last read</span>' : '') + '</li>';
|
|
49
50
|
}
|
|
50
51
|
export function backlogHtml(m, f = '') {
|
|
51
|
-
if (!m) return '
|
|
52
|
-
if (m.empty) return '
|
|
52
|
+
if (!m) return SB.error('The backlog could not be read. Try again in a moment.');
|
|
53
|
+
if (m.empty) return SB.empty('No Jira reading for this board yet. The backlog appears once the Jira status check has read the initiatives\' tickets.');
|
|
53
54
|
const opts = [['', 'All'], ['blocked', 'Blocked']].concat(m.bugs ? [['bug', 'Bugs']] : []);
|
|
54
55
|
const secs = m.sections.map((s) => {
|
|
55
56
|
const rows = s.rows.filter(keep(f));
|
|
@@ -70,7 +71,7 @@ async function openTicket({ ws, board, initiative, key, url }) {
|
|
|
70
71
|
export function openBacklog({ ws, board, title } = {}) {
|
|
71
72
|
vwStyle('backlog');
|
|
72
73
|
let m = null; let f = '';
|
|
73
|
-
const draw = (el) => { el.innerHTML = `<div class="vbl">${m === undefined ? '
|
|
74
|
+
const draw = (el) => { el.innerHTML = `<div class="vbl">${m === undefined ? SB.loading('Reading the backlog.') : backlogHtml(m, f)}</div>`; };
|
|
74
75
|
return vwOpen({
|
|
75
76
|
id: 'backlog:' + (board || ''), title: title || 'Backlog', icon: 'list',
|
|
76
77
|
render: async (el) => {
|
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
.vc .vc-seg button{min-height:32px;padding:0 var(--space-12);border-radius:var(--radius-sm, 6px);font-size:var(--fs-meta);font-weight:var(--fw-regular);color:var(--ink-2);line-height:var(--lh-meta);}
|
|
20
20
|
.vc .vc-seg button[aria-pressed="true"]{background:var(--solid);color:var(--on-solid)}
|
|
21
21
|
.vc button:focus-visible{outline:2px solid var(--ember);outline-offset:2px}
|
|
22
|
-
.vc .vc-
|
|
23
|
-
.vc .vc-w>.vc-empty:last-child{border-bottom:0}
|
|
22
|
+
.vc .vc-w>.pm-state{padding-left:var(--space-12);padding-right:var(--space-12)}
|
|
24
23
|
/* the timeline (Day and Week), as the console's Calendar draws it (console3.css .cal3-tg): 46px an hour, every hour labelled */
|
|
25
24
|
.vc{--vc-ev:color-mix(in oklab,var(--ember) 30%,var(--card-solid));--vc-evh:color-mix(in oklab,var(--ember) 42%,var(--card-solid));--vc-we:color-mix(in oklab,var(--well) 70%,transparent);--vc-now:color-mix(in oklab,var(--ember) 9%,transparent)}
|
|
26
25
|
.vc .vc-sx{overflow-x:auto;min-width:0}
|
|
@@ -23,6 +23,7 @@ import { open as vOpen, current as vCur, czSummary, setWidth, widthOf } from './
|
|
|
23
23
|
import { pmGet } from './http.js';
|
|
24
24
|
import { notesCards } from './premium-vw-notes.js';
|
|
25
25
|
import './premium-vw-open.js'; // registers window.czViews
|
|
26
|
+
import * as SB from './state-blocks.js'; // the empty, loading and error states every block has (Komorebi State)
|
|
26
27
|
|
|
27
28
|
export const VIEWS = [['day', 'Day'], ['week', 'Week'], ['month', 'Month']];
|
|
28
29
|
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
@@ -130,9 +131,9 @@ export function calHtml(M, esc, nowMin = null) {
|
|
|
130
131
|
const seg = `<div class="vc-seg" role="group" aria-label="Calendar view">${VIEWS.map(([k, l]) => `<button type="button" data-cv="${k}" aria-pressed="${M.view === k}">${l}</button>`).join('')}</div>`;
|
|
131
132
|
const step = M.view === 'day' ? 'day' : M.view === 'week' ? 'week' : 'month';
|
|
132
133
|
const head = `<div class="vc-h"><button type="button" class="vc-ib" data-cn="-1" aria-label="Previous ${step}">${ic('back')}</button><button type="button" class="vc-ib" data-cn="1" aria-label="Next ${step}">${ic('next')}</button><button type="button" class="vc-tdy" data-cn="0">Today</button><b class="vc-t">${esc(M.title)}</b><small class="vc-cap">${esc(M.caption)}</small>${seg}</div>`;
|
|
133
|
-
if (M.state !== 'ok') return `<div class="vc-w">${head}
|
|
134
|
+
if (M.state !== 'ok') return `<div class="vc-w">${head}${SB.error('Calendar not read. ' + (M.reason || ''))}</div>`;
|
|
134
135
|
const chip = (a) => a.row ? `<button type="button" class="vc-ad meet" data-ev="${esc(a.ref)}" title="${esc(a.title + ', all day')}">${esc(a.title)}</button>` : `<span class="vc-ad ${esc(a.kind)}${a.tone ? ' t-' + esc(a.tone) : ''}" title="${esc(a.title)}">${esc(a.title)}</span>`;
|
|
135
|
-
const empty = M.empty ?
|
|
136
|
+
const empty = M.empty ? SB.empty(M.empty) : '';
|
|
136
137
|
if (M.view === 'month') {
|
|
137
138
|
const cells = M.days.map((x) => {
|
|
138
139
|
const ev = [...x.allday.filter((a) => a.row), ...x.timed].sort((a, b) => (a.s || 0) - (b.s || 0));
|
|
@@ -281,8 +282,8 @@ export function calSummary(TD) {
|
|
|
281
282
|
/** The day (XvACal): the five weekdays with their load bars, then one list, each entry at its time. A day other than today says its count. */
|
|
282
283
|
export function dayHtml(strip, D, isToday = false) {
|
|
283
284
|
const h = [`<div class="vzc-days" role="group" aria-label="This week">${strip.map((d) => `<button type="button" class="vzc-dy${d.today ? ' now' : ''}" aria-pressed="${d.on}" data-c="day" data-k="${d.key}" aria-label="${esc(d.dow + ' ' + d.n + (d.today ? ', today' : '') + ': ' + plural(d.count, 'meeting'))}"><span>${d.dow}</span><b>${d.n}</b><span class="vzc-lb" data-tl="${Math.round(d.bar * 100)}%"><i></i></span></button>`).join('')}</div>`];
|
|
284
|
-
if (D.state === 'error') return h.join('') +
|
|
285
|
-
if (!D.rows.length) return h.join('') + '
|
|
285
|
+
if (D.state === 'error') return h.join('') + SB.error('The calendar was not read. ' + (D.reason || ''));
|
|
286
|
+
if (!D.rows.length) return h.join('') + SB.empty('No meetings on this day.');
|
|
286
287
|
if (!isToday) { const mins = D.rows.reduce((a, r) => a + (r.mins || 0), 0), allEv = D.rows.every((r) => r.kind === 'event'); h.push(`<p class="vzc-mut">${esc(D.title)} · ${allEv ? plural(D.rows.length, 'meeting') : plural(D.rows.length, 'entry', 'entries')}${mins ? ' · ' + hrsText(mins) : ''}</p>`); }
|
|
287
288
|
h.push(`<div class="vzc-list">${D.rows.map((r, i) => `<button type="button" class="vzc-de vz-hv${r.ended ? ' past' : ''}" data-c="open" data-i="${i}"${r.next ? ' data-next' : ''}><span class="vzc-t">${esc(r.time)}</span><span class="vzc-dt"><b>${esc(r.title)}</b><small>${esc(r.sub)}</small></span>${r.chip === 'Link it' ? `<span class="vz-cc vzc-link" data-c="link" data-i="${i}" role="button" tabindex="0" title="Link it to an initiative">Link it</span>` : r.chip ? chipHtml(r.chip, r.k) : r.next ? '<i class="vzc-nx" aria-label="Next"></i>' : ''}</button>`).join('')}</div>`);
|
|
288
289
|
return h.join('');
|
|
@@ -306,20 +307,20 @@ export function calViewHtml(st, X) {
|
|
|
306
307
|
if (S) h.push(czSummary(S));
|
|
307
308
|
if (st.view !== 'day') h.push(`<div class="vzc-head"><h2 class="vzm-h2">${esc(rangeTitle(st.view, st.date, X.today))}</h2><button type="button" class="vzm-ib vz-hv" data-c="nav" data-k="-1" aria-label="Previous ${st.view}">${sv('prev')}</button><button type="button" class="vzm-ib vz-hv" data-c="nav" data-k="1" aria-label="Next ${st.view}">${sv('next')}</button><button type="button" class="vzm-btn vzm-soft" data-c="nav" data-k="0">Today</button><span class="vz-sp"></span><button type="button" class="vzm-btn vzm-soft" data-c="view" data-k="day">Day</button></div>`);
|
|
308
309
|
const M = X.M;
|
|
309
|
-
if (!M) h.push('
|
|
310
|
-
else if (M.state !== 'ok' && st.view !== 'day') h.push(
|
|
311
|
-
else if (st.view === 'week') h.push(weekHtml(M, X.notes, X.nowMin) + (M.empty ?
|
|
312
|
-
else if (st.view === 'month') h.push(monthHtml(M) + (M.empty ?
|
|
313
|
-
else h.push(X.day ? dayHtml(X.strip, X.day, st.date === X.today) : '
|
|
310
|
+
if (!M) h.push(SB.loading('Reading the calendar PMOS holds.'));
|
|
311
|
+
else if (M.state !== 'ok' && st.view !== 'day') h.push(SB.error('The calendar was not read. ' + (M.reason || '')));
|
|
312
|
+
else if (st.view === 'week') h.push(weekHtml(M, X.notes, X.nowMin) + (M.empty ? SB.empty(M.empty) : ''));
|
|
313
|
+
else if (st.view === 'month') h.push(monthHtml(M) + (M.empty ? SB.empty(M.empty) : ''));
|
|
314
|
+
else h.push(X.day ? dayHtml(X.strip, X.day, st.date === X.today) : SB.loading('Reading the calendar PMOS holds.'));
|
|
314
315
|
if (st.view !== 'day') h.push(`<div class="vzc-leg"><span><i class="vzc-sw"></i>Linked</span><span><i class="vzc-sw un"></i>Not linked</span><span class="vz-sp"></span><span title="${esc(CAL_FOOT)}">${esc(CAL_HINT)}</span></div>`);
|
|
315
316
|
} else {
|
|
316
317
|
const C = X.cards;
|
|
317
318
|
h.push(`<div class="vzm-in vzc-find">${sv('find')}<input type="search" data-c="q" aria-label="${esc(SEARCH_HINT)}" placeholder="${esc(SEARCH_HINT)}" value="${esc(st.q || '')}">${st.q ? `<span class="vzc-mut">${C && C.state === 'ok' ? plural(C.count, 'note') : ''}</span><button type="button" class="vzm-ib vz-hv" data-c="clear" aria-label="Clear the search">${sv('x', 14)}</button>` : ''}</div>`);
|
|
318
319
|
h.push(`<div class="vzc-chips" role="group" aria-label="Show">${NOTE_FILTERS.map(([k, l]) => `<button type="button" class="vzm-chip${(st.filter || 'all') === k ? ' on' : ''}" data-c="filter" data-k="${k}" aria-pressed="${(st.filter || 'all') === k}">${l}</button>`).join('')}</div>`);
|
|
319
|
-
if (!C) h.push('
|
|
320
|
-
else if (C.state === 'error') h.push(
|
|
321
|
-
else if (!C.total) h.push('
|
|
322
|
-
else if (!C.groups.length) h.push(
|
|
320
|
+
if (!C) h.push(SB.loading('Reading the notes.'));
|
|
321
|
+
else if (C.state === 'error') h.push(SB.error('The notes could not be read. ' + (C.error || '')));
|
|
322
|
+
else if (!C.total) h.push(SB.empty('No notes yet. Notes you record show here, grouped by initiative.'));
|
|
323
|
+
else if (!C.groups.length) h.push((st.searching ? SB.loading('Searching what was said.') : SB.empty(st.q ? 'No note matches “' + st.q + '”.' : 'No note of this kind.')));
|
|
323
324
|
else C.groups.forEach((g) => h.push(`<section class="vzc-grp"><p class="vzm-lbl">${esc(g.title)} <small>${esc(g.n)}</small></p>${g.entries.map((e) => entryHtml(e, st)).join('')}</section>`));
|
|
324
325
|
}
|
|
325
326
|
return `<div class="vz vz-cal" data-tab="${st.tab}" data-view="${st.view}">${h.join('')}</div>`;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { vwOpen, vwStyle } from './premium-viewer.js';
|
|
11
11
|
import { pmGet, pmPost } from './http.js';
|
|
12
12
|
import { mdHtml, copyKindOf } from './premium-doc-edit.js';
|
|
13
|
+
import * as SB from './state-blocks.js'; // the empty, loading and error states every block has (Komorebi State)
|
|
13
14
|
|
|
14
15
|
const TOOL = { google: 'Google Docs', confluence: 'Confluence', 'google-slides': 'Google Slides', 'google-sheets': 'Google Sheets' };
|
|
15
16
|
const COPY = { google: 'the Google Doc', confluence: 'the Confluence page', 'google-slides': 'the slides', 'google-sheets': 'the sheet' };
|
|
@@ -86,9 +87,9 @@ export function openCopy(o) {
|
|
|
86
87
|
}
|
|
87
88
|
const head = `<div class="cpv-bar">${ICON(kind)}<div><b>${t}</b><small>${esc(tool)}${where}</small></div><span class="chp"><i></i>${r.state === 'reading' ? 'Reading' : 'Link only'}</span></div>`;
|
|
88
89
|
if (r.state === 'reading') return `<div class="cpv">${head}<p class="note">A session is reading the page with your ${esc(tool)} connector${r.since ? ' (started ' + esc(r.since) + ')' : ''}. The text shows here when it is done.</p><div class="cpv-acts">${ext(o.url, tool)}</div></div>`;
|
|
89
|
-
return `<div class="cpv">${head}
|
|
90
|
+
return `<div class="cpv">${head}${SB.empty('PMOS has only the address of this page. It was added as a link, so PMOS holds no text to show here.')}`
|
|
90
91
|
+ `<div class="cpv-acts">${r.state === 'none' ? `<button type="button" class="dmcta" data-cp="read"${S.busy ? ' disabled' : ''}>Read it now</button>` : ''}${ext(o.url, tool)}</div>`
|
|
91
|
-
+ `<p class="note">${r.state === 'error' ? esc(r.error) : r.failed ? 'The last read did not finish: ' + esc(r.failed) + '. Press Read it now to try again.' : `Read it now starts one session that reads the page with your ${esc(tool)} connector and keeps the text in PMOS. It changes nothing in ${esc(tool)}.`}</p></div
|
|
92
|
+
+ `<p class="note">${r.state === 'error' ? esc(r.error) : r.failed ? 'The last read did not finish: ' + esc(r.failed) + '. Press Read it now to try again.' : `Read it now starts one session that reads the page with your ${esc(tool)} connector and keeps the text in PMOS. It changes nothing in ${esc(tool)}.`}</p></div>`;
|
|
92
93
|
}
|
|
93
94
|
async function load() {
|
|
94
95
|
S.err = '';
|
|
@@ -14,9 +14,6 @@
|
|
|
14
14
|
.cpv-why code{font-size:var(--fs-meta);line-height:var(--lh-meta);}
|
|
15
15
|
.cpv-acts{display:flex;flex-wrap:wrap;align-items:center;gap:var(--space-8)}
|
|
16
16
|
.cpv-acts .dmcta{border-radius:var(--radius-sm);text-decoration:none}
|
|
17
|
-
.cpv-empty{display:grid;gap:var(--space-8);padding:18px 20px;border:1px dashed var(--ink-3);border-radius:8px;color:var(--ink-2)}
|
|
18
|
-
.cpv-empty b{font-size:var(--fs-row);font-weight:var(--fw-strong);color:var(--ink);line-height:var(--lh-row);}
|
|
19
|
-
.cpv-empty p{margin:0;font-size:var(--fs-body);line-height:var(--lh-body);}
|
|
20
17
|
.cpv-page{padding:18px 22px;border:1px solid var(--hair);border-radius:8px;background:var(--card-solid)}
|
|
21
18
|
.cpv-page.dim{opacity:.62}
|
|
22
19
|
@media (max-width:700px){
|
|
@@ -45,6 +45,7 @@ import { replayView, phoneHtml, editHtml, mentions, phraseOf as phraseOfPage, de
|
|
|
45
45
|
import { announce } from './rec-state.js';
|
|
46
46
|
import { presentInRecording } from './cozy-rec-bridge.js'; // while a meeting records, Present goes to the recording tab (batch 12 item 1, rule 10)
|
|
47
47
|
import { factsOf } from './meeting-share.js'; // the facts mentioned: one list for the note and a shared copy (shareable-meeting-notes)
|
|
48
|
+
import * as SB from './state-blocks.js'; // the empty, loading and error states every block has (Komorebi State)
|
|
48
49
|
export { factsOf };
|
|
49
50
|
|
|
50
51
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
@@ -356,7 +357,7 @@ export function summaryHtml(m, ui = {}) {
|
|
|
356
357
|
|
|
357
358
|
function agendaHtml(P) {
|
|
358
359
|
return P.agenda.length ? `<div class="vzm-agl">${P.agenda.map((a, i) => `<div class="vz-ag"><i class="vz-num" aria-hidden="true">${a.n}</i><span>${esc(a.text)}</span><button type="button" class="vz-min vz-hv" data-a="min" data-i="${i}" title="Change the minutes for this topic" aria-label="${esc(a.text)}: ${a.min} minutes. Change">${a.min} min</button></div>`).join('')}</div>`
|
|
359
|
-
: '
|
|
360
|
+
: SB.empty('The invite lists no topics yet.');
|
|
360
361
|
}
|
|
361
362
|
/** Tagged rows (What matters, Since the last one, Facts). W: the word fixes, shown in the words (Facts, batch 27 item 12). */
|
|
362
363
|
const tagRows = (rows, W) => rows.map((x) => `<div class="vz-tagrow"><span class="vz-tag" data-k="${x.k}">${esc(x.tag)}</span><span><span class="vz-said">${W ? wx(W, x.text) : esc(x.text)}</span> <small>${esc(x.meta || x.owner || x.src || '')}</small></span></div>`).join('');
|
|
@@ -379,19 +380,19 @@ const hlHtml = (L) => L.hl.map((x) => `<div class="vz-hl"><time>${esc(x.t)}</tim
|
|
|
379
380
|
function caughtHtml(m) {
|
|
380
381
|
const L = m.live, Fo = m.focus, h = [];
|
|
381
382
|
if (Fo.gist) h.push(`<p class="vz-p">${esc('So far: ' + Fo.gist)}</p>`);
|
|
382
|
-
else if (Fo.error) h.push(
|
|
383
|
+
else if (Fo.error) h.push(SB.error(Fo.error));
|
|
383
384
|
if (L.topics.length) h.push(weightBar('vz-stretch', L.topics.map((t) => ({ w: +t.flex || 1, attrs: ` data-k="${t.k}"` }))));
|
|
384
|
-
return h.join('') || '
|
|
385
|
+
return h.join('') || SB.empty('What was said shows here while the note records.');
|
|
385
386
|
}
|
|
386
387
|
/** The live Agenda: the 3 to 5 topics (pm/agenda-live.js) when the read has them. No Change topic: PMOS follows the talk, the PM says Not this one. */
|
|
387
388
|
function liveAgendaHtml(m) {
|
|
388
389
|
const Fo = m.focus;
|
|
389
390
|
if (Fo.model) return mergedAgendaHtml(Fo.model);
|
|
390
|
-
return (Fo.agenda.length ? Fo.agenda.map((a) => `<div class="vzm-ag" data-k="${a.k}"><span>${a.k === 'now' || a.k === 'late' ? `<b>${a.n} ${esc(a.text)}</b>` : esc(a.n + ' ' + a.text)}</span>${fillBar(a.fill, a.k)}<small>${esc(a.say)}</small></div>`).join('') : '
|
|
391
|
+
return (Fo.agenda.length ? Fo.agenda.map((a) => `<div class="vzm-ag" data-k="${a.k}"><span>${a.k === 'now' || a.k === 'late' ? `<b>${a.n} ${esc(a.text)}</b>` : esc(a.n + ' ' + a.text)}</span>${fillBar(a.fill, a.k)}<small>${esc(a.say)}</small></div>`).join('') : SB.empty('The invite lists no topics yet.'));
|
|
391
392
|
}
|
|
392
393
|
function transcriptHtml(m, ui, lines, seek) {
|
|
393
394
|
const W = m.notes && m.notes.replay ? m.notes.replay.W : null; // the word fixes (MvF) show in the transcript too
|
|
394
|
-
return (lines.length ? lines.map((l, i) => lineHtml(l, i, ui, seek, W)).join('') :
|
|
395
|
+
return (lines.length ? lines.map((l, i) => lineHtml(l, i, ui, seek, W)).join('') : SB.empty(m.private ? 'This note is private: only what you type is kept.' : m.mk === 'live' ? 'Nothing has been said yet.' : 'Nothing was transcribed.'))
|
|
395
396
|
+ `<p class="vz-note vz-fine">${esc(LIVE_FOOT)}</p>`;
|
|
396
397
|
}
|
|
397
398
|
function stepHtml(a, ui, W) {
|
|
@@ -532,7 +533,7 @@ export function heldHtml(m, ui = {}, ctx = {}) {
|
|
|
532
533
|
+ `<button type="button" class="y" data-a="h-add" aria-label="Yes, add ${n === 1 ? 'it' : 'them'}" title="Yes, add ${n === 1 ? 'it' : 'them'}">${svg('check', 14)}</button><button type="button" data-a="h-no" aria-label="No" title="No">${svg('x', 14)}</button></div></div>`);
|
|
533
534
|
}
|
|
534
535
|
if (H.notes.length) h.push('<h6>Notes</h6><ul>' + H.notes.map((t) => `<li>${esc(t)}</li>`).join('') + '</ul>');
|
|
535
|
-
if (!H.lead && !H.decisions.length && !H.tasks.length && !H.notes.length) h.push(
|
|
536
|
+
if (!H.lead && !H.decisions.length && !H.tasks.length && !H.notes.length) h.push(SB.empty(NO_NOTES));
|
|
536
537
|
const about = H.about ? `<button type="button" class="vzh-sel" data-a="${H.ini ? 'h-ini' : 'm-about'}" title="${esc(m.about)}"><span>${esc(H.about)}</span>${svg('next', 14)}</button>` : `<button type="button" class="vzh-sel" data-a="m-about">Link it</button>`;
|
|
537
538
|
const side = ['<h6>The meeting</h6>',
|
|
538
539
|
H.held ? `<div class="r"><span>Held</span><em>${esc(H.held)}</em></div>` : '',
|
|
@@ -559,8 +560,8 @@ export function matPopHtml(P) {
|
|
|
559
560
|
}
|
|
560
561
|
export function matListHtml(P) {
|
|
561
562
|
const items = P.q ? P.found : P.sug;
|
|
562
|
-
if (!items) return P.q ? '
|
|
563
|
-
if (!items.length) return P.q ? '
|
|
563
|
+
if (!items) return P.q ? SB.loading('Looking in PMOS.', { rows: 2 }) : '';
|
|
564
|
+
if (!items.length) return P.q ? SB.empty('Nothing in PMOS matches. Paste a link instead.') : '';
|
|
564
565
|
return `<p class="vzm-mlbl">${P.q ? 'Found in PMOS' : 'Suggested for this meeting'}</p>` + items.map((it, i) => `<button type="button" class="vzm-mi2 vz-hv" data-a="matadd" data-i="${i}">${svg(it.kind === 'pmos-deck' ? 'deck' : it.kind === 'board' ? 'board' : 'doc', 16)}<span class="vzm-grow">${esc(clip(it.title, 80))}${it.meta ? `<br><span class="vzm-sm vzm-mut">${esc(clip(it.meta, 80))}</span>` : ''}</span><span class="vzm-k">Add</span></button>`).join('');
|
|
565
566
|
}
|
|
566
567
|
/** What it is about's popover (MtAfter). O = aboutOptions(), q = the find text */
|
|
@@ -571,7 +572,7 @@ export function aboutListHtml(O, q = '') {
|
|
|
571
572
|
const words = norm(q).split(' ').filter(Boolean), hit = (x) => words.every((w) => norm(x.label).includes(w));
|
|
572
573
|
const item = (x, ic, hl) => `<button type="button" class="vzm-mi2 vz-hv${hl ? ' hl' : ''}" data-a="aboutpick" data-v="${esc(x.v)}"${x.v === O.cur ? ' aria-current="true"' : ''}>${svg(ic, 16)}<span class="vzm-grow">${esc(x.label)}${x.sub ? `<br><span class="vzm-sm vzm-mut">${esc(x.sub)}</span>` : ''}</span>${x.v === O.cur ? svg('check', 14) : ''}</button>`;
|
|
573
574
|
const h = [];
|
|
574
|
-
if (words.length) { const f = O.initiatives.filter(hit).slice(0, 8); h.push(`<p class="vzm-mlbl">Initiatives</p>${f.length ? f.map((x) => item(x, 'flag')).join('') : '
|
|
575
|
+
if (words.length) { const f = O.initiatives.filter(hit).slice(0, 8); h.push(`<p class="vzm-mlbl">Initiatives</p>${f.length ? f.map((x) => item(x, 'flag')).join('') : SB.empty('No initiative has that name.')}`); }
|
|
575
576
|
else if (O.suggested.length) h.push(`<p class="vzm-mlbl">Suggested from the notes</p>${O.suggested.map((x) => item(x, 'flag', true)).join('')}`);
|
|
576
577
|
else if (O.initiatives.length) h.push(`<p class="vzm-mlbl">Initiatives</p>${O.initiatives.slice(0, 5).map((x) => item(x, 'flag')).join('')}`);
|
|
577
578
|
h.push(`<p class="vzm-mlbl">Or</p>${O.boards.filter((x) => !words.length || hit(x)).map((x) => item(x, 'prod')).join('')}${item(O.portfolio, 'board')}${item(O.none, 'x')}`);
|
|
@@ -620,7 +621,7 @@ export async function openMeeting(ref, o = {}) {
|
|
|
620
621
|
if (MT) { MT.alive = false; MT.timers.forEach(clearInterval); stopPlay(MT); }
|
|
621
622
|
MT = me;
|
|
622
623
|
const id = 'meeting:' + (R.note || R.event || R.title || 'new');
|
|
623
|
-
const draw0 = (body) => { body.innerHTML = '<div class="vz"
|
|
624
|
+
const draw0 = (body) => { body.innerHTML = '<div class="vz">' + SB.loading('Reading the meeting.') + '</div>'; };
|
|
624
625
|
me.vid = id;
|
|
625
626
|
vOpen({ id, kind: 'Meeting', title: R.title || 'Meeting', icon: CLOCK_ICON, url: meetingUrl({ ...R, ws: me.ws }), render: draw0, onClose: () => closed(me) });
|
|
626
627
|
widen('mtg');
|
|
@@ -834,7 +835,7 @@ function placePop(me, body) {
|
|
|
834
835
|
const P = me.ui.pop; if (P !== 'mat' && P !== 'about') return;
|
|
835
836
|
const anc = P === 'mat' ? shown(body, '[data-pop="mat"]') : body.querySelector('[data-pop="head"]'); if (!anc) return;
|
|
836
837
|
if (P === 'mat') { anc.innerHTML = matPopHtml(me.mat || { row: me.row }); if (!me.matShown && anc.scrollIntoView) { me.matShown = true; anc.scrollIntoView({ block: 'nearest' }); } }
|
|
837
|
-
else anc.innerHTML = me.about ? aboutPopHtml(me.about, me.aboutQ || '', me.row ? 'Applies to every meeting of “' + me.row.title + '”. The calendar itself is never written.' : 'Applies to this note.') : '<div class="vzm-pop"
|
|
838
|
+
else anc.innerHTML = me.about ? aboutPopHtml(me.about, me.aboutQ || '', me.row ? 'Applies to every meeting of “' + me.row.title + '”. The calendar itself is never written.' : 'Applies to this note.') : '<div class="vzm-pop">' + SB.loading('Reading what it can be about.', { rows: 2 }) + '</div>';
|
|
838
839
|
}
|
|
839
840
|
function keydown(me, e, body) {
|
|
840
841
|
const a = e.target.dataset && e.target.dataset.a;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* pm/product-switcher.js — the product switcher row (bet A381, initiative product-switcher-dots). One quiet row of product tiles on Today
|
|
2
|
+
* and Work. A tile carries one blue dot when its product has rows that need the PM (GET /api/briefing-premium/products?needs=1, from
|
|
3
|
+
* lib/product-dots.js): no count, and no dot at zero or before the product is read (zero is silence, honest state).
|
|
4
|
+
*
|
|
5
|
+
* readDots() → the pick with `needs` on each product, or null
|
|
6
|
+
* switcherHtml(P, o) PURE. The row: '' for fewer than two products. o.tones: the page's tints (cozy-pick.js tonesOf), o.cls: an extra class
|
|
7
|
+
* pressOf(P, ws) PURE. The pick a press saves: that product alone, or every product when it is already shown alone
|
|
8
|
+
* press(P, ws) saves pressOf with savePick, so every page follows (pp:changed) → savePick's answer
|
|
9
|
+
*
|
|
10
|
+
* Each tile is a button with data-psw, so the local use log (pm/use-log.js, A466) counts the presses: the outcome check reads them with
|
|
11
|
+
* node workspace/lib/product-dots.js count. Tiles, letters and tints are the product chip's own (cozy-pick.js). */
|
|
12
|
+
import { pmGet } from './http.js';
|
|
13
|
+
import { codeOf, tonesOf, savePick } from './cozy-pick.js';
|
|
14
|
+
import { productName } from './scope-chip.js';
|
|
15
|
+
|
|
16
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
17
|
+
const nameOf = (p) => productName(p && p.ws, (p && p.name) || '');
|
|
18
|
+
|
|
19
|
+
export async function readDots() { const r = await pmGet('/api/briefing-premium/products?needs=1'); return r && r.ok && Array.isArray(r.products) ? r : null; }
|
|
20
|
+
|
|
21
|
+
/** The one product shown alone, or null when two or more are shown. */
|
|
22
|
+
const aloneOf = (P) => { const on = P.products.filter((p) => p.on); return on.length === 1 ? on[0].ws : null; };
|
|
23
|
+
|
|
24
|
+
export function switcherHtml(P, o = {}) {
|
|
25
|
+
if (!P || !Array.isArray(P.products) || P.products.length < 2) return '';
|
|
26
|
+
const T = o.tones || tonesOf(P.products), alone = aloneOf(P);
|
|
27
|
+
const tiles = P.products.map((p) => {
|
|
28
|
+
const n = Number.isInteger(p.needs) ? p.needs : 0, nm = nameOf(p);
|
|
29
|
+
const words = n > 0 ? nm + ', ' + n + ' need' + (n === 1 ? 's' : '') + ' you' : nm;
|
|
30
|
+
return `<button type="button" class="psw-b" data-psw="${esc(p.ws)}" aria-pressed="${p.ws === alone}" aria-label="${esc(words)}" title="${esc(words)}">`
|
|
31
|
+
+ `<i class="ppk-t t${T[p.ws] || 0}" aria-hidden="true">${esc(codeOf(p))}</i>${n > 0 ? '<i class="psw-dot" aria-hidden="true"></i>' : ''}</button>`;
|
|
32
|
+
}).join('');
|
|
33
|
+
return `<div class="psw${o.cls ? ' ' + esc(o.cls) : ''}" role="group" aria-label="Switch product">${tiles}</div>`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function pressOf(P, ws) {
|
|
37
|
+
const all = P.products.map((p) => p.ws);
|
|
38
|
+
return aloneOf(P) === ws ? all : [ws];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const press = (P, ws) => savePick(pressOf(P, ws));
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* Use from the next cycle on an agreed outline). Rename and Delete on Mine only.
|
|
12
12
|
* S = the GET answer · G = { sel, i, ren } · o = { esc, ic, slideCard, pics(id) → [slide] | null, now: [slide], busy, hidden: Set, issued }
|
|
13
13
|
*/
|
|
14
|
+
import * as SB from './state-blocks.js'; // the empty, loading and error states every block has (Komorebi State)
|
|
14
15
|
|
|
15
16
|
const keyOf = (S, k) => k + ':' + (S && S.slot) + ':' + ((S && S.pick && S.pick.id) || (S && S.now && S.now.id) || '');
|
|
16
17
|
export const hideKey = keyOf;
|
|
@@ -79,7 +80,7 @@ function cardHtml(S, o, c) {
|
|
|
79
80
|
}
|
|
80
81
|
/** The gallery (TpD), or one order pressed open. */
|
|
81
82
|
export function galHtml(S, G, o) {
|
|
82
|
-
if (!S || !S.ok) return '
|
|
83
|
+
if (!S || !S.ok) return SB.loading('Reading the orders.');
|
|
83
84
|
const e = o.esc;
|
|
84
85
|
const close = `<button type="button" class="rp-tl vz-hv ro-ib" data-r="ord|close" aria-label="Close the orders" title="Close">${o.ic('x', 16)}</button>`;
|
|
85
86
|
if (G.sel) return detailHtml(S, G, o);
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* THE RULE (as the premium models): every number, date and chip comes from a field of a record. Where a record is silent the part says so or
|
|
19
19
|
* is left out; nothing is filled with a guess. */
|
|
20
20
|
import { tableStarts, readTable, tableHtml } from './md-table.js';
|
|
21
|
+
import * as SB from './state-blocks.js'; // the empty, loading and error states every block has (Komorebi State)
|
|
21
22
|
|
|
22
23
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
23
24
|
const inline = (s) => esc(s).replace(/\*\*([^*]+)\*\*/g, '<b>$1</b>').replace(/`([^`]+)`/g, '<code>$1</code>');
|
|
@@ -127,7 +128,7 @@ export function briefLooksHtml(B, o = {}) {
|
|
|
127
128
|
}
|
|
128
129
|
/** The whole Brief as html, its four groups in order. o = { issued, busy, msg } */
|
|
129
130
|
export function briefHtml(B, o = {}) {
|
|
130
|
-
if (!B) return '
|
|
131
|
+
if (!B) return SB.loading('Reading how this report is made.');
|
|
131
132
|
return `<div class="rp-brief"><p class="rp-lbl">At a glance</p>${briefGlanceHtml(B)}<p class="rp-lbl">Please confirm</p>${briefConfirmHtml(B, o)}<p class="rp-lbl">Why it looks like this</p>${briefWhyHtml(B)}${briefLooksHtml(B, o)}`
|
|
132
133
|
+ (o.msg ? `<p class="vz-msg" role="status">${esc(o.msg)}</p>` : '') + '</div>';
|
|
133
134
|
}
|
|
@@ -329,7 +330,7 @@ function chartSvg(c, hover) {
|
|
|
329
330
|
}
|
|
330
331
|
/** The live page as html. s = { name, audience, period, issued, readAgo, hover, products } */
|
|
331
332
|
export function liveHtml(L, s = {}) {
|
|
332
|
-
if (!L) return '
|
|
333
|
+
if (!L) return SB.loading('Reading the numbers.');
|
|
333
334
|
const head = `<div class="rp-lvh"><div class="rp-grow"><p class="rp-lbl">${esc((s.audience ? s.audience + ' · ' : '') + 'live')}</p><h2 class="rp-h2">${esc(s.name || 'Report')}</h2></div>`
|
|
334
335
|
+ `<span class="rp-per" title="${s.issued ? 'An issued cycle shows its numbers as they were on its day' : 'The numbers as they are now'}">${esc(s.period || 'Now')}</span>`
|
|
335
336
|
+ `<button type="button" class="cz-pick" data-r="lv|prod" aria-haspopup="menu" aria-expanded="${!!s.prodOpen}">${esc((L.board && L.board.name) || 'This product')}${SV('M7 10l5 5 5-5', 14)}</button>`
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* state-blocks.js — the three states every block has, drawn once (Komorebi part State; initiative shared-empty-states).
|
|
2
|
+
*
|
|
3
|
+
* empty(line, { step }) one quiet line, and the one next step when there is one. Never "0 items".
|
|
4
|
+
* loading(what, { rows }) soft placeholder rows in the block's own place (3 by default). No text on screen, no spinner;
|
|
5
|
+
* a screen reader hears `what` ("Reading the report.").
|
|
6
|
+
* error(line, { retry }) one line in words that says what failed, and Retry when the page can try again.
|
|
7
|
+
* `retry` is the data attribute the page listens for, e.g. 'data-vc-retry'.
|
|
8
|
+
*
|
|
9
|
+
* `line` and `what` are plain text and are escaped here. `step` is trusted HTML the page built (a button or a link).
|
|
10
|
+
* The look lives in ui/components/bundle.css (.pm-state), so a Komorebi token change reaches every state on every page.
|
|
11
|
+
* An error writes one [state-block] line per distinct failure, so a responder can find it in the console. */
|
|
12
|
+
|
|
13
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
14
|
+
const ATTR = /^data-[a-z0-9-]+(="[^"<>]*")?$/; // a page's own press mark, nothing else
|
|
15
|
+
const RETRY = '<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg>';
|
|
16
|
+
const said = new Set();
|
|
17
|
+
|
|
18
|
+
export function empty(line, { step = '' } = {}) {
|
|
19
|
+
return `<p class="pm-state empty">${esc(line)}${step ? ' ' + step : ''}</p>`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function loading(what, { rows = 3 } = {}) {
|
|
23
|
+
const n = Math.max(1, Math.min(8, Math.round(Number(rows)) || 3));
|
|
24
|
+
return `<div class="pm-state loading" role="status" aria-label="${esc(what)}">${'<span class="ph"><i></i></span>'.repeat(n)}</div>`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function error(line, { retry = '' } = {}) {
|
|
28
|
+
const text = String(line == null ? '' : line);
|
|
29
|
+
if (!said.has(text)) {
|
|
30
|
+
said.add(text);
|
|
31
|
+
try { console.info('[state-block] error:', text); } catch { /* no console */ }
|
|
32
|
+
}
|
|
33
|
+
const mark = retry && ATTR.test(retry) ? retry : '';
|
|
34
|
+
const btn = mark ? `<button type="button" class="pm-btn" aria-label="Try again" title="Try again" ${mark}>${RETRY}</button>` : '';
|
|
35
|
+
return `<p class="pm-state error" role="alert"><span>${esc(text)}</span>${btn}</p>`;
|
|
36
|
+
}
|
|
@@ -6,14 +6,27 @@
|
|
|
6
6
|
* controlOf(el) PURE: the name a pressed element is logged under, or '' to log nothing
|
|
7
7
|
* deviceOf(width) PURE: phone (≤ 760 px), tablet (≤ 1100 px) or desk
|
|
8
8
|
*
|
|
9
|
+
* HIDE THE BUTTONS NOBODY PRESSES (idea A454; the rule and the store are lib/unused-controls.js). startUseLog also:
|
|
10
|
+
* at load hides this page's hidden buttons (GET /api/use-log/hidden, one style rule per id, so a button drawn later is hidden too);
|
|
11
|
+
* after UNUSED_MS tells the server which buttons the page shows (POST /api/use-log/unused, ids only) and, when it proposes some, shows
|
|
12
|
+
* the Komorebi Suggestion: "Hide N buttons…", icon-only Yes and No, the buttons outlined while it shows. Yes hides them and the
|
|
13
|
+
* Komorebi Toast offers Undo; No folds it and PMOS does not suggest them again. Settings › General › Use log lists them with Show.
|
|
14
|
+
* presentControls(doc) the ids a page shows that may be proposed (PURE over the doc it is given)
|
|
15
|
+
* hideCss(ids) PURE: the style rule that hides them · sugHtml(n) · hidToastHtml(n) PURE: the parts' markup
|
|
16
|
+
*
|
|
9
17
|
* ON THIS COMPUTER ONLY. Events go to this workspace's own server (POST /api/use-log, a relative URL) in batches: every 15 s while there
|
|
10
18
|
* are some, and once more when the page hides (keepalive). Nothing goes anywhere else. NOTHING PERSONAL: a control is named by its id or
|
|
11
19
|
* by the NAME of its first data- attribute (data-ev-sub), never by a value, its text or its label; an element with neither is not logged. */
|
|
12
|
-
import { pmPost } from './http.js';
|
|
20
|
+
import { pmPost, pmGet } from './http.js';
|
|
13
21
|
|
|
14
22
|
const FLUSH_MS = 15000;
|
|
15
23
|
const MAX_QUEUE = 200;
|
|
16
24
|
const ID_RE = /^[A-Za-z][A-Za-z0-9_-]{0,79}$/;
|
|
25
|
+
const UNUSED_MS = 4000;
|
|
26
|
+
const TOAST_MS = 6000;
|
|
27
|
+
const PROPOSABLE = 'button[id], a[href][id], [role="button"][id], [role="tab"][id], [role="switch"][id], [role="menuitem"][id]';
|
|
28
|
+
// a button inside the menu, a dialog, a list, a table or a form is about one item or one task: never proposed
|
|
29
|
+
const NOT_IN = '#czNav, nav, dialog, [role="dialog"], [aria-modal="true"], ul, ol, table, [role="list"], [role="listbox"], [role="grid"], [role="table"], [role="tree"], form, [data-pm-unused-host]';
|
|
17
30
|
const PRESSABLE = 'button, a[href], [role="button"], [role="tab"], [role="switch"], [role="menuitem"], input[type="checkbox"], input[type="radio"], select, summary';
|
|
18
31
|
let started = false;
|
|
19
32
|
const Q = [];
|
|
@@ -58,5 +71,109 @@ export function startUseLog(doc = typeof document !== 'undefined' ? document : n
|
|
|
58
71
|
const hide = () => flush(true);
|
|
59
72
|
try { window.addEventListener('pagehide', hide); doc.addEventListener('visibilitychange', () => { if (doc.visibilityState === 'hidden') hide(); }); } catch { /* no window */ }
|
|
60
73
|
setTimeout(() => flush(false), 2000); // the open goes soon after load, so a page closed quickly still counts
|
|
74
|
+
try { startUnused(doc); } catch { /* the page still works without it */ }
|
|
61
75
|
return true;
|
|
62
76
|
}
|
|
77
|
+
|
|
78
|
+
/* ── hide the buttons nobody presses (idea A454) ── */
|
|
79
|
+
|
|
80
|
+
/** The ids this page shows that may be proposed: a pressable element with a plain id, visible, outside the menu, a dialog, a list, a
|
|
81
|
+
* table or a form. Never its text. */
|
|
82
|
+
export function presentControls(doc) {
|
|
83
|
+
if (!doc || !doc.querySelectorAll) return [];
|
|
84
|
+
const out = new Set();
|
|
85
|
+
for (const el of doc.querySelectorAll(PROPOSABLE)) {
|
|
86
|
+
const id = el.getAttribute('id') || '';
|
|
87
|
+
if (!ID_RE.test(id) || /^data-/i.test(id)) continue;
|
|
88
|
+
if (el.closest && el.closest(NOT_IN)) continue;
|
|
89
|
+
if (el.getClientRects && !el.getClientRects().length) continue; // not on screen: display none, or inside something closed
|
|
90
|
+
out.add(id);
|
|
91
|
+
if (out.size >= 300) break;
|
|
92
|
+
}
|
|
93
|
+
return [...out];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** One style rule that hides these ids, so a button the page draws later is hidden too. Ids match ID_RE, so they need no escaping. */
|
|
97
|
+
export const hideCss = (ids) => (ids || []).filter((id) => ID_RE.test(id)).map((id) => `#${id}`).join(',') + ((ids || []).some((id) => ID_RE.test(id)) ? '{display:none!important}' : '');
|
|
98
|
+
|
|
99
|
+
const STAR = '<svg class="pm-ic pm-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z"/></svg>';
|
|
100
|
+
const icon = (d) => `<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
101
|
+
const YES = 'M5 12.5l4.5 4.5L19 7.5', NO = 'M6 6l12 12M18 6L6 18', UNDO = 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3';
|
|
102
|
+
const buttons = (n) => `${n} ${n === 1 ? 'button' : 'buttons'}`;
|
|
103
|
+
|
|
104
|
+
/** The Komorebi Suggestion for n buttons: the ✦, one line, icon-only Yes and No. */
|
|
105
|
+
export function sugHtml(n) {
|
|
106
|
+
return `<div class="pm-sug" role="group" aria-label="PMOS suggests"><span title="PMOS saw these on this page on many days, and you have not pressed them in 14 days. Outlined while this shows.">${STAR}</span>`
|
|
107
|
+
+ `<span class="say">Hide ${buttons(n)} on this page you have not pressed in 14 days? They stay in Settings › Use log.</span>`
|
|
108
|
+
+ `<button type="button" class="pm-btn primary" data-uc-yes aria-label="Yes, hide them" title="Yes, hide them">${icon(YES)}</button>`
|
|
109
|
+
+ `<button type="button" class="pm-btn outline" data-uc-no aria-label="No, keep them" title="No, keep them">${icon(NO)}</button></div>`;
|
|
110
|
+
}
|
|
111
|
+
/** The Komorebi Toast after Yes, Undo as an icon button. */
|
|
112
|
+
export function hidToastHtml(n) {
|
|
113
|
+
return `<div class="pm-toast" role="status" aria-live="polite"><span class="in"><span>${buttons(n)} hidden. Show them again in Settings › Use log.</span>`
|
|
114
|
+
+ `<button type="button" class="pm-btn" data-uc-undo aria-label="Undo: show them again" title="Undo">${icon(UNDO)}</button></span><span class="timer" data-uc-timer></span></div>`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const UC = { css: null, host: null, ids: [], timer: 0 };
|
|
118
|
+
// the suggestion's place: a desk, bottom centre as the Toast part says; a phone (the menu's 760 px edge), under the top bar, so it never
|
|
119
|
+
// covers the chat box at the foot (as draft-keep). The outline marks the proposed buttons while the suggestion shows.
|
|
120
|
+
const HOST_CSS = '[data-pm-unused-host]{position:fixed;left:50%;bottom:var(--space-24);transform:translateX(-50%);z-index:2147482990;background:none;max-width:min(560px,calc(100vw - 32px))}'
|
|
121
|
+
+ '@media (max-width:760px){[data-pm-unused-host]{bottom:auto;top:var(--space-64)}}'
|
|
122
|
+
+ '[data-pm-unused]{outline:2px dashed var(--blue, currentColor);outline-offset:2px}';
|
|
123
|
+
function applyHidden(doc, ids) {
|
|
124
|
+
UC.ids = ids;
|
|
125
|
+
if (!UC.css) { UC.css = doc.createElement('style'); UC.css.id = 'pmUnusedCss'; doc.head.appendChild(UC.css); }
|
|
126
|
+
UC.css.innerHTML = hideCss(ids) + HOST_CSS;
|
|
127
|
+
}
|
|
128
|
+
function host(doc) {
|
|
129
|
+
if (UC.host && UC.host.isConnected) return UC.host;
|
|
130
|
+
if (!UC.css) applyHidden(doc, UC.ids); // the host's place is in the same style element (HOST_CSS)
|
|
131
|
+
const h = doc.createElement('div');
|
|
132
|
+
h.className = 'pm-ds'; h.setAttribute('data-pm-unused-host', '');
|
|
133
|
+
doc.body.appendChild(h);
|
|
134
|
+
return (UC.host = h);
|
|
135
|
+
}
|
|
136
|
+
const mark = (doc, ids, on) => { for (const id of ids) { const el = doc.getElementById(id); if (el) { if (on) el.setAttribute('data-pm-unused', ''); else el.removeAttribute('data-pm-unused'); } } };
|
|
137
|
+
|
|
138
|
+
function propose(doc, page, ids) {
|
|
139
|
+
const h = host(doc);
|
|
140
|
+
h.innerHTML = sugHtml(ids.length);
|
|
141
|
+
mark(doc, ids, true);
|
|
142
|
+
h.onclick = async (e) => {
|
|
143
|
+
const b = e.target.closest && e.target.closest('button'); if (!b) return;
|
|
144
|
+
if (b.hasAttribute('data-uc-yes')) {
|
|
145
|
+
mark(doc, ids, false);
|
|
146
|
+
const r = await pmPost('/api/use-log/hide', { page, controls: ids });
|
|
147
|
+
if (r && r.ok) { applyHidden(doc, [...new Set(UC.ids.concat(ids))]); hidToast(doc, page, ids); } else h.innerHTML = '';
|
|
148
|
+
} else if (b.hasAttribute('data-uc-no')) {
|
|
149
|
+
mark(doc, ids, false); h.innerHTML = '';
|
|
150
|
+
pmPost('/api/use-log/decline', { page, controls: ids });
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function hidToast(doc, page, ids) {
|
|
155
|
+
const h = host(doc);
|
|
156
|
+
h.innerHTML = hidToastHtml(ids.length);
|
|
157
|
+
const done = () => { clearTimeout(UC.timer); h.innerHTML = ''; };
|
|
158
|
+
h.onclick = async (e) => {
|
|
159
|
+
if (!(e.target.closest && e.target.closest('[data-uc-undo]'))) return;
|
|
160
|
+
done();
|
|
161
|
+
const r = await pmPost('/api/use-log/show', { page, controls: ids });
|
|
162
|
+
if (r && r.ok) applyHidden(doc, UC.ids.filter((id) => !ids.includes(id)));
|
|
163
|
+
};
|
|
164
|
+
h.onmouseenter = () => clearTimeout(UC.timer);
|
|
165
|
+
h.onmouseleave = () => { UC.timer = setTimeout(done, TOAST_MS); };
|
|
166
|
+
clearTimeout(UC.timer); UC.timer = setTimeout(done, TOAST_MS);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function startUnused(doc) {
|
|
170
|
+
const page = pageNow();
|
|
171
|
+
Promise.resolve(pmGet('/api/use-log/hidden?page=' + encodeURIComponent(page))).then((r) => {
|
|
172
|
+
if (r && r.ok && Array.isArray(r.hidden) && r.hidden.length) applyHidden(doc, r.hidden.map((x) => x.control));
|
|
173
|
+
}).catch(() => null);
|
|
174
|
+
setTimeout(() => {
|
|
175
|
+
Promise.resolve(pmPost('/api/use-log/unused', { page, present: presentControls(doc) })).then((r) => {
|
|
176
|
+
if (r && r.ok && Array.isArray(r.propose) && r.propose.length) propose(doc, page, r.propose);
|
|
177
|
+
}).catch(() => null);
|
|
178
|
+
}, UNUSED_MS);
|
|
179
|
+
}
|