create-pmos 0.736.0 → 0.738.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.
Files changed (37) hide show
  1. package/package.json +39 -99
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/changelog.json +38 -0
  7. package/workspace/guide/breakdown.md +7 -1
  8. package/workspace/guide/home.md +1 -0
  9. package/workspace/guide/layout.md +10 -3
  10. package/workspace/lib/use-log.js +26 -4
  11. package/workspace/package-lock.json +2 -2
  12. package/workspace/package.json +1 -1
  13. package/workspace/public/pm/action-keys.js +1 -1
  14. package/workspace/public/pm/bd-backlog.js +4 -0
  15. package/workspace/public/pm/bd-pop-ds.css +18 -0
  16. package/workspace/public/pm/bd-pop-ds.js +33 -3
  17. package/workspace/public/pm/cozy-day-pick.css +0 -1
  18. package/workspace/public/pm/cozy-ev.css +9 -0
  19. package/workspace/public/pm/cozy-nav.js +2 -0
  20. package/workspace/public/pm/cozy-pop-work.js +52 -23
  21. package/workspace/public/pm/focus-mode.js +161 -0
  22. package/workspace/public/pm/hi-pop.js +2 -2
  23. package/workspace/public/pm/home-app.js +5 -1
  24. package/workspace/public/pm/home-ini.js +9 -5
  25. package/workspace/public/pm/ini-tasks.js +20 -22
  26. package/workspace/public/pm/live-edit.js +280 -0
  27. package/workspace/public/pm/premium-board.js +12 -6
  28. package/workspace/public/pm/range-pick.css +50 -0
  29. package/workspace/public/pm/range-pick.js +155 -0
  30. package/workspace/public/pm/task-card.css +2 -19
  31. package/workspace/public/pm/task-card.js +16 -36
  32. package/workspace/stage-card-tasks-test.js +11 -11
  33. package/workspace/task-card-test.js +17 -10
  34. package/workspace/task-views-test.js +7 -5
  35. package/workspace/test-lists/edits-show-at-once.json +9 -0
  36. package/workspace/test-lists/focus-mode.json +9 -0
  37. package/workspace/test-lists/range-pick.json +5 -0
@@ -0,0 +1,280 @@
1
+ /* pm/live-edit.js — an edit shows at once, everywhere it is drawn (Wawan, 2026-11-23: "When I change date or status here, it didn't change
2
+ * immediately on the UI ... Also applies to any other changes ... show issue when it is failed to update eventually").
3
+ *
4
+ * Before: a task's status or day was drawn again only after the save answered AND the page read the whole board again (Home reads eleven
5
+ * routes; the Board can answer "stale, ask again"). A drilled-in page, such as the big Work breakdown, was not drawn again at all until the
6
+ * popup was opened again.
7
+ *
8
+ * Now, one path for every page. install() (run once when this module first loads in a page) watches the page's own fetch, so every task
9
+ * write is seen whatever helper sends it (pm/http.js pmPost, pressFetch, data.js postJson):
10
+ * begin(path, body) a task write (POST /api/boards/tasks/state | edit | rename) is put on every copy of the task that a page holds
11
+ * (source()), and every page and open view is drawn again at once. Returns { ok(), fail() } or null.
12
+ * ok() the save landed: the change stays on until a read that started after the save replaces it (loaded()).
13
+ * fail() the save did not land: every copy gets its old value back and is drawn again. The caller says why in its toast.
14
+ * loaded({ since, stale }) a page read its data again: the changes still saving (and the saved ones a stale read cannot hold yet) are
15
+ * put back on the new copies, then the open views are drawn again, so a drilled-in page follows the read too.
16
+ * source({ model, redraw }) a page's data (a root, or a list of roots) and the draw that shows it; returns the call that removes it.
17
+ * view(el, redraw) an open view drawn from those sources (the popup body, the big Work breakdown); dropped once el leaves the page.
18
+ *
19
+ * Pure apart from the redraw calls and install(): no DOM reads, no requests of its own, so live-edit.test.js runs it in Node.
20
+ */
21
+
22
+ /** The write's field → the names a page's copy of a task uses for it (the Board's rows say status and end; Home's and the Backlog's say
23
+ * state and due). Only these fields are drawn at once; any other field waits for the read, as before. */
24
+ export const FIELDS = {
25
+ state: ['status', 'state'],
26
+ start: ['start'],
27
+ due: ['end', 'due'],
28
+ milestone: ['milestone', 'ms'],
29
+ owner: ['owner'],
30
+ priority: ['priority'],
31
+ sprint: ['sprint'],
32
+ title: ['title'],
33
+ notes: ['notes'],
34
+ section: ['section'],
35
+ parent: ['parent'],
36
+ };
37
+ const TASK_WRITE = /^\/api\/boards\/tasks\/(state|edit|rename|add|delete|bulk)(?:\?|$)/;
38
+ const JIRA_KEY = /^[A-Z][A-Z0-9]+-\d+$/i;
39
+ const isJira = (id) => JIRA_KEY.test(id) && !/^task-/i.test(id); // a PMOS task id is task-<hex>, which can be all digits
40
+ const DAY = /^\d{4}-\d{2}-\d{2}$/;
41
+
42
+ const SOURCES = new Set();
43
+ const VIEWS = new Map(); // el (or a token) → redraw
44
+ const PENDING = new Map(); // a write's token → { op, saved: 0 | the time it landed }
45
+ let seq = 0;
46
+
47
+ /** The fields of one task write that can be drawn at once: { state: 'Done' }, { due: '2026-11-30' }, … null when none. */
48
+ function pick(body, rename) {
49
+ const out = {};
50
+ for (const k of Object.keys(FIELDS)) if (body[k] !== undefined && body[k] !== null) out[k] = body[k];
51
+ if (!rename) delete out.title;
52
+ if ('state' in out) out.state = String(out.state);
53
+ return Object.keys(out).length ? out : null;
54
+ }
55
+
56
+ /** What a write does to the pages' copies of its tasks, as a list of ops; null when it is not a task write.
57
+ * { kind: 'patch', id, fields } status, days, owner, priority, sprint, name, stage (section), parent; fields.shift: move both days by N
58
+ * { kind: 'remove', id } tasks/delete
59
+ * { kind: 'add', ini, row } tasks/add: a row drawn under its initiative until the read brings the real one */
60
+ export function opsOf(path, body) {
61
+ const m = TASK_WRITE.exec(String(path || ''));
62
+ if (!m || !body || typeof body !== 'object') return null;
63
+ const w = m[1];
64
+ if (w === 'add') {
65
+ if (typeof body.initiative !== 'string' || !body.initiative || typeof body.title !== 'string' || !body.title.trim()) return null;
66
+ const row = { uid: 'adding:' + (++seq), title: body.title.trim(), status: 'To do', owner: body.owner || '', start: body.start || '', end: body.due || '', adding: true,
67
+ ...(typeof body.section === 'string' ? { section: body.section } : {}), ...(body.parent ? { parent: body.parent } : {}), ...(body.milestone ? { milestone: true } : {}) };
68
+ return [{ kind: 'add', ini: body.initiative, row }];
69
+ }
70
+ if (w === 'bulk') {
71
+ const ids = Array.isArray(body.tasks) ? body.tasks.filter((x) => typeof x === 'string' && x) : [];
72
+ const v = body.value, f = body.op === 'done' ? { state: 'Done' } : body.op === 'shift' ? (Number.isInteger(Number(v)) && Number(v) ? { shift: Number(v) } : null)
73
+ : ['section', 'owner', 'parent'].includes(body.op) && typeof v === 'string' ? { [body.op]: v } : null;
74
+ // Jira keeps a ticket's status, stage and assignee, so the server skips those: they are not drawn either
75
+ const keep = body.op === 'shift' || body.op === 'parent' ? ids : ids.filter((id) => !isJira(id));
76
+ return f && keep.length ? keep.map((id) => ({ kind: 'patch', id, fields: f })) : null;
77
+ }
78
+ if (typeof body.task !== 'string' || !body.task) return null;
79
+ if (w === 'delete') return [{ kind: 'remove', id: body.task }];
80
+ const fields = pick(body, w === 'rename');
81
+ return fields ? [{ kind: 'patch', id: body.task, fields }] : null;
82
+ }
83
+
84
+ /** The fields of a single task write (kept for callers that only patch). */
85
+ export function fieldsOf(path, body) {
86
+ const ops = opsOf(path, body);
87
+ return ops && ops.length === 1 && ops[0].kind === 'patch' && path.indexOf('/bulk') < 0 ? ops[0].fields : null;
88
+ }
89
+
90
+ /** Is o a copy of task id? A PMOS task carries uid; a Backlog row carries id; a Jira ticket carries its key. */
91
+ export function isTask(o, id) {
92
+ if (!o || typeof o !== 'object' || Array.isArray(o)) return false;
93
+ if (o.uid === id) return true;
94
+ if (o.id === id && typeof o.title === 'string' && ('state' in o || 'status' in o)) return true;
95
+ return isJira(id) && typeof o.key === 'string' && o.key.toUpperCase() === id.toUpperCase() && ('status' in o || 'state' in o);
96
+ }
97
+
98
+ /** Every place under root that holds something test() accepts: { o, parent, key } (objects, arrays, Map values), each place once. Stops
99
+ * at DOM nodes and at depth 12. */
100
+ function walk(root, test, out, seen, depth) {
101
+ if (!root || typeof root !== 'object' || depth > 12 || seen.has(root)) return out;
102
+ if (typeof root.nodeType === 'number' || typeof root.then === 'function') return out;
103
+ seen.add(root);
104
+ const visit = (v, key) => {
105
+ if (!v || typeof v !== 'object') return;
106
+ if (test(v)) out.push({ o: v, parent: root, key });
107
+ walk(v, test, out, seen, depth + 1);
108
+ };
109
+ if (Array.isArray(root)) root.forEach((v, i) => visit(v, i));
110
+ else if (root instanceof Map) for (const [k, v] of root) visit(v, k);
111
+ else if (!(root instanceof Set)) for (const k of Object.keys(root)) visit(root[k], k);
112
+ return out;
113
+ }
114
+ export function findAll(root, id, out = [], seen = new WeakSet()) { return walk(root, (v) => isTask(v, id), out, seen, 0); }
115
+
116
+ /** A day N days later (or earlier): '2026-11-23' + 2 → '2026-11-25'. Anything that is not a day is left as it is. */
117
+ export function shiftDay(d, n) {
118
+ if (typeof d !== 'string' || !DAY.test(d)) return d;
119
+ const t = new Date(d + 'T00:00:00Z'); t.setUTCDate(t.getUTCDate() + n);
120
+ return t.toISOString().slice(0, 10);
121
+ }
122
+
123
+ /** The copy with the fields put on it (a new object: whoever holds the old one, such as a press's Undo, still reads the old value). A field
124
+ * the copy does not have is added under its first name only on a PMOS task copy (it has uid), so a ticket never grows a field its page
125
+ * does not read. fields.shift moves every day the copy has by that many days. */
126
+ export function patched(o, fields) {
127
+ const n = { ...o };
128
+ for (const [k, v] of Object.entries(fields)) {
129
+ if (k === 'shift') { for (const name of ['start', 'end', 'due']) if (name in o) n[name] = shiftDay(o[name], v); continue; }
130
+ const names = FIELDS[k] || [k], val = k === 'milestone' ? !!v : v;
131
+ let hit = false;
132
+ for (const name of names) if (name in o) { n[name] = val; hit = true; }
133
+ if (!hit && 'uid' in o) n[names[0]] = val;
134
+ }
135
+ return n;
136
+ }
137
+
138
+ const get = (parent, key) => (parent instanceof Map ? parent.get(key) : parent[key]);
139
+ const put = (parent, key, v) => { if (parent instanceof Map) parent.set(key, v); else parent[key] = v; };
140
+
141
+ function rootsOf(s) { try { const m = s.model(); return Array.isArray(m) ? m : [m]; } catch { return []; } }
142
+ function places(test) {
143
+ const at = [], seen = new WeakSet();
144
+ for (const s of SOURCES) for (const r of rootsOf(s)) walk(r, test, at, seen, 0);
145
+ return at;
146
+ }
147
+
148
+ /** Do one op on every copy the pages hold; returns the undo steps, for fail(). */
149
+ function apply(op) {
150
+ const steps = [];
151
+ if (op.kind === 'patch') {
152
+ const made = new Map();
153
+ for (const { o, parent, key } of places((v) => isTask(v, op.id))) {
154
+ // a copy that already says it (the read caught up) is left alone, so a read never draws twice for nothing
155
+ if (!made.has(o)) { const n = patched(o, op.fields); made.set(o, Object.keys(n).some((k) => n[k] !== o[k]) ? n : o); }
156
+ if (made.get(o) === o) continue;
157
+ const n = made.get(o);
158
+ put(parent, key, n);
159
+ steps.push(() => { if (get(parent, key) === n) { put(parent, key, o); return 1; } return 0; });
160
+ }
161
+ } else if (op.kind === 'remove') {
162
+ // from the end of each list first, so the places of the others hold
163
+ const at = places((v) => isTask(v, op.id)).sort((a, b) => (typeof b.key === 'number' ? b.key : 0) - (typeof a.key === 'number' ? a.key : 0));
164
+ for (const { o, parent, key } of at) {
165
+ if (Array.isArray(parent)) { const i = parent.indexOf(o); if (i < 0) continue; parent.splice(i, 1); steps.push(() => { if (parent.includes(o)) return 0; parent.splice(Math.min(i, parent.length), 0, o); return 1; }); }
166
+ else if (parent instanceof Map) { parent.delete(key); steps.push(() => { if (parent.has(key)) return 0; parent.set(key, o); return 1; }); }
167
+ }
168
+ } else if (op.kind === 'add') {
169
+ // under each copy of its initiative that lists tasks (the Board's and Home's rows); a copy that has the task already is left alone
170
+ for (const { o } of places((v) => !Array.isArray(v) && v.id === op.ini && Array.isArray(v.tasks))) {
171
+ if (o.tasks.some((t) => t && t.uid === op.row.uid)) continue;
172
+ const row = { ...op.row }, arr = o.tasks;
173
+ arr.push(row);
174
+ steps.push(() => { const i = arr.indexOf(row); if (i < 0) return 0; arr.splice(i, 1); return 1; });
175
+ }
176
+ }
177
+ return steps;
178
+ }
179
+
180
+ /** Draw every page and open view again. One failing draw never stops the others. */
181
+ /** A task card's picker (status, dates) is open: it hangs from a row a redraw would replace, and closes when that row goes. */
182
+ const pickerOpen = () => typeof document !== 'undefined' && !!document.querySelector('.tkc.ivq');
183
+ let HELD = null;
184
+ export function paint(views = true) {
185
+ // hold the redraw while a picker is open (the picker itself already shows the new value), and draw once it closes
186
+ if (pickerOpen()) {
187
+ HELD = HELD === null ? views : HELD || views;
188
+ if (HELD !== null && !paint.wait) paint.wait = setInterval(() => { if (pickerOpen()) return; clearInterval(paint.wait); paint.wait = 0; const v = HELD; HELD = null; paint(v); }, 120);
189
+ return;
190
+ }
191
+ for (const s of SOURCES) if (s.redraw) { try { s.redraw(); } catch { /* the next read draws it */ } }
192
+ if (!views) return;
193
+ for (const [el, fn] of [...VIEWS]) {
194
+ if (el && typeof el === 'object' && 'isConnected' in el && !el.isConnected) { VIEWS.delete(el); continue; }
195
+ try { fn(); } catch { /* the next read draws it */ }
196
+ }
197
+ }
198
+
199
+ /** A write is about to be sent. null when it is not a task write. */
200
+ export function begin(path, body) {
201
+ const ops = opsOf(path, body);
202
+ if (!ops) return null;
203
+ const entries = ops.map((op) => { const e = { op, saved: 0 }; PENDING.set(++seq, e); return [seq, e]; });
204
+ const steps = ops.flatMap((op) => apply(op));
205
+ if (steps.length) paint();
206
+ return {
207
+ ok(at) { const t = at || Date.now(); for (const [, e] of entries) e.saved = t; },
208
+ fail() {
209
+ for (const [k] of entries) PENDING.delete(k);
210
+ // only a copy still showing this change goes back: a newer read or a newer change is left as it is
211
+ let back = 0;
212
+ for (const undo of steps.reverse()) back += undo();
213
+ if (back) paint();
214
+ },
215
+ };
216
+ }
217
+
218
+ /** A page read its data again (since: when that read started; stale: the server said a press is still being folded in). */
219
+ export function loaded({ since = 0, stale = false } = {}) {
220
+ let n = 0;
221
+ for (const [k, e] of [...PENDING]) {
222
+ // a read that started after the save landed, and is not stale, holds the saved value itself
223
+ if (e.saved && !stale && since >= e.saved) { PENDING.delete(k); continue; }
224
+ // a saved new task may already be in the read under its real id: its stand-in is not drawn twice
225
+ if (e.op.kind === 'add' && e.saved) continue;
226
+ n += apply(e.op).length;
227
+ }
228
+ // the page drew the read already; it draws again only when a change still saving was put back on it
229
+ if (n) { paint(); return; }
230
+ for (const [el, fn] of [...VIEWS]) {
231
+ if (el && typeof el === 'object' && 'isConnected' in el && !el.isConnected) { VIEWS.delete(el); continue; }
232
+ try { fn(); } catch { /* the next read draws it */ }
233
+ }
234
+ }
235
+
236
+ /** The one line a page shows when a save did not land: the change is already back as it was. Plain words; the server's reason when it
237
+ * gave one. */
238
+ export function notSaved(res) {
239
+ const why = res && typeof res.error === 'string' && res.error.trim() ? res.error.trim().replace(/[.\s]+$/, '') : 'the workspace did not answer';
240
+ return 'Not saved, so it is back as it was: ' + why + '.';
241
+ }
242
+
243
+ /** Watch the page's fetch: a POST of a task write begins before it is sent, and ok() or fail() follows the answer (a refused answer, a
244
+ * body with ok:false, or no answer at all). The answer itself is handed back untouched; its body is read from a clone. */
245
+ export function install(g = globalThis) {
246
+ if (!g || typeof g.fetch !== 'function' || g.fetch.__liveEdit) return false;
247
+ const real = g.fetch;
248
+ const watched = async function (input, init) {
249
+ let le = null;
250
+ try {
251
+ const url = typeof input === 'string' ? input : input && input.url;
252
+ const method = String((init && init.method) || (input && typeof input === 'object' && input.method) || 'GET').toUpperCase();
253
+ if (method === 'POST' && url && init && typeof init.body === 'string') {
254
+ const p = new URL(url, 'http://x').pathname;
255
+ if (TASK_WRITE.test(p)) le = begin(p, JSON.parse(init.body));
256
+ }
257
+ } catch { le = null; }
258
+ if (!le) return real.call(this, input, init);
259
+ let res;
260
+ try { res = await real.call(this, input, init); } catch (e) { le.fail(); throw e; }
261
+ // a 403 (a stale nonce) is put back at once: pressFetch sends the press again, and that send begins on its own
262
+ if (res.status === 403) { le.fail(); return res; }
263
+ // landed now: the caller reads again as soon as it has the answer, and that read must count as after the save
264
+ const at = Date.now();
265
+ let body = null; try { body = await res.clone().json(); } catch { body = null; }
266
+ if (!res.ok || !body || body.ok === false) le.fail(); else le.ok(at);
267
+ return res;
268
+ };
269
+ watched.__liveEdit = true;
270
+ g.fetch = watched;
271
+ return true;
272
+ }
273
+ if (typeof window !== 'undefined' && typeof document !== 'undefined') install(window);
274
+
275
+ export function source(s) { SOURCES.add(s); return () => SOURCES.delete(s); }
276
+ export function view(el, redraw) { VIEWS.set(el, redraw); return () => { if (VIEWS.get(el) === redraw) VIEWS.delete(el); }; }
277
+ /** The task ids with a change still on the pages (tests). */
278
+ export const pending = () => new Map([...PENDING.values()].map((e) => [e.op.id || e.op.ini, e]));
279
+ /** Tests only: forget every source, view and pending write. */
280
+ export function reset() { SOURCES.clear(); VIEWS.clear(); PENDING.clear(); HELD = null; if (paint.wait) { clearInterval(paint.wait); paint.wait = 0; } }
@@ -20,6 +20,7 @@
20
20
  import './fetch-share.js'; // first: identical GETs in flight are asked once (page-open-speed)
21
21
  import * as WK from './work-kind.js'; // the kind of work before each title (batch 29 item 11, KdBd)
22
22
  import { pmPost } from './http.js';
23
+ import * as LE from './live-edit.js'; // a task's status or days show at once (the save answers later; a failed save is put back)
23
24
  import { followDoc } from './doc-follow.js';
24
25
  import { $, $$, esc, store, chatAbout, setPageGaps } from './premium-shell.js';
25
26
  import * as PK from './cozy-pick.js';
@@ -221,8 +222,8 @@ function closePanel() {
221
222
  /* ── the toast: the Agreed design's dark pill ─────────────────────────────────────────────────────────────────────────────── */
222
223
  let toastT = null;
223
224
  /** The toast; with `undo`, an Undo button that runs it once (the write's opposite, through the same route). */
224
- function say(msg, undo) {
225
- const t = $('#bdToast'); t.innerHTML = `<span>${esc(msg)}</span>${undo ? '<button type="button" class="bd-undo">Undo</button>' : ''}`; t.hidden = false;
225
+ function say(msg, undo, label = 'Undo') {
226
+ const t = $('#bdToast'); t.innerHTML = `<span>${esc(msg)}</span>${undo ? '<button type="button" class="bd-undo">' + esc(label) + '</button>' : ''}`; t.hidden = false;
226
227
  const u = t.querySelector('.bd-undo'); if (u) u.onclick = () => { u.disabled = true; t.hidden = true; undo(); };
227
228
  clearTimeout(toastT); toastT = setTimeout(() => { t.hidden = true; }, undo ? 10000 : 5000);
228
229
  }
@@ -1428,7 +1429,10 @@ async function readAll(q) {
1428
1429
  if (lost.length) { model.header.missing = [...model.header.missing, ...lost]; model.header.text += (/not read: /.test(model.header.text) ? ', ' : ' · not read: ') + lost.join(', '); }
1429
1430
  return { r: { ok: true, model, stale: got.some((g) => g.r && g.r.stale) || h.r.stale }, status: 200 };
1430
1431
  }
1432
+ /* the Board's copy of every task, drawn again the moment a task write is sent (pm/live-edit.js), before the board is read again */
1433
+ LE.source({ model: () => M, redraw: () => { if (!M) return; drawInit(); if (peek && peek.kind === 'ini') BI.refresh(true); } });
1431
1434
  async function load() {
1435
+ const since = Date.now();
1432
1436
  // while the board is read (the pick's default board, then the picked ones) the page says so and shows no row instead of a guess
1433
1437
  const reading = () => {
1434
1438
  const t0 = Date.now(), tick = () => { const s = 'Reading the board · ' + Math.round((Date.now() - t0) / 1000) + ' s so far'; $('#snap').textContent = s; if (!M && !$('#ibBody .ls-bd')) { $('#ibBody').innerHTML = SKEL; LS.slowLine($('#ibBody'), () => M); } };
@@ -1449,6 +1453,7 @@ async function load() {
1449
1453
  }
1450
1454
  M = r.model; readTries = 0; jiraReading = false; holdNames(); draw();
1451
1455
  readChanges();
1456
+ LE.loaded({ since, stale: !!r.stale }); // a change still saving stays on the new read; open views (the big Work breakdown) follow it
1452
1457
  STRAT.refresh($('#cStrat'), { ws: M.board.ws || null, board: M.board.id || null, single: !ALL, say });
1453
1458
  PRIN.refresh($('#cPrin'), { ws: M.board.ws || null, single: !ALL, say });
1454
1459
  focusOnce(); programOnce(); newOnce(); loadOthers(); loadWorkflows();
@@ -1475,7 +1480,8 @@ async function loadWorkflows() {
1475
1480
  async function setTask(r, uid, state, w) {
1476
1481
  const k = (r.tasks || []).find((x) => x.uid === uid), body = { ws: r.ws || M.board.ws, board: r.boardId || M.board.id, task: uid }, happened = (w && w.happened) || null;
1477
1482
  const res = await pmPost('/api/boards/tasks/state', { ...body, state, ...(happened ? { happened } : {}) }).catch(() => null);
1478
- if (!res || res.ok === false) { say((res && res.error) || 'Nothing was changed.'); return; }
1483
+ // the new status showed at once (pm/live-edit.js); a save that did not land is back as it was, and the toast says so with Try again
1484
+ if (!res || res.ok === false) { say(LE.notSaved(res), () => setTask(r, uid, state, w), 'Try again'); return; }
1479
1485
  // a breakdown item closed as Won't do is withdrawn, which the ledger cannot undo; every other change can go back (batch 9 item 5b)
1480
1486
  const undo = k && k.status !== state && !(k.item && state === "Won't do");
1481
1487
  // the day it really happened is said too (round 3 point 18): "Done on 14 Nov, noted today: <title>."
@@ -1487,7 +1493,7 @@ async function setTask(r, uid, state, w) {
1487
1493
  async function setDates(r, uid, patch) {
1488
1494
  const k = (r.tasks || []).find((x) => x.uid === uid), body = { ws: r.ws || M.board.ws, board: r.boardId || M.board.id, task: uid };
1489
1495
  const res = await pmPost('/api/boards/tasks/edit', { ...body, ...patch }).catch(() => null);
1490
- if (!res || res.ok === false) { say((res && res.error) || 'Nothing was changed.'); return; }
1496
+ if (!res || res.ok === false) { say(LE.notSaved(res), () => setDates(r, uid, patch), 'Try again'); return; }
1491
1497
  const ms = 'milestone' in patch;
1492
1498
  const back = {}; for (const f of Object.keys(patch)) back[f] = f === 'milestone' ? (res.from && 'milestone' in res.from ? !!res.from.milestone : !patch.milestone) : k ? (f === 'due' ? k.end : k[f]) || '' : res.from && f in res.from ? res.from[f] || '' : ''; // a Jira ticket's days come back in from (batch 11 item 23)
1493
1499
  const words = ms ? (patch.milestone ? 'Milestone' : 'Not a milestone') : 'Dates saved';
@@ -1499,7 +1505,7 @@ async function setDates(r, uid, patch) {
1499
1505
  async function removeTask(r, uid) {
1500
1506
  const k = (r.tasks || []).find((x) => x.uid === uid), body = { ws: r.ws || M.board.ws, board: r.boardId || M.board.id, task: uid };
1501
1507
  const res = await pmPost('/api/boards/tasks/delete', body).catch(() => null);
1502
- if (!res || res.ok === false) { say((res && res.error) || 'The task was not deleted.'); return; }
1508
+ if (!res || res.ok === false) { say(LE.notSaved(res), () => removeTask(r, uid), 'Try again'); return; } // the row went at once and is back
1503
1509
  say('Deleted · ' + (k ? k.title : uid) + '.', async () => { const u = await pmPost('/api/boards/tasks/restore', body).catch(() => null); if (!u || u.ok === false) say((u && u.error) || 'The undo did not land.'); load(); });
1504
1510
  load();
1505
1511
  }
@@ -1555,7 +1561,7 @@ async function addTask(r, title, section, dates, name) {
1555
1561
  // dates: a gap's + (batch 11 item 13) fills the task's start and due with the gap's days ahead; section: the stage it goes under (the
1556
1562
  // add route places it, batch 18 item 16); the add field's chips also send milestone and owner in it (batch 25 item 5)
1557
1563
  const res = await pmPost('/api/boards/tasks/add', { ...body, initiative: r.id, title, ...(dates && dates.start ? { start: dates.start } : {}), ...(dates && dates.due ? { due: dates.due } : {}), ...(dates && dates.milestone ? { milestone: true } : {}), ...(dates && dates.owner ? { owner: dates.owner } : {}), ...(section ? { section } : {}) }).catch(() => null);
1558
- if (!res || res.ok === false) { say((res && res.error) || 'The task was not added.'); return false; }
1564
+ if (!res || res.ok === false) { say(LE.notSaved(res), () => addTask(r, title, section, dates, name), 'Try again'); return false; } // the row showed at once (pm/live-edit.js) and is gone again
1559
1565
  const uid = res.item && res.item.uid;
1560
1566
  // the + on a stage (batch 18 item 16, StA5Add): "Added to Build" with Undo
1561
1567
  if (name && uid) say('Added to ' + name + '.', async () => { const u = await pmPost('/api/boards/tasks/delete', { ...body, task: uid, why: 'undo of add' }).catch(() => null); if (!u || u.ok === false) say((u && u.error) || 'The undo did not land.'); load(); });
@@ -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) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[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: 300px; padding: var(--space-12); }
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(300px, calc(100vw - 48px)); }
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); }