create-pmos 0.735.0 → 0.737.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 +57 -33
- package/payload/AGENTS.md +1 -0
- 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/changelog.json +56 -0
- package/workspace/guide/cli.md +9 -0
- package/workspace/guide/home.md +1 -0
- package/workspace/guide/initiatives-and-next-steps.md +1 -1
- package/workspace/guide/layout.md +13 -3
- package/workspace/guide/positioning.md +5 -3
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/positioning-cli.js +91 -0
- package/workspace/lib/use-log.js +26 -4
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/action-keys.js +1 -1
- package/workspace/public/pm/bd-ini-panel.js +3 -2
- package/workspace/public/pm/bd-pop-ds.css +18 -0
- package/workspace/public/pm/bd-pop-ds.js +33 -3
- package/workspace/public/pm/bd-views.js +9 -1
- package/workspace/public/pm/cozy-board.css +7 -0
- package/workspace/public/pm/cozy-day-pick.css +0 -1
- package/workspace/public/pm/cozy-ev.css +9 -0
- package/workspace/public/pm/cozy-nav.js +2 -0
- package/workspace/public/pm/cozy-pop-work.js +16 -13
- package/workspace/public/pm/cozy-today-app.js +37 -3
- package/workspace/public/pm/cozy-today-model.js +12 -4
- package/workspace/public/pm/cozy-today-page.css +7 -0
- package/workspace/public/pm/cozy-today-view.js +15 -9
- package/workspace/public/pm/cozy-viewer.js +17 -2
- package/workspace/public/pm/focus-mode.js +161 -0
- package/workspace/public/pm/home-chat.js +4 -2
- package/workspace/public/pm/ini-tasks.js +8 -18
- package/workspace/public/pm/open-questions-view.js +96 -0
- package/workspace/public/pm/range-pick.css +50 -0
- package/workspace/public/pm/range-pick.js +155 -0
- package/workspace/public/pm/task-card.css +2 -19
- package/workspace/public/pm/task-card.js +16 -36
- package/workspace/stage-card-tasks-test.js +11 -11
- package/workspace/task-card-test.js +17 -10
- package/workspace/task-views-test.js +7 -5
- package/workspace/test-lists/chat-open-keeps-back.json +9 -0
- package/workspace/test-lists/focus-mode.json +9 -0
- package/workspace/test-lists/open-questions-view.json +9 -0
- package/workspace/test-lists/range-pick.json +5 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/* pm/focus-mode.js — focus mode: one item and its chat, nothing else (bet A335, initiative focus-mode).
|
|
2
|
+
*
|
|
3
|
+
* f hides every part of the page except the item under the pointer (or with focus) and its chat f again puts it all back
|
|
4
|
+
*
|
|
5
|
+
* The item is what the pointer is over, or what has focus, whichever moved last (the rule of pm/action-keys.js). Its panel is the nearest
|
|
6
|
+
* popup card, Viewer, dialog or [data-panel]; with none, the row it is on. Its chat is the popup's chat side (already in the popup card),
|
|
7
|
+
* else the page's chat (#hmChat, .pc-chat, [data-chat]). Every other part of the page gets data-pm-focus-off (hidden by cozy-ev.css) and
|
|
8
|
+
* inert. Nothing moves in the DOM, so leaving restores each part exactly; an inert the page set itself stays. Leaving also puts back the
|
|
9
|
+
* scroll place and the focus. The next decision (the kept panel's first Yes button) scrolls into view on entry.
|
|
10
|
+
* Leave with f, or the icon-only Leave focus button at the top right. Focus ends by itself when the kept panel closes or hides (Esc on the
|
|
11
|
+
* popup), so the page never stays hidden. Not on a phone: it has no key, and it already shows one item at a time.
|
|
12
|
+
* Keys do nothing while typing, in a terminal, with Ctrl, Cmd or Alt, on a held key, or when the page already used the key.
|
|
13
|
+
* Each press is counted on this computer only (pm/use-log.js noteUse: focus-on, focus-off or focus-miss, no text, no value).
|
|
14
|
+
*
|
|
15
|
+
* startFocusMode(doc) called once by the menu (pm/cozy-nav.js mountNav), which every page mounts; a second call does nothing
|
|
16
|
+
* focusKey(e) PURE: true when the key event asks to enter or leave focus
|
|
17
|
+
* keepOf(here, doc) the parts to keep for the item at `here`: [panel] in the popup, [panel, chat?] elsewhere; [] for a miss
|
|
18
|
+
* enter(keep, doc) hide the rest; true when focus is on · leave(doc) put it all back · isOn()
|
|
19
|
+
* check(doc) leave when a kept part is gone or hidden; true when it left
|
|
20
|
+
* leaveHtml() PURE: the Leave focus button's markup */
|
|
21
|
+
import { noteUse } from './use-log.js';
|
|
22
|
+
import { actOf, wordsOf, PRESS } from './action-keys.js';
|
|
23
|
+
|
|
24
|
+
const TYPING = 'input, textarea, select, [contenteditable=""], [contenteditable="true"], [role="textbox"]';
|
|
25
|
+
const POP = '.cz-pop-card';
|
|
26
|
+
const PANEL = '.cz-pop-card, .cz-vw, dialog, [role="dialog"], [data-cz-panel], [data-panel]';
|
|
27
|
+
const ROW = '[role="row"], [role="option"], [role="listitem"], .pm-li, li, tr, [data-open]';
|
|
28
|
+
const CHAT = '#hmChat, .pc-chat, [data-chat]';
|
|
29
|
+
const OFF = 'data-pm-focus-off';
|
|
30
|
+
const say = (s) => { try { console.info('[focus-mode] ' + s); } catch { /* no console */ } };
|
|
31
|
+
const isPhone = () => typeof innerWidth === 'number' && innerWidth <= 760;
|
|
32
|
+
const shown = (el) => !!el && el.isConnected !== false && !(el.closest && el.closest('[hidden]'))
|
|
33
|
+
&& (typeof el.getClientRects !== 'function' || el.getClientRects().length > 0);
|
|
34
|
+
|
|
35
|
+
/** PURE: true when the key event asks to enter or leave focus. */
|
|
36
|
+
export function focusKey(e) {
|
|
37
|
+
if (!e || e.defaultPrevented || e.repeat || e.ctrlKey || e.metaKey || e.altKey) return false;
|
|
38
|
+
if (e.key !== 'f' && e.key !== 'F') return false;
|
|
39
|
+
const t = e.target;
|
|
40
|
+
if (t && t.closest && (t.closest(TYPING) || t.closest('.xterm'))) return false;
|
|
41
|
+
if (t && t.isContentEditable) return false;
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The parts to keep for the item at `here`: the popup card (item and chat together), or the panel or row and the page's chat. */
|
|
46
|
+
export function keepOf(here, doc) {
|
|
47
|
+
const el = here && here.nodeType === 3 ? here.parentElement : here;
|
|
48
|
+
if (!el || !el.closest || !doc || el === doc.body || el === doc.documentElement) return [];
|
|
49
|
+
const pop = el.closest(POP);
|
|
50
|
+
if (pop) return [pop];
|
|
51
|
+
const panel = el.closest(PANEL) || el.closest(ROW);
|
|
52
|
+
if (!panel) return [];
|
|
53
|
+
const chat = doc.querySelectorAll ? [...doc.querySelectorAll(CHAT)].find((c) => shown(c) && !panel.contains(c) && !c.contains(panel)) : null;
|
|
54
|
+
return chat ? [panel, chat] : [panel];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const X = '<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg>';
|
|
58
|
+
|
|
59
|
+
/** PURE: the Leave focus button (icon-only, Komorebi pm-btn). */
|
|
60
|
+
export function leaveHtml() {
|
|
61
|
+
return `<button type="button" class="pm-btn pm-focus-leave" data-pm-focus-leave aria-label="Leave focus" title="Leave focus (F)">${X}</button>`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const S = { on: false, keep: [], hid: [], btn: null, scroll: null, back: null, started: false, pointer: null, pointerT: 0, focusT: 0, obs: null };
|
|
65
|
+
export const isOn = () => S.on;
|
|
66
|
+
|
|
67
|
+
/** Hide every part of the page that is not kept and holds nothing kept. True when focus is on. */
|
|
68
|
+
export function enter(keep, doc) {
|
|
69
|
+
if (S.on || !keep || !keep.length || !doc || !doc.body) return false;
|
|
70
|
+
const path = new Set();
|
|
71
|
+
for (const k of keep) for (let e = k; e; e = e.parentElement) path.add(e);
|
|
72
|
+
const hid = [];
|
|
73
|
+
for (const p of path) {
|
|
74
|
+
if (keep.includes(p)) continue; // inside a kept part nothing is touched
|
|
75
|
+
for (const c of [...(p.children || [])]) {
|
|
76
|
+
if (path.has(c) || c.hasAttribute(OFF) || c.tagName === 'SCRIPT' || c.tagName === 'STYLE' || c.tagName === 'LINK') continue;
|
|
77
|
+
hid.push({ el: c, inert: !!c.inert });
|
|
78
|
+
c.setAttribute(OFF, '');
|
|
79
|
+
c.inert = true;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const w = doc.defaultView;
|
|
83
|
+
S.scroll = w ? [w.scrollX || 0, w.scrollY || 0] : null;
|
|
84
|
+
S.back = doc.activeElement && doc.activeElement !== doc.body ? doc.activeElement : null;
|
|
85
|
+
S.on = true; S.keep = keep.slice(); S.hid = hid;
|
|
86
|
+
doc.body.classList.add('pm-focus');
|
|
87
|
+
if (doc.createElement && doc.body.appendChild) {
|
|
88
|
+
const holder = doc.createElement('div');
|
|
89
|
+
holder.setAttribute('class', 'pm-focus-bar');
|
|
90
|
+
holder.innerHTML = leaveHtml();
|
|
91
|
+
doc.body.appendChild(holder);
|
|
92
|
+
S.btn = holder;
|
|
93
|
+
}
|
|
94
|
+
const yes = (keep[0].querySelectorAll ? [...keep[0].querySelectorAll(PRESS)] : []).find((b) => actOf(wordsOf(b)) === 'approve' && shown(b));
|
|
95
|
+
if (yes && yes.scrollIntoView) yes.scrollIntoView({ block: 'nearest' }); // the next decision in view
|
|
96
|
+
say('on: ' + hid.length + ' parts hidden');
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Put every part back as it was: marks off, the page's own inert kept, the scroll place and the focus back. */
|
|
101
|
+
export function leave(doc) {
|
|
102
|
+
if (!S.on) return false;
|
|
103
|
+
for (const { el, inert } of S.hid) { el.removeAttribute(OFF); el.inert = inert; }
|
|
104
|
+
if (S.btn && S.btn.remove) S.btn.remove();
|
|
105
|
+
if (doc && doc.body) { const cl = doc.body.classList; (cl.remove || cl.delete).call(cl, 'pm-focus'); }
|
|
106
|
+
const w = doc && doc.defaultView;
|
|
107
|
+
if (w && S.scroll && typeof w.scrollTo === 'function') w.scrollTo(S.scroll[0], S.scroll[1]);
|
|
108
|
+
const back = S.back;
|
|
109
|
+
S.on = false; S.keep = []; S.hid = []; S.btn = null; S.scroll = null; S.back = null;
|
|
110
|
+
if (back && back.isConnected !== false && typeof back.focus === 'function') { try { back.focus({ preventScroll: true }); } catch { /* gone */ } }
|
|
111
|
+
say('off');
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Leave by itself when a kept part is gone or hidden (the popup closed), so the page never stays hidden. True when it left. */
|
|
116
|
+
export function check(doc) {
|
|
117
|
+
if (!S.on) return false;
|
|
118
|
+
if (S.keep.every((k) => shown(k))) return false;
|
|
119
|
+
leave(doc);
|
|
120
|
+
noteUse('focus-off');
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function hereOf(doc) {
|
|
125
|
+
const a = doc.activeElement;
|
|
126
|
+
const focused = a && a !== doc.body && a !== doc.documentElement ? a : null;
|
|
127
|
+
return focused && (S.focusT >= S.pointerT || !S.pointer || !S.pointer.isConnected) ? focused : (S.pointer && S.pointer.isConnected ? S.pointer : focused);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function toggle(doc) {
|
|
131
|
+
if (S.on) { leave(doc); noteUse('focus-off'); return; }
|
|
132
|
+
if (!enter(keepOf(hereOf(doc), doc), doc)) { noteUse('focus-miss'); say('nothing here to focus on'); return; }
|
|
133
|
+
noteUse('focus-on');
|
|
134
|
+
const w = doc.defaultView;
|
|
135
|
+
if (w && typeof w.MutationObserver === 'function' && !S.obs) {
|
|
136
|
+
S.obs = new w.MutationObserver(() => { if (check(doc) && S.obs) { S.obs.disconnect(); S.obs = null; } });
|
|
137
|
+
S.obs.observe(doc.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['hidden', 'class', 'open'] });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function startFocusMode(doc = typeof document !== 'undefined' ? document : null) {
|
|
142
|
+
if (S.started || !doc || !doc.addEventListener) return false;
|
|
143
|
+
S.started = true;
|
|
144
|
+
doc.addEventListener('pointerover', (e) => { if (!S.on) { S.pointer = e.target; S.pointerT = Date.now(); } }, { passive: true });
|
|
145
|
+
doc.addEventListener('focusin', () => { if (!S.on) S.focusT = Date.now(); });
|
|
146
|
+
// Leave focus is a real <button>; its press is delegated from the window, like the ? list's Close (pm/action-keys.js)
|
|
147
|
+
if (doc.defaultView) doc.defaultView.addEventListener('click', (e) => {
|
|
148
|
+
if (S.on && e.target && e.target.closest && e.target.closest('[data-pm-focus-leave]')) {
|
|
149
|
+
leave(doc); noteUse('focus-off');
|
|
150
|
+
if (S.obs) { S.obs.disconnect(); S.obs = null; }
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
// the bubble phase, so a page's own f (the meeting view) runs first and wins
|
|
154
|
+
doc.addEventListener('keydown', (e) => {
|
|
155
|
+
if (!focusKey(e) || isPhone()) return;
|
|
156
|
+
e.preventDefault();
|
|
157
|
+
toggle(doc);
|
|
158
|
+
if (!S.on && S.obs) { S.obs.disconnect(); S.obs = null; }
|
|
159
|
+
});
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
@@ -422,7 +422,9 @@ export function mountChat(el, host) {
|
|
|
422
422
|
if (rep !== undefined) { const sig = blockSig(rep); if (rep && sig !== C.auto.rep) { const P = rep.proposal; show({ kind: 'report', block: rep, title: P ? (rep.kind === 'chart' ? P.title || P.measure : P.name) : rep.id, sub: rep.kind === 'report' ? 'Report' : rep.kind === 'chart' ? 'Chart' : 'Dashboard' }); } C.auto.rep = sig; }
|
|
423
423
|
const gs = now ? now.sig : null; if (now && gs !== C.auto.goal) show({ kind: 'goal', title: now.title, sub: now.sub }); C.auto.goal = gs;
|
|
424
424
|
}
|
|
425
|
-
|
|
425
|
+
// what the chat opens by itself goes in front of the item shown, so ← comes back to it (chat-open-keeps-back)
|
|
426
|
+
const keepBehind = () => { try { if (window.czViewer && window.czViewer.behind) window.czViewer.behind(); } catch { /* no Viewer */ } };
|
|
427
|
+
function show(it) { if (host.desk()) { keepBehind(); openIt(it); } else peek(it); }
|
|
426
428
|
function openIt(it) {
|
|
427
429
|
if (it.kind === 'goal') return openGoal();
|
|
428
430
|
if (it.kind === 'report') return views.block(it.block, { chat: C.t.key || null, auto: true });
|
|
@@ -434,7 +436,7 @@ export function mountChat(el, host) {
|
|
|
434
436
|
if (!it) { if (b) b.hidden = true; return; }
|
|
435
437
|
if (!b) { foot.insertAdjacentHTML('beforebegin', '<button type="button" class="hm-peek" id="hmPeek" hidden></button>'); b = el.querySelector('#hmPeek'); }
|
|
436
438
|
b.innerHTML = `<span>${esc(it.sub || '')} · <b>${esc(it.title || '')}</b></span><em>View</em>`; b.hidden = false;
|
|
437
|
-
b.onclick = () => { peek(null); openIt(it); };
|
|
439
|
+
b.onclick = () => { peek(null); keepBehind(); openIt(it); };
|
|
438
440
|
C.peekT = setTimeout(() => peek(null), 15000);
|
|
439
441
|
}
|
|
440
442
|
const where = () => ({ session: sid(), ws: C.t.ws || new URLSearchParams(location.search).get('ws') });
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
* h.dates(uid, { start?, due? }) the quick changes (each with Undo), h.remove(uid) the picker's trash (batch 11 item 16: Delete, Undo in the toast), h.redraw(). A Jira ticket is read-only: the Jira mark, a plain date, no
|
|
24
24
|
* picker and no drag. Archived tasks show in no view here (the List folds them after Done). */
|
|
25
25
|
import { STATES, stateIcon, stateKey, datePickerHtml, cardStyle } from './task-card.js';
|
|
26
|
+
import { mountRange } from './range-pick.js'; // start and due on one calendar
|
|
26
27
|
import * as LK from './ini-links.js'; // the links' marks on bars and cards (batch 11 item 15)
|
|
27
28
|
import * as JM from './jira-move.js'; // a Jira ticket's status, moved in Jira (Wawan 2026-10-29)
|
|
28
29
|
|
|
@@ -652,29 +653,18 @@ export function jiraPop(anchor, key, status, raw, H) {
|
|
|
652
653
|
if (s !== status && H.jiraMove) H.jiraMove({ key, to: s, from: status, fromRaw: raw });
|
|
653
654
|
});
|
|
654
655
|
}
|
|
655
|
-
/** The date picker under a date press (a bottom sheet on a phone, batch 18 item 16 StA3Dates)
|
|
656
|
-
*
|
|
656
|
+
/** The date picker under a date press (a bottom sheet on a phone, batch 18 item 16 StA3Dates): start and due on one calendar
|
|
657
|
+
* (pm/range-pick.js), the first tap the start and the second the due day, which closes it. data-f 'due' opens on the due day (the open
|
|
658
|
+
* row's Due chip); data-one: a milestone's one day, "◇ Date" (StA4Milestone). */
|
|
657
659
|
export function datePop(anchor, uid, H) {
|
|
658
660
|
const one = anchor.dataset.one === '1', sheet = PHONE();
|
|
659
|
-
const t = { start: one ? '' : anchor.dataset.s || '', due: anchor.dataset.e || '' }, st = { field: !one && anchor.dataset.f === '
|
|
661
|
+
const t = { start: one ? '' : anchor.dataset.s || '', due: anchor.dataset.e || '' }, st = { field: !one && anchor.dataset.f === 'due' ? 'due' : 'start', month: '', one };
|
|
660
662
|
const nm = anchor.dataset.t || '';
|
|
661
663
|
if (sheet) st.head = `<div class="ivd-h">${one ? SVG(P.dia, 15, 2.2) : SVG(P.cal, 15, 2)}<b>${one ? 'Date' : 'Dates'}</b><button type="button" class="iv-ib" data-ivd-x aria-label="Close" title="Close">${SVG('M6 6l12 12M18 6L6 18', 16, 2)}</button></div>`
|
|
662
664
|
+ (nm ? `<p class="ivd-s">${esc(nm + (one ? ' · one date: the milestone' : ''))}</p>` : '');
|
|
663
|
-
const
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
if ('ivdX' in d) { closePop(); return; }
|
|
667
|
-
if (d.tkcField) { st.field = d.tkcField; st.month = ''; draw(); return; }
|
|
668
|
-
if (d.tkcMonth) { st.month = d.tkcMonth; draw(); return; }
|
|
669
|
-
if (d.tkcDay == null) return;
|
|
670
|
-
const iso = d.tkcDay, f = st.field, p = { [f]: iso };
|
|
671
|
-
if (iso && f === 'due' && t.start && iso < t.start) p.start = iso; // a due day before the start moves the start with it
|
|
672
|
-
if (iso && f === 'start' && t.due && iso > t.due) p.due = iso;
|
|
673
|
-
Object.assign(t, p);
|
|
674
|
-
if (H.dates) H.dates(uid, p);
|
|
675
|
-
// after the start, the next tap is the due day; after the due day the picker closes
|
|
676
|
-
if (f === 'start' && iso) { st.field = 'due'; st.month = ''; draw(); } else closePop();
|
|
677
|
-
}, sheet ? { sheet: true } : {});
|
|
665
|
+
const el = openPop(anchor, datePickerHtml(t, st), (b) => { if ('ivdX' in b.dataset) closePop(); }, sheet ? { sheet: true } : {});
|
|
666
|
+
mountRange(el.querySelector('.tkc-dp'), { ...t, one, field: st.field, head: st.head, onPick: (p, done) => { Object.assign(t, p); if (done) closePop(); if (H.dates) H.dates(uid, p); } });
|
|
667
|
+
el.querySelector('.rp-g [tabindex="0"]')?.focus({ preventScroll: true });
|
|
678
668
|
}
|
|
679
669
|
function menuPop(anchor, label, items, go) {
|
|
680
670
|
const html = `<div class="tkc-pop ivq-m" role="menu" aria-label="${esc(label)}">${items.map((x, i) => `<button type="button" role="menuitemradio" class="o${x.on ? ' hl' : ''}" aria-checked="${!!x.on}" data-ivq-i="${i}"><span class="ck" aria-hidden="true">${x.on ? SVG(P.check, 14, 2.4) : ''}</span><span>${esc(x.label)}</span>${x.count ? `<span class="k">${esc(x.count)}</span>` : ''}</button>`).join('')}</div>`;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/* pm/open-questions-view.js — the open questions in Today's Decide tab (initiative open-questions-today, bet A420; board QuestionsA and
|
|
2
|
+
* the left phone of QuestionsPhone, main canvas, In development; brief /mnt/project-files/design-system/open-questions/brief.md).
|
|
3
|
+
* Pure: Node imports it (open-questions-view.test.js).
|
|
4
|
+
*
|
|
5
|
+
* rowsOf(lines, today) → { mine, others, all } the register's lines (GET /api/open-questions, each with its ws) as rows, oldest first
|
|
6
|
+
* groupsHtml(Q) → the two groups for a desk: "Waiting on you · n · oldest first", "Waiting on others · n"; '' with none
|
|
7
|
+
* phoneGroupsHtml(Q) → the same two groups for a phone: rows with a dot, no cards; '' with none
|
|
8
|
+
* overviewSay(Q) → one sentence for the Overview: how many wait on you, the oldest and its default; '' with none
|
|
9
|
+
* OLD_DAYS
|
|
10
|
+
*
|
|
11
|
+
* A ROW: { key: 'q:<ws>:<line key>', ws, ini, title, meta, age, old, under, toPm, owner, due, line }. The title says what waits, the meta
|
|
12
|
+
* line the initiative and the kind, the under line what PMOS does if nobody answers ("If nobody answers by 7 Dec, …") or why it has no
|
|
13
|
+
* default ("No default: …"). A press opens the initiative (data-td="open"); Remind on a teammate's row writes a draft in the chat, unsent
|
|
14
|
+
* (data-td="q-remind"). Taking the default and putting it off a week are slice 2. Built from Komorebi parts only: pm-group, pm-li, pm-badge. */
|
|
15
|
+
|
|
16
|
+
export const OLD_DAYS = 14;
|
|
17
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
18
|
+
const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
|
|
19
|
+
const ic = (d, w = 16, cls = '') => `<svg class="pm-ic${cls ? ' ' + cls : ''}" aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24"><path d="${d}"/></svg>`;
|
|
20
|
+
const I = { decide: 'M12 4l8 8-8 8-8-8z', person: 'M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 20a8 8 0 0 1 16 0', spark: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z',
|
|
21
|
+
clock: 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18zM12 7v5l3 2', open: 'M5 12h14M13 6l6 6-6 6', remind: 'M5 5h14v10H9l-4 4z' };
|
|
22
|
+
const firstSentence = (t) => { const s = String(t || '').replace(/\s+/g, ' ').trim(); const m = /^(.+?[?.])(\s|$)/.exec(s); return (m ? m[1] : s).slice(0, 140); };
|
|
23
|
+
const clip = (s, n) => { s = String(s || ''); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
|
|
24
|
+
|
|
25
|
+
/** What waits, in one line. A line of drafts only: "4 drafts on <initiative> wait on you". Else the first sentence of what it asks;
|
|
26
|
+
* a teammate's line starts with their name. */
|
|
27
|
+
function titleOf(l) {
|
|
28
|
+
const k = l.kinds || {};
|
|
29
|
+
if (k.draft && !k.change && !k.ask) return plural(k.draft, 'draft', 'drafts') + ' on ' + (l.title || l.ini) + (l.toPm ? (k.draft === 1 ? ' waits on you' : ' wait on you') : '');
|
|
30
|
+
const s = firstSentence(l.text) || 'An open question';
|
|
31
|
+
return l.toPm ? s : (l.owner ? l.owner + ': ' : '') + s;
|
|
32
|
+
}
|
|
33
|
+
/** The kind of what waits, in a few words. */
|
|
34
|
+
function kindWords(l) {
|
|
35
|
+
const k = l.kinds || {}, out = [];
|
|
36
|
+
if (k.change) out.push(k.change === 1 ? 'PMOS holds a change with no source' : 'PMOS holds ' + k.change + ' changes with no source');
|
|
37
|
+
if (k.ask) out.push(k.ask === 1 ? 'a sign-off or a ticket question' : k.ask + ' sign-offs or ticket questions');
|
|
38
|
+
if (k.draft) out.push(k.draft === 1 ? 'PMOS drafted it' : 'PMOS drafted them');
|
|
39
|
+
return out.join(', ');
|
|
40
|
+
}
|
|
41
|
+
const underOf = (l) => (l.default && l.default.say ? l.default.say : 'No default: ' + String(l.waits || 'it waits for an answer.').replace(/^./, (c) => c.toLowerCase()));
|
|
42
|
+
|
|
43
|
+
/** The register's lines as rows, split by who answers, oldest first. PURE. */
|
|
44
|
+
export function rowsOf(lines, today = '') {
|
|
45
|
+
const seen = new Set(), all = [];
|
|
46
|
+
for (const l of lines || []) {
|
|
47
|
+
if (!l || !l.key || !l.ini) continue;
|
|
48
|
+
const key = 'q:' + (l.ws || '') + ':' + l.key;
|
|
49
|
+
if (seen.has(key)) continue;
|
|
50
|
+
seen.add(key);
|
|
51
|
+
const age = Math.max(0, Number(l.age) || 0);
|
|
52
|
+
const due = l.default && l.default.due ? String(l.default.due) : '';
|
|
53
|
+
all.push({ key, ws: l.ws || '', ini: l.ini, title: clip(titleOf(l), 120), meta: [l.toPm ? (l.title || l.ini) : l.title || l.ini, kindWords(l)].filter(Boolean).join(' · '),
|
|
54
|
+
age, old: age > OLD_DAYS, under: clip(underOf(l), 220), toPm: !!l.toPm, owner: l.owner || '', due, dueToday: !!(due && today && due <= today), line: l });
|
|
55
|
+
}
|
|
56
|
+
all.sort((a, b) => b.age - a.age || a.title.localeCompare(b.title));
|
|
57
|
+
return { mine: all.filter((r) => r.toPm), others: all.filter((r) => !r.toPm), all };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const ageWord = (n) => plural(n, 'day', 'days');
|
|
61
|
+
function rowHtml(r) {
|
|
62
|
+
const acts = (r.toPm ? '' : `<button type="button" class="td-ib pm-btn" data-td="q-remind" data-key="${esc(r.key)}" aria-label="${esc('Remind ' + (r.owner || 'them') + ': ' + r.title)}" title="Remind them">${ic(I.remind)}</button>`)
|
|
63
|
+
+ `<button type="button" class="td-ib pm-btn" data-td="open" data-key="${esc(r.key)}" aria-label="${esc('Answer: ' + r.title)}" title="Answer">${ic(I.open)}</button>`;
|
|
64
|
+
return `<div class="td-li pm-li oq-r" data-key="${esc(r.key)}"><span class="td-kind" role="img" aria-label="${r.toPm ? 'Decision' : 'Waits on ' + esc(r.owner || 'someone')}">${ic(r.toPm ? I.decide : I.person)}</span>`
|
|
65
|
+
+ `<span class="txt"><button type="button" class="t td-t" data-td="open" data-key="${esc(r.key)}">${esc(r.title)}</button>`
|
|
66
|
+
+ `<span class="w td-rs">${esc(r.meta)}</span><span class="w td-rs oq-u">${ic(r.line && r.line.default ? I.spark : I.clock, 13, r.line && r.line.default ? 'pm-star' : '')}${esc(r.under)}</span></span>`
|
|
67
|
+
+ `<span class="pm-badge${r.old ? ' alert' : ''}">${esc(ageWord(r.age))}</span><span class="acts td-a">${acts}</span></div>`;
|
|
68
|
+
}
|
|
69
|
+
/** The two groups on a desk. '' when nothing waits (zero is silence). */
|
|
70
|
+
export function groupsHtml(Q) {
|
|
71
|
+
if (!Q || (!Q.mine.length && !Q.others.length)) return '';
|
|
72
|
+
let h = '';
|
|
73
|
+
if (Q.mine.length) h += `<div class="td-gr pm-group oq-g">${ic(I.decide, 14)}Waiting on you <span class="td-n">${esc(Q.mine.length)} · oldest first</span></div><div class="rows">${Q.mine.map(rowHtml).join('')}</div>`;
|
|
74
|
+
if (Q.others.length) h += `<div class="td-gr pm-group oq-g">${ic(I.person, 14)}Waiting on others <span class="td-n">${esc(Q.others.length)}</span></div><div class="rows">${Q.others.map(rowHtml).join('')}</div>`;
|
|
75
|
+
return h;
|
|
76
|
+
}
|
|
77
|
+
function phoneRow(r) {
|
|
78
|
+
return `<li class="tdp-r oq-r" data-key="${esc(r.key)}"><i class="tdp-dot ${r.old ? 'alert' : r.toPm ? 'blue' : ''}" role="img" aria-label="${r.old ? 'Older than ' + OLD_DAYS + ' days' : r.toPm ? 'Waits on you' : 'Waits on ' + esc(r.owner || 'someone')}"></i>`
|
|
79
|
+
+ `<div class="tdp-x"><button type="button" class="tdp-t" data-td="open" data-key="${esc(r.key)}">${esc(r.title)}</button>`
|
|
80
|
+
+ `<small class="tdp-m">${esc((r.toPm ? 'You' : r.owner || 'Someone') + ' · ' + ageWord(r.age))}</small><small class="tdp-m oq-u${r.line && r.line.default ? ' d' : ''}">${esc(r.under)}</small></div></li>`;
|
|
81
|
+
}
|
|
82
|
+
/** The two groups on a phone: rows with a dot, red over 14 days. '' when nothing waits. */
|
|
83
|
+
export function phoneGroupsHtml(Q) {
|
|
84
|
+
if (!Q || (!Q.mine.length && !Q.others.length)) return '';
|
|
85
|
+
let h = '';
|
|
86
|
+
if (Q.mine.length) h += `<h3 class="tdp-gh oq-g">Waiting on you · ${esc(Q.mine.length)}</h3><ul class="tdp-rows">${Q.mine.map(phoneRow).join('')}</ul>`;
|
|
87
|
+
if (Q.others.length) h += `<h3 class="tdp-gh oq-g">Waiting on others · ${esc(Q.others.length)}</h3><ul class="tdp-rows">${Q.others.map(phoneRow).join('')}</ul>`;
|
|
88
|
+
return h;
|
|
89
|
+
}
|
|
90
|
+
/** The Overview's sentence: how many wait on you, the oldest and what PMOS does if nobody answers. '' when none waits on you. */
|
|
91
|
+
export function overviewSay(Q) {
|
|
92
|
+
if (!Q || !Q.mine.length) return '';
|
|
93
|
+
const o = Q.mine[0];
|
|
94
|
+
const what = o.line && o.line.default ? ' ' + o.line.default.say : ' It has no default, so it waits for you.';
|
|
95
|
+
return plural(Q.mine.length, 'question waits', 'questions wait') + ' on you; the oldest, ' + o.title.replace(/ waits? on you$/, '') + ', has waited ' + ageWord(o.age) + '.' + what;
|
|
96
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* pm/range-pick.css — a task's start and due on one calendar (pm/range-pick.js), on Komorebi tokens. Each button rule names its parent, so a
|
|
2
|
+
* host's own button reset (task-card.css .tkc button, hi-pop's) does not undo it. A phone (a sheet, or a coarse pointer) gets thumb-sized days. */
|
|
3
|
+
.rp { display: flex; flex-direction: column; gap: var(--space-8); min-width: 0; }
|
|
4
|
+
.rp-ends { display: flex; align-items: center; gap: var(--space-4); color: var(--cz-ink3); }
|
|
5
|
+
.rp-ends > svg { flex: none; }
|
|
6
|
+
.rp .rp-end { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 1px; height: 52px; padding: 6px 10px; border-radius: var(--radius-md); background: var(--cz-well); cursor: pointer; box-sizing: border-box; }
|
|
7
|
+
.rp .rp-end.on { background: var(--cz-bluebg); box-shadow: inset 0 0 0 1.5px var(--cz-blue); }
|
|
8
|
+
.rp .rp-end small { display: inline-flex; align-items: center; gap: var(--space-4); font-size: var(--fs-badge); font-weight: var(--fw-strong); color: var(--cz-ink3); line-height: var(--lh-badge); }
|
|
9
|
+
.rp .rp-in { width: 100%; min-width: 0; border: 0; padding: 0; background: none; font: inherit; font-size: var(--fs-body); font-weight: var(--fw-strong); color: var(--cz-ink); line-height: var(--lh-body); outline: 0; cursor: pointer; }
|
|
10
|
+
.rp .rp-in::placeholder { color: var(--cz-ink3); font-weight: var(--fw-regular); }
|
|
11
|
+
.rp .rp-end:focus-within { box-shadow: inset 0 0 0 2px var(--cz-blue); }
|
|
12
|
+
.rp-qk { display: flex; gap: 6px; flex-wrap: wrap; }
|
|
13
|
+
.rp .rp-qk button { height: 30px; padding: 0 10px; border: 0; border-radius: var(--radius-pill); background: var(--cz-well); font: inherit; font-size: var(--fs-label); font-weight: var(--fw-strong); color: var(--cz-ink2); line-height: var(--lh-label); cursor: pointer; }
|
|
14
|
+
.rp-mh { display: flex; align-items: center; justify-content: space-between; font-size: var(--fs-row); line-height: var(--lh-row); }
|
|
15
|
+
.rp-mh b { font-weight: var(--fw-strong); color: var(--cz-ink); }
|
|
16
|
+
.rp .rp-nav { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: var(--radius-pill); background: none; color: var(--cz-ink2); cursor: pointer; }
|
|
17
|
+
.rp-g { display: flex; flex-direction: column; gap: 0; }
|
|
18
|
+
.rp-row { display: grid; grid-template-columns: repeat(7, 1fr); }
|
|
19
|
+
.rp-wk i { font-style: normal; text-align: center; font-size: var(--fs-badge); font-weight: var(--fw-strong); color: var(--cz-ink3); line-height: 22px; }
|
|
20
|
+
/* a day: the button is the band, its span the pill, so a range reads as one strip with round ends */
|
|
21
|
+
.rp .rp-d { height: 36px; padding: 0; border: 0; background: none; font: inherit; font-size: var(--fs-meta); color: var(--cz-ink); cursor: pointer; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
|
|
22
|
+
.rp .rp-d span { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-pill); }
|
|
23
|
+
.rp .rp-d.out { color: var(--cz-ink3); }
|
|
24
|
+
.rp .rp-d.td span { box-shadow: inset 0 0 0 1.5px var(--cz-ink3); }
|
|
25
|
+
.rp .rp-d.rg, .rp .rp-d.pv { background: var(--cz-bluebg); }
|
|
26
|
+
.rp .rp-d.bs { background: linear-gradient(to right, transparent 50%, var(--cz-bluebg) 50%); }
|
|
27
|
+
.rp .rp-d.be, .rp .rp-d.pve { background: linear-gradient(to left, transparent 50%, var(--cz-bluebg) 50%); }
|
|
28
|
+
.rp .rp-d.pve span { box-shadow: inset 0 0 0 1.5px var(--cz-blue); }
|
|
29
|
+
.rp .rp-d.a span { background: var(--cz-solid); color: var(--cz-onsolid); font-weight: var(--fw-strong); }
|
|
30
|
+
.rp .rp-d:focus-visible { outline: 0; }
|
|
31
|
+
.rp .rp-d:focus-visible span { box-shadow: 0 0 0 2px var(--cz-card), 0 0 0 4px var(--cz-blue); }
|
|
32
|
+
.rp-msg { margin: 0; font-size: var(--fs-meta); color: var(--cz-late); }
|
|
33
|
+
.rp-ft { display: flex; border-top: 1px solid var(--cz-hair); padding-top: var(--space-8); }
|
|
34
|
+
.rp .rp-clear { border: 0; background: none; font: inherit; font-size: var(--fs-row); font-weight: var(--fw-strong); color: var(--cz-ink2); padding: 6px 10px; border-radius: var(--radius-md); cursor: pointer; }
|
|
35
|
+
/* a pointer that hovers: the presses light up; a touch or the keys (:focus-visible) show the same without it */
|
|
36
|
+
@media (hover: hover) {
|
|
37
|
+
.rp .rp-qk button:hover { background: var(--cz-hair); color: var(--cz-ink); }
|
|
38
|
+
.rp .rp-nav:hover { background: var(--cz-well); color: var(--cz-ink); }
|
|
39
|
+
.rp .rp-d:hover span { background: var(--cz-well); }
|
|
40
|
+
.rp .rp-clear:hover { background: var(--cz-well); color: var(--cz-ink); }
|
|
41
|
+
}
|
|
42
|
+
/* a phone: thumb-sized days and ends, the calendar takes the sheet's width */
|
|
43
|
+
@media (pointer: coarse), (max-width: 640px) {
|
|
44
|
+
.rp .rp-end { height: 60px; }
|
|
45
|
+
.rp .rp-d { height: 46px; }
|
|
46
|
+
.rp .rp-d span { width: 42px; height: 42px; }
|
|
47
|
+
.rp .rp-qk button { height: 38px; padding: 0 14px; }
|
|
48
|
+
.rp .rp-nav { width: 44px; height: 44px; }
|
|
49
|
+
.rp .rp-clear { min-height: 44px; }
|
|
50
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/* pm/range-pick.js — a task's start and due on one calendar, picked like a flight's depart and return (Wawan 2026-11-23: "selecting start
|
|
2
|
+
* and end together"). One picker for every place that sets a task's dates: the work popup's date press (cozy-pop-work.js), the task card
|
|
3
|
+
* (task-card.js) and the initiative's Tasks rows, bars and add row (ini-tasks.js datePop). The look is in range-pick.css, on Komorebi tokens.
|
|
4
|
+
*
|
|
5
|
+
* The first tap sets the start, the second the due day; the days between show as one band, and a hover or a focused day previews the band
|
|
6
|
+
* before the second tap. A tap before the start moves the start and still waits for the due day. A press on Start or Due picks which end
|
|
7
|
+
* the next tap sets. A milestone (one) has one Date, and one tap sets it. Each tap saves (nothing is lost when the picker closes early);
|
|
8
|
+
* the second tap closes it. "No date" clears both. Typing works too: "15 Oct", "2026-10-15", "15/10/2026" in an end's field, then Enter.
|
|
9
|
+
* Keyboard: arrows move a day or a week, Page Up/Down a month, Home/End the week's ends, Enter or Space picks.
|
|
10
|
+
*
|
|
11
|
+
* rangeHtml(s, o) → markup pure, for node tests. s: { start, due, field: 'start'|'due', month: 'YYYY-MM', one, focus }
|
|
12
|
+
* o: { today, head (html drawn first), coarse (a phone: the fields do not open the keyboard) }
|
|
13
|
+
* rangeTap(s, iso) → { patch, field, done } pure: what one tap (or a typed day, or '' for "No date") writes, and what comes next
|
|
14
|
+
* mountRange(el, o) → { state } draws into el and wires it. o: { start, due, one, field, today, head,
|
|
15
|
+
* onPick(patch, done, state) — after each tap; done: the range is complete, the host closes;
|
|
16
|
+
* onState(state) — after each draw, so a host that redraws can open it where it was }
|
|
17
|
+
* Its own presses stop at el, so a popup's click handler around it sees only the host's own buttons (a sheet's ✕). */
|
|
18
|
+
import { dayText, parseDay, localToday } from './cozy-day-pick.js';
|
|
19
|
+
|
|
20
|
+
const CSS = new URL('./range-pick.css', import.meta.url).href;
|
|
21
|
+
if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${CSS}"]`)) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = CSS; document.head.appendChild(l); }
|
|
22
|
+
|
|
23
|
+
const FULL = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
24
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
25
|
+
const isDay = (v) => /^\d{4}-\d{2}-\d{2}$/.test(String(v || ''));
|
|
26
|
+
const ms = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? Date.UTC(+m[1], +m[2] - 1, +m[3]) : null; };
|
|
27
|
+
const iso = (n) => new Date(n).toISOString().slice(0, 10);
|
|
28
|
+
const addDays = (v, n) => iso(ms(v) + n * 864e5);
|
|
29
|
+
const addMonths = (ym, n) => { const [y, m] = ym.split('-').map(Number); return iso(Date.UTC(y, m - 1 + n, 1)).slice(0, 7); };
|
|
30
|
+
const svg = (d, s = 16) => `<svg aria-hidden="true" width="${s}" height="${s}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
31
|
+
const ARR = { prev: 'M15 6l-6 6 6 6', next: 'M9 6l6 6-6 6' }, DIA = 'M12 4l8 8-8 8-8-8z';
|
|
32
|
+
|
|
33
|
+
/** The month shown: the one asked for, else the end being picked, else the start, else today's. */
|
|
34
|
+
const monthOf = (s, today) => (s.month && /^\d{4}-\d{2}$/.test(s.month) ? s.month : String((isDay(s[fieldOf(s)]) && s[fieldOf(s)]) || (isDay(s.start) && s.start) || (isDay(s.due) && s.due) || today).slice(0, 7));
|
|
35
|
+
const fieldOf = (s) => (s.one ? 'due' : s.field === 'due' ? 'due' : 'start');
|
|
36
|
+
|
|
37
|
+
export function rangeTap(s, v) {
|
|
38
|
+
const f = fieldOf(s);
|
|
39
|
+
if (!v) return { patch: s.one ? { due: '' } : { start: '', due: '' }, field: s.one ? 'due' : 'start', done: true };
|
|
40
|
+
if (s.one) return { patch: { due: v }, field: 'due', done: true };
|
|
41
|
+
if (f === 'start') {
|
|
42
|
+
const patch = { start: v };
|
|
43
|
+
if (isDay(s.due) && v > s.due) patch.due = v; // a start after the due day takes the due day with it; the next tap moves it on
|
|
44
|
+
return { patch, field: 'due', done: false };
|
|
45
|
+
}
|
|
46
|
+
if (isDay(s.start) && v < s.start) return { patch: { start: v }, field: 'due', done: false }; // before the start: a new start, still waiting for the due day
|
|
47
|
+
return { patch: { due: v }, field: 'due', done: true };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function rangeHtml(s, o = {}) {
|
|
51
|
+
const today = o.today || localToday(), f = fieldOf(s), ym = monthOf(s, today), [y, m] = ym.split('-').map(Number);
|
|
52
|
+
const a = isDay(s.start) && !s.one ? s.start : '', b = isDay(s.due) ? s.due : '';
|
|
53
|
+
const first = Date.UTC(y, m - 1, 1), lead = (new Date(first).getUTCDay() + 6) % 7; // weeks start on Monday
|
|
54
|
+
const inMonth = (v) => v && v.slice(0, 7) === ym;
|
|
55
|
+
const focus = [s.focus, s[f], a, b, today].find((v) => isDay(v) && inMonth(v)) || ym + '-01';
|
|
56
|
+
const weeks = [];
|
|
57
|
+
for (let w = 0, cur = first - lead * 864e5; w < 6; w++) {
|
|
58
|
+
const row = [];
|
|
59
|
+
for (let k = 0; k < 7; k++, cur += 864e5) {
|
|
60
|
+
const v = iso(cur), out = v.slice(0, 7) !== ym, end = v === a || v === b;
|
|
61
|
+
const band = a && b && a < b && v >= a && v <= b;
|
|
62
|
+
const cls = ['rp-d', out ? 'out' : '', end ? 'a' : '', band ? (v === a ? 'bs' : v === b ? 'be' : 'rg') : '', v === today ? 'td' : ''].filter(Boolean).join(' ');
|
|
63
|
+
const say = dayText(v) + (v === a ? ', start' : '') + (v === b ? (s.one ? ', the date' : ', due') : '') + (v === today ? ', today' : '');
|
|
64
|
+
row.push(`<button type="button" class="${cls}" data-rp-day="${v}" tabindex="${v === focus ? 0 : -1}" aria-pressed="${end}" aria-label="${esc(say)}"><span>${+v.slice(8)}</span></button>`);
|
|
65
|
+
}
|
|
66
|
+
weeks.push('<div class="rp-row" role="row">' + row.join('') + '</div>');
|
|
67
|
+
if (iso(cur).slice(0, 7) !== ym) break;
|
|
68
|
+
}
|
|
69
|
+
const inp = (k, label, icon) => `<label class="rp-end${f === k ? ' on' : ''}" data-rp-end="${k}"><small>${icon || ''}${label}</small><input class="rp-in" type="text" autocomplete="off" spellcheck="false"${o.coarse ? ' inputmode="none"' : ''} placeholder="${f === k ? 'Pick a day' : 'None'}" value="${esc(dayText(s[k]))}" aria-label="${esc(label + (f === k ? ', the next tap sets it' : ''))}"></label>`;
|
|
70
|
+
const ends = s.one ? `<div class="rp-ends one">${inp('due', 'Date', svg(DIA, 12))}</div>` : `<div class="rp-ends">${inp('start', 'Start')}${svg(ARR.next, 14)}${inp('due', 'Due')}</div>`;
|
|
71
|
+
const tom = addDays(today, 1), dow = new Date(ms(today)).getUTCDay(), fri = addDays(today, ((5 - dow + 7) % 7) || 7);
|
|
72
|
+
const quick = `<div class="rp-qk"><button type="button" data-rp-day="${today}">Today</button><button type="button" data-rp-day="${tom}">Tomorrow</button><button type="button" data-rp-day="${fri}">Fri</button></div>`;
|
|
73
|
+
return `<div class="rp${s.one ? ' one' : ''}" data-rp>${o.head || ''}${ends}${quick}`
|
|
74
|
+
+ `<div class="rp-mh"><button type="button" class="rp-nav" data-rp-month="${addMonths(ym, -1)}" aria-label="Previous month">${svg(ARR.prev)}</button><b aria-live="polite">${FULL[m - 1]} ${y}</b><button type="button" class="rp-nav" data-rp-month="${addMonths(ym, 1)}" aria-label="Next month">${svg(ARR.next)}</button></div>`
|
|
75
|
+
+ `<div class="rp-g" role="grid" aria-label="${esc(FULL[m - 1] + ' ' + y)}"><div class="rp-row rp-wk" aria-hidden="true"><i>M</i><i>T</i><i>W</i><i>T</i><i>F</i><i>S</i><i>S</i></div>${weeks.join('')}</div>`
|
|
76
|
+
+ `<p class="rp-msg" role="status"${o.msg ? '' : ' hidden'}>${esc(o.msg || '')}</p>`
|
|
77
|
+
+ `<div class="rp-ft"><button type="button" class="rp-clear" data-rp-clear>No date</button></div></div>`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const coarse = () => typeof matchMedia === 'function' && matchMedia('(pointer: coarse)').matches;
|
|
81
|
+
|
|
82
|
+
export function mountRange(el, o = {}) {
|
|
83
|
+
const today = o.today || localToday();
|
|
84
|
+
const s = { start: isDay(o.start) && !o.one ? o.start : '', due: isDay(o.due) ? o.due : '', one: !!o.one, field: o.one ? 'due' : o.field === 'due' ? 'due' : 'start', month: o.month || '', focus: '' };
|
|
85
|
+
let msg = '', drawing = false;
|
|
86
|
+
const draw = (focusDay) => {
|
|
87
|
+
if (focusDay) { s.focus = focusDay; s.month = focusDay.slice(0, 7); }
|
|
88
|
+
drawing = true; // a focused field removed by the redraw fires its change: that is not a second pick
|
|
89
|
+
try { el.innerHTML = rangeHtml(s, { today, head: o.head, coarse: coarse(), msg }); } finally { drawing = false; }
|
|
90
|
+
if (focusDay) el.querySelector(`.rp-g [data-rp-day="${focusDay}"]`)?.focus({ preventScroll: true });
|
|
91
|
+
if (o.onState) o.onState({ ...s });
|
|
92
|
+
};
|
|
93
|
+
const tap = (v, from) => {
|
|
94
|
+
const r = rangeTap(s, v);
|
|
95
|
+
Object.assign(s, r.patch); s.field = r.field; msg = '';
|
|
96
|
+
draw(from === 'grid' && v ? v : null);
|
|
97
|
+
if (from === 'type' && !r.done) el.querySelector(`[data-rp-end="${s.field}"] .rp-in`)?.focus({ preventScroll: true });
|
|
98
|
+
if (o.onPick) o.onPick(r.patch, r.done, { ...s });
|
|
99
|
+
};
|
|
100
|
+
// the band's preview: from the start to the day under the pointer or the focus, while the due day is next
|
|
101
|
+
const preview = (v) => {
|
|
102
|
+
el.querySelectorAll('.rp-d.pv').forEach((x) => x.classList.remove('pv', 'pve'));
|
|
103
|
+
if (s.one || s.field !== 'due' || !isDay(s.start) || !v || v <= s.start) return;
|
|
104
|
+
el.querySelectorAll('.rp-g .rp-d').forEach((x) => { const d = x.dataset.rpDay; if (d > s.start && d <= v) x.classList.add('pv'); if (d === v) x.classList.add('pve'); });
|
|
105
|
+
};
|
|
106
|
+
// the presses land on real buttons (each one a <button> with its own keys); one handler on the root reads them
|
|
107
|
+
el.onclick = (e) => {
|
|
108
|
+
const b = e.target.closest('button'); if (!b || !el.contains(b) || !b.closest('[data-rp]')) return;
|
|
109
|
+
const d = b.dataset;
|
|
110
|
+
if (d.rpDay == null && d.rpMonth == null && !('rpClear' in d)) return; // the host's own button (a sheet's ✕)
|
|
111
|
+
e.stopPropagation();
|
|
112
|
+
if (d.rpMonth) { const next = b.getAttribute('aria-label') === 'Next month'; s.month = d.rpMonth; s.focus = ''; draw(); el.querySelector(next ? '.rp-mh .rp-nav:last-child' : '.rp-mh .rp-nav')?.focus({ preventScroll: true }); return; }
|
|
113
|
+
if ('rpClear' in d) { tap('', 'clear'); return; }
|
|
114
|
+
tap(d.rpDay, b.closest('.rp-g') ? 'grid' : 'quick');
|
|
115
|
+
};
|
|
116
|
+
// an end's field: a press (or Tab into it) picks which end the next tap sets
|
|
117
|
+
el.addEventListener('focusin', (e) => {
|
|
118
|
+
const end = e.target.closest && e.target.closest('[data-rp-end]');
|
|
119
|
+
if (end && end.dataset.rpEnd !== s.field && !s.one) {
|
|
120
|
+
s.field = end.dataset.rpEnd;
|
|
121
|
+
el.querySelectorAll('[data-rp-end]').forEach((x) => { const on = x.dataset.rpEnd === s.field; x.classList.toggle('on', on); x.querySelector('.rp-in').placeholder = on ? 'Pick a day' : 'None'; });
|
|
122
|
+
preview(null);
|
|
123
|
+
}
|
|
124
|
+
const day = e.target.closest && e.target.closest('.rp-g [data-rp-day]');
|
|
125
|
+
if (day) preview(day.dataset.rpDay);
|
|
126
|
+
});
|
|
127
|
+
el.onpointerover = (e) => { const day = e.target.closest && e.target.closest('.rp-g [data-rp-day]'); if (day) preview(day.dataset.rpDay); };
|
|
128
|
+
el.onpointerleave = () => preview(null);
|
|
129
|
+
const take = (inp) => {
|
|
130
|
+
if (drawing || !inp.isConnected) return;
|
|
131
|
+
const t = inp.value.trim(), k = inp.closest('[data-rp-end]').dataset.rpEnd;
|
|
132
|
+
if (t === dayText(s[k])) return;
|
|
133
|
+
if (!t) { msg = ''; return; }
|
|
134
|
+
const v = parseDay(t, today);
|
|
135
|
+
if (!v) { msg = 'Write a day like 15 Oct 2026.'; const p = el.querySelector('.rp-msg'); if (p) { p.textContent = msg; p.hidden = false; } return; }
|
|
136
|
+
s.field = k; tap(v, 'type');
|
|
137
|
+
};
|
|
138
|
+
el.addEventListener('keydown', (e) => {
|
|
139
|
+
const inp = e.target.closest && e.target.closest('.rp-in');
|
|
140
|
+
if (inp) { if (e.key === 'Enter') { e.preventDefault(); e.stopPropagation(); take(inp); } return; }
|
|
141
|
+
const day = e.target.closest && e.target.closest('.rp-g [data-rp-day]'); if (!day) return;
|
|
142
|
+
const v = day.dataset.rpDay, dow = (new Date(ms(v)).getUTCDay() + 6) % 7;
|
|
143
|
+
const step = { ArrowLeft: -1, ArrowRight: 1, ArrowUp: -7, ArrowDown: 7, Home: -dow, End: 6 - dow }[e.key];
|
|
144
|
+
let to = step != null ? addDays(v, step) : null;
|
|
145
|
+
if (e.key === 'PageUp' || e.key === 'PageDown') { const [y, m, dd] = v.split('-').map(Number), n = Date.UTC(y, m - 1 + (e.key === 'PageUp' ? -1 : 1), 1), last = new Date(Date.UTC(new Date(n).getUTCFullYear(), new Date(n).getUTCMonth() + 1, 0)).getUTCDate(); to = iso(n).slice(0, 8) + String(Math.min(dd, last)).padStart(2, '0'); }
|
|
146
|
+
if (!to) return;
|
|
147
|
+
e.preventDefault(); e.stopPropagation();
|
|
148
|
+
const btn = el.querySelector(`.rp-g [data-rp-day="${to}"]:not(.out)`);
|
|
149
|
+
if (btn) { el.querySelectorAll('.rp-g [tabindex="0"]').forEach((x) => x.setAttribute('tabindex', '-1')); btn.setAttribute('tabindex', '0'); btn.focus({ preventScroll: true }); }
|
|
150
|
+
else draw(to);
|
|
151
|
+
});
|
|
152
|
+
el.addEventListener('change', (e) => { const inp = e.target.closest && e.target.closest('.rp-in'); if (inp) take(inp); });
|
|
153
|
+
draw();
|
|
154
|
+
return { state: s, focus() { (el.querySelector('.rp-g [tabindex="0"]') || el.querySelector('.rp-in'))?.focus({ preventScroll: true }); } };
|
|
155
|
+
}
|
|
@@ -45,23 +45,7 @@
|
|
|
45
45
|
.tkc .tkc-pop hr { border: 0; border-top: 1px solid var(--cz-hair); margin: var(--space-4) 6px; }
|
|
46
46
|
.tkc .tkc-new input { width: 100%; box-sizing: border-box; height: 38px; border: 0; border-radius: var(--radius-md); padding: 0 10px; margin-bottom: var(--space-4); font: inherit; font-size: var(--fs-body); background: var(--cz-well); color: var(--cz-ink); outline: 0; line-height: var(--lh-body); }
|
|
47
47
|
.tkc .tkc-new input:focus { box-shadow: 0 0 0 1.5px var(--cz-blue); }
|
|
48
|
-
.tkc .tkc-dp { width:
|
|
49
|
-
.tkc .tkc-dp .two { display: flex; gap: 6px; margin-bottom: 10px; }
|
|
50
|
-
.tkc .tkc-dp .two button { flex: 1; height: 52px; border-radius: 12px; background: var(--cz-well); padding: 6px 10px; display: flex; flex-direction: column; justify-content: center; gap: 1px; }
|
|
51
|
-
.tkc .tkc-dp .two button.on { background: var(--cz-bluebg); box-shadow: inset 0 0 0 1.5px var(--cz-blue); }
|
|
52
|
-
.tkc .tkc-dp .two small { font-size: var(--fs-badge); color: var(--cz-ink3); font-weight: var(--fw-strong); line-height: var(--lh-badge); }
|
|
53
|
-
.tkc .tkc-dp .two b { font-size: var(--fs-body); line-height: var(--lh-body); }
|
|
54
|
-
.tkc .tkc-dp .qk { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
|
|
55
|
-
.tkc .tkc-dp .qk button { height: 30px; padding: 0 10px; border-radius: var(--radius-pill); background: var(--cz-well); font-size: var(--fs-label); font-weight: var(--fw-strong); color: var(--cz-ink2); display: inline-flex; align-items: center; line-height: var(--lh-label); }
|
|
56
|
-
.tkc .tkc-dp .mh { display: flex; align-items: center; justify-content: space-between; font-size: var(--fs-row); font-weight: var(--fw-strong); padding: 0 var(--space-4) 6px; line-height: var(--lh-row); }
|
|
57
|
-
.tkc .tkc-dp .g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: var(--fs-meta); line-height: var(--lh-meta); }
|
|
58
|
-
.tkc .tkc-dp .g .h { color: var(--cz-ink3); font-size: var(--fs-badge); font-weight: var(--fw-strong); height: 22px; display: flex; align-items: center; justify-content: center; line-height: var(--lh-badge); }
|
|
59
|
-
.tkc .tkc-dp .g button { height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-pill); font-weight: var(--fw-strong); text-align: center; }
|
|
60
|
-
.tkc .tkc-dp .g button:hover { background: var(--cz-well); }
|
|
61
|
-
.tkc .tkc-dp .g .m { color: var(--cz-ink3); opacity: .6; }
|
|
62
|
-
.tkc .tkc-dp .g .rg { background: var(--cz-bluebg); border-radius: 0; }
|
|
63
|
-
.tkc .tkc-dp .g .td { box-shadow: inset 0 0 0 1.5px var(--cz-ink3); }
|
|
64
|
-
.tkc .tkc-dp .g .a { background: var(--cz-solid); color: var(--cz-onsolid); font-weight: var(--fw-strong); }
|
|
48
|
+
.tkc .tkc-dp { width: 316px; padding: var(--space-12); max-height: none; overflow: visible; }
|
|
65
49
|
|
|
66
50
|
/* the header's check box in the tile's place (cozy-viewer.js `check`) */
|
|
67
51
|
.cz-vw-chk { border: 0; padding: 0; cursor: pointer; background: transparent !important; }
|
|
@@ -77,7 +61,7 @@
|
|
|
77
61
|
|
|
78
62
|
/* phone: the same card, full screen (canvas OvViewers "Phone") */
|
|
79
63
|
@media (max-width: 760px) {
|
|
80
|
-
.tkc .tkc-dp { width: min(
|
|
64
|
+
.tkc .tkc-dp { width: min(316px, calc(100vw - 48px)); }
|
|
81
65
|
.tkc .ovf { column-gap: var(--space-12); padding: var(--space-12) 14px; }
|
|
82
66
|
.tkc .ovf .tkc-dp { left: -64px; } /* the picker starts at the card's edge, so it stays on the screen */
|
|
83
67
|
}
|
|
@@ -99,4 +83,3 @@
|
|
|
99
83
|
.tkc .tkc-hu:hover { background: var(--cz-well); color: var(--cz-ink); }
|
|
100
84
|
.tkc .seg .ivq-del:hover, .tkc .seg .ivq-del:focus-visible { color: var(--cz-red); background: var(--cz-redbg, transparent); }
|
|
101
85
|
/* one date (batch 18 item 16, StA4Milestone): a milestone's picker names its one day, with no Start and Due tabs */
|
|
102
|
-
.tkc .tkc-dp .one { display: flex; align-items: center; gap: var(--space-8); height: 36px; padding: 0 var(--space-4); margin-bottom: var(--space-8); font-size: var(--fs-body); color: var(--cz-ink); line-height: var(--lh-body); }
|