create-pmos 0.736.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 +26 -20
- 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 +25 -0
- package/workspace/guide/home.md +1 -0
- package/workspace/guide/layout.md +10 -3
- 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-pop-ds.css +18 -0
- package/workspace/public/pm/bd-pop-ds.js +33 -3
- 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/focus-mode.js +161 -0
- package/workspace/public/pm/ini-tasks.js +8 -18
- 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/focus-mode.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
|
+
}
|
|
@@ -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,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); }
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
* section and the initiative → tasks/edit, the group → /api/initiative-layout place,
|
|
24
24
|
* a Jira ticket's notes → tickets/note. Each answers { ok, from } so Undo is save(from). */
|
|
25
25
|
|
|
26
|
+
import { rangeHtml, mountRange } from './range-pick.js'; // start and due on one calendar (the same picker everywhere a task's dates are set)
|
|
27
|
+
|
|
26
28
|
export const STATES = ['To do', 'In progress', 'Done', "Won't do", 'Archived']; // a task's only stage is its state (scripts/boards.js TASK_STATES)
|
|
27
29
|
const SKEY = { 'To do': 'todo', 'In progress': 'prog', Done: 'done', "Won't do": 'wont', Archived: 'arch' };
|
|
28
30
|
const SICON = {
|
|
@@ -44,7 +46,6 @@ const I = {
|
|
|
44
46
|
const ico = (d, w = 16) => `<svg width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${d}</svg>`;
|
|
45
47
|
export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
46
48
|
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
47
|
-
const MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
48
49
|
const DAY = /^(\d{4})-(\d{2})-(\d{2})/;
|
|
49
50
|
const pad = (n) => String(n).padStart(2, '0');
|
|
50
51
|
export const isoOf = (d) => d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate());
|
|
@@ -112,29 +113,11 @@ export function checkOf(t) {
|
|
|
112
113
|
return t.status === 'Done' ? { state, label: 'Mark not done', title: 'Mark not done' } : { state, label: 'Mark done', title: 'Mark done' };
|
|
113
114
|
}
|
|
114
115
|
|
|
116
|
+
/** The start and due picker (pm/range-pick.js): one calendar, the first tap the start and the second the due day; a milestone one date
|
|
117
|
+
* (batch 18 item 16, StA4Milestone). o: { field, month: 'YYYY-MM', one, head — a sheet's own head (its title and ✕), drawn first } */
|
|
115
118
|
function picker(t, o, now) {
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
const y = base.getFullYear(), m = base.getMonth(), first = new Date(y, m, 1), lead = (first.getDay() + 6) % 7, today = isoOf(todayOf(now));
|
|
119
|
-
const cells = [];
|
|
120
|
-
for (let i = 0; i < 42; i++) {
|
|
121
|
-
const d = new Date(y, m, 1 - lead + i), iso = isoOf(d);
|
|
122
|
-
if (i >= 35 && d.getMonth() !== m) break;
|
|
123
|
-
const cls = [d.getMonth() !== m ? 'm' : '', iso === t.start || iso === t.due ? 'a' : t.start && t.due && iso > t.start && iso < t.due ? 'rg' : '', iso === today ? 'td' : ''].filter(Boolean).join(' ');
|
|
124
|
-
cells.push(`<button type="button" data-tkc-day="${iso}"${cls ? ` class="${cls}"` : ''} aria-label="${d.getDate()} ${MONTHS[d.getMonth()]}"${iso === t[field] ? ' aria-pressed="true"' : ''}>${d.getDate()}</button>`);
|
|
125
|
-
}
|
|
126
|
-
const fri = (() => { const d = todayOf(now); d.setDate(d.getDate() + ((5 - d.getDay() + 7) % 7 || 7)); return isoOf(d); })();
|
|
127
|
-
const tom = (() => { const d = todayOf(now); d.setDate(d.getDate() + 1); return isoOf(d); })();
|
|
128
|
-
const two = ['start', 'due'].map((f) => `<button type="button" data-tkc-field="${f}"${f === field ? ' class="on" aria-pressed="true"' : ' aria-pressed="false"'}><small>${f === 'start' ? 'Start' : 'Due'}</small><b>${esc(short(t[f]) || 'None')}</b></button>`).join('');
|
|
129
|
-
const prevM = isoOf(new Date(y, m - 1, 1)).slice(0, 7), nextM = isoOf(new Date(y, m + 1, 1)).slice(0, 7);
|
|
130
|
-
// one date (batch 18 item 16, StA4Milestone): a milestone has its day only, so the Start and Due tabs give way to "◇ Date"; o.head: a
|
|
131
|
-
// sheet's own head (its title and ✕), drawn first
|
|
132
|
-
const top = o.one ? (o.head ? '' : `<div class="one">${ico('<path d="M12 4l8 8-8 8-8-8z"/>', 14)}<b>Date</b></div>`) : `<div class="two">${two}</div>`;
|
|
133
|
-
return `<div class="tkc-pop tkc-dp${o.one ? ' one' : ''}" role="dialog" aria-label="${o.one ? 'Date' : 'Start and due'}">${o.head || ''}${top}`
|
|
134
|
-
+ `<div class="qk"><button type="button" data-tkc-day="${today}">Today</button><button type="button" data-tkc-day="${tom}">Tomorrow</button><button type="button" data-tkc-day="${fri}">Fri</button>`
|
|
135
|
-
+ `<button type="button" data-tkc-day="" aria-label="Clear the ${field === 'start' ? 'start' : 'due'} date" title="Clear">${ico(I.clear, 14)}</button></div>`
|
|
136
|
-
+ `<div class="mh"><button type="button" class="tkc-ib s" data-tkc-month="${prevM}" aria-label="Previous month">${ico(I.prev, 16)}</button><span>${MONTHS[m]} ${y}</span><button type="button" class="tkc-ib s" data-tkc-month="${nextM}" aria-label="Next month">${ico(I.next, 16)}</button></div>`
|
|
137
|
-
+ `<div class="g">${['M', 'T', 'W', 'T', 'F', 'S', 'S'].map((x) => `<span class="h" aria-hidden="true">${x}</span>`).join('')}${cells.join('')}</div></div>`;
|
|
119
|
+
const s = { start: o.one ? '' : t.start || '', due: t.due || '', field: o.field, month: o.month, one: !!o.one };
|
|
120
|
+
return `<div class="tkc-pop tkc-dp${o.one ? ' one' : ''}" role="dialog" aria-label="${o.one ? 'Date' : 'Start and due'}">${rangeHtml(s, { today: isoOf(todayOf(now)), head: o.head })}</div>`;
|
|
138
121
|
}
|
|
139
122
|
function listPop(label, items, extra = '') {
|
|
140
123
|
return `<div class="tkc-pop" role="menu" aria-label="${esc(label)}">${extra}${items.map((x) => x.sep ? '<hr>' : `<button type="button" role="menuitemradio" class="o${x.on ? ' hl' : ''}" aria-checked="${x.on ? 'true' : 'false'}" ${x.attr}>${x.icon || ''}<span>${esc(x.label)}</span>${x.on ? `<span class="k" aria-hidden="true">${ico(I.tick, 14)}</span>` : ''}</button>`).join('')}</div>`;
|
|
@@ -181,7 +164,7 @@ export function cardHtml(t, o = {}) {
|
|
|
181
164
|
// last, after its own divider, the trash (batch 17 item 2): the same Delete as the Tasks list's status picker, with Undo in the toast
|
|
182
165
|
const delBtn = o.del ? `<span class="vr" aria-hidden="true"></span><button type="button" class="ivq-del" data-tkc-del aria-label="Delete task" title="Delete task">${ico(I.bin, 15)}</button>` : '';
|
|
183
166
|
const facts = `<div class="ovf tkc-f"><span class="k">Status</span><div class="v"><div class="seg" role="radiogroup" aria-label="Status">${seg}${msBtn}${delBtn}</div></div>`
|
|
184
|
-
+ `<span class="k">Due</span><div class="v"><span class="anc">${dueBtn}${dOpen ? picker(t, o, now) : ''}</span>${late}</div>`
|
|
167
|
+
+ `<span class="k">Due</span><div class="v"><span class="anc">${dueBtn}${dOpen ? picker(t, { ...o, one: !!t.milestone }, now) : ''}</span>${late}</div>`
|
|
185
168
|
+ `<span class="k">Owner</span><div class="v"><span class="anc">${ownerBtn}${ownerPop}</span></div></div>`;
|
|
186
169
|
const notes = `<div class="ovb"><label class="ovl" for="tkcNotes">Notes</label><textarea class="nt" id="tkcNotes" data-tkc-notes rows="2" maxlength="4000" placeholder="Add notes">${esc(t.notes)}</textarea></div>`;
|
|
187
170
|
// where it sits: initiative › section › breakdown item; the move icon changes the section (or the group, or the initiative)
|
|
@@ -234,13 +217,20 @@ const WORDS = {
|
|
|
234
217
|
|
|
235
218
|
export function mountCard(el, t, h) {
|
|
236
219
|
cardStyle();
|
|
237
|
-
const st = { open: null, field: '
|
|
220
|
+
const st = { open: null, field: 'start', month: '', msg: '' };
|
|
238
221
|
const lists = () => ({ owners: h.owners ? h.owners() : [], groups: h.groups ? h.groups() : null, sections: h.sections ? h.sections() : null, inis: h.inis ? h.inis() : [] });
|
|
239
222
|
const draw = () => {
|
|
240
223
|
const keep = document.activeElement && el.contains(document.activeElement) && document.activeElement.matches('[data-tkc-notes]');
|
|
241
224
|
if (keep) return; // never redraw under the PM's typing
|
|
225
|
+
const inDp = !!(document.activeElement && document.activeElement.closest && document.activeElement.closest('.tkc-dp'));
|
|
242
226
|
el.innerHTML = cardHtml(t, { ...st, ...lists(), hist: st.hist, histOpen: st.histOpen, del: !!h.remove, now: h.now ? h.now() : Date.now() });
|
|
243
227
|
const f = el.querySelector('.tkc-new input'); if (f && (st.open === 'owner' || st.open === 'group')) f.focus();
|
|
228
|
+
// the dates picker wires itself; each tap saves with Undo, and the second tap (the due day) closes it
|
|
229
|
+
const dp = el.querySelector('.tkc-dp');
|
|
230
|
+
if (dp) mountRange(dp, { start: t.start, due: t.due, one: !!t.milestone, field: st.field, month: st.month, today: isoOf(todayOf(h.now ? h.now() : Date.now())),
|
|
231
|
+
onState: (s) => { st.field = s.field; st.month = s.month; },
|
|
232
|
+
onPick: (patch, done) => { if (done) st.open = null; change('dates', patch); } });
|
|
233
|
+
if (dp && inDp) dp.querySelector('.rp-g [tabindex="0"]')?.focus({ preventScroll: true });
|
|
244
234
|
};
|
|
245
235
|
const word = (kind) => (WORDS[kind] || (() => 'Saved'))(t, h);
|
|
246
236
|
// one change: write it, show it, then "… · Undo" puts back what was there
|
|
@@ -259,13 +249,6 @@ export function mountCard(el, t, h) {
|
|
|
259
249
|
return u || { ok: false };
|
|
260
250
|
});
|
|
261
251
|
};
|
|
262
|
-
const pick = (iso) => {
|
|
263
|
-
const f = st.field, p = { [f]: iso };
|
|
264
|
-
if (iso && f === 'due' && t.start && iso < t.start) p.start = iso; // a due day before the start moves the start with it
|
|
265
|
-
if (iso && f === 'start' && t.due && iso > t.due) p.due = iso;
|
|
266
|
-
if (f === 'start' && iso) st.field = 'due'; // after the start, the next tap is the due day
|
|
267
|
-
change('dates', p);
|
|
268
|
-
};
|
|
269
252
|
el.onclick = (e) => {
|
|
270
253
|
const b = e.target.closest('button'); if (!b || b.disabled || !el.contains(b)) return;
|
|
271
254
|
const d = b.dataset;
|
|
@@ -278,16 +261,13 @@ export function mountCard(el, t, h) {
|
|
|
278
261
|
if (d.tkcState) { if (d.tkcState !== t.status) { st.open = null; change('status', { status: d.tkcState }); } return; }
|
|
279
262
|
if ('tkcMs' in d) { st.open = null; change('milestone', { milestone: !t.milestone }); return; }
|
|
280
263
|
if ('tkcDel' in d && h.remove) { st.open = null; b.disabled = true; Promise.resolve(h.remove()).catch(() => null).then(() => { if (b.isConnected) b.disabled = false; }); return; }
|
|
281
|
-
if (d.tkcDay != null && b.closest('.tkc-dp')) { pick(d.tkcDay); return; }
|
|
282
|
-
if (d.tkcField) { st.field = d.tkcField; st.month = ''; draw(); return; }
|
|
283
|
-
if (d.tkcMonth) { st.month = d.tkcMonth; draw(); return; }
|
|
284
264
|
if (d.tkcOwner != null) { st.open = null; if (d.tkcOwner !== t.owner) change('owner', { owner: d.tkcOwner }); else draw(); return; }
|
|
285
265
|
if (d.tkcGroup != null) { st.open = null; if (d.tkcGroup !== t.group) change('group', { group: d.tkcGroup }); else draw(); return; }
|
|
286
266
|
if (d.tkcSection != null) { st.open = null; if (d.tkcSection !== t.section) change('section', { section: d.tkcSection }); else draw(); return; }
|
|
287
267
|
if (d.tkcMove) { st.open = null; change('initiative', { initiative: d.tkcMove }); return; }
|
|
288
268
|
const k = d.tkc;
|
|
289
269
|
if (k === 'ini') { if (h.openIni) h.openIni(t.ini); return; }
|
|
290
|
-
if (k === 'dates' || k === 'owner' || k === 'move') { st.open = st.open === k ? null : k; st.field = '
|
|
270
|
+
if (k === 'dates' || k === 'owner' || k === 'move') { st.open = st.open === k ? null : k; st.field = 'start'; st.month = ''; draw(); }
|
|
291
271
|
};
|
|
292
272
|
el.onsubmit = (e) => {
|
|
293
273
|
const f = e.target.closest('[data-tkc-form]'); if (!f) return;
|