create-pmos 0.861.0 → 0.862.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 +23 -38
- 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 +22 -0
- package/workspace/guide/layout.md +13 -0
- package/workspace/lib/prefs-sync.js +1 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/card-size.js +85 -0
- package/workspace/public/pm/cozy-ev.css +50 -0
- package/workspace/public/pm/cozy-nav.js +6 -2
- package/workspace/public/pm/cozy-today-app.js +2 -1
- package/workspace/public/pm/page-arrange.js +321 -0
- package/workspace/public/pm/page-layout.js +155 -0
- package/workspace/public/pm/readonly.js +2 -0
- package/workspace/test-lists/card-size.json +9 -0
- package/workspace/test-lists/page-arrange.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.862.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -33,6 +33,28 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.862.0",
|
|
38
|
+
"at": "2026-11-26T01:46:33.114Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 2073,
|
|
43
|
+
"t": "Arrange any page or popup yourself — cards fit their column (card-size + page-arrange)",
|
|
44
|
+
"s": "Arrange any page or popup yourself — cards fit their column (card-size + page-arrange)",
|
|
45
|
+
"k": "new",
|
|
46
|
+
"i": "card-size",
|
|
47
|
+
"try": {
|
|
48
|
+
"steps": [
|
|
49
|
+
"Open Today on a wide window, then make the window narrow step by step",
|
|
50
|
+
"Open Work and one initiative and do the same"
|
|
51
|
+
],
|
|
52
|
+
"see": "Each card changes to its compact form by its own width: rows wrap, tabs scroll sideways, wide tables scroll inside the card and small row details hide. No card pushes the page wider than the window.",
|
|
53
|
+
"open": "/today.html"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
},
|
|
36
58
|
{
|
|
37
59
|
"v": "0.861.0",
|
|
38
60
|
"at": "2026-11-26T00:54:33.021Z",
|
|
@@ -666,43 +688,6 @@
|
|
|
666
688
|
}
|
|
667
689
|
}
|
|
668
690
|
]
|
|
669
|
-
},
|
|
670
|
-
{
|
|
671
|
-
"v": "0.836.0",
|
|
672
|
-
"at": "2026-11-25T15:53:32.838Z",
|
|
673
|
-
"f": 4,
|
|
674
|
-
"prs": [
|
|
675
|
-
{
|
|
676
|
-
"n": 2047,
|
|
677
|
-
"t": "Breakdown says \"let go\", not the reserved word \"release\"",
|
|
678
|
-
"s": "Breakdown says \"let go\", not the reserved word \"release\"",
|
|
679
|
-
"k": "fix",
|
|
680
|
-
"h": "Breakdown says \"let go\", not the reserved word \"release\"",
|
|
681
|
-
"try": {
|
|
682
|
-
"steps": [
|
|
683
|
-
"Open Work, open an initiative, choose Gantt under ⋯ and drag a bar's right end"
|
|
684
|
-
],
|
|
685
|
-
"see": "Unchanged behaviour; only the guide wording changed."
|
|
686
|
-
}
|
|
687
|
-
},
|
|
688
|
-
{
|
|
689
|
-
"n": 2035,
|
|
690
|
-
"t": "First hour for a new engineer on Work (A55)",
|
|
691
|
-
"s": "First hour for a new engineer on Work (A55)",
|
|
692
|
-
"k": "new",
|
|
693
|
-
"i": "first-hour",
|
|
694
|
-
"h": "First hour for a new engineer on Work (A55)",
|
|
695
|
-
"try": {
|
|
696
|
-
"steps": [
|
|
697
|
-
"Open Work on one product. When ✦ says a person is new here, press ✓ to start their first hour",
|
|
698
|
-
"Press each of the steps under Welcome, <name> to open it",
|
|
699
|
-
"When every step is open, the block becomes one line: <name> finished the welcome. Press ✕ to clear it"
|
|
700
|
-
],
|
|
701
|
-
"see": "Up to four steps from your own records: the product from its strategy lines, the current bets, a real first task in a tested part of the code map, and who changed those parts last. A step marks done…",
|
|
702
|
-
"open": "/premium-board.html"
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
]
|
|
706
691
|
}
|
|
707
692
|
]
|
|
708
693
|
}
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-26T01:46:29Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-26T01:46:29Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-26T01:46:29Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.862.0",
|
|
4
|
+
"at": "2026-11-26T01:46:33.114Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 2073,
|
|
9
|
+
"t": "Arrange any page or popup yourself — cards fit their column (card-size + page-arrange)",
|
|
10
|
+
"s": "Arrange any page or popup yourself — cards fit their column (card-size + page-arrange)",
|
|
11
|
+
"k": "new",
|
|
12
|
+
"i": "card-size",
|
|
13
|
+
"try": {
|
|
14
|
+
"steps": [
|
|
15
|
+
"Open Today on a wide window, then make the window narrow step by step",
|
|
16
|
+
"Open Work and one initiative and do the same"
|
|
17
|
+
],
|
|
18
|
+
"see": "Each card changes to its compact form by its own width: rows wrap, tabs scroll sideways, wide tables scroll inside the card and small row details hide. No card pushes the page wider than the window.",
|
|
19
|
+
"open": "/today.html"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
},
|
|
2
24
|
{
|
|
3
25
|
"v": "0.861.0",
|
|
4
26
|
"at": "2026-11-26T00:54:33.021Z",
|
|
@@ -104,6 +104,19 @@ On a computer, Work is built from the parts of the PMOS design system. The top l
|
|
|
104
104
|
|
|
105
105
|
**Fold a big card.** **Strategy**, **Where it stands** and **North Star** each have a chevron at the right of their head. Press it to fold the card to its head line; **Where it stands** keeps its first sentence. When PMOS has a suggestion in a folded card, a small **✦ 1** shows beside the head; press it to open the card. PMOS keeps each fold for you, per page and per card, on every device you use. Press the chevron again to open the card.
|
|
106
106
|
|
|
107
|
+
**Cards fit their column.** Every card reads its own width, not the page's. In a narrow column it shows its compact form: rows wrap, tabs scroll sideways, wide tables scroll in their own box and the small details beside a row hide. In a wide column the same card shows in full. Each card also knows the smallest column it can show in (for example 3 of 12 columns for Where it stands, 6 for the Work breakdown), so when you arrange a page PMOS can tell you before a card goes into a column that is too narrow.
|
|
108
|
+
|
|
109
|
+
**Arrange a page.** Every page and popup that shows two or more cards has an arrange icon above its cards: Today, Work and its tabs, Events, Goals, the initiative popup and the task popup. Press it to arrange the cards your way:
|
|
110
|
+
|
|
111
|
+
- A page is rows. Pick each row's split in the bar: 1, 1:1, 2:1, 1:2, 3:1, 1:3 or 1:1:1. Press a row's label to pick that row. **+** adds a row.
|
|
112
|
+
- Drag a card to any column or row, above or below other cards. Drag the line between two columns to change their widths: it snaps to a 12-column grid and says the widths (for example 7 | 5). No column is narrower than 3 of 12.
|
|
113
|
+
- While you drag, the place under the pointer says if the card fits: blue when it fits, grey when it shows its compact form there, red when the column is too narrow ("It needs 6 of 12 columns; this column has 4"). Let go on red and the card stays where it was; the column then offers an icon that widens it to fit and puts the card there.
|
|
114
|
+
- The eye on a card hides it. Hidden cards wait as chips at the top; drag a chip onto the page, or press it.
|
|
115
|
+
- A split with fewer columns moves the cards of the removed column to the column on its left. No card is ever lost.
|
|
116
|
+
- Undo takes back the last change, Reset puts back the page's own layout, and Done keeps your layout. PMOS keeps it for you on every device, per page; a popup keeps one layout wherever it opens. On Today it wins over the day's order. PMOS never moves a card by itself.
|
|
117
|
+
- In a column, each card is as wide as the column and shows its full or compact form for that width.
|
|
118
|
+
- On a narrow window or a phone the rows show as one column in your order, and arranging is moving and hiding cards; your desktop layout is kept.
|
|
119
|
+
|
|
107
120
|
**Reference cards are hidden behind one icon.** On Work › Initiatives, the product's reference cards (**Strategy**, **Principles**, **One-person areas**, **Segments**, **Roadmap for others**, **Code** and the other product cards) are not on the page. Press the small layers icon at the top right, above the list, to show them, and press it again to hide them. A blue dot on the icon means PMOS has a suggestion inside. **Line**, **Backlog**, **This sprint** and the other work tabs never show them. On an initiative, **Next milestones**, **Stages**, **Details** and **People** are hidden the same way; the icon sits at the right of the numbers strip at the top. PMOS keeps each choice for you on every device. When PMOS could not check an initiative, one quiet line says so with **Try again**; point at the line to read why.
|
|
108
121
|
|
|
109
122
|
**Initiatives** has three blocks:
|
|
@@ -50,7 +50,7 @@ const KEYS = Object.freeze({
|
|
|
50
50
|
'pmos.chat.fs', // the text size of every chat (Small, Normal, Large), the + menu of the chat box
|
|
51
51
|
'pmos.pop.five', // the work popup's four toolbar actions, worked out weekly from use (idea A498, pm/pop-cap.js)
|
|
52
52
|
]),
|
|
53
|
-
prefix: Object.freeze(['pmos.board.', 'pmos.pv.tab:', 'pmos.dash.view:', 'cz-vw-fold:', 'pmos.fold:']),
|
|
53
|
+
prefix: Object.freeze(['pmos.board.', 'pmos.pv.tab:', 'pmos.dash.view:', 'cz-vw-fold:', 'pmos.fold:', 'pmos.layout:']), // pmos.layout: the page layouts a person arranges (page-arrange)
|
|
54
54
|
});
|
|
55
55
|
const EXACT = new Set(KEYS.exact);
|
|
56
56
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.862.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.862.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/* pm/card-size.js — every card adapts to the width its column gives it (initiative card-size, slice 1 of arranged layouts).
|
|
2
|
+
*
|
|
3
|
+
* Users arrange pages themselves (rows split 1, 1:1, 2:1, 1:2, 3:1, 1:3 or 1:1:1 on a 12-column grid, cards stacked freely in each
|
|
4
|
+
* column; Wawan, 2026-11-26). So a card can not know its width from the page any more: it reads its OWN width. This module measures
|
|
5
|
+
* every card (`.pm-block`) and writes `data-cw="s" | "m" | "l"` on it; the shared compact rules in cozy-ev.css key off that mark, so a
|
|
6
|
+
* card in a narrow column shows its compact form and the same card in a wide column shows its full form. No card's markup changes.
|
|
7
|
+
*
|
|
8
|
+
* Every card also declares the smallest width it can show in: MIN_COLS, by its aria-label, in grid columns of 12. Arrange mode
|
|
9
|
+
* (slice 2) reads it to warn before a card is dropped in a column that is too narrow. card-size.test.js fails when a page card's
|
|
10
|
+
* aria-label is missing here, so a new card can not ship without saying how small it can go.
|
|
11
|
+
*
|
|
12
|
+
* sizeOf(px) PURE: 's' under 360px, 'm' under 640px, else 'l'
|
|
13
|
+
* minCols(label) PURE: the card's smallest width in grid columns (DEFAULT_MIN when it is not listed)
|
|
14
|
+
* fits(label, cols) PURE: 'full' | 'compact' | 'no' — a card fits compact one column under its minimum
|
|
15
|
+
* mark(el) write data-cw on one card from its width · sweep(doc) every card
|
|
16
|
+
* startCardSize(doc) called once by the menu (pm/cozy-nav.js mountNav), which every page mounts; a second call does nothing */
|
|
17
|
+
|
|
18
|
+
export const S_UNDER = 360;
|
|
19
|
+
export const M_UNDER = 640;
|
|
20
|
+
export const DEFAULT_MIN = 4;
|
|
21
|
+
export const SEL = '.pm-block';
|
|
22
|
+
|
|
23
|
+
/** The smallest width each card can show in, in columns of the 12-column page grid. Lists and summaries go to 3 or 4; cards that
|
|
24
|
+
* are a table, a timeline or a board need room. Keep it in step with the cards' aria-labels (card-size.test.js checks). */
|
|
25
|
+
export const MIN_COLS = Object.freeze({
|
|
26
|
+
'Activity': 3, 'Always yours': 3, 'Artefacts': 3, 'Backlog': 6, 'Before the meeting': 3, 'Calendar': 6,
|
|
27
|
+
'Changes PMOS makes': 4, 'Code': 4, 'Coming up': 3, 'Copy test': 4, 'Cost': 3, 'Customer voice': 4, 'Description': 4,
|
|
28
|
+
'Details': 3, 'Everything that repeats': 4, 'Findings': 4, 'In numbers': 4, 'Initiatives': 6, 'Key results': 4, 'Layouts': 4,
|
|
29
|
+
'Lessons': 4, 'Library': 6, 'Linked': 3, 'Next milestones': 3, 'Notes': 4, 'One-person areas': 4, 'Overview': 4,
|
|
30
|
+
'PMOS can do this now': 3, 'PMOS did': 3, 'PMOS suggests': 3, 'People': 3, 'Portfolio': 6, 'Principles': 4, 'Review': 4,
|
|
31
|
+
'Review pack': 6, 'Roadmap for others': 4, 'Segments': 4, 'Show': 3, 'Sign-offs': 4, 'Spec and code no longer match': 4,
|
|
32
|
+
'Sprint goal': 3, 'Sprint tasks': 6, 'Stages': 4, 'Standing rules': 4, 'Starter goals': 4, 'Story map': 8, 'Strategy': 4,
|
|
33
|
+
'Subtasks': 4, 'Summary': 4, 'Switches': 4, 'Team skills': 4, 'The case': 4, 'The line': 6, 'The meeting you recorded': 4,
|
|
34
|
+
'Today': 3, 'Today’s agenda': 3, 'Today’s batch': 4, 'Today’s log': 4, 'Upstream': 3, 'Versions': 4,
|
|
35
|
+
'Waiting on other teams': 3, 'What PMOS does alone': 4, 'What needs you': 4, 'Where it stands': 3, 'Work breakdown': 6,
|
|
36
|
+
'Your move': 4,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const sizeOf = (px) => { const w = Number(px) || 0; return w < S_UNDER ? 's' : w < M_UNDER ? 'm' : 'l'; };
|
|
40
|
+
export const minCols = (label) => MIN_COLS[String(label || '').trim()] || DEFAULT_MIN;
|
|
41
|
+
|
|
42
|
+
/** PURE: how a card shows in a column of `cols` grid columns. One column under its minimum it still shows, in its compact form. */
|
|
43
|
+
export function fits(label, cols) {
|
|
44
|
+
const need = minCols(label); const have = Number(cols) || 0;
|
|
45
|
+
return have >= need ? 'full' : have >= need - 1 && have >= 3 ? 'compact' : 'no';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Write data-cw on one card from its own width. Returns the mark, or '' when the card has no width yet (hidden, not laid out). */
|
|
49
|
+
export function mark(el, width) {
|
|
50
|
+
if (!el || !el.setAttribute) return '';
|
|
51
|
+
const w = width != null ? width : (el.getBoundingClientRect ? el.getBoundingClientRect().width : 0);
|
|
52
|
+
if (!w) return '';
|
|
53
|
+
const cw = sizeOf(w);
|
|
54
|
+
if (el.getAttribute('data-cw') !== cw) el.setAttribute('data-cw', cw);
|
|
55
|
+
return cw;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function sweep(doc, ro) {
|
|
59
|
+
let n = 0;
|
|
60
|
+
doc.querySelectorAll(SEL).forEach((el) => {
|
|
61
|
+
if (ro && !el.__pmCw) { el.__pmCw = true; ro.observe(el); }
|
|
62
|
+
if (mark(el)) n++;
|
|
63
|
+
});
|
|
64
|
+
return n;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let started = false;
|
|
68
|
+
export function startCardSize(doc = typeof document !== 'undefined' ? document : null) {
|
|
69
|
+
if (started || !doc || !doc.body) return false;
|
|
70
|
+
started = true;
|
|
71
|
+
const win = doc.defaultView;
|
|
72
|
+
const ro = win && win.ResizeObserver
|
|
73
|
+
? new win.ResizeObserver((entries) => { for (const e of entries) mark(e.target); })
|
|
74
|
+
: null;
|
|
75
|
+
let queued = false;
|
|
76
|
+
const later = () => {
|
|
77
|
+
if (queued) return; queued = true;
|
|
78
|
+
const run = () => { queued = false; try { sweep(doc, ro); } catch (e) { try { console.info('[card-size] ' + e.message); } catch { /* no console */ } } };
|
|
79
|
+
if (win && win.requestAnimationFrame) win.requestAnimationFrame(run); else setTimeout(run, 16);
|
|
80
|
+
};
|
|
81
|
+
if (win && win.MutationObserver) new win.MutationObserver(later).observe(doc.body, { childList: true, subtree: true });
|
|
82
|
+
if (!ro && win) win.addEventListener('resize', later);
|
|
83
|
+
later();
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
@@ -578,9 +578,59 @@ body.pm-focus .cz-pop-card { inset: 0; border-radius: 0; }
|
|
|
578
578
|
.pm-folded > [data-fold-one] { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; color: var(--muted); }
|
|
579
579
|
.pm-fold-sug { border: 0; cursor: pointer; display: inline-flex; align-items: center; padding: var(--space-4) var(--space-8); border-radius: var(--radius-pill); background: var(--blue-tint); color: var(--blue); font: inherit; font-size: var(--fs-badge); font-weight: var(--fw-strong); }
|
|
580
580
|
|
|
581
|
+
/* ── card size (pm/card-size.js, initiative card-size): every card reads its OWN width (data-cw s, m or l: see pm/card-size.js) and
|
|
582
|
+
* shows its compact form in a narrow column, whatever the page's layout. Shared rules only; a card may add its own under the same
|
|
583
|
+
* mark. Tokens only. ── */
|
|
584
|
+
.pm-block[data-cw="s"] .pm-row { flex-wrap: wrap; }
|
|
585
|
+
.pm-block[data-cw="s"] .pm-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
|
|
586
|
+
.pm-block[data-cw="s"] .pm-table, .pm-block[data-cw="m"] .pm-table { display: block; max-width: 100%; overflow-x: auto; }
|
|
587
|
+
.pm-block[data-cw="s"] .pm-li .w, .pm-block[data-cw="s"] [data-cw-hide~="s"], .pm-block[data-cw="m"] [data-cw-hide~="m"] { display: none !important; }
|
|
588
|
+
.pm-block[data-cw="s"] .pm-cw-stack, .pm-block[data-cw="m"] .pm-cw-stack { grid-template-columns: minmax(0, 1fr) !important; flex-direction: column; }
|
|
589
|
+
.pm-block[data-cw="s"] .pm-li .txt { min-width: 0; overflow-wrap: anywhere; }
|
|
590
|
+
.pm-block[data-cw="s"] img, .pm-block[data-cw="s"] svg:not(.pm-ic) { max-width: 100%; height: auto; }
|
|
591
|
+
|
|
581
592
|
/* ── reference cards behind one icon (pm/ref-toggle.js, initiative fold-by-default): pressed, the icon is blue on a blue tint; while the
|
|
582
593
|
* group is hidden, a blue dot says a suggestion waits inside. Tokens only. ── */
|
|
583
594
|
.pm-ref { position: relative; }
|
|
584
595
|
.pm-ref[aria-pressed="true"] { background: var(--blue-tint); color: var(--blue); }
|
|
585
596
|
.pm-ref-dot { position: absolute; top: var(--space-4); right: var(--space-4); width: var(--space-8); height: var(--space-8); border-radius: var(--radius-pill); background: var(--blue); }
|
|
586
597
|
.pm-ref-dot[hidden] { display: none; }
|
|
598
|
+
|
|
599
|
+
/* ── arrange a page (pm/page-arrange.js, initiative page-arrange): rows split on the 12-column grid, cards stacked in each column, the
|
|
600
|
+
* arrange bar, the tray of hidden cards, the drop slot (fits, compact, too narrow) and the dividers. Tokens only. ── */
|
|
601
|
+
[data-pl-tools], .wk-ref-ph { gap: var(--space-8); }
|
|
602
|
+
.pl-tools { display: flex; justify-content: flex-end; margin-bottom: var(--space-8); }
|
|
603
|
+
.pl-host { display: block !important; align-self: stretch; width: 100%; max-width: 100%; box-sizing: border-box; }
|
|
604
|
+
.pl-host > :not(.pl):not(.pl-shelf) { display: none !important; }
|
|
605
|
+
.pl { display: flex; flex-direction: column; gap: var(--space-24); min-width: 0; width: 100%; box-sizing: border-box; }
|
|
606
|
+
.pl-row { position: relative; display: flex; flex-direction: column; gap: var(--space-8); min-width: 0; }
|
|
607
|
+
.pl-grid { display: grid; grid-template-columns: var(--pl-cols, minmax(0, 1fr)); align-items: start; min-width: 0; width: 100%; }
|
|
608
|
+
.pl-col { display: flex; flex-direction: column; gap: var(--space-16); min-width: 0; }
|
|
609
|
+
.pl-col > .pm-block { container-type: inline-size; align-self: stretch; width: auto !important; max-width: none !important; margin-inline: 0 !important; flex: none !important; box-sizing: border-box; } /* a placed card is as wide as its column, and its own @container rules answer to that width */
|
|
610
|
+
.pl-div { display: flex; justify-content: center; align-self: stretch; position: relative; }
|
|
611
|
+
.pl-on .pl-div { cursor: col-resize; touch-action: none; }
|
|
612
|
+
.pl-on .pl-div::before { content: ""; width: var(--space-4); border-radius: var(--radius-pill); background: var(--line); }
|
|
613
|
+
.pl-on .pl-div:hover::before { background: var(--blue); }
|
|
614
|
+
.pl-dl { position: absolute; top: var(--space-24); left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--ink); color: var(--card); border-radius: var(--radius-md); padding: 0 var(--space-8); font-size: var(--fs-meta); }
|
|
615
|
+
.pl-on .pl { padding: var(--space-16); border-radius: var(--radius-card); background-color: var(--well); background-image: radial-gradient(circle, var(--line) 6%, transparent 8%); background-size: var(--space-24) var(--space-24); }
|
|
616
|
+
.pl-bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-8); padding: var(--space-8) var(--space-12); background: var(--card); border: thin solid var(--line); border-radius: var(--radius-md); box-shadow: var(--raise); }
|
|
617
|
+
.pl-say { margin-right: auto; }
|
|
618
|
+
.pl-splits { display: inline-flex; gap: var(--space-4); padding: var(--space-4); border-radius: var(--radius-md); background: var(--well); }
|
|
619
|
+
.pl-sp[aria-pressed="true"] { background: var(--ink); color: var(--card); }
|
|
620
|
+
.pl-sp rect { fill: none; stroke: currentColor; stroke-width: 1.6; }
|
|
621
|
+
.pl-tray { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-8); }
|
|
622
|
+
.pl-chip { display: inline-flex; align-items: center; gap: var(--space-4); border-radius: var(--radius-pill); cursor: grab; }
|
|
623
|
+
.pl-rl { align-self: flex-start; border: thin solid var(--line); background: var(--card); border-radius: var(--radius-md); padding: 0 var(--space-8); cursor: pointer; font: inherit; font-size: var(--fs-meta); }
|
|
624
|
+
.pl-row.sel > .pl-rl { background: var(--blue); color: var(--card); border-color: var(--blue); }
|
|
625
|
+
.pl-row.sel > .pl-grid { outline: thin dashed var(--blue); outline-offset: var(--space-8); border-radius: var(--radius-md); }
|
|
626
|
+
.pl-card { position: relative; cursor: grab; }
|
|
627
|
+
.pl-card.pl-drag { opacity: .5; }
|
|
628
|
+
.pl-hide { position: absolute; top: calc(var(--space-12) * -1); right: calc(var(--space-12) * -1); z-index: 2; background: var(--card); border: thin solid var(--line); border-radius: var(--radius-pill); box-shadow: var(--raise); }
|
|
629
|
+
.pl-on .pl-card { overflow: visible !important; background: var(--card); box-shadow: var(--raise); border-radius: var(--radius-card); }
|
|
630
|
+
.pl-slot { border: medium dashed var(--blue); background: var(--blue-tint); color: var(--blue); border-radius: var(--radius-md); padding: var(--space-12); font-size: var(--fs-meta); font-weight: var(--fw-strong); text-align: center; }
|
|
631
|
+
.pl-slot.compact { border-color: var(--muted); background: var(--card); color: var(--ink); }
|
|
632
|
+
.pl-slot.no, .pl-warn { border: medium dashed var(--alert); background: var(--alert-tint); color: var(--alert); border-radius: var(--radius-md); padding: var(--space-12); font-size: var(--fs-meta); }
|
|
633
|
+
.pl-warn { display: flex; align-items: center; gap: var(--space-8); }
|
|
634
|
+
.pl-tight { color: var(--alert); margin: 0; }
|
|
635
|
+
.pl-empty { margin: 0; padding: var(--space-16); border: thin dashed var(--line); border-radius: var(--radius-md); text-align: center; }
|
|
636
|
+
@media (max-width: 62.5em) { .pl-grid { grid-template-columns: minmax(0, 1fr) !important; } .pl-div, .pl-splits, .pl-bar [data-pl="row"] { display: none; } }
|
|
@@ -49,8 +49,10 @@ import { startUseLog } from './use-log.js'; // bet A466: every page mounts the
|
|
|
49
49
|
import { startActionKeys } from './action-keys.js'; // bet A477: y o s p z act on the item under the pointer, ? lists the keys
|
|
50
50
|
import { startGlossary } from './glossary.js'; // bet A386: a product's own words show their meaning on hover (a long press on a phone)
|
|
51
51
|
import { startFocusMode } from './focus-mode.js'; // bet A335: f shows only the item under the pointer and its chat; f again puts the page back
|
|
52
|
-
import { startCardFold } from './card-fold.js';
|
|
53
|
-
import {
|
|
52
|
+
import { startCardFold } from './card-fold.js'; // card-fold: Strategy, Where it stands and North Star fold to one line, kept per person
|
|
53
|
+
import { startAuto as startArrange } from './page-arrange.js'; // page-arrange: every page's and popup's cards can be arranged in rows by the person
|
|
54
|
+
import { startCardSize } from './card-size.js'; // card-size: every card reads its own width and shows its full or compact form
|
|
55
|
+
import { startRefToggle } from './ref-toggle.js'; // fold-by-default: reference cards hidden behind one icon, kept per person
|
|
54
56
|
|
|
55
57
|
/* The six places (slice 1). A place shows once it has an href: Events, Library and Routine get theirs when their slice ships. Until then
|
|
56
58
|
* Today is today.html (slice 5; Home before it), Work is the Board and Goals is premium-goals.html (slice 9; Intelligence before it); the keys stay the pages' own (home, board, insights). */
|
|
@@ -212,6 +214,8 @@ export function mountNav(here, doc = document, opts = {}) {
|
|
|
212
214
|
startActionKeys(doc);
|
|
213
215
|
startFocusMode(doc);
|
|
214
216
|
startCardFold(doc);
|
|
217
|
+
startCardSize(doc);
|
|
218
|
+
startArrange(doc);
|
|
215
219
|
startRefToggle(doc);
|
|
216
220
|
startGlossary(doc);
|
|
217
221
|
const fab = w.querySelector('#czFab'), menu = w.querySelector('#czMenu'), scrim = w.querySelector('#czScrim');
|
|
@@ -25,6 +25,7 @@ import { noteUse } from './use-log.js'; // your-move (A468): each press on a Y
|
|
|
25
25
|
import * as QB from './quiet-batch.js'; // quiet-rows: Today's batch, the popup (Approve, Skip, Change it first; nothing sent without a press)
|
|
26
26
|
import * as PA from './page-one-answer.js'; // page-one-answer (A308): the one sentence that opens Today; Your move is its list
|
|
27
27
|
import * as CAP from './five-action-cap.js'; // five-action-cap (A529): a row shows two actions and ⋯; which two comes from the use log, once a week
|
|
28
|
+
import * as PLA from './page-arrange.js'; // page-arrange: the person arranges Today's cards in rows (the menu starts it); their layout wins over the day's order
|
|
28
29
|
import * as TO from './today-order.js'; // today-order (A310, board BatchMoreBDS panel 30): the same blocks in the day's order, and the pin
|
|
29
30
|
import * as NL from './cozy-name-links.js'; // name-links (A536): names in a line you typed link to the person, meeting or document, with a small card
|
|
30
31
|
import * as CC from './change-cues.js'; // idea A313: a short cue on the row that is done, moved or dropped, before the log draws again // the phone: rows and the proposal swipe (phone design, Ph2_today)
|
|
@@ -425,7 +426,7 @@ export function mountToday(ctx) {
|
|
|
425
426
|
const cap = document.getElementById('tdCap'), draft = cap ? cap.value : '', focus = !!cap && document.activeElement === cap;
|
|
426
427
|
// the log filters by job (All, Reply, Do, Decide, Send) on a desk and a phone; a job whose count went to zero goes back to All
|
|
427
428
|
if (X.job && !(L.counts || {})[X.job.toLowerCase()] && !(X.job === 'Decide' && L.questions && L.questions.others.length)) X.job = '';
|
|
428
|
-
const T = X.order = orderOf(A), ord = { order: T.order, orderLine: TO.lineHtml(T) }; // today-order (A310)
|
|
429
|
+
const T = X.order = orderOf(A), ord = { order: T.order, orderLine: PLA.has(PLA.TODAY) ? '' : TO.lineHtml(T) }; // today-order (A310); a layout the person arranged wins, so no line
|
|
429
430
|
if (phone()) {
|
|
430
431
|
// PhoneTodayDS (job #1540): Where it stands, the log with All ⌄, the capture box at the foot, the ✦ proposal's sheet
|
|
431
432
|
if (X.sheet && !(O.suggest || []).some((x) => x.key === X.sheet)) X.sheet = '';
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/* pm/page-arrange.js — arrange a page yourself (initiative page-arrange, slice 2 of arranged layouts; canvas "Page layouts you arrange",
|
|
2
|
+
* boards 1 to 3, agreed by Wawan 2026-11-26). The model is pm/page-layout.js; how small each card can go is pm/card-size.js.
|
|
3
|
+
*
|
|
4
|
+
* mount(host, page, { tools }) called by a page after every draw. host holds the page's cards (`.pm-block[aria-label]`); tools is
|
|
5
|
+
* where the arrange icon goes. With a saved layout, the cards are placed in its rows; with none, the
|
|
6
|
+
* page stays as it draws itself. Cards are MOVED, never redrawn, so each keeps its own presses.
|
|
7
|
+
* Arrange mode (the icon): a bar with the selected row's split (1, 1:1, 2:1, 1:2, 3:1, 1:3, 1:1:1), add a row, Undo, Reset and Done;
|
|
8
|
+
* the tray of hidden cards; every card drags (and hides with its eye icon); dividers drag and snap to the 12-column grid. While a
|
|
9
|
+
* card is dragged, the slot says before you let go: fits (blue), shows compact (grey) or too narrow (red, with the numbers). Let go
|
|
10
|
+
* on red and the card stays where it was; the column then shows one line with an icon that widens it.
|
|
11
|
+
* The layout is kept per person and page ('pmos.layout:<page>', it follows the person). PMOS never moves a card by itself. */
|
|
12
|
+
|
|
13
|
+
import * as PL from './page-layout.js';
|
|
14
|
+
import { fits, minCols } from './card-size.js';
|
|
15
|
+
|
|
16
|
+
const S = {}; // per page: { cards: Map(label → element), host, tools, saved, work, undo: [], on, sel, warn }
|
|
17
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
18
|
+
const ic = (d) => `<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
19
|
+
export const ICON = {
|
|
20
|
+
arrange: 'M4 4h9v16H4zM15 4h5v7h-5zM15 13h5v7h-5z',
|
|
21
|
+
plus: 'M12 5v14M5 12h14',
|
|
22
|
+
undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3',
|
|
23
|
+
reset: 'M4 12a8 8 0 1 0 3-6.2M4 4v4h4',
|
|
24
|
+
done: 'M5 12.5l4.5 4.5L19 7.5', // brand/icons.json approve
|
|
25
|
+
hide: 'M3 3l18 18M10.6 5.1A10 10 0 0 1 12 5c6 0 10 7 10 7a17 17 0 0 1-3 3.7M6.6 6.6A17 17 0 0 0 2 12s4 7 10 7a9.7 9.7 0 0 0 5.4-1.6',
|
|
26
|
+
widen: 'M8 7l-5 5 5 5M16 7l5 5-5 5M3 12h18',
|
|
27
|
+
grip: 'M9 6h.01M15 6h.01M9 12h.01M15 12h.01M9 18h.01M15 18h.01',
|
|
28
|
+
};
|
|
29
|
+
/** PURE: the split glyph for a split name, as small boxes in one svg. */
|
|
30
|
+
export function splitIcon(name) {
|
|
31
|
+
const w = PL.SPLITS[name] || [12]; let x = 2; const unit = 20 / 12; const gap = 1.5;
|
|
32
|
+
const rects = w.map((n, i) => { const width = n * unit - (i < w.length - 1 ? gap : 0); const r = `<rect x="${x.toFixed(2)}" y="5" width="${width.toFixed(2)}" height="14" rx="1.5"/>`; x += n * unit; return r; });
|
|
33
|
+
return `<svg class="pm-ic" width="18" height="18" viewBox="0 0 24 24" aria-hidden="true">${rects.join('')}</svg>`;
|
|
34
|
+
}
|
|
35
|
+
const SPLIT_SAY = { '1': 'One column', '1:1': 'Split 1 to 1', '2:1': 'Split 2 to 1', '1:2': 'Split 1 to 2', '3:1': 'Split 3 to 1', '1:3': 'Split 1 to 3', '1:1:1': 'Three equal columns' };
|
|
36
|
+
|
|
37
|
+
/** PURE: what a drop slot says for a card in a column of `cols`. */
|
|
38
|
+
export function slotSay(label, cols) {
|
|
39
|
+
const f = fits(label, cols), need = minCols(label);
|
|
40
|
+
if (f === 'full') return { state: 'full', say: `Fits here · ${cols} columns` };
|
|
41
|
+
if (f === 'compact') return { state: 'compact', say: 'Shows compact here' };
|
|
42
|
+
return { state: 'no', say: `Too narrow for ${label}. It needs ${need} of 12 columns; this column has ${cols}.` };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** PURE: the arrange bar. */
|
|
46
|
+
export function barHtml(L, sel, canUndo) {
|
|
47
|
+
const r = L.rows[sel] || L.rows[0]; const cur = PL.splitName(r.cols);
|
|
48
|
+
const splits = PL.NAMES.map((n) => `<button type="button" class="pm-btn pl-sp" data-pl="split" data-split="${n}" aria-pressed="${n === cur}" aria-label="${esc(SPLIT_SAY[n] + ' for row ' + (sel + 1))}" title="${n}">${splitIcon(n)}</button>`).join('');
|
|
49
|
+
const b = (act, label, d, extra = '') => `<button type="button" class="pm-btn pl-ib" data-pl="${act}" aria-label="${esc(label)}" title="${esc(label)}"${extra}>${ic(d)}</button>`;
|
|
50
|
+
return `<div class="pl-bar" role="toolbar" aria-label="Arrange this page"><span class="pm-meta pl-say">Arranging · only you see this layout</span>`
|
|
51
|
+
+ `<span class="pm-meta">Row ${sel + 1}${cur ? ' · ' + cur : ' · ' + r.cols.join(' | ')}</span><span class="pl-splits" role="group" aria-label="Split for row ${sel + 1}">${splits}</span>`
|
|
52
|
+
+ b('row', 'Add a row', ICON.plus) + b('undo', 'Undo', ICON.undo, canUndo ? '' : ' disabled') + b('reset', 'Reset to the page’s own layout', ICON.reset)
|
|
53
|
+
+ `<button type="button" class="pm-btn primary pl-ib" data-pl="done" aria-label="Done arranging" title="Done">${ic(ICON.done)}</button></div>`;
|
|
54
|
+
}
|
|
55
|
+
export function trayHtml(hidden) {
|
|
56
|
+
if (!hidden.length) return '';
|
|
57
|
+
return `<div class="pl-tray" aria-label="Hidden cards"><span class="pm-meta">Hidden, drag onto the page or press to show:</span>`
|
|
58
|
+
+ hidden.map((x) => `<button type="button" class="pm-btn pl-chip" draggable="true" data-pl="show" data-card="${esc(x)}" aria-label="${esc('Show ' + x)}">${ic(ICON.grip)}${esc(x)}</button>`).join('') + '</div>';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const store = () => { try { return window.localStorage; } catch { return null; } };
|
|
62
|
+
export function load(page) {
|
|
63
|
+
const ls = store(); if (!ls) return null;
|
|
64
|
+
try { const L = JSON.parse(ls.getItem(PL.key(page)) || 'null'); return PL.valid(L) ? L : null; } catch { return null; }
|
|
65
|
+
}
|
|
66
|
+
function save(page, L) {
|
|
67
|
+
const ls = store(); if (!ls) return;
|
|
68
|
+
try { if (L) ls.setItem(PL.key(page), JSON.stringify(L)); else ls.removeItem(PL.key(page)); } catch { /* storage blocked: kept for this visit */ }
|
|
69
|
+
}
|
|
70
|
+
export const has = (page) => !!load(page);
|
|
71
|
+
|
|
72
|
+
/** The page's top-level cards, by aria-label (a card inside another card moves with it). */
|
|
73
|
+
function cardsOf(host) {
|
|
74
|
+
const m = new Map();
|
|
75
|
+
host.querySelectorAll('.pm-block[aria-label]').forEach((el) => {
|
|
76
|
+
const up = el.parentElement && el.parentElement.closest('.pm-block'); if (up && host.contains(up)) return;
|
|
77
|
+
if (!el.getClientRects().length && !el.closest('.pl, .pl-shelf')) return; // a card the page does not show now stays where it is
|
|
78
|
+
const k = el.getAttribute('aria-label'); if (k && !m.has(k)) m.set(k, el);
|
|
79
|
+
});
|
|
80
|
+
return m;
|
|
81
|
+
}
|
|
82
|
+
/** The page's own layout, read from where it drew each card (pm/page-layout.js bandsOf). */
|
|
83
|
+
function ownLayout(st) {
|
|
84
|
+
const box = st.host.getBoundingClientRect();
|
|
85
|
+
const rects = [...st.cards.entries()].map(([name, el]) => { const r = el.getBoundingClientRect(); return { name, left: r.left - box.left, top: r.top - box.top, width: r.width }; });
|
|
86
|
+
return PL.bandsOf(rects, box.width);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** No place for the icon given: a small bar right before the host holds it (kept when the host redraws). */
|
|
90
|
+
function toolsBefore(host) {
|
|
91
|
+
// a page may name a row of icons for it (data-pl-tools, or Work's .wk-ref-ph) before the host or before one of its containers: the icon joins that row
|
|
92
|
+
for (let a = host, up = 0; a && up < 5; a = a.parentElement, up++) {
|
|
93
|
+
for (let p = a.previousElementSibling; p; p = p.previousElementSibling) if ((p.hasAttribute('data-pl-tools') || p.classList.contains('wk-ref-ph')) && p.getClientRects().length) return p;
|
|
94
|
+
}
|
|
95
|
+
const prev = host.previousElementSibling;
|
|
96
|
+
if (prev && prev.classList.contains('pl-tools')) return prev;
|
|
97
|
+
const bar = host.ownerDocument.createElement('div'); bar.className = 'pl-tools';
|
|
98
|
+
host.parentNode.insertBefore(bar, host);
|
|
99
|
+
return bar;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function mount(host, page, o = {}) {
|
|
103
|
+
if (!host || !page) return false;
|
|
104
|
+
const st = S[page] || (S[page] = { undo: [], on: false, sel: 0, warn: null });
|
|
105
|
+
st.host = host; st.page = page; st.cards = cardsOf(host);
|
|
106
|
+
host.dataset.plPage = page;
|
|
107
|
+
if (o.auto) host.setAttribute('data-pl-auto', ''); else host.removeAttribute('data-pl-auto');
|
|
108
|
+
for (const k of Object.keys(S)) if (k !== page && S[k].host === host) delete S[k]; // one layout per container
|
|
109
|
+
st.tools = o.tools || toolsBefore(host);
|
|
110
|
+
st.home = new Map([...st.cards].map(([k, el]) => [k, el.parentElement])); // where the page drew each card, to put it back on Reset
|
|
111
|
+
st.saved = load(page);
|
|
112
|
+
if (st.tools && !st.tools.querySelector('[data-pl="arrange"]')) {
|
|
113
|
+
const b = host.ownerDocument.createElement('button');
|
|
114
|
+
b.type = 'button'; b.className = 'pm-btn pl-ib pl-go'; b.dataset.pl = 'arrange';
|
|
115
|
+
b.setAttribute('aria-label', 'Arrange this page'); b.title = 'Arrange this page'; b.innerHTML = ic(ICON.arrange);
|
|
116
|
+
st.tools.appendChild(b);
|
|
117
|
+
}
|
|
118
|
+
if (st.tools) { const g = st.tools.querySelector('[data-pl="arrange"]'); if (g) g.setAttribute('aria-pressed', String(st.on)); }
|
|
119
|
+
wire(host.ownerDocument);
|
|
120
|
+
draw(st);
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function current(st) {
|
|
125
|
+
const names = [...st.cards.keys()];
|
|
126
|
+
if (st.on) return (st.work = PL.whole(st.work || st.saved || ownLayout(st), names));
|
|
127
|
+
return st.saved ? PL.whole(st.saved, names) : null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function draw(st) {
|
|
131
|
+
const doc = st.host.ownerDocument; const L = current(st);
|
|
132
|
+
let pl = st.host.querySelector(':scope > .pl');
|
|
133
|
+
if (!L) {
|
|
134
|
+
if (pl) { st.cards.forEach((el, k) => { const home = st.home.get(k); if (home && home !== el.parentElement) home.appendChild(el); el.draggable = false; el.classList.remove('pl-card'); const h = el.querySelector(':scope > .pl-hide'); if (h) h.remove(); }); pl.remove(); }
|
|
135
|
+
const sh = st.host.querySelector(':scope > .pl-shelf'); if (sh) sh.remove();
|
|
136
|
+
st.host.classList.remove('pl-host', 'pl-on'); return;
|
|
137
|
+
}
|
|
138
|
+
if (!pl) { pl = doc.createElement('div'); pl.className = 'pl'; st.host.appendChild(pl); }
|
|
139
|
+
st.host.classList.add('pl-host'); st.host.classList.toggle('pl-on', st.on);
|
|
140
|
+
if (st.sel >= L.rows.length) st.sel = 0;
|
|
141
|
+
const parked = doc.createDocumentFragment();
|
|
142
|
+
st.cards.forEach((el) => parked.appendChild(el)); // keep every card element while the rows are rebuilt
|
|
143
|
+
pl.innerHTML = (st.on ? barHtml(L, st.sel, st.undo.length > 0) + trayHtml(L.hidden) : '')
|
|
144
|
+
+ L.rows.map((r, ri) => {
|
|
145
|
+
const tpl = r.cols.map((n) => `minmax(0, ${n}fr)`).join(' var(--space-16) ');
|
|
146
|
+
const cols = r.cols.map((n, ci) => `<div class="pl-col" data-row="${ri}" data-col="${ci}" data-cols="${n}"></div>`
|
|
147
|
+
+ (ci < r.cols.length - 1 ? `<div class="pl-div" data-row="${ri}" data-div="${ci}" role="separator" aria-orientation="vertical" aria-label="${esc('Divider ' + (ci + 1) + ' of row ' + (ri + 1))}"><b class="pl-dl" hidden></b></div>` : '')).join('');
|
|
148
|
+
return `<div class="pl-row${st.on && ri === st.sel ? ' sel' : ''}" data-row="${ri}" data-tpl="${tpl}">${st.on ? `<button type="button" class="pl-rl pm-meta" data-pl="sel" data-row="${ri}">Row ${ri + 1} · ${PL.splitName(r.cols) || r.cols.join(' | ')}</button>` : ''}<div class="pl-grid">${cols}</div></div>`;
|
|
149
|
+
}).join('');
|
|
150
|
+
pl.querySelectorAll('.pl-row').forEach((row) => { row.querySelector('.pl-grid').style.setProperty('--pl-cols', row.dataset.tpl); });
|
|
151
|
+
L.rows.forEach((r, ri) => r.cards.forEach((c, ci) => {
|
|
152
|
+
const col = pl.querySelector(`.pl-col[data-row="${ri}"][data-col="${ci}"]`);
|
|
153
|
+
c.forEach((name) => { const el = st.cards.get(name); if (el) col.appendChild(el); });
|
|
154
|
+
if (st.on) {
|
|
155
|
+
if (st.warn && st.warn.row === ri && st.warn.col === ci) col.insertAdjacentHTML('beforeend', warnHtml(st.warn));
|
|
156
|
+
for (const name of c) { const f = fits(name, r.cols[ci]); if (f === 'no') col.insertAdjacentHTML('beforeend', `<p class="pm-meta pl-tight">${esc(name + ' needs ' + minCols(name) + ' of 12 columns: it shows compact here.')}</p>`); }
|
|
157
|
+
if (!c.length) col.insertAdjacentHTML('beforeend', '<p class="pm-meta pl-empty">Drag a card here</p>');
|
|
158
|
+
}
|
|
159
|
+
}));
|
|
160
|
+
for (const name of L.hidden) { const el = st.cards.get(name); if (el) { parked.appendChild(el); } }
|
|
161
|
+
let shelf = st.host.querySelector(':scope > .pl-shelf');
|
|
162
|
+
if (!shelf) { shelf = doc.createElement('div'); shelf.className = 'pl-shelf'; shelf.hidden = true; st.host.appendChild(shelf); }
|
|
163
|
+
shelf.appendChild(parked); // hidden cards stay in the page, out of sight, so their own code still finds them
|
|
164
|
+
st.cards.forEach((el, name) => {
|
|
165
|
+
el.draggable = st.on;
|
|
166
|
+
el.classList.toggle('pl-card', st.on);
|
|
167
|
+
const h = el.querySelector(':scope > .pl-hide');
|
|
168
|
+
if (st.on && !h) el.insertAdjacentHTML('afterbegin', `<button type="button" class="pm-btn pl-ib pl-hide" data-pl="hide" data-card="${esc(name)}" aria-label="${esc('Hide ' + name)}" title="Hide">${ic(ICON.hide)}</button>`);
|
|
169
|
+
if (!st.on && h) h.remove();
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function warnHtml(w) {
|
|
173
|
+
return `<div class="pl-warn" role="alert"><span>${esc(slotSay(w.card, w.have).say)}</span>`
|
|
174
|
+
+ `<button type="button" class="pm-btn pl-ib" data-pl="widen" aria-label="${esc('Widen this column to ' + w.need + ' and put ' + w.card + ' here')}" title="Widen to ${w.need}">${ic(ICON.widen)}</button></div>`;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function change(st, L) {
|
|
178
|
+
if (!L || L === st.work) return;
|
|
179
|
+
st.undo.push(st.work); if (st.undo.length > 40) st.undo.shift();
|
|
180
|
+
st.work = L; st.warn = null; draw(st);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
let wired = false;
|
|
184
|
+
let drag = null; // { page, card }
|
|
185
|
+
function stOf(el) { const host = el && el.closest && el.closest('.pl-host, [data-pl-page]'); return host ? Object.values(S).find((s) => s.host === host || s.host.contains(el)) : Object.values(S).find((s) => s.tools && s.tools.contains(el)); }
|
|
186
|
+
function wire(document) {
|
|
187
|
+
if (wired || !document) return; wired = true;
|
|
188
|
+
const doc = document;
|
|
189
|
+
document.addEventListener('click', (e) => {
|
|
190
|
+
const b = e.target.closest && e.target.closest('[data-pl]'); if (!b) return;
|
|
191
|
+
const st = stOf(b); if (!st) return;
|
|
192
|
+
e.preventDefault();
|
|
193
|
+
const act = b.dataset.pl;
|
|
194
|
+
if (act === 'arrange' && !st.on) { st.on = true; st.work = null; st.undo = []; b.setAttribute('aria-pressed', 'true'); draw(st); return; }
|
|
195
|
+
if (act === 'done' || act === 'arrange') { const kept = PL.dropEmptyRows(st.work); save(st.page, kept); st.saved = load(st.page) || kept; st.on = false; st.warn = null; const g = st.tools && st.tools.querySelector('[data-pl="arrange"]'); if (g) { g.setAttribute('aria-pressed', 'false'); g.focus(); } console.info('[page-arrange] saved page=' + st.page + ' rows=' + st.saved.rows.length); draw(st); return; }
|
|
196
|
+
if (act === 'reset') { save(st.page, null); st.saved = null; st.work = null; st.undo = []; st.on = false; st.warn = null; console.info('[page-arrange] reset page=' + st.page); draw(st); return; }
|
|
197
|
+
if (act === 'undo') { if (st.undo.length) { st.work = st.undo.pop(); st.warn = null; draw(st); } return; }
|
|
198
|
+
if (act === 'sel') { st.sel = Number(b.dataset.row) || 0; draw(st); return; }
|
|
199
|
+
if (act === 'split') return change(st, PL.setSplit(st.work, st.sel, b.dataset.split));
|
|
200
|
+
if (act === 'row') { const L = PL.addRow(st.work, '1:1'); st.sel = L.rows.length - 1; return change(st, L); }
|
|
201
|
+
if (act === 'hide') return change(st, PL.hide(st.work, b.dataset.card));
|
|
202
|
+
if (act === 'show') return change(st, PL.show(st.work, b.dataset.card, st.sel, 0));
|
|
203
|
+
if (act === 'widen' && st.warn) { const w = st.warn; const L = PL.widen(st.work, w.row, w.col, w.need); if (L) change(st, PL.move(L, w.card, w.row, w.col, w.index)); return; }
|
|
204
|
+
}, true);
|
|
205
|
+
document.addEventListener('dragstart', (e) => {
|
|
206
|
+
const el = e.target.closest && e.target.closest('.pl-card, .pl-chip'); if (!el) return;
|
|
207
|
+
const st = stOf(el); if (!st || !st.on) return;
|
|
208
|
+
const card = el.dataset.card || el.getAttribute('aria-label');
|
|
209
|
+
drag = { page: st.page, card }; el.classList.add('pl-drag');
|
|
210
|
+
try { e.dataTransfer.setData('text/plain', card); e.dataTransfer.effectAllowed = 'move'; } catch { /* old browser */ }
|
|
211
|
+
});
|
|
212
|
+
document.addEventListener('dragover', (e) => {
|
|
213
|
+
if (!drag) return;
|
|
214
|
+
const col = e.target.closest && e.target.closest('.pl-col'); const st = S[drag.page];
|
|
215
|
+
clearSlot(doc); if (!col || !st || !st.host.contains(col)) return;
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
const have = Number(col.dataset.cols); const s = slotSay(drag.card, have);
|
|
218
|
+
const kids = [...col.querySelectorAll(':scope > .pm-block')];
|
|
219
|
+
const index = kids.filter((k) => { const r = k.getBoundingClientRect(); return r.top + r.height / 2 < e.clientY; }).length;
|
|
220
|
+
const slot = doc.createElement('div'); slot.className = 'pl-slot ' + s.state; slot.textContent = s.say; slot.dataset.index = String(index);
|
|
221
|
+
col.insertBefore(slot, kids[index] || null);
|
|
222
|
+
});
|
|
223
|
+
document.addEventListener('drop', (e) => {
|
|
224
|
+
if (!drag) return;
|
|
225
|
+
const col = e.target.closest && e.target.closest('.pl-col'); const st = S[drag.page]; const slot = doc.querySelector('.pl-slot');
|
|
226
|
+
if (!col || !st || !slot) return;
|
|
227
|
+
e.preventDefault();
|
|
228
|
+
const row = Number(col.dataset.row), c = Number(col.dataset.col), have = Number(col.dataset.cols), index = Number(slot.dataset.index);
|
|
229
|
+
const card = drag.card; drag = null; clearSlot(doc);
|
|
230
|
+
if (fits(card, have) === 'no') { st.warn = { card, row, col: c, have, need: minCols(card), index }; draw(st); return; } // red: the card stays where it was
|
|
231
|
+
change(st, PL.move(st.work, card, row, c, index));
|
|
232
|
+
});
|
|
233
|
+
document.addEventListener('dragend', () => { drag = null; clearSlot(doc); doc.querySelectorAll('.pl-drag').forEach((x) => x.classList.remove('pl-drag')); });
|
|
234
|
+
// dividers: drag, snapped to the 12-column grid
|
|
235
|
+
document.addEventListener('pointerdown', (e) => {
|
|
236
|
+
const d = e.target.closest && e.target.closest('.pl-on .pl-div'); if (!d) return;
|
|
237
|
+
const st = stOf(d); if (!st) return;
|
|
238
|
+
e.preventDefault();
|
|
239
|
+
const grid = d.parentElement; const row = Number(d.dataset.row), i = Number(d.dataset.div); const label = d.querySelector('.pl-dl');
|
|
240
|
+
const before = st.work; let L = st.work;
|
|
241
|
+
const moveTo = (x) => {
|
|
242
|
+
const r = grid.getBoundingClientRect(); const at = Math.round(((x - r.left) / r.width) * PL.GRID);
|
|
243
|
+
const next = PL.setDivider(before, row, i, at); if (next === L) return; L = next;
|
|
244
|
+
grid.style.setProperty('--pl-cols', L.rows[row].cols.map((n) => `minmax(0, ${n}fr)`).join(' var(--space-16) '));
|
|
245
|
+
grid.querySelectorAll('.pl-col').forEach((c, ci) => { c.dataset.cols = String(L.rows[row].cols[ci]); });
|
|
246
|
+
label.hidden = false; label.textContent = L.rows[row].cols.join(' | ');
|
|
247
|
+
};
|
|
248
|
+
const up = () => { document.removeEventListener('pointermove', mv); document.removeEventListener('pointerup', up); label.hidden = true; if (L !== before) { st.work = before; change(st, L); } };
|
|
249
|
+
const mv = (ev) => moveTo(ev.clientX);
|
|
250
|
+
document.addEventListener('pointermove', mv); document.addEventListener('pointerup', up);
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
function clearSlot(doc) { doc.querySelectorAll('.pl-slot').forEach((x) => x.remove()); }
|
|
254
|
+
|
|
255
|
+
/* ── every page and popup (slice 3): the cards' own container becomes arrangeable by itself, with no wiring per page ──
|
|
256
|
+
* hostsOf(doc) the containers that hold two or more top-level cards: for each card, the nearest ancestor that holds another card;
|
|
257
|
+
* a container inside another such container joins it (Today's main and side columns are one page).
|
|
258
|
+
* Not inside a chat, nor where a page says data-pl-off. The key is the page and the container (its id, else its first class), so
|
|
259
|
+
* every initiative popup shares one layout, and each tab keeps its own. */
|
|
260
|
+
const OFF = '[data-pl-off], .pm-chat, .cz-chat, .pl-shelf';
|
|
261
|
+
const ZONE = '[role="dialog"], [aria-modal="true"], #czViewer, .cz-vw';
|
|
262
|
+
export function hostsOf(doc) {
|
|
263
|
+
const cards = [...doc.querySelectorAll('.pm-block[aria-label]')].filter((el) => !(el.parentElement && el.parentElement.closest('.pm-block')) && !el.closest(OFF) && !el.closest('.pl'))
|
|
264
|
+
.filter((el) => el.offsetParent || el.getClientRects().length); // a hidden card (a folded group) does not widen the host
|
|
265
|
+
const hosts = new Set();
|
|
266
|
+
for (const c of cards) {
|
|
267
|
+
// a popup or the viewer is its own place: its cards never share a host with the page's cards beside it
|
|
268
|
+
const zone = c.closest(ZONE); const mates = cards.filter((x) => x !== c && x.closest(ZONE) === zone);
|
|
269
|
+
let a = c.parentElement;
|
|
270
|
+
while (a && a !== doc.body && !mates.some((x) => a.contains(x))) a = a.parentElement;
|
|
271
|
+
if (a && a !== doc.body && a !== doc.documentElement) hosts.add(a);
|
|
272
|
+
}
|
|
273
|
+
return [...hosts].filter((h) => ![...hosts].some((o) => o !== h && o.contains(h)));
|
|
274
|
+
}
|
|
275
|
+
const pageName = (doc) => { const p = (doc.defaultView && doc.defaultView.location ? doc.defaultView.location.pathname : '') || ''; return (p.split('/').pop() || 'index').replace(/\.html?$/i, '') || 'index'; };
|
|
276
|
+
export const TODAY = 'today:tdPage'; // Today's cards live in #tdPage (pm/cozy-today-app.js), so this is Today's layout
|
|
277
|
+
const nameOf = (host) => host.id || String(host.className || '').trim().split(/\s+/).filter((c) => !/^pl-/.test(c))[0] || host.tagName.toLowerCase();
|
|
278
|
+
/** The layout's key: a popup's cards keep one layout wherever the popup opens (every initiative popup, every task popup); a page's are its own. */
|
|
279
|
+
export const hostKey = (page, host) => (host.closest && host.closest('[role="dialog"], [aria-modal="true"]') ? 'popup' : page) + ':' + nameOf(host);
|
|
280
|
+
function unmount(k) {
|
|
281
|
+
const st = S[k]; delete S[k]; if (!st) return;
|
|
282
|
+
st.host.removeAttribute('data-pl-page'); st.host.removeAttribute('data-pl-auto');
|
|
283
|
+
const g = st.tools && st.tools.querySelector('[data-pl="arrange"]'); if (g) g.remove();
|
|
284
|
+
if (st.tools && st.tools.classList.contains('pl-tools')) st.tools.remove();
|
|
285
|
+
}
|
|
286
|
+
function stale(host) {
|
|
287
|
+
const st = Object.values(S).find((s) => s.host === host);
|
|
288
|
+
if (!st || !(st.tools && st.tools.isConnected && st.tools.querySelector('[data-pl="arrange"]'))) return true;
|
|
289
|
+
const known = new Set(st.cards.values());
|
|
290
|
+
for (const el of cardsOf(host).values()) if (!known.has(el)) return true; // the page drew its cards again
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
let auto = false;
|
|
294
|
+
export function startAuto(doc = typeof document !== 'undefined' ? document : null) {
|
|
295
|
+
if (auto || !doc || !doc.body) return false;
|
|
296
|
+
auto = true;
|
|
297
|
+
const win = doc.defaultView; let queued = false;
|
|
298
|
+
const run = () => {
|
|
299
|
+
queued = false;
|
|
300
|
+
try {
|
|
301
|
+
const page = pageName(doc); const now = hostsOf(doc);
|
|
302
|
+
// a container that no longer holds the cards (the page drew them elsewhere) gives its icon back, unless it holds an arranged layout
|
|
303
|
+
for (const [k, st] of Object.entries(S)) {
|
|
304
|
+
if (!st.host || !st.host.hasAttribute('data-pl-auto') || st.on || now.includes(st.host) || (st.host.isConnected && st.host.querySelector(':scope > .pl'))) continue;
|
|
305
|
+
unmount(k);
|
|
306
|
+
}
|
|
307
|
+
for (const h of now) {
|
|
308
|
+
const own = h.closest('[data-pl-page]');
|
|
309
|
+
if (own && own !== h && !own.hasAttribute('data-pl-auto')) continue; // a page that mounts itself (Today) keeps its own
|
|
310
|
+
if (h.hasAttribute('data-pl-page') && !h.hasAttribute('data-pl-auto')) continue;
|
|
311
|
+
if (!stale(h)) continue;
|
|
312
|
+
mount(h, hostKey(page, h), { auto: true });
|
|
313
|
+
}
|
|
314
|
+
doc.querySelectorAll('.pl-tools').forEach((t) => { const n = t.nextElementSibling; if (!n || !n.hasAttribute('data-pl-page')) t.remove(); });
|
|
315
|
+
} catch (e) { try { console.info('[page-arrange] ' + e.message); } catch { /* no console */ } }
|
|
316
|
+
};
|
|
317
|
+
const later = () => { if (queued) return; queued = true; if (win && win.requestAnimationFrame) win.requestAnimationFrame(run); else setTimeout(run, 16); };
|
|
318
|
+
if (win && win.MutationObserver) new win.MutationObserver(later).observe(doc.body, { childList: true, subtree: true });
|
|
319
|
+
later();
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/* pm/page-layout.js — the layout a person arranges on a page (initiative page-arrange, slice 2 of arranged layouts; canvas "Page
|
|
2
|
+
* layouts you arrange", agreed by Wawan 2026-11-26). Pure: Node imports it (page-arrange.test.js); pm/page-arrange.js draws it.
|
|
3
|
+
*
|
|
4
|
+
* A page is ROWS. Each row splits the 12-column grid into columns (SPLITS: 1, 1:1, 2:1, 1:2, 3:1, 1:3, 1:1:1, or any widths of 3 or
|
|
5
|
+
* more that add up to 12, from dragging the divider). Each column holds cards, top to bottom. A card is named by its aria-label.
|
|
6
|
+
* Hidden cards wait in the tray. PMOS never moves a card by itself (Wawan, 2026-11-26): only the person changes a layout.
|
|
7
|
+
* CARDS NEVER DISAPPEAR: whole() puts a card the page shows but the layout does not name at the end of the last row, and leaves out
|
|
8
|
+
* a name the page no longer shows. A split with fewer columns moves the cards of each removed column to the end of the column on its left.
|
|
9
|
+
*
|
|
10
|
+
* key(page) the storage key, 'pmos.layout:<page>' (follows the person: lib/prefs-sync.js)
|
|
11
|
+
* valid(L) → true when L is a layout: rows of columns, widths of 3+ adding to 12
|
|
12
|
+
* whole(L, cards) → L with every card on the page exactly once (in a column or in the tray)
|
|
13
|
+
* splitName(cols) → '2:1' for [8, 4], '' for widths that are no named split
|
|
14
|
+
* setSplit(L, row, name | widths) → L with that row's columns changed; removed columns' cards go left
|
|
15
|
+
* setDivider(L, row, i, at) → L with the divider after column i moved to grid line `at`, snapped, each column 3 or more
|
|
16
|
+
* move(L, card, row, col, index) → L with the card at that place (out of the tray too)
|
|
17
|
+
* widen(L, row, col, need) → L with that column `need` wide, the others narrowed (never under 3), or null when it can not
|
|
18
|
+
* hide(L, card) · show(L, card, row, col) tray out and back
|
|
19
|
+
* addRow(L, name) · dropEmptyRows(L)
|
|
20
|
+
* rowsOf(columns) → a first layout from the page's own columns: [[cards…], …] and their widths */
|
|
21
|
+
|
|
22
|
+
export const GRID = 12;
|
|
23
|
+
export const MIN = 3;
|
|
24
|
+
export const SPLITS = Object.freeze({ '1': [12], '1:1': [6, 6], '2:1': [8, 4], '1:2': [4, 8], '3:1': [9, 3], '1:3': [3, 9], '1:1:1': [4, 4, 4] });
|
|
25
|
+
export const NAMES = Object.freeze(Object.keys(SPLITS));
|
|
26
|
+
export const PREFIX = 'pmos.layout:';
|
|
27
|
+
export const key = (page) => PREFIX + String(page || 'page');
|
|
28
|
+
|
|
29
|
+
const copy = (L) => JSON.parse(JSON.stringify(L));
|
|
30
|
+
const sum = (a) => a.reduce((x, y) => x + y, 0);
|
|
31
|
+
const okWidths = (w) => Array.isArray(w) && w.length >= 1 && w.length <= 4 && w.every((n) => Number.isInteger(n) && n >= MIN) && sum(w) === GRID;
|
|
32
|
+
|
|
33
|
+
export function splitName(cols) {
|
|
34
|
+
const s = (cols || []).join(',');
|
|
35
|
+
return NAMES.find((n) => SPLITS[n].join(',') === s) || '';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function valid(L) {
|
|
39
|
+
if (!L || typeof L !== 'object' || !Array.isArray(L.rows) || !L.rows.length || L.rows.length > 12) return false;
|
|
40
|
+
if (L.hidden != null && !Array.isArray(L.hidden)) return false;
|
|
41
|
+
return L.rows.every((r) => r && okWidths(r.cols) && Array.isArray(r.cards) && r.cards.length === r.cols.length
|
|
42
|
+
&& r.cards.every((c) => Array.isArray(c) && c.every((x) => typeof x === 'string' && x)));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Every card the page shows exactly once; names the page does not show are left out (kept nowhere). */
|
|
46
|
+
export function whole(L, cards) {
|
|
47
|
+
const on = new Set(cards || []); const seen = new Set();
|
|
48
|
+
const out = { rows: [], hidden: [] };
|
|
49
|
+
for (const r of (valid(L) ? L.rows : [])) {
|
|
50
|
+
out.rows.push({ cols: r.cols.slice(), cards: r.cards.map((c) => c.filter((x) => on.has(x) && !seen.has(x) && seen.add(x))) });
|
|
51
|
+
}
|
|
52
|
+
for (const x of (valid(L) && L.hidden) || []) if (on.has(x) && !seen.has(x)) { seen.add(x); out.hidden.push(x); }
|
|
53
|
+
if (!out.rows.length) out.rows.push({ cols: [GRID], cards: [[]] });
|
|
54
|
+
const last = out.rows[out.rows.length - 1];
|
|
55
|
+
for (const x of cards || []) if (!seen.has(x)) { seen.add(x); last.cards[last.cards.length - 1].push(x); }
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function setSplit(L, row, split) {
|
|
60
|
+
const w = Array.isArray(split) ? split : SPLITS[split];
|
|
61
|
+
if (!okWidths(w) || !L.rows[row]) return L;
|
|
62
|
+
const out = copy(L); const r = out.rows[row];
|
|
63
|
+
const cards = r.cards.slice(0, w.length);
|
|
64
|
+
while (cards.length < w.length) cards.push([]);
|
|
65
|
+
for (let i = w.length; i < r.cards.length; i++) cards[w.length - 1].push(...r.cards[i]); // fewer columns: the cards go left
|
|
66
|
+
r.cols = w.slice(); r.cards = cards;
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The divider after column i moves to grid line `at` (1..11, counted from the row's left edge). */
|
|
71
|
+
export function setDivider(L, row, i, at) {
|
|
72
|
+
const r = L.rows[row]; if (!r || i < 0 || i >= r.cols.length - 1) return L;
|
|
73
|
+
const left = sum(r.cols.slice(0, i)); const pair = r.cols[i] + r.cols[i + 1];
|
|
74
|
+
const a = Math.max(MIN, Math.min(pair - MIN, Math.round(Number(at) - left)));
|
|
75
|
+
if (a === r.cols[i]) return L;
|
|
76
|
+
const out = copy(L); out.rows[row].cols[i] = a; out.rows[row].cols[i + 1] = pair - a;
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function takeOut(L, card) {
|
|
81
|
+
L.hidden = (L.hidden || []).filter((x) => x !== card);
|
|
82
|
+
for (const r of L.rows) r.cards = r.cards.map((c) => c.filter((x) => x !== card));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function move(L, card, row, col, index) {
|
|
86
|
+
if (!L.rows[row] || !L.rows[row].cards[col]) return L;
|
|
87
|
+
const out = copy(L);
|
|
88
|
+
// the index counts the column as it is drawn, with the card still in it: moving down past itself lands one higher
|
|
89
|
+
const was = out.rows[row].cards[col].indexOf(card);
|
|
90
|
+
takeOut(out, card);
|
|
91
|
+
const c = out.rows[row].cards[col];
|
|
92
|
+
let at = Number.isInteger(index) ? index : c.length;
|
|
93
|
+
if (was >= 0 && was < at) at -= 1;
|
|
94
|
+
c.splice(Math.max(0, Math.min(at, c.length)), 0, card);
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Make column `col` at least `need` wide by narrowing the others in its row (each stays 3 or more). null when the row has no room. */
|
|
99
|
+
export function widen(L, row, col, need) {
|
|
100
|
+
const r = L.rows[row]; if (!r || !r.cols[col]) return null;
|
|
101
|
+
if (r.cols[col] >= need) return L;
|
|
102
|
+
const others = r.cols.length - 1;
|
|
103
|
+
if (need > GRID - others * MIN) return null;
|
|
104
|
+
const w = r.cols.slice(); let short = need - w[col]; w[col] = need;
|
|
105
|
+
const order = w.map((n, i) => i).filter((i) => i !== col).sort((a, b) => w[b] - w[a]);
|
|
106
|
+
while (short > 0) {
|
|
107
|
+
const i = order.find((j) => w[j] > MIN); if (i == null) return null;
|
|
108
|
+
w[i] -= 1; short -= 1; order.sort((a, b) => w[b] - w[a]);
|
|
109
|
+
}
|
|
110
|
+
const out = copy(L); out.rows[row].cols = w; return out;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function hide(L, card) { const out = copy(L); takeOut(out, card); out.hidden.push(card); return out; }
|
|
114
|
+
export function show(L, card, row = 0, col = 0) { return move(L, card, row, col, 0); }
|
|
115
|
+
|
|
116
|
+
export function addRow(L, name = '1') { const out = copy(L); const w = SPLITS[name] || [GRID]; out.rows.push({ cols: w.slice(), cards: w.map(() => []) }); return out; }
|
|
117
|
+
export function dropEmptyRows(L) {
|
|
118
|
+
const out = copy(L); const keep = out.rows.filter((r) => r.cards.some((c) => c.length));
|
|
119
|
+
out.rows = keep.length ? keep : [out.rows[0]];
|
|
120
|
+
return out;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** A first layout from the page's own columns and their measured widths (px): one row, widths snapped to the grid. */
|
|
124
|
+
export function rowsOf(columns, widths) {
|
|
125
|
+
const cols = (columns || []).filter((c) => Array.isArray(c));
|
|
126
|
+
if (!cols.length) return { rows: [{ cols: [GRID], cards: [[]] }], hidden: [] };
|
|
127
|
+
if (cols.length > 4) return { rows: [{ cols: [GRID], cards: [cols.flat()] }], hidden: [] };
|
|
128
|
+
const px = (widths || []).map((n) => Number(n) || 0); const total = sum(px);
|
|
129
|
+
let w = total > 0 && px.length === cols.length ? px.map((n) => Math.max(MIN, Math.round((n / total) * GRID))) : (SPLITS[['1', '1:1', '1:1:1'][cols.length - 1]] || [12]).slice();
|
|
130
|
+
if (cols.length === 4) w = [3, 3, 3, 3];
|
|
131
|
+
while (sum(w) > GRID) { const i = w.indexOf(Math.max(...w)); w[i] -= 1; }
|
|
132
|
+
while (sum(w) < GRID) { const i = w.indexOf(Math.max(...w)); w[i] += 1; }
|
|
133
|
+
return { rows: [{ cols: w, cards: cols.map((c) => c.slice()) }], hidden: [] };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** A first layout from where the page drew its cards: [{ name, left, top, width }] and the host's width. A card almost as wide as the
|
|
137
|
+
* page is a row of its own; the others between two such rows form one row, in columns by their left edge (at most 4, else one). */
|
|
138
|
+
export function bandsOf(rects, hostWidth) {
|
|
139
|
+
const W = Number(hostWidth) || 0; const rs = (rects || []).filter((r) => r && r.name).slice().sort((a, b) => a.top - b.top || a.left - b.left);
|
|
140
|
+
const rows = []; let band = [];
|
|
141
|
+
const flush = () => {
|
|
142
|
+
if (!band.length) return;
|
|
143
|
+
const cols = [];
|
|
144
|
+
for (const r of band.slice().sort((a, b) => a.left - b.left)) {
|
|
145
|
+
const c = cols.find((x) => Math.abs(x.left - r.left) <= 24);
|
|
146
|
+
if (c) { c.items.push(r); c.width = Math.max(c.width, r.width); } else cols.push({ left: r.left, width: r.width, items: [r] });
|
|
147
|
+
}
|
|
148
|
+
const names = cols.map((c) => c.items.sort((a, b) => a.top - b.top).map((r) => r.name));
|
|
149
|
+
rows.push(...rowsOf(names.length > 4 ? [names.flat()] : names, names.length > 4 ? [] : cols.map((c) => c.width)).rows);
|
|
150
|
+
band = [];
|
|
151
|
+
};
|
|
152
|
+
for (const r of rs) { if (W && r.width >= W * 0.75) { flush(); rows.push({ cols: [GRID], cards: [[r.name]] }); } else band.push(r); }
|
|
153
|
+
flush();
|
|
154
|
+
return { rows: rows.length ? rows : [{ cols: [GRID], cards: [[]] }], hidden: [] };
|
|
155
|
+
}
|
|
@@ -21,6 +21,8 @@ export const VIEW_CONTROLS = [
|
|
|
21
21
|
'[data-card-fold]', '[data-card-fold-sug]',
|
|
22
22
|
// the reference cards' show / hide icon (pm/ref-toggle.js, fold-by-default): it only shows or hides what is already on the page
|
|
23
23
|
'[data-ref-toggle]',
|
|
24
|
+
// arranging a page (pm/page-arrange.js): it only moves, splits and hides cards on the reader's own screen, saved in their own browser
|
|
25
|
+
'[data-pl]', '.pl-div',
|
|
24
26
|
// the Timeline: the span, the legend behind (i), a column's sort, back to today, the edge tab that scrolls to a bar off the view, the Deliveries lane, the folds, an initiative's name (opens its viewer)
|
|
25
27
|
'#bdLgdBtn', '.tg-chd', '.tg-tback', '.tg-edge', '.dl-fb', '.dl-dn', '.dl-e[aria-label*="press to open"]', '.bd-fold', '.bd-prdb', 'label.tg-n', 'button.tg-n.ini2',
|
|
26
28
|
// the stage track: the switch between it and the Timeline (the two views a publisher shares), an initiative's name, the Monitor and Evaluate fold
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Every card fits its column (initiative card-size, done test planning/done-tests/card-size.md C1-C4, N1-N2): each card measured by its own width, the shared compact rules, the smallest width per card and the fits() answer arrange mode reads. No server, network or browser.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"card-size.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"card-size.test.js": 1
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Arrange a page yourself (initiative page-arrange, done test planning/done-tests/page-arrange.md A1-A6, N1-N2): rows and splits on the 12-column grid, cards moved, hidden and shown, the drop slot's warning and Widen, cards never lost, Today's arrange icon and the saved layout. No server, network or browser.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"page-arrange.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"page-arrange.test.js": 1
|
|
8
|
+
}
|
|
9
|
+
}
|