@blueshed/joined 0.2.1 → 0.3.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 (209) hide show
  1. package/.claude/skills/joined/SKILL.md +9 -1
  2. package/.claude/skills/joined/reference.md +270 -55
  3. package/.claude/skills/joined-door/SKILL.md +57 -0
  4. package/README.md +19 -50
  5. package/docs/design.md +76 -10
  6. package/docs/introduction.md +18 -18
  7. package/docs/light-and-shadow.svg +1 -1
  8. package/examples/README.md +20 -0
  9. package/examples/account/account.json +1 -0
  10. package/examples/account/derive.ts +41 -0
  11. package/examples/account/generated/elements.ts +52 -0
  12. package/examples/account/generated/rows.ts +22 -0
  13. package/examples/account/generated/rules.ts +32 -0
  14. package/examples/account/routes.ts +5 -0
  15. package/examples/app.css +2 -1
  16. package/examples/cafe/books.html +2 -2
  17. package/examples/cafe/cafe.css +9 -16
  18. package/examples/cafe/generated/books.rows.ts +22 -0
  19. package/examples/cafe/generated/books.rules.ts +3 -2
  20. package/examples/cafe/generated/kitchen.rows.ts +27 -0
  21. package/examples/cafe/generated/kitchen.rules.ts +11 -1
  22. package/examples/cafe/generated/menu.rows.ts +22 -0
  23. package/examples/cafe/generated/menu.rules.ts +3 -2
  24. package/examples/cafe/generated/order.rows.ts +27 -0
  25. package/examples/cafe/generated/order.rules.ts +11 -1
  26. package/examples/cafe/generated/staff.rows.ts +22 -0
  27. package/examples/cafe/generated/staff.rules.ts +6 -1
  28. package/examples/cafe/generated/supplies.queries.ts +4 -2
  29. package/examples/cafe/generated/supplies.rows.ts +22 -0
  30. package/examples/cafe/generated/supplies.rules.ts +12 -1
  31. package/examples/cafe/generated/till.queries.ts +2 -0
  32. package/examples/cafe/generated/till.rows.ts +27 -0
  33. package/examples/cafe/generated/till.rules.ts +11 -1
  34. package/examples/cafe/index.html +14 -15
  35. package/examples/cafe/kitchen.ts +1 -1
  36. package/examples/cafe/look.ts +30 -0
  37. package/examples/cafe/menu.html +10 -26
  38. package/examples/cafe/menu.ts +8 -80
  39. package/examples/cafe/order.html +6 -6
  40. package/examples/cafe/order.ts +5 -1
  41. package/examples/cafe/routes.ts +0 -1
  42. package/examples/cafe/stories.jsonl +3 -1
  43. package/examples/cafe/supplies.html +34 -34
  44. package/examples/cafe/supplies.ts +14 -11
  45. package/examples/cafe/till.ts +5 -1
  46. package/examples/chart/arches.ts +148 -0
  47. package/examples/chart/chart.css +6 -0
  48. package/examples/chart/chart.json +87 -0
  49. package/examples/chart/generated/elements.ts +105 -0
  50. package/examples/chart/generated/queries.ts +36 -0
  51. package/examples/chart/generated/rows.ts +27 -0
  52. package/examples/chart/generated/rules.ts +111 -0
  53. package/examples/chart/grid.ts +118 -0
  54. package/examples/chart/index.html +78 -0
  55. package/examples/chart/migrations/001-chart.ts +6 -0
  56. package/examples/chart/migrations/002-create-conditions.ts +6 -0
  57. package/examples/chart/page.ts +20 -0
  58. package/examples/chart/routes.ts +7 -0
  59. package/examples/chart/stories.jsonl +14 -0
  60. package/examples/chart/teeth.ts +57 -0
  61. package/examples/desk/generated/rows.ts +22 -0
  62. package/examples/desk/generated/rules.ts +34 -1
  63. package/examples/desk/index.html +9 -2
  64. package/examples/desk/routes.ts +0 -2
  65. package/examples/desk/stories.jsonl +3 -2
  66. package/examples/desk/thumbs.ts +2 -2
  67. package/examples/hello/generated/elements.ts +2 -2
  68. package/examples/hello/generated/rules.ts +3 -2
  69. package/examples/hello/hello.css +2 -4
  70. package/examples/hello/index.html +10 -3
  71. package/examples/hello/page.ts +4 -4
  72. package/examples/index.html +4 -5
  73. package/examples/notes/generated/elements.ts +112 -0
  74. package/examples/notes/generated/queries.ts +36 -0
  75. package/examples/notes/generated/rows.ts +27 -0
  76. package/examples/notes/generated/rules.ts +133 -0
  77. package/examples/notes/index.html +32 -0
  78. package/examples/notes/look.ts +41 -0
  79. package/examples/notes/migrations/001-notes.ts +7 -0
  80. package/examples/notes/notes.json +78 -0
  81. package/examples/notes/page.ts +21 -0
  82. package/examples/notes/routes.ts +6 -0
  83. package/examples/notes/stories.jsonl +21 -0
  84. package/examples/people/generated/rows.ts +22 -0
  85. package/examples/people/generated/rules.ts +11 -1
  86. package/examples/people/links.ts +2 -1
  87. package/examples/people/routes.ts +1 -3
  88. package/examples/people/stories.jsonl +1 -0
  89. package/examples/people/view.ts +5 -2
  90. package/examples/trip/generated/elements.ts +4 -2
  91. package/examples/trip/generated/queries.ts +12 -1
  92. package/examples/trip/generated/rows.ts +27 -0
  93. package/examples/trip/generated/rules.ts +56 -2
  94. package/examples/trip/index.html +58 -12
  95. package/examples/trip/line.css +186 -0
  96. package/examples/trip/line.ts +51 -40
  97. package/examples/trip/page.ts +65 -71
  98. package/examples/trip/routes.ts +9 -5
  99. package/examples/trip/stays.css +12 -12
  100. package/examples/trip/stays.ts +15 -10
  101. package/examples/trip/stories.jsonl +2 -0
  102. package/examples/trip/told.ts +3 -26
  103. package/examples/trip/trip.css +16 -0
  104. package/examples/trips/generated/rows.ts +22 -0
  105. package/examples/trips/generated/rules.ts +9 -1
  106. package/examples/trips/index.html +10 -10
  107. package/examples/trips/map.ts +3 -14
  108. package/examples/trips/new-trip.ts +14 -16
  109. package/examples/weeks/generated/elements.ts +1 -1
  110. package/examples/weeks/generated/queries.ts +11 -0
  111. package/examples/weeks/generated/rows.ts +22 -0
  112. package/examples/weeks/generated/rules.ts +11 -5
  113. package/examples/weeks/routes.ts +3 -2
  114. package/examples/weeks/stories.jsonl +1 -0
  115. package/examples/welcome.css +7 -5
  116. package/package.json +8 -2
  117. package/src/awesome.ts +103 -0
  118. package/src/board.css +75 -0
  119. package/src/board.ts +173 -0
  120. package/src/cli.ts +15 -2
  121. package/src/compile.ts +569 -35
  122. package/src/definitions.ts +53 -15
  123. package/src/draft.ts +38 -23
  124. package/src/drawer.ts +222 -0
  125. package/src/engine.ts +240 -166
  126. package/src/fields.ts +268 -0
  127. package/src/files.ts +6 -4
  128. package/src/ground.ts +110 -0
  129. package/src/icon-names.ts +15 -2
  130. package/src/kit.ts +51 -0
  131. package/src/link.ts +3 -3
  132. package/src/map.css +133 -0
  133. package/src/map.ts +200 -0
  134. package/src/mcp.ts +176 -38
  135. package/src/members/demo.ts +13 -12
  136. package/src/members/generated/rows.ts +22 -0
  137. package/src/members/generated/rules.ts +3 -2
  138. package/src/members/group.ts +65 -39
  139. package/src/members/keys.ts +93 -77
  140. package/src/members/panel.css +23 -17
  141. package/src/members/panel.ts +49 -35
  142. package/src/migrate.ts +120 -104
  143. package/src/month.css +125 -0
  144. package/src/month.ts +179 -0
  145. package/src/page.css +8 -0
  146. package/src/page.ts +11 -7
  147. package/src/parts.css +462 -170
  148. package/src/parts.ts +209 -26
  149. package/src/plane.css +56 -0
  150. package/src/plane.ts +151 -0
  151. package/src/postgres-server.ts +60 -0
  152. package/src/reading.css +77 -0
  153. package/src/reading.ts +238 -0
  154. package/src/rows.css +308 -0
  155. package/src/rows.ts +780 -0
  156. package/src/search.css +80 -0
  157. package/src/search.ts +130 -0
  158. package/src/server.ts +211 -114
  159. package/src/settings.ts +9 -4
  160. package/src/sheet.ts +114 -0
  161. package/src/skill.ts +40 -0
  162. package/src/slots.css +94 -0
  163. package/src/slots.ts +213 -0
  164. package/src/specs.ts +38 -0
  165. package/src/starter.ts +5 -2
  166. package/src/store.ts +184 -143
  167. package/src/stories.ts +43 -11
  168. package/src/surface.ts +159 -0
  169. package/src/timeline.css +111 -0
  170. package/src/timeline.ts +226 -0
  171. package/src/toast.ts +21 -48
  172. package/src/together.ts +0 -7
  173. package/src/tokens.css +78 -1
  174. package/src/tokens.json +249 -0
  175. package/src/tool.ts +211 -0
  176. package/src/upkeep.ts +18 -20
  177. package/src/views.css +44 -0
  178. package/src/views.ts +94 -0
  179. package/src/week.css +151 -0
  180. package/src/week.ts +250 -0
  181. package/src/write.ts +219 -73
  182. package/starter/CLAUDE.md +3 -3
  183. package/starter/bunfig +4 -0
  184. package/starter/prettierignore +4 -0
  185. package/starter/tests/hello.test.ts +2 -0
  186. package/docs/learning.md +0 -76
  187. package/examples/cafe/trust.ts +0 -20
  188. package/examples/desk/trust.ts +0 -24
  189. package/examples/people/trust.ts +0 -14
  190. package/examples/trip/answer-rows.ts +0 -70
  191. package/examples/trip/bar.ts +0 -89
  192. package/examples/trip/calendar-map.css +0 -711
  193. package/examples/trip/calendar-map.ts +0 -249
  194. package/examples/trip/drags.ts +0 -143
  195. package/examples/trip/drawer.ts +0 -250
  196. package/examples/trip/event-form.ts +0 -200
  197. package/examples/trip/holding.ts +0 -61
  198. package/examples/trip/map.ts +0 -234
  199. package/examples/trip/month.ts +0 -87
  200. package/examples/trip/other-weeks.ts +0 -67
  201. package/examples/trip/peek.ts +0 -71
  202. package/examples/trip/people-chips.ts +0 -74
  203. package/examples/trip/shell.ts +0 -39
  204. package/examples/trip/trust.ts +0 -51
  205. package/examples/trip/week.ts +0 -237
  206. package/examples/trip/writes.ts +0 -91
  207. package/examples/trip/zones.ts +0 -16
  208. package/examples/weeks/derive.ts +0 -23
  209. package/src/scrim.ts +0 -81
@@ -0,0 +1,186 @@
1
+ /* <trip-line> (./line.ts), in its shadow, over joined's parts. */
2
+ /* the week read as a line (./line.ts): the line's geometry is LINE-UX's, a 62px gutter, the line 7px wide at
3
+ 30px, each bead centred on it; filled and hollow share one box and differ only in fill. Colour is identity: an
4
+ event's hue on its card's stripe, a person's on their face. */
5
+ .reading {
6
+ font: var(--font-row);
7
+ color: var(--ink);
8
+ }
9
+ /* whose line it is: a chip for each person, a face and a name, the reader's pressed (src/parts.css) */
10
+ .reading .faces {
11
+ margin: 0 0 var(--space-14);
12
+ }
13
+
14
+ /* the line, down the days */
15
+ .reading .line {
16
+ position: relative;
17
+ list-style: none;
18
+ margin: 0;
19
+ padding: 0 0 0 62px;
20
+ }
21
+ .reading .line::before {
22
+ content: "";
23
+ position: absolute;
24
+ left: 30px;
25
+ top: 10px;
26
+ bottom: 10px;
27
+ width: 7px;
28
+ background: var(--ink);
29
+ }
30
+ .reading .line > li {
31
+ position: relative;
32
+ }
33
+ /* where we sleep: each night's run of the line in its stay's hue, from its first night to its last; its name and
34
+ nights where it begins; a change of stay an interchange, a ring across the line */
35
+ .reading .line > li::before {
36
+ content: "";
37
+ position: absolute;
38
+ left: -32px;
39
+ top: 0;
40
+ bottom: 0;
41
+ width: 7px;
42
+ background: var(--stay, transparent);
43
+ }
44
+ .reading .date .stay {
45
+ display: block;
46
+ margin-top: 2px;
47
+ padding-left: var(--space-8);
48
+ border-left: 3px solid var(--stay);
49
+ font: var(--font-small);
50
+ color: var(--muted);
51
+ }
52
+ .reading .date.interchange::after {
53
+ content: "";
54
+ position: absolute;
55
+ z-index: 1;
56
+ left: -45px;
57
+ top: 16px;
58
+ width: 33px;
59
+ height: 9px;
60
+ box-sizing: border-box;
61
+ border: 3px solid var(--ink);
62
+ border-radius: 4px;
63
+ background: var(--card);
64
+ }
65
+ .reading .date {
66
+ padding: 14px 0 6px;
67
+ font: var(--font-label);
68
+ }
69
+ .reading .stop {
70
+ padding: 0 0 8px;
71
+ }
72
+ .reading .bead {
73
+ position: absolute;
74
+ box-sizing: border-box;
75
+ left: -42px;
76
+ top: 14px;
77
+ width: 27px;
78
+ height: 10px;
79
+ border: 2px solid var(--ink);
80
+ border-radius: 5px;
81
+ }
82
+ .reading .bead.filled {
83
+ background: var(--ink);
84
+ }
85
+ .reading .bead.hollow {
86
+ background: var(--card);
87
+ }
88
+ /* the reader's answer: keen, the bead pierced; asked and not yet said, ringed */
89
+ .reading .bead.keen {
90
+ background: radial-gradient(circle, var(--card) 0 2px, var(--ink) 2.5px);
91
+ }
92
+ .reading .bead.asked {
93
+ outline: 2px solid var(--ink);
94
+ outline-offset: 2px;
95
+ }
96
+ /* where the reader lands partway, an interchange; where they go home, a terminus */
97
+ .reading .bead.lands {
98
+ left: -45px;
99
+ width: 33px;
100
+ height: 9px;
101
+ border-width: 3px;
102
+ border-radius: 4px;
103
+ background: var(--card);
104
+ }
105
+ .reading .bead.home {
106
+ left: -45px;
107
+ width: 33px;
108
+ height: 9px;
109
+ border-width: 3px;
110
+ border-radius: 4px;
111
+ background: var(--ink);
112
+ }
113
+ /* who comes and goes at an event, said on its card */
114
+ .reading .card .gates {
115
+ font: var(--font-small);
116
+ color: var(--ink);
117
+ }
118
+ /* events at one time: in lanes, side by side, for a while */
119
+ .reading .while .lanes {
120
+ display: grid;
121
+ grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
122
+ gap: var(--space-6);
123
+ }
124
+ /* each face as they've answered: asked, its ring dashed; no, faint */
125
+ .reading .who .j-face[data-answer="asked"] {
126
+ border-style: dashed;
127
+ }
128
+ .reading .who .j-face[data-answer="declined"] {
129
+ opacity: 0.4;
130
+ }
131
+ .reading .end {
132
+ height: 20px;
133
+ }
134
+ .reading .bead.terminus {
135
+ left: -45px;
136
+ top: 5px;
137
+ width: 33px;
138
+ height: 9px;
139
+ border-width: 3px;
140
+ border-radius: 4px;
141
+ background: var(--card);
142
+ }
143
+
144
+ /* an event's card: a button that opens it, its hue a stripe; without you, set back and quieter */
145
+ .reading .card {
146
+ display: grid;
147
+ gap: 2px;
148
+ width: 100%;
149
+ box-sizing: border-box;
150
+ padding: 6px 10px;
151
+ border: 1px solid var(--line);
152
+ border-left: 3px solid var(--hue);
153
+ border-radius: 4px;
154
+ background: var(--card);
155
+ color: var(--ink);
156
+ font: var(--font-row);
157
+ text-align: left;
158
+ cursor: pointer;
159
+ }
160
+ .reading .card:hover {
161
+ background: var(--card-hover);
162
+ }
163
+ .reading .card b {
164
+ font-weight: 600;
165
+ }
166
+ .reading .card span {
167
+ font: var(--font-small);
168
+ color: var(--muted);
169
+ }
170
+ .reading .card .who {
171
+ display: flex;
172
+ gap: 3px;
173
+ margin-top: 2px;
174
+ }
175
+ .reading .card[picked] {
176
+ outline: 2px solid var(--ink);
177
+ outline-offset: 1px;
178
+ background: color-mix(in srgb, var(--hue) var(--tint), var(--card));
179
+ }
180
+ .reading .without .card {
181
+ margin-left: 16px;
182
+ width: calc(100% - 16px);
183
+ opacity: 0.66;
184
+ }
185
+
186
+ /* its buttons are joined's (src/parts.css, adopted before this) */
@@ -1,60 +1,69 @@
1
- // The line: the week's events read as one line down its days (Can You's line, japan-eta's LINE-UX), drawn by
2
- // <calendar-map> in place of its calendar, beside the same map. Each event is a bead on the line and a card beside
3
- // it, drawn as ./line-stops.ts says, from what the event says to the reader (./line-words.ts). The reader is
4
- // whoever is signed in, as a person of the same name; a tap on a face reads the line as theirs. A tap on a card picks
5
- // its event, as a block or a pin does, and opens it in the display's drawer.
1
+ // <trip-line for="events" people="the-people" stays="the-stays">: the week's events read as one line down its days (Can
2
+ // You's line, japan-eta's LINE-UX), a reading of the trip's own beside the kit's (joined/kit's Reading: the week the
3
+ // readings show, what the search finds, the events' sheet). Each event is a bead on the line and a card beside it,
4
+ // drawn as ./line-stops.ts says, from what the event says to the reader (./line-words.ts). The reader is whoever is
5
+ // signed in, as a person of the same name; a tap on a face reads the line as theirs. A tap on a card opens its event
6
+ // in the sheet. The people and the stays are the lists it's told of (./told.ts).
6
7
 
7
- import type { JEvent, JStay } from "./generated/elements.ts";
8
- import type { JPerson } from "../people/generated/elements.ts";
8
+ import type { JEvent } from "./generated/elements.ts";
9
9
  import { hueOf } from "joined/hues";
10
10
  import { keep, type Row } from "joined/keep";
11
+ import { Reading } from "joined/kit";
11
12
  import { face } from "joined/parts";
12
13
  import { members, signedIn } from "joined/panel";
13
14
  import { end, station, stop } from "./line-stops.ts";
14
15
  import { saidOf, whiles } from "./line-words.ts";
15
- import { dated, dayOf, stayed } from "joined/time";
16
+ import { Told } from "./told.ts";
17
+ import { dated, dayOf, mondayOf, stayed } from "joined/time";
18
+ import STYLE from "./line.css" with { type: "text" };
16
19
 
17
- /** What the line reads from its display: its events, the people by key and as elements, the event picked, how to pick
18
- * one, the stays, and the week shown. */
19
- type From = {
20
- events: () => JEvent[];
21
- people: () => Map<number, string>;
22
- persons: () => Iterable<JPerson>;
23
- picked: () => JEvent | null;
24
- pick: (el: JEvent) => void;
25
- stays: () => JStay[];
26
- week: () => number;
27
- };
20
+ const SHEET = new CSSStyleSheet();
21
+ SHEET.replaceSync(STYLE);
28
22
 
29
- export class Line {
23
+ class TripLine extends Reading {
24
+ static override sheets = [SHEET];
30
25
  #kept = { faces: new Map(), line: new Map() } as Record<string, Map<string, { shows: string; el: HTMLElement }>>;
31
26
  #me: number | null = null; // the person who's the signed-in member: said to be them, or of their name
32
27
  #member: number | null = null; // who's signed in
33
28
  #reader: number | null = null; // whose line it is: the reader's, or a face tapped
34
- #faces: HTMLElement;
35
- #line: HTMLElement;
36
- #from: From;
29
+ #faces = Object.assign(document.createElement("div"), {
30
+ className: "faces j-chips",
31
+ role: "group",
32
+ ariaLabel: "Whose line",
33
+ });
34
+ #line = Object.assign(document.createElement("ol"), { className: "line", ariaLabel: "The week, day by day" });
35
+ #told = new Told(this);
36
+ #away = new AbortController();
37
37
 
38
- /** Drawn in `faces` and `line`, from its display; it listens for who's signed in until `signal` lets it go. */
39
- constructor(faces: HTMLElement, line: HTMLElement, from: From, signal?: AbortSignal) {
40
- [this.#faces, this.#line, this.#from] = [faces, line, from];
41
- signedIn((me) => ((this.#member = me), this.draw()), signal);
38
+ protected made() {
39
+ const reading = Object.assign(document.createElement("div"), { className: "reading" });
40
+ reading.append(this.#faces, this.#line);
41
+ this.root.append(reading);
42
+ }
43
+ override connectedCallback() {
44
+ super.connectedCallback();
45
+ this.#away = new AbortController();
46
+ signedIn((me) => ((this.#member = me), this.again()), this.#away.signal);
47
+ }
48
+ override disconnectedCallback() {
49
+ super.disconnectedCallback();
50
+ this.#away.abort();
42
51
  }
43
52
 
44
53
  /** The person who's whoever is signed in: the one they've said is them, else the one with their name. */
45
54
  #meOf() {
46
55
  if (this.#member === null) return null;
47
- const said = [...this.#from.persons()].find((p) => p.data.member === this.#member);
56
+ const said = [...this.#told.persons()].find((p) => p.data.member === this.#member);
48
57
  if (said) return said.key;
49
58
  const name = [...members].find((m) => m.key === this.#member)?.data.name.toLowerCase();
50
- return [...this.#from.people()].find(([, n]) => n.toLowerCase() === name)?.[0] ?? null;
59
+ return [...this.#told.people()].find(([, n]) => n.toLowerCase() === name)?.[0] ?? null;
51
60
  }
52
- draw() {
61
+ protected draw() {
53
62
  const was = this.#me;
54
63
  this.#me = this.#meOf();
55
64
  // the reader follows you, unless a face was tapped
56
65
  if (this.#reader === null || this.#reader === was) this.#reader = this.#me;
57
- const names = this.#from.people();
66
+ const names = this.#told.people();
58
67
  // the faces: a person each, the line's reader pressed
59
68
  keep(
60
69
  this.#faces,
@@ -74,11 +83,13 @@ export class Line {
74
83
  },
75
84
  })),
76
85
  );
77
- // the line: a day a station (each with an event, or a stay beginning), an event a stop, in the order they
78
- // happen; each the colour of the stay that night, from its first to its last
79
- const events = this.#from.events().sort((a, b) => a.data.start.localeCompare(b.data.start));
80
- const stays = this.#from.stays().sort((a, b) => a.data.from.localeCompare(b.data.from)),
81
- week = this.#from.week();
86
+ // the line: the week shown, a day a station (each with an event, or a stay beginning), an event a stop, in the
87
+ // order they happen; each the colour of the stay that night, from its first to its last
88
+ const week = mondayOf(this.day);
89
+ const events = (this.items() as JEvent[])
90
+ .filter((el) => dayOf(el.data.start) >= week && dayOf(el.data.start) < week + 7)
91
+ .sort((a, b) => a.data.start.localeCompare(b.data.start));
92
+ const stays = this.#told.stays().sort((a, b) => a.data.from.localeCompare(b.data.from));
82
93
  const stayOn = (d: number) => stays.find((s) => dayOf(s.data.from) <= d && d < dayOf(s.data.until)) ?? null;
83
94
  const days = [
84
95
  ...new Set([
@@ -86,8 +97,7 @@ export class Line {
86
97
  ...stays.map((s) => dayOf(s.data.from)).filter((d) => d >= week && d < week + 7),
87
98
  ]),
88
99
  ].sort((a, b) => a - b);
89
- const reading = { reader: this.#reader, names },
90
- picked = this.#from.picked();
100
+ const reading = { reader: this.#reader, names };
91
101
  const rows: Row[] = [{ key: "begins", shows: "", make: () => end("begins") }];
92
102
  for (const [i, d] of days.entries()) {
93
103
  const words = dated(
@@ -107,11 +117,11 @@ export class Line {
107
117
  // its events, one after another; those at one time side by side, the group in lanes for a while: a stop kept
108
118
  // while what it says is as it was
109
119
  for (const group of whiles(events.filter((e) => dayOf(e.data.start) === d))) {
110
- const said = group.map((el) => saidOf(el, el === picked, reading));
120
+ const said = group.map((el) => saidOf(el, this.opened(el), reading));
111
121
  rows.push({
112
122
  key: `event ${group.map((el) => el.key).join(" ")}`,
113
123
  shows: JSON.stringify([said, stay?.key]),
114
- make: () => stop(group, said, names, stay, (el) => this.#from.pick(el)),
124
+ make: () => stop(group, said, names, stay, (el) => this.open(el)),
115
125
  });
116
126
  }
117
127
  }
@@ -119,3 +129,4 @@ export class Line {
119
129
  keep(this.#line, this.#kept.line!, rows);
120
130
  }
121
131
  }
132
+ customElements.define("trip-line", TripLine);
@@ -1,95 +1,92 @@
1
- // A trip's page, at /trip/<key>: it holds its documents by having their collections on it: a week of the trip's
2
- // events, <j-events>, and its weeks, <j-weeks> (../weeks), inside <calendar-map>, which draws them, the week as a
3
- // calendar, a line (?view=line) or a month (?view=month) beside a map; and <j-people>, in a sheet, whose <j-person>s draw themselves (the
4
- // people's own view, ../people/view.ts). The events are the trip's own, trip:<key>, one of the trips (../trips), a
5
- // week of it: trip:1?week=2026-11-02, the week its address names (?week=), or, none named, the week with today in it
6
- // while the trip is on, else its first; another week, as the calendar asks (a "week" event), is held in place of it.
7
- // An event links to people by their keys. A .ics file coming in is events to add, sent as any other write; the whole
8
- // trip goes out as /trip/<key>/trip.ics. The trips (../trips) are held too, for this trip's name, the page's.
1
+ // A trip's page, at /trip/<key>: joined's kit reads its events (../../src/kit.ts): a week, the trip's own line
2
+ // (./line.ts) or a month, beside its map, each the way into the events' sheet. It holds the trip's events by having
3
+ // their collection on it, <j-events>, a window of them: the six weeks of the month the readings show (trip:1?month=
4
+ // 2026-10-26, its grid's first Monday), held again as they're moved to another. It opens on the week with today in it
5
+ // while the trip is on, else its first (its weeks, ../weeks, as ./routes.ts answers them). <j-people>, in a sheet, whose
6
+ // <j-person>s draw themselves (the people's own view, ../people/view.ts), and a link of theirs opens its event. A
7
+ // .ics file coming in is events to add, sent as any other write; the whole trip goes out as /trip/<key>/trip.ics.
8
+ // The trips (../trips) are held too, for this trip's name, the page's.
9
9
 
10
10
  import { fromIcs } from "joined/ics";
11
11
  import "../people/view.ts";
12
12
  import { addingPeople } from "../people/adding.ts";
13
13
  import { booking } from "./stays.ts";
14
- import "./calendar-map.ts";
14
+ import "./line.ts";
15
15
  import "joined/panel";
16
16
  import "joined/toast";
17
+ import { use } from "joined/kit";
17
18
  import { iconify } from "joined/icons";
18
- import { said, showsOpen } from "joined/parts";
19
- import { JWeek } from "../weeks/generated/elements.ts";
19
+ import { said } from "joined/parts";
20
+ import { sheets } from "joined/surface";
20
21
  import { JEvent, type JEvents } from "./generated/elements.ts";
22
+ import { specs } from "./generated/rows.ts";
21
23
  import { JTrip } from "../trips/generated/elements.ts";
22
24
  import * as trips from "../trips/generated/rules.ts";
23
25
  import * as trip from "./generated/rules.ts";
24
- import * as weeks from "../weeks/generated/rules.ts";
25
26
  import { DAY, dayOf, gridOf, local, now, wall, weekOf } from "joined/time";
26
27
 
28
+ use(specs);
27
29
  const key = location.pathname.split("/").filter(Boolean).at(-1);
28
30
  document.querySelector<HTMLAnchorElement>("a[download]")!.href = `/trip/${key}/trip.ics`;
29
31
 
30
- const cal = document.querySelector("calendar-map")!;
31
- /** What the page's address says: the week held, and how it's read (a calendar, ?view=line or ?view=month); and what
32
- * it no longer says, taken off. */
33
- function address(name: string, value: string, off?: string) {
32
+ /** The month held: its grid's first Monday. */
33
+ let held = "";
34
+ /** The window that holds a day (the six weeks of its month), held in place of what was held before: the events, and
35
+ * the stays, all of them, held as the same document. */
36
+ function hold(day: string) {
37
+ const month = local(gridOf(dayOf(day)) * DAY).slice(0, 10);
38
+ if (month === held) return;
39
+ held = month;
40
+ for (const [c, into] of [
41
+ [trip.collections.events, document.getElementById("held")!],
42
+ [trip.collections.stays, document.getElementById("the-stays")!],
43
+ ] as const) {
44
+ const fresh = document.createElement(c.place);
45
+ fresh.setAttribute("doc", `trip:${key}?month=${month}`);
46
+ const was = document.querySelector(c.place);
47
+ if (was) was.replaceWith(fresh);
48
+ else into.append(fresh);
49
+ }
50
+ }
51
+ /** The day the readings show, said in the address: they show it, and it's held. */
52
+ function show(day: string) {
34
53
  const url = new URL(location.href);
35
- url.searchParams.set(name, value);
36
- if (off) url.searchParams.delete(off);
54
+ url.searchParams.set("day", day);
55
+ url.searchParams.delete("week");
56
+ url.searchParams.delete("month");
37
57
  history.replaceState(history.state, "", url);
58
+ document.dispatchEvent(new CustomEvent("j-day", { detail: { param: "day", day } }));
38
59
  }
39
- /** A week of the trip held, or a month (six weeks from the Monday its grid starts on), in place of what was held
40
- * before, and named in the page's address. */
41
- function hold(by: "week" | "month", day: string) {
42
- const events = document.createElement(trip.collections.events.place);
43
- events.setAttribute("doc", `trip:${key}?${by}=${day}`);
44
- const was = cal.querySelector(trip.collections.events.place);
45
- if (was) was.replaceWith(events);
46
- else cal.append(events);
47
- // its stays, all of them, held as the same document: its window is the events'
48
- const stays = document.createElement(trip.collections.stays.place);
49
- stays.setAttribute("doc", `trip:${key}?${by}=${day}`);
50
- const had = document.querySelector(trip.collections.stays.place);
51
- if (had) had.replaceWith(stays);
52
- else document.querySelector("#stays header")!.after(stays);
53
- address(by, day, by === "week" ? "month" : "week");
54
- }
55
- /** A week held as the page reads it: as a month, the month it's in. */
56
- const holdWeek = (week: string) =>
57
- cal.getAttribute("view") === "month"
58
- ? hold("month", local(gridOf(dayOf(week) + 3) * DAY).slice(0, 10))
59
- : hold("week", week);
60
- cal.addEventListener("week", (e) => hold("week", (e as CustomEvent<string>).detail));
61
- cal.addEventListener("month", (e) => hold("month", (e as CustomEvent<string>).detail));
62
- // the week read as a line or the month, if its address says so; another reading chosen, said there
63
- const view = new URLSearchParams(location.search).get("view");
64
- if (view === "line" || view === "month") cal.setAttribute("view", view);
65
- cal.addEventListener("view", (e) => address("view", (e as CustomEvent<string>).detail));
60
+ // another day shown by a reading: its month held, if it isn't
61
+ document.addEventListener("j-day", (e) => {
62
+ const d = (e as CustomEvent<{ param: string; day: string }>).detail;
63
+ if (d.param === "day") hold(d.day);
64
+ });
65
+ // a person's link to an event opens it (../people/links.ts)
66
+ document.addEventListener("pick", (e) => {
67
+ const el = e.target as Element;
68
+ if (el.localName === trip.collections.events.tag)
69
+ document.querySelector<HTMLElement & { show(it: Element): void }>(`j-sheet[for="events"]`)?.show(el);
70
+ });
66
71
  const params = new URLSearchParams(location.search),
67
- asked = params.get("week") ?? params.get("month") ?? "";
72
+ asked = params.get("day") ?? params.get("week") ?? params.get("month") ?? "";
68
73
  if (/^\d{4}-\d{2}-\d{2}$/.test(asked) && Number.isFinite(wall(`${asked}T00:00:00`)))
69
74
  // a month is named by the Monday its grid starts on, which may be the month before's: a week on, it's the month's
70
- params.has("month") && cal.getAttribute("view") === "month"
71
- ? hold("month", local(gridOf(dayOf(asked) + 7) * DAY).slice(0, 10))
72
- : holdWeek(weekOf(asked));
73
- else {
74
- // none named: once the trip's weeks are here, today's (where the person is) while the trip is on, else its first;
75
- // no weeks, today's
76
- const opening = () => {
77
- const today = weekOf(now()),
78
- held = [...document.getElementsByTagName(weeks.collections.weeks.tag)]
79
- .map((w) => (w as JWeek).data)
80
- .filter((w) => String(w.trip) === key);
81
- holdWeek(held.length && !(today >= held[0]!.week && today <= held.at(-1)!.week) ? held[0]!.week : today);
82
- };
83
- if (document.body.dataset.weeks !== undefined) opening();
84
- else
85
- new MutationObserver((_, seen) => {
86
- if (document.body.dataset.weeks === undefined) return;
87
- seen.disconnect();
88
- opening();
89
- }).observe(document.body, { attributeFilter: ["data-weeks"] });
90
- }
75
+ show(params.has("month") && !params.has("day") ? local((dayOf(asked) + 7) * DAY).slice(0, 10) : asked);
76
+ else
77
+ // none named: today's (where the person is) while the trip is on, else its first week; no weeks, today's
78
+ void fetch(`/trip/${key}/weeks`)
79
+ .then((r) => (r.ok ? r.json() : []))
80
+ .then((had: string[]) => {
81
+ const today = weekOf(now());
82
+ show(
83
+ had.length && !(today >= had[0]! && today <= had.at(-1)!) ? had[0]! : local(dayOf(now()) * DAY).slice(0, 10),
84
+ );
85
+ });
91
86
  iconify();
92
- showsOpen(document);
87
+ addingPeople(document.querySelector("#people form")!);
88
+ booking(document.querySelector("#booking")!, document.querySelector("#stays [name=book]")!);
89
+ sheets();
93
90
 
94
91
  const line = document.querySelector("#said")!;
95
92
  const file = document.querySelector<HTMLInputElement>("input[type=file]")!;
@@ -99,12 +96,9 @@ file.addEventListener("change", async () => {
99
96
  else line.textContent = "No events in that file.";
100
97
  file.value = "";
101
98
  });
102
- addingPeople(document.querySelector("#people form")!);
103
- booking(document.querySelector("#stays form")!);
104
99
 
105
100
  // defined last, once all they draw with is made
106
101
  customElements.define(trip.collections.events.tag, JEvent);
107
- customElements.define(weeks.collections.weeks.tag, JWeek);
108
102
  // this trip, of the trips: its name is the page's
109
103
  customElements.define(
110
104
  trips.collections.trips.tag,
@@ -1,19 +1,23 @@
1
1
  // A trip: its document, one for each of the trips (../trips: trip:1 Japan, trip:2 Hokkaido), its page at /trip/<key>,
2
- // and the trip going out as .ics, which reads the document as it is now, as whoever asks sees it: a trip they're
3
- // not on is none of theirs.
2
+ // the weeks it has events in (../weeks), for its page to open on, and the trip going out as .ics, which reads the
3
+ // document as it is now, as whoever asks sees it: a trip they're not on is none of theirs.
4
4
 
5
5
  import type { Read } from "joined/server";
6
6
  import { tripIcs, type TripEvent } from "./ics.ts";
7
7
  import page from "./index.html";
8
8
 
9
9
  export * as document from "./generated/rules.ts";
10
- /** The trip's own rule: an answer is from someone on the event, one each (./trust.ts). */
11
- export { trust } from "./trust.ts";
12
10
  /** What an agent is told at the MCP door, of the trips' events (src/mcp.ts). */
13
11
  export const instructions =
14
- "A trip (trip:<key>, its key a trip's id in trips) holds its events: a start is a wall clock where it happens, its zone (Asia/Tokyo) where it's said, a length ISO 8601 (PT2H), a place geo:lat,lng. Read the trip before changing it, and say why in a few words.";
12
+ "A trip (trip:<key>, its key a trip's id in trips) holds its events: a start is a wall clock where it happens, its zone (Asia/Tokyo) where it's said, a length ISO 8601 (PT2H), a place geo:lat,lng.";
15
13
  export const routes = (read: Read) => ({
16
14
  "/trip/:n": page,
15
+ "/trip/:n/weeks": (req: Request & { params: { n: string } }, who?: { member: number }) =>
16
+ Response.json(
17
+ (read("weeks", who?.member).weeks as { trip: number; week: string }[])
18
+ .filter((w) => String(w.trip) === req.params.n)
19
+ .map((w) => w.week),
20
+ ),
17
21
  "/trip/:n/trip.ics": (req: Request & { params: { n: string } }, who?: { member: number }) => {
18
22
  const trips = read("trips", who?.member).trips as { id: number; name: string }[];
19
23
  const trip = trips.find((t) => String(t.id) === req.params.n);
@@ -1,6 +1,5 @@
1
1
  /* The trip's stays, in their sheet: each its hue a stripe, its name changed where it is, its nights and place under it,
2
- its cancel at the end; the booking form at the foot: where, the whole width, and under it the night it starts, how
3
- many, and Book. */
2
+ its cancel at the end; Book a stay at the foot, asking in a modal. */
4
3
  j-stays {
5
4
  display: grid;
6
5
  gap: var(--space-12);
@@ -33,19 +32,20 @@ j-stay .said {
33
32
  j-stay .said {
34
33
  color: var(--danger);
35
34
  }
36
- form.add.book {
35
+ /* the booking, a modal's: where, the whole width; under it the night it starts and how many */
36
+ form.book {
37
37
  display: grid;
38
- grid-template-columns: minmax(0, 1fr) auto auto;
39
- align-items: end;
38
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
39
+ gap: var(--space-12);
40
40
  }
41
- form.add.book :is([name="name"], .said) {
41
+ form.book :is([name="name"], .said) {
42
42
  grid-column: 1 / -1;
43
43
  }
44
- form.book label {
45
- display: grid;
46
- gap: var(--space-4);
47
- font: var(--font-label);
44
+ form.book .said {
45
+ margin: 0;
46
+ font: var(--font-small);
47
+ color: var(--danger);
48
48
  }
49
- form.book input[type="number"] {
50
- width: 4.5rem;
49
+ form.book .said:empty {
50
+ display: none;
51
51
  }
@@ -1,11 +1,11 @@
1
1
  // The trip's stays, where it sleeps: <j-stay>, in a sheet beside the people. Each its hue, its name to change where
2
- // it is, its nights and its place in words, and a way to cancel it (asking nothing: it's one row, put back by
3
- // booking it again). A form books one: its name, the night it starts and how many. Two stays never share a night
4
- // (the stories' noOverlap): refused, why is said under the form.
2
+ // it is, its nights and its place in words, and a way to cancel it, asked first in a modal, as removing always is
3
+ // (design.md). A form books one: its name, the night it starts and how many. Two stays never share a night (the
4
+ // stories' noOverlap): refused, why is said under the form.
5
5
 
6
6
  import { iconButton } from "joined/icons";
7
7
  import { hueOf } from "joined/hues";
8
- import { said } from "joined/parts";
8
+ import { askOnPage, said } from "joined/parts";
9
9
  import { JStay, type JStays } from "./generated/elements.ts";
10
10
  import { collections } from "./generated/rules.ts";
11
11
  import { DAY, dayOf, local, stayed } from "joined/time";
@@ -14,7 +14,9 @@ export class Stay extends JStay {
14
14
  #name = Object.assign(document.createElement("input"), { ariaLabel: "Name" });
15
15
  #when = Object.assign(document.createElement("p"), { className: "when" });
16
16
  #said = Object.assign(document.createElement("p"), { className: "said", role: "status" });
17
- #gone = iconButton("remove", "", () => said(this.#said, this.removeItem()));
17
+ #gone = iconButton("remove", "", () =>
18
+ askOnPage(`Cancel ${this.data.name}?`, () => said(this.#said, this.removeItem()), "Cancel it"),
19
+ );
18
20
  connectedCallback() {
19
21
  if (this.childElementCount) return this.draw();
20
22
  this.#name.addEventListener(
@@ -47,21 +49,24 @@ export class Stay extends JStay {
47
49
  }
48
50
  }
49
51
 
50
- /** A form that books a stay: its name, the night it starts (in at three, out at ten) and how many nights. */
51
- export function booking(form: HTMLFormElement) {
52
+ /** Book a stay: its button opens the modal that asks for it (design.md: new is a modal), its name, the night it
53
+ * starts (in at three, out at ten) and how many nights; booked, the modal closes, and refused, why is said in it. */
54
+ export function booking(dialog: HTMLElement & { open: boolean }, opener: HTMLElement) {
55
+ const form = dialog.querySelector("form")!;
56
+ opener.addEventListener("click", () => (dialog.open = true));
57
+ dialog.querySelector("[name=keep]")!.addEventListener("click", () => (form.reset(), (dialog.open = false)));
52
58
  form.addEventListener("submit", (e) => {
53
59
  e.preventDefault();
54
- const field = (n: string) => (form.elements.namedItem(n) as HTMLInputElement).value.trim();
60
+ const field = (n: string) => ((form.elements.namedItem(n) as HTMLInputElement).value ?? "").trim();
55
61
  const [name, day, n] = [field("name"), field("day"), Number(field("nights")) || 1];
56
62
  if (!name || !day) return;
57
63
  const until = local((dayOf(day) + n) * DAY).slice(0, 10);
58
- // refused, what was typed stays, and why is said under it
59
64
  said(
60
65
  form.querySelector(".said")!,
61
66
  document
62
67
  .querySelector<JStays>(collections.stays.place)!
63
68
  .add({ name, from: `${day}T15:00:00`, until: `${until}T10:00:00` }),
64
- ).then((why) => why || form.reset());
69
+ ).then((why) => why || (form.reset(), (dialog.open = false)));
65
70
  });
66
71
  }
67
72
  // defined last, once all it draws with is made