@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.
- package/.claude/skills/joined/SKILL.md +9 -1
- package/.claude/skills/joined/reference.md +270 -55
- package/.claude/skills/joined-door/SKILL.md +57 -0
- package/README.md +19 -50
- package/docs/design.md +76 -10
- package/docs/introduction.md +18 -18
- package/docs/light-and-shadow.svg +1 -1
- package/examples/README.md +20 -0
- package/examples/account/account.json +1 -0
- package/examples/account/derive.ts +41 -0
- package/examples/account/generated/elements.ts +52 -0
- package/examples/account/generated/rows.ts +22 -0
- package/examples/account/generated/rules.ts +32 -0
- package/examples/account/routes.ts +5 -0
- package/examples/app.css +2 -1
- package/examples/cafe/books.html +2 -2
- package/examples/cafe/cafe.css +9 -16
- package/examples/cafe/generated/books.rows.ts +22 -0
- package/examples/cafe/generated/books.rules.ts +3 -2
- package/examples/cafe/generated/kitchen.rows.ts +27 -0
- package/examples/cafe/generated/kitchen.rules.ts +11 -1
- package/examples/cafe/generated/menu.rows.ts +22 -0
- package/examples/cafe/generated/menu.rules.ts +3 -2
- package/examples/cafe/generated/order.rows.ts +27 -0
- package/examples/cafe/generated/order.rules.ts +11 -1
- package/examples/cafe/generated/staff.rows.ts +22 -0
- package/examples/cafe/generated/staff.rules.ts +6 -1
- package/examples/cafe/generated/supplies.queries.ts +4 -2
- package/examples/cafe/generated/supplies.rows.ts +22 -0
- package/examples/cafe/generated/supplies.rules.ts +12 -1
- package/examples/cafe/generated/till.queries.ts +2 -0
- package/examples/cafe/generated/till.rows.ts +27 -0
- package/examples/cafe/generated/till.rules.ts +11 -1
- package/examples/cafe/index.html +14 -15
- package/examples/cafe/kitchen.ts +1 -1
- package/examples/cafe/look.ts +30 -0
- package/examples/cafe/menu.html +10 -26
- package/examples/cafe/menu.ts +8 -80
- package/examples/cafe/order.html +6 -6
- package/examples/cafe/order.ts +5 -1
- package/examples/cafe/routes.ts +0 -1
- package/examples/cafe/stories.jsonl +3 -1
- package/examples/cafe/supplies.html +34 -34
- package/examples/cafe/supplies.ts +14 -11
- package/examples/cafe/till.ts +5 -1
- package/examples/chart/arches.ts +148 -0
- package/examples/chart/chart.css +6 -0
- package/examples/chart/chart.json +87 -0
- package/examples/chart/generated/elements.ts +105 -0
- package/examples/chart/generated/queries.ts +36 -0
- package/examples/chart/generated/rows.ts +27 -0
- package/examples/chart/generated/rules.ts +111 -0
- package/examples/chart/grid.ts +118 -0
- package/examples/chart/index.html +78 -0
- package/examples/chart/migrations/001-chart.ts +6 -0
- package/examples/chart/migrations/002-create-conditions.ts +6 -0
- package/examples/chart/page.ts +20 -0
- package/examples/chart/routes.ts +7 -0
- package/examples/chart/stories.jsonl +14 -0
- package/examples/chart/teeth.ts +57 -0
- package/examples/desk/generated/rows.ts +22 -0
- package/examples/desk/generated/rules.ts +34 -1
- package/examples/desk/index.html +9 -2
- package/examples/desk/routes.ts +0 -2
- package/examples/desk/stories.jsonl +3 -2
- package/examples/desk/thumbs.ts +2 -2
- package/examples/hello/generated/elements.ts +2 -2
- package/examples/hello/generated/rules.ts +3 -2
- package/examples/hello/hello.css +2 -4
- package/examples/hello/index.html +10 -3
- package/examples/hello/page.ts +4 -4
- package/examples/index.html +4 -5
- package/examples/notes/generated/elements.ts +112 -0
- package/examples/notes/generated/queries.ts +36 -0
- package/examples/notes/generated/rows.ts +27 -0
- package/examples/notes/generated/rules.ts +133 -0
- package/examples/notes/index.html +32 -0
- package/examples/notes/look.ts +41 -0
- package/examples/notes/migrations/001-notes.ts +7 -0
- package/examples/notes/notes.json +78 -0
- package/examples/notes/page.ts +21 -0
- package/examples/notes/routes.ts +6 -0
- package/examples/notes/stories.jsonl +21 -0
- package/examples/people/generated/rows.ts +22 -0
- package/examples/people/generated/rules.ts +11 -1
- package/examples/people/links.ts +2 -1
- package/examples/people/routes.ts +1 -3
- package/examples/people/stories.jsonl +1 -0
- package/examples/people/view.ts +5 -2
- package/examples/trip/generated/elements.ts +4 -2
- package/examples/trip/generated/queries.ts +12 -1
- package/examples/trip/generated/rows.ts +27 -0
- package/examples/trip/generated/rules.ts +56 -2
- package/examples/trip/index.html +58 -12
- package/examples/trip/line.css +186 -0
- package/examples/trip/line.ts +51 -40
- package/examples/trip/page.ts +65 -71
- package/examples/trip/routes.ts +9 -5
- package/examples/trip/stays.css +12 -12
- package/examples/trip/stays.ts +15 -10
- package/examples/trip/stories.jsonl +2 -0
- package/examples/trip/told.ts +3 -26
- package/examples/trip/trip.css +16 -0
- package/examples/trips/generated/rows.ts +22 -0
- package/examples/trips/generated/rules.ts +9 -1
- package/examples/trips/index.html +10 -10
- package/examples/trips/map.ts +3 -14
- package/examples/trips/new-trip.ts +14 -16
- package/examples/weeks/generated/elements.ts +1 -1
- package/examples/weeks/generated/queries.ts +11 -0
- package/examples/weeks/generated/rows.ts +22 -0
- package/examples/weeks/generated/rules.ts +11 -5
- package/examples/weeks/routes.ts +3 -2
- package/examples/weeks/stories.jsonl +1 -0
- package/examples/welcome.css +7 -5
- package/package.json +8 -2
- package/src/awesome.ts +103 -0
- package/src/board.css +75 -0
- package/src/board.ts +173 -0
- package/src/cli.ts +15 -2
- package/src/compile.ts +569 -35
- package/src/definitions.ts +53 -15
- package/src/draft.ts +38 -23
- package/src/drawer.ts +222 -0
- package/src/engine.ts +240 -166
- package/src/fields.ts +268 -0
- package/src/files.ts +6 -4
- package/src/ground.ts +110 -0
- package/src/icon-names.ts +15 -2
- package/src/kit.ts +51 -0
- package/src/link.ts +3 -3
- package/src/map.css +133 -0
- package/src/map.ts +200 -0
- package/src/mcp.ts +176 -38
- package/src/members/demo.ts +13 -12
- package/src/members/generated/rows.ts +22 -0
- package/src/members/generated/rules.ts +3 -2
- package/src/members/group.ts +65 -39
- package/src/members/keys.ts +93 -77
- package/src/members/panel.css +23 -17
- package/src/members/panel.ts +49 -35
- package/src/migrate.ts +120 -104
- package/src/month.css +125 -0
- package/src/month.ts +179 -0
- package/src/page.css +8 -0
- package/src/page.ts +11 -7
- package/src/parts.css +462 -170
- package/src/parts.ts +209 -26
- package/src/plane.css +56 -0
- package/src/plane.ts +151 -0
- package/src/postgres-server.ts +60 -0
- package/src/reading.css +77 -0
- package/src/reading.ts +238 -0
- package/src/rows.css +308 -0
- package/src/rows.ts +780 -0
- package/src/search.css +80 -0
- package/src/search.ts +130 -0
- package/src/server.ts +211 -114
- package/src/settings.ts +9 -4
- package/src/sheet.ts +114 -0
- package/src/skill.ts +40 -0
- package/src/slots.css +94 -0
- package/src/slots.ts +213 -0
- package/src/specs.ts +38 -0
- package/src/starter.ts +5 -2
- package/src/store.ts +184 -143
- package/src/stories.ts +43 -11
- package/src/surface.ts +159 -0
- package/src/timeline.css +111 -0
- package/src/timeline.ts +226 -0
- package/src/toast.ts +21 -48
- package/src/together.ts +0 -7
- package/src/tokens.css +78 -1
- package/src/tokens.json +249 -0
- package/src/tool.ts +211 -0
- package/src/upkeep.ts +18 -20
- package/src/views.css +44 -0
- package/src/views.ts +94 -0
- package/src/week.css +151 -0
- package/src/week.ts +250 -0
- package/src/write.ts +219 -73
- package/starter/CLAUDE.md +3 -3
- package/starter/bunfig +4 -0
- package/starter/prettierignore +4 -0
- package/starter/tests/hello.test.ts +2 -0
- package/docs/learning.md +0 -76
- package/examples/cafe/trust.ts +0 -20
- package/examples/desk/trust.ts +0 -24
- package/examples/people/trust.ts +0 -14
- package/examples/trip/answer-rows.ts +0 -70
- package/examples/trip/bar.ts +0 -89
- package/examples/trip/calendar-map.css +0 -711
- package/examples/trip/calendar-map.ts +0 -249
- package/examples/trip/drags.ts +0 -143
- package/examples/trip/drawer.ts +0 -250
- package/examples/trip/event-form.ts +0 -200
- package/examples/trip/holding.ts +0 -61
- package/examples/trip/map.ts +0 -234
- package/examples/trip/month.ts +0 -87
- package/examples/trip/other-weeks.ts +0 -67
- package/examples/trip/peek.ts +0 -71
- package/examples/trip/people-chips.ts +0 -74
- package/examples/trip/shell.ts +0 -39
- package/examples/trip/trust.ts +0 -51
- package/examples/trip/week.ts +0 -237
- package/examples/trip/writes.ts +0 -91
- package/examples/trip/zones.ts +0 -16
- package/examples/weeks/derive.ts +0 -23
- 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) */
|
package/examples/trip/line.ts
CHANGED
|
@@ -1,60 +1,69 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
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
|
|
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 {
|
|
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
|
-
|
|
18
|
-
|
|
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
|
-
|
|
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
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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.#
|
|
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.#
|
|
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.#
|
|
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
|
|
78
|
-
// happen; each the colour of the stay that night, from its first to its last
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
|
|
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
|
|
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
|
|
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);
|
package/examples/trip/page.ts
CHANGED
|
@@ -1,95 +1,92 @@
|
|
|
1
|
-
// A trip's page, at /trip/<key>:
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
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 "./
|
|
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
|
|
19
|
-
import {
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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(
|
|
36
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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") &&
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
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,
|
package/examples/trip/routes.ts
CHANGED
|
@@ -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
|
-
//
|
|
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.
|
|
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);
|
package/examples/trip/stays.css
CHANGED
|
@@ -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;
|
|
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
|
-
|
|
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)
|
|
39
|
-
|
|
38
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
39
|
+
gap: var(--space-12);
|
|
40
40
|
}
|
|
41
|
-
form.
|
|
41
|
+
form.book :is([name="name"], .said) {
|
|
42
42
|
grid-column: 1 / -1;
|
|
43
43
|
}
|
|
44
|
-
form.book
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
form.book .said {
|
|
45
|
+
margin: 0;
|
|
46
|
+
font: var(--font-small);
|
|
47
|
+
color: var(--danger);
|
|
48
48
|
}
|
|
49
|
-
form.book
|
|
50
|
-
|
|
49
|
+
form.book .said:empty {
|
|
50
|
+
display: none;
|
|
51
51
|
}
|
package/examples/trip/stays.ts
CHANGED
|
@@ -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
|
|
3
|
-
//
|
|
4
|
-
//
|
|
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", "", () =>
|
|
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
|
-
/**
|
|
51
|
-
|
|
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
|