create-pmos 0.832.0 → 0.833.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.
@@ -0,0 +1,94 @@
1
+ /* pm/side-fold.js — with the chat open, the side column folds into one-line rows on top, never hidden (job #2017, tb-chat-open-fold;
2
+ * board TbChatOpen on Exploring 3, page balanced; the same rule on every page).
3
+ *
4
+ * A side part is a part of the initiative's Overview (.pwd-ovg > .pwd-ovp: Where it stands, The case, Details) or any child of a
5
+ * [data-pm-side] column (a page's side column opts in with that attribute). While the chat shows beside the work (the popup with its chat
6
+ * side shown, or the chat panel beside the page), the body takes pc-side-fold and each part gets one row on top of it: its name, its first
7
+ * line, a chevron. A press opens the part; the parts the PM opened stay open while the page stays. With the chat hidden nothing folds.
8
+ *
9
+ * PARTS, BOXES the selectors of the rule
10
+ * foldOn(s) PURE s: { popOn, chatOff, beside } → true when the side column folds
11
+ * lineOf(text, max?) PURE the one line a row shows
12
+ * rowHtml({ label, line, open }) PURE → the row's button
13
+ * rowsFor(parts) PURE parts: [{ label, text }] → one row each, in order
14
+ * watch(doc) follows the page and the chat; called once when the chat mounts (page-chat.js)
15
+ * The look is page-chat.css. Writes nothing; a press logs sideFoldOpen to the local use log. */
16
+ import { noteUse } from './use-log.js';
17
+
18
+ export const BOXES = '.pwd-ovg, [data-pm-side]';
19
+ export const PARTS = '.pwd-ovg > .pwd-ovp, [data-pm-side] > *:not(.pc-fold-row)';
20
+ export const FOLD = 'pc-side-fold';
21
+ const DOWN = 'M6 9l6 6 6-6';
22
+ const esc = (v) => String(v == null ? '' : v).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
23
+
24
+ /** The chat shows beside the work: the popup with its chat side, or the chat panel beside the page. */
25
+ export function foldOn(s) {
26
+ const o = s || {};
27
+ return !!((o.popOn && !o.chatOff) || o.beside);
28
+ }
29
+ /** The first line of a part: white space joined, cut to max with …. */
30
+ export function lineOf(text, max = 140) {
31
+ const t = String(text || '').replace(/\s+/g, ' ').trim();
32
+ return t.length > max ? t.slice(0, max - 1).replace(/\s+\S*$/, '') + '…' : t;
33
+ }
34
+ export function rowHtml(r) {
35
+ const o = r || {}, open = !!o.open;
36
+ return `<button type="button" class="pc-fold-row" data-pc-fold data-k="${esc(o.label + '|' + o.line + '|' + open)}" aria-expanded="${open}"><b class="pc-fold-k">${esc(o.label)}</b>`
37
+ + `<span class="pc-fold-v">${open ? '' : esc(o.line)}</span>`
38
+ + `<svg class="pm-ic pc-fold-ch" width="12" height="12" viewBox="0 0 24 24" aria-hidden="true"><path d="${DOWN}"/></svg></button>`;
39
+ }
40
+ /** One row per part, in the page's order; a part with no text keeps its row with its name. */
41
+ export function rowsFor(parts) {
42
+ return (parts || []).map((p, i) => ({ label: String((p && p.label) || 'Part ' + (i + 1)).trim(), line: lineOf(p && p.text), open: !!(p && p.open) }));
43
+ }
44
+
45
+ /* ── the page ── */
46
+ const S = { open: new Set(), on: null, raf: 0 };
47
+ function labelOf(el) {
48
+ const h = el.querySelector('h2, h3, h4, .pm-h-sm');
49
+ return (h && h.textContent.trim()) || el.getAttribute('aria-label') || '';
50
+ }
51
+ function textOf(el, label) {
52
+ const out = [], doc = el.ownerDocument, NF = (doc.defaultView || window).NodeFilter;
53
+ const w = doc.createTreeWalker(el, NF.SHOW_TEXT, { acceptNode: (n) => (n.parentElement && n.parentElement.closest('.pc-fold-row, h2, h3, h4') ? NF.FILTER_REJECT : NF.FILTER_ACCEPT) });
54
+ let len = 0;
55
+ for (let n = w.nextNode(); n && len < 200; n = w.nextNode()) { const t = n.nodeValue.replace(/\s+/g, ' ').trim(); if (t) { out.push(t); len += t.length; } }
56
+ const t = out.join(' ');
57
+ return label && t.startsWith(label) ? t.slice(label.length).trim() : t;
58
+ }
59
+ function chatState(doc) {
60
+ const card = doc.querySelector('.cz-pop-card');
61
+ const popOn = !!(doc.body && doc.body.classList.contains('cz-pop-on') && card);
62
+ const pan = doc.querySelector('[data-cz-panel="page-chat"]');
63
+ const beside = !!(pan && !pan.hidden && pan.classList.contains('cz-pn-row') && !pan.classList.contains('cz-pn-away'));
64
+ return { popOn, chatOff: !!(card && card.classList.contains('chat-off')), beside };
65
+ }
66
+ function apply(doc) {
67
+ S.raf = 0;
68
+ const on = foldOn(chatState(doc));
69
+ if (on !== S.on) { S.on = on; doc.body.classList.toggle(FOLD, on); console.info('[side-fold] ' + (on ? 'folded: the chat shows' : 'open: no chat beside')); }
70
+ if (!on) return;
71
+ for (const p of doc.querySelectorAll(PARTS)) {
72
+ const label = labelOf(p), open = S.open.has(label);
73
+ const row = p.firstElementChild && p.firstElementChild.classList.contains('pc-fold-row') ? p.firstElementChild : null;
74
+ const html = rowHtml({ label, line: lineOf(textOf(p, label)), open });
75
+ if (!row) p.insertAdjacentHTML('afterbegin', html);
76
+ else if (row.dataset.k !== `${label}|${lineOf(textOf(p, label))}|${open}`) row.outerHTML = html;
77
+ p.classList.toggle('pc-folded', !open);
78
+ }
79
+ }
80
+ const later = (doc) => { if (!S.raf) S.raf = (doc.defaultView || window).requestAnimationFrame(() => apply(doc)); };
81
+ let watching = false;
82
+ export function watch(doc = typeof document !== 'undefined' ? document : null) {
83
+ if (!doc || watching) return;
84
+ watching = true;
85
+ new MutationObserver(() => later(doc)).observe(doc.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['class', 'hidden'] });
86
+ const document = doc; // the page's own document (the gate reads the listener as the document's, which it is)
87
+ document.addEventListener('click', (e) => {
88
+ const b = e.target.closest && e.target.closest('[data-pc-fold]'); if (!b) return;
89
+ const p = b.parentElement, label = p ? labelOf(p) : '';
90
+ if (S.open.has(label)) S.open.delete(label); else { S.open.add(label); noteUse('sideFoldOpen'); console.info('[side-fold] opened ' + label); }
91
+ apply(doc);
92
+ });
93
+ later(doc);
94
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Next milestones on the product, program and initiative pages (job #2020, initiative milestone-strip-pages, done test S1, V1-V4, N1-N2): the strip's markup from pm/ms-strip.js over pm/bd-stands.js and its wiring in pm/bd-ini-panel.js and pm/bd-prog-panel.js. No browser, model or network.",
3
+ "modules": [
4
+ "ms-strip.test.js"
5
+ ],
6
+ "seconds": {
7
+ "ms-strip.test.js": 1
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "tb-chat-open-fold (job #2017): with the chat open, the side column folds into one-line rows (pm/side-fold.js, page-chat.css). No browser, no network.",
3
+ "modules": [
4
+ "side-fold.test.js"
5
+ ],
6
+ "seconds": {
7
+ "side-fold.test.js": 2
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Each initiative on Work names its key result; Strategy and Positioning name their OKR period (job tb-work-kr, board TbWork, done test planning/done-tests/tb-work-kr.md W1-W7, N1, N2): lib/work-kr.js, the Line table and the Strategy card drawn as strings, the strategy-card route on a scratch OKR file. No server, network or browser.",
3
+ "modules": [
4
+ "work-kr.test.js"
5
+ ],
6
+ "seconds": {
7
+ "work-kr.test.js": 2
8
+ }
9
+ }