@blueshed/joined 0.1.20 → 0.2.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 +1 -1
- package/.claude/skills/joined/reference.md +96 -17
- package/docs/design.md +31 -8
- package/examples/cafe/kitchen.ts +2 -2
- package/examples/desk/card.ts +43 -0
- package/examples/desk/desk.css +17 -0
- package/examples/desk/desk.json +41 -0
- package/examples/desk/generated/elements.ts +69 -0
- package/examples/desk/generated/queries.ts +33 -0
- package/examples/desk/generated/rules.ts +94 -0
- package/examples/desk/index.html +34 -0
- package/examples/desk/lanes.css +126 -0
- package/examples/desk/lanes.ts +133 -0
- package/examples/desk/migrations/001-desk.ts +8 -0
- package/examples/desk/page.ts +29 -0
- package/examples/desk/pulse.ts +20 -0
- package/examples/desk/routes.ts +9 -0
- package/examples/desk/steps.ts +32 -0
- package/examples/desk/stories.jsonl +18 -0
- package/examples/desk/tally.css +62 -0
- package/examples/desk/tally.ts +76 -0
- package/examples/desk/thumbs.ts +45 -0
- package/examples/desk/trust.ts +24 -0
- package/examples/desk/words.ts +17 -0
- package/examples/trip/bar.ts +1 -1
- package/examples/trip/calendar-map.css +2 -0
- package/examples/trip/drags.ts +3 -3
- package/examples/trip/drawer.ts +5 -5
- package/examples/trip/event-form.ts +8 -7
- package/examples/trip/holding.ts +1 -1
- package/examples/trip/ics.ts +22 -112
- package/examples/trip/line-stops.ts +1 -1
- package/examples/trip/line-words.ts +1 -1
- package/examples/trip/line.ts +1 -1
- package/examples/trip/map.ts +1 -1
- package/examples/trip/month.ts +1 -1
- package/examples/trip/other-weeks.ts +1 -1
- package/examples/trip/page.ts +2 -2
- package/examples/trip/peek.ts +1 -1
- package/examples/trip/routes.ts +3 -3
- package/examples/trip/shell.ts +3 -3
- package/examples/trip/stays.ts +1 -1
- package/examples/trip/week.ts +1 -1
- package/examples/trip/writes.ts +1 -1
- package/examples/trips/card.ts +1 -1
- package/examples/trips/map.ts +1 -1
- package/examples/weeks/derive.ts +1 -1
- package/package.json +7 -1
- package/src/attachment.ts +7 -2
- package/src/demo.css +29 -26
- package/src/demo.ts +2 -2
- package/src/draft.ts +23 -8
- package/src/files.ts +24 -8
- package/{examples/trip/mercator.ts → src/geo.ts} +13 -3
- package/src/icon-names.ts +4 -0
- package/src/ics.ts +130 -0
- package/src/members/panel.css +208 -201
- package/src/members/panel.ts +17 -8
- package/src/outbox.ts +70 -0
- package/src/page.css +76 -70
- package/src/page.ts +79 -14
- package/src/parts.css +575 -428
- package/src/parts.ts +18 -5
- package/{examples/trip → src}/place-search.ts +5 -5
- package/{examples/trip → src}/places.ts +9 -7
- package/src/rank.ts +20 -0
- package/src/scrim.ts +81 -0
- package/src/server.ts +28 -1
- package/{examples/trip → src}/time.ts +37 -5
- package/src/tokens.css +5 -0
- package/src/tokens.json +35 -0
package/examples/trip/bar.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// How it's read is which of its panes is shown: the calendar (and a phone's strip of its days), the line, or the month.
|
|
4
4
|
|
|
5
5
|
import type { Part } from "./shell.ts";
|
|
6
|
-
import { dated, firstOf, gridOf, mondayOf } from "
|
|
6
|
+
import { dated, firstOf, gridOf, mondayOf } from "joined/time";
|
|
7
7
|
|
|
8
8
|
const VIEWS = ["calendar", "line", "month"] as const;
|
|
9
9
|
/** Its panes, and how the week is read when each is shown. */
|
|
@@ -368,7 +368,9 @@ dialog[data-side="left"] {
|
|
|
368
368
|
.times label:first-child {
|
|
369
369
|
grid-column: 1 / -1;
|
|
370
370
|
}
|
|
371
|
+
/* its field shrinks with the drawer, so a scrollbar that takes room (Chrome's, off a Mac) leaves it no wider */
|
|
371
372
|
.place {
|
|
373
|
+
min-width: 0;
|
|
372
374
|
display: flex;
|
|
373
375
|
gap: var(--space-4);
|
|
374
376
|
align-items: center;
|
package/examples/trip/drags.ts
CHANGED
|
@@ -9,9 +9,9 @@ import type { MapView } from "./map.ts";
|
|
|
9
9
|
import type { Peek } from "./peek.ts";
|
|
10
10
|
import { label, type Week } from "./week.ts";
|
|
11
11
|
import { follow } from "joined/follow";
|
|
12
|
-
import { geo } from "
|
|
13
|
-
import { nameOf } from "
|
|
14
|
-
import { DAY, hhmm, iso, local, MIN, seconds, snap, SNAP, wall } from "
|
|
12
|
+
import { geo } from "joined/geo";
|
|
13
|
+
import { nameOf } from "joined/places";
|
|
14
|
+
import { DAY, hhmm, iso, local, MIN, seconds, snap, SNAP, wall } from "joined/time";
|
|
15
15
|
|
|
16
16
|
/** What a drag reads from its display: the event picked, how to pick one (making room for the drawer, or not yet, the
|
|
17
17
|
* finger still down), how to draw one again, and whether it's on a phone. */
|
package/examples/trip/drawer.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { Part } from "./shell.ts";
|
|
|
11
11
|
import { EventForm, type Input } from "./event-form.ts";
|
|
12
12
|
import { askFirst } from "joined/parts";
|
|
13
13
|
import { hueOf } from "joined/hues";
|
|
14
|
-
import { seconds, wall } from "
|
|
14
|
+
import { seconds, wall } from "joined/time";
|
|
15
15
|
import { Writes } from "./writes.ts";
|
|
16
16
|
|
|
17
17
|
/** An event as it's drawn: as the document has it, or, while it's in the drawer, as the form has it. */
|
|
@@ -219,13 +219,13 @@ export class Drawer {
|
|
|
219
219
|
const { host, drawer } = this.#parts;
|
|
220
220
|
host.style.paddingRight = host.style.paddingBottom = "";
|
|
221
221
|
if (drawer.hidden) return;
|
|
222
|
-
// where it sits, not where it is as it
|
|
223
|
-
const
|
|
222
|
+
// where it sits, not where it is as it comes into place (an offset leaves out the transform)
|
|
223
|
+
const left = drawer.offsetLeft,
|
|
224
224
|
top = drawer.offsetTop,
|
|
225
225
|
right = host.getBoundingClientRect().right;
|
|
226
|
-
if (top <= 0 && right >
|
|
226
|
+
if (top <= 0 && right > left) host.style.paddingRight = `${right - left + 16}px`;
|
|
227
227
|
// a phone's sheet: room below the calendar, so what it covers can be scrolled above it
|
|
228
|
-
else if (top > 0) host.style.paddingBottom = `${
|
|
228
|
+
else if (top > 0) host.style.paddingBottom = `${drawer.offsetHeight}px`;
|
|
229
229
|
}
|
|
230
230
|
/** The picked event in sight: its day scrolled to, on a week too wide for the room the drawer leaves; and, picked on
|
|
231
231
|
* the calendar, the page scrolled to put it above a phone's sheet (never from the map, where the finger is). */
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
// modal to add one. It holds what's typed, dragged on the week or tapped on the map (a Draft, joined/draft)
|
|
3
3
|
// until Save, and what it holds, the display draws (its host's redraw): the picked event where the form puts it.
|
|
4
4
|
// Its parts are their own: the time zone found by typing (./zones.ts), the place searched for near the map's middle
|
|
5
|
-
// (
|
|
5
|
+
// (joined/place-search), a chip for each person (./people-chips.ts) and a row for each one's answer (./answer-rows.ts).
|
|
6
6
|
|
|
7
7
|
import type { JEventData } from "./generated/elements.ts";
|
|
8
8
|
import { Draft } from "joined/draft";
|
|
9
9
|
import { icon } from "joined/icons";
|
|
10
10
|
import { ANSWERS, answerOf, type Answer } from "./answers.ts";
|
|
11
11
|
import { AnswerRows, type Gates } from "./answer-rows.ts";
|
|
12
|
-
import { geo } from "
|
|
12
|
+
import { geo } from "joined/geo";
|
|
13
13
|
import { PeopleChips } from "./people-chips.ts";
|
|
14
|
-
import { PlaceSearch } from "
|
|
15
|
-
import type { Place } from "
|
|
16
|
-
import { hhmm, iso, MIN, minutes, seconds, SNAP, wall } from "
|
|
14
|
+
import { PlaceSearch } from "joined/place-search";
|
|
15
|
+
import type { Place } from "joined/places";
|
|
16
|
+
import { hhmm, iso, MIN, minutes, seconds, SNAP, wall } from "joined/time";
|
|
17
17
|
import { zones } from "./zones.ts";
|
|
18
18
|
|
|
19
19
|
const INPUTS = ["title", "day", "from", "to", "zone", "location", "coordinates"] as const;
|
|
@@ -21,7 +21,7 @@ export type Input = (typeof INPUTS)[number];
|
|
|
21
21
|
/** What the form asks of the display it's in: to draw what it holds, the people, and the map's middle. */
|
|
22
22
|
type Host = { redraw(): void; people(): Map<number, string>; near(): { lat: number; lng: number } };
|
|
23
23
|
|
|
24
|
-
const FORM = `<header><h2 class="mode"></h2
|
|
24
|
+
const FORM = `<header><h2 class="mode"></h2></header>
|
|
25
25
|
<label>Title<input name="title" autocomplete="off" required></label>
|
|
26
26
|
<div class="times"><label>Day<input name="day" type="date"></label><label>Starts<input name="from" type="time" step="900"></label><label>Ends<input name="to" type="time" step="900"></label></div>
|
|
27
27
|
<label>Time zone<input name="zone" autocomplete="off" placeholder="Where its clock is: Asia/Tokyo"></label>
|
|
@@ -155,7 +155,8 @@ export class EventForm {
|
|
|
155
155
|
// its icon swapped only as what it does changes: not on every change
|
|
156
156
|
if (go.dataset.mark !== mark) ((go.dataset.mark = mark), go.querySelector("svg")?.remove(), go.prepend(icon(mark)));
|
|
157
157
|
go.querySelector("span")!.textContent = d ? "Save" : "Add";
|
|
158
|
-
|
|
158
|
+
// kept only with a title: Save (Add) off till it has one
|
|
159
|
+
this.held.show(!d ? "new" : dirty ? "changed" : "kept", !!this.input("title").value.trim());
|
|
159
160
|
q("[name=remove]").hidden = !d;
|
|
160
161
|
const at = geo(this.input("coordinates").value);
|
|
161
162
|
q("[name=unsettle]").hidden = !this.input("location").value && !at;
|
package/examples/trip/holding.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import type { JEvent, JEvents } from "./generated/elements.ts";
|
|
7
7
|
import { collections as trip } from "./generated/rules.ts";
|
|
8
|
-
import { DAY, dayOf, gridOf, local } from "
|
|
8
|
+
import { DAY, dayOf, gridOf, local } from "joined/time";
|
|
9
9
|
|
|
10
10
|
/** What it reads from its display: the week shown, and whether it's read as a month. */
|
|
11
11
|
type From = { at: () => { week: number }; monthly: () => boolean };
|
package/examples/trip/ics.ts
CHANGED
|
@@ -1,117 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
// The trip's events as a calendar file (joined/ics): each event's uid its key, and each person on it an attendee, by
|
|
2
|
+
// name, their answer (./answers.ts) as a calendar says it.
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// calendar anywhere puts it at that hour there, or floating where it hasn't; its length a DURATION (or DTEND), its
|
|
6
|
-
// place a LOCATION and a GEO.
|
|
4
|
+
import { toIcs, type IcsEvent } from "joined/ics";
|
|
5
|
+
import { answerOf, type Answer } from "./answers.ts";
|
|
7
6
|
|
|
8
|
-
export type IcsEvent = {
|
|
9
|
-
title: string;
|
|
10
|
-
start: string;
|
|
11
|
-
duration: string;
|
|
12
|
-
location?: string;
|
|
13
|
-
coordinates?: string;
|
|
14
|
-
zone?: string;
|
|
15
|
-
people?: number[];
|
|
16
|
-
keen?: number[];
|
|
17
|
-
asked?: number[];
|
|
18
|
-
declined?: number[];
|
|
19
|
-
};
|
|
20
7
|
/** An answer as a calendar says it: keen and yes accepted, asked needing it, no declined. */
|
|
21
|
-
const PARTSTAT:
|
|
22
|
-
yes: "ACCEPTED",
|
|
23
|
-
keen: "ACCEPTED",
|
|
24
|
-
asked: "NEEDS-ACTION",
|
|
25
|
-
declined: "DECLINED",
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const esc = (s: string) =>
|
|
29
|
-
s
|
|
30
|
-
.replace(/\\/g, "\\\\")
|
|
31
|
-
.replace(/\n/g, "\\n")
|
|
32
|
-
.replace(/([,;])/g, "\\$1");
|
|
33
|
-
const unesc = (s: string) => s.replace(/\\(.)/g, (_, c: string) => (c.toLowerCase() === "n" ? "\n" : c));
|
|
34
|
-
const fold = (line: string) => line.match(/.{1,73}/g)!.join("\r\n ");
|
|
35
|
-
const stamp = (local: string) => local.replace(/[-:]/g, ""); // 2026-11-12T19:00:00 → 20261112T190000
|
|
36
|
-
const local = (v: string) => {
|
|
37
|
-
const [, y, mo, d, h = "00", mi = "00", s = "00"] = /^(\d{4})(\d{2})(\d{2})(?:T(\d{2})(\d{2})(\d{2}))?/.exec(v) ?? [];
|
|
38
|
-
return y ? `${y}-${mo}-${d}T${h}:${mi}:${s}` : null;
|
|
39
|
-
};
|
|
40
|
-
const minutes = (from: string, to: string) => (Date.parse(`${to}Z`) - Date.parse(`${from}Z`)) / 60_000;
|
|
41
|
-
|
|
42
|
-
/** A start a calendar can read: a wall clock, to the second; and a length: days, or hours, minutes and seconds. */
|
|
43
|
-
const WHEN = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/,
|
|
44
|
-
LENGTH = /^P(?=\d|T\d)(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?$/,
|
|
45
|
-
ZONE = /^[A-Za-z][A-Za-z0-9_+/-]*$/; // a zone as the world names it, and nothing a line could break on
|
|
46
|
-
|
|
47
|
-
/** The events as a calendar file: one whose start or length a calendar couldn't read (one kept from
|
|
48
|
-
* before the database typed them) is left out, rather than the file being one no calendar opens. */
|
|
49
|
-
export function toIcs(events: (IcsEvent & { id: number })[], name: string, names = new Map<number, string>()): string {
|
|
50
|
-
const now = new Date().toISOString().replace(/[-:]/g, "").slice(0, 15) + "Z";
|
|
51
|
-
const lines = ["BEGIN:VCALENDAR", "VERSION:2.0", "PRODID:-//blueshed//joined//EN", `X-WR-CALNAME:${esc(name)}`];
|
|
52
|
-
for (const e of events.filter((e) => WHEN.test(e.start) && LENGTH.test(e.duration))) {
|
|
53
|
-
lines.push(
|
|
54
|
-
"BEGIN:VEVENT",
|
|
55
|
-
`UID:${e.id}@joined`,
|
|
56
|
-
`DTSTAMP:${now}`,
|
|
57
|
-
e.zone && ZONE.test(e.zone) ? `DTSTART;TZID=${e.zone}:${stamp(e.start)}` : `DTSTART:${stamp(e.start)}`,
|
|
58
|
-
`DURATION:${e.duration}`,
|
|
59
|
-
`SUMMARY:${esc(e.title)}`,
|
|
60
|
-
);
|
|
61
|
-
if (e.location) lines.push(`LOCATION:${esc(e.location)}`);
|
|
62
|
-
// its place's digits as they were given (35.6720), so a trip comes back as it went out: not mercator's geo,
|
|
63
|
-
// which reads them as numbers (35.672)
|
|
64
|
-
const geo = /^geo:(-?[\d.]+),(-?[\d.]+)/.exec(e.coordinates ?? "");
|
|
65
|
-
if (geo) lines.push(`GEO:${geo[1]};${geo[2]}`);
|
|
66
|
-
// who's on it, by name where it's known (quoted, so a comma or a colon in it is only a name)
|
|
67
|
-
for (const k of e.people ?? []) {
|
|
68
|
-
const cn = (names.get(k) ?? "").replace(/["\r\n]/g, "");
|
|
69
|
-
lines.push(`ATTENDEE;${cn ? `CN="${cn}";` : ""}PARTSTAT=${PARTSTAT[answerOf(e, k)]}:urn:joined:person:${k}`);
|
|
70
|
-
}
|
|
71
|
-
lines.push("END:VEVENT");
|
|
72
|
-
}
|
|
73
|
-
return [...lines, "END:VCALENDAR"].map(fold).join("\r\n") + "\r\n";
|
|
74
|
-
}
|
|
8
|
+
const PARTSTAT = { yes: "ACCEPTED", keen: "ACCEPTED", asked: "NEEDS-ACTION", declined: "DECLINED" } as const;
|
|
75
9
|
|
|
76
|
-
|
|
77
|
-
|
|
10
|
+
export type TripEvent = IcsEvent & { id: number; people?: number[] } & Partial<
|
|
11
|
+
Record<Exclude<Answer, "yes">, number[]>
|
|
12
|
+
>;
|
|
78
13
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
// time in UTC read as a wall clock in UTC
|
|
94
|
-
const zone = at.TZID && ZONES.has(at.TZID) ? at.TZID : /Z$/.test(at.DTSTART!) ? "UTC" : undefined;
|
|
95
|
-
events.push({
|
|
96
|
-
title: unesc(at.SUMMARY ?? "An event"),
|
|
97
|
-
start,
|
|
98
|
-
duration,
|
|
99
|
-
...(at.LOCATION ? { location: unesc(at.LOCATION) } : {}),
|
|
100
|
-
...(geo?.length === 2 ? { coordinates: `geo:${geo[0]},${geo[1]}` } : {}),
|
|
101
|
-
...(zone ? { zone } : {}),
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
at = null;
|
|
105
|
-
} else if (at) {
|
|
106
|
-
const colon = line.indexOf(":");
|
|
107
|
-
if (colon > 0) {
|
|
108
|
-
const [name, ...params] = line.slice(0, colon).split(";");
|
|
109
|
-
at[name!.toUpperCase()] = line.slice(colon + 1);
|
|
110
|
-
// a start's zone, as its TZID names it
|
|
111
|
-
const tz = params.find((p) => /^TZID=/i.test(p));
|
|
112
|
-
if (name!.toUpperCase() === "DTSTART" && tz) at.TZID = tz.slice(5).replace(/^"|"$/g, "");
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return events;
|
|
117
|
-
}
|
|
14
|
+
/** The trip's events as a calendar file, each person on one by their name in `names`. */
|
|
15
|
+
export const tripIcs = (events: TripEvent[], name: string, names = new Map<number, string>()) =>
|
|
16
|
+
toIcs(
|
|
17
|
+
events.map(({ id, people, keen, asked, declined, ...e }) => ({
|
|
18
|
+
...e,
|
|
19
|
+
uid: `${id}@joined`,
|
|
20
|
+
attendees: (people ?? []).map((k) => ({
|
|
21
|
+
name: names.get(k),
|
|
22
|
+
answer: PARTSTAT[answerOf({ keen, asked, declined }, k)],
|
|
23
|
+
uri: `urn:joined:person:${k}`,
|
|
24
|
+
})),
|
|
25
|
+
})),
|
|
26
|
+
name,
|
|
27
|
+
);
|
|
@@ -8,7 +8,7 @@ import { hueOf } from "joined/hues";
|
|
|
8
8
|
import { face } from "joined/parts";
|
|
9
9
|
import { answerOf } from "./answers.ts";
|
|
10
10
|
import type { Said } from "./line-words.ts";
|
|
11
|
-
import { hhmm, hours, stayed, wall } from "
|
|
11
|
+
import { hhmm, hours, stayed, wall } from "joined/time";
|
|
12
12
|
|
|
13
13
|
/** A day's station: its date, the colour of the stay that night, and where a stay begins its name and nights. */
|
|
14
14
|
export function station(words: string, stay: JStay | null, begins: JStay | null, change: boolean) {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type { JEvent } from "./generated/elements.ts";
|
|
6
6
|
import { answerOf } from "./answers.ts";
|
|
7
|
-
import { seconds, wall } from "
|
|
7
|
+
import { seconds, wall } from "joined/time";
|
|
8
8
|
import { and } from "./words.ts";
|
|
9
9
|
|
|
10
10
|
/** What an event says to the line's reader. */
|
package/examples/trip/line.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { face } from "joined/parts";
|
|
|
12
12
|
import { members, signedIn } from "joined/panel";
|
|
13
13
|
import { end, station, stop } from "./line-stops.ts";
|
|
14
14
|
import { saidOf, whiles } from "./line-words.ts";
|
|
15
|
-
import { dated, dayOf, stayed } from "
|
|
15
|
+
import { dated, dayOf, stayed } from "joined/time";
|
|
16
16
|
|
|
17
17
|
/** What the line reads from its display: its events, the people by key and as elements, the event picked, how to pick
|
|
18
18
|
* one, the stays, and the week shown. */
|
package/examples/trip/map.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type { Peek } from "./peek.ts";
|
|
|
12
12
|
import type { Part } from "./shell.ts";
|
|
13
13
|
import { follow, held } from "joined/follow";
|
|
14
14
|
import { hueOf } from "joined/hues";
|
|
15
|
-
import { bounds, geo, placeAt, TILE, tileAt, world } from "
|
|
15
|
+
import { bounds, geo, placeAt, TILE, tileAt, world } from "joined/geo";
|
|
16
16
|
|
|
17
17
|
export const MAP_H = 320; // the map's least height: beside the calendar it's as tall as it
|
|
18
18
|
/** Where the map looks: its zoom, and the world's pixel at its top left. */
|
package/examples/trip/month.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { JEvent } from "./generated/elements.ts";
|
|
|
7
7
|
import type { Part } from "./shell.ts";
|
|
8
8
|
import { keep } from "joined/keep";
|
|
9
9
|
import { hueOf } from "joined/hues";
|
|
10
|
-
import { DAY, dated, dayOf, firstOf, hhmm, mondayOf, wall } from "
|
|
10
|
+
import { DAY, dated, dayOf, firstOf, hhmm, mondayOf, wall } from "joined/time";
|
|
11
11
|
|
|
12
12
|
/** What the month reads from its display: the Monday its grid starts on, its events and the one picked, how to pick
|
|
13
13
|
* one, whether it's on a phone and the day a phone's calendar shows; and how to read a week as a calendar instead. */
|
|
@@ -5,7 +5,7 @@ import type { JWeek } from "../weeks/generated/elements.ts";
|
|
|
5
5
|
import type { Part } from "./shell.ts";
|
|
6
6
|
import { keep, type Row } from "joined/keep";
|
|
7
7
|
import { collections as weeks } from "../weeks/generated/rules.ts";
|
|
8
|
-
import { DAY, dated, dayOf, local } from "
|
|
8
|
+
import { DAY, dated, dayOf, local } from "joined/time";
|
|
9
9
|
|
|
10
10
|
/** What it reads from its display: the trip held, the week shown, whether it's read as a month, and how to go to a
|
|
11
11
|
* week. */
|
package/examples/trip/page.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
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
8
|
// trip goes out as /trip/<key>/trip.ics. The trips (../trips) are held too, for this trip's name, the page's.
|
|
9
9
|
|
|
10
|
-
import { fromIcs } from "
|
|
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";
|
|
@@ -22,7 +22,7 @@ import { JTrip } from "../trips/generated/elements.ts";
|
|
|
22
22
|
import * as trips from "../trips/generated/rules.ts";
|
|
23
23
|
import * as trip from "./generated/rules.ts";
|
|
24
24
|
import * as weeks from "../weeks/generated/rules.ts";
|
|
25
|
-
import { DAY, dayOf, gridOf, local, now, wall, weekOf } from "
|
|
25
|
+
import { DAY, dayOf, gridOf, local, now, wall, weekOf } from "joined/time";
|
|
26
26
|
|
|
27
27
|
const key = location.pathname.split("/").filter(Boolean).at(-1);
|
|
28
28
|
document.querySelector<HTMLAnchorElement>("a[download]")!.href = `/trip/${key}/trip.ics`;
|
package/examples/trip/peek.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { JEvent } from "./generated/elements.ts";
|
|
|
6
6
|
import type { MapView } from "./map.ts";
|
|
7
7
|
import type { Part } from "./shell.ts";
|
|
8
8
|
import { hueOf } from "joined/hues";
|
|
9
|
-
import { DAY, dated, hours, wall } from "
|
|
9
|
+
import { DAY, dated, hours, wall } from "joined/time";
|
|
10
10
|
|
|
11
11
|
/** What the card reads from its display: the people by key, and how to pick an event. */
|
|
12
12
|
type From = { people: () => Map<number, string>; pick: (el: JEvent) => void };
|
package/examples/trip/routes.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// not on is none of theirs.
|
|
4
4
|
|
|
5
5
|
import type { Read } from "joined/server";
|
|
6
|
-
import {
|
|
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";
|
|
@@ -18,9 +18,9 @@ export const routes = (read: Read) => ({
|
|
|
18
18
|
const trips = read("trips", who?.member).trips as { id: number; name: string }[];
|
|
19
19
|
const trip = trips.find((t) => String(t.id) === req.params.n);
|
|
20
20
|
if (!trip) return new Response("no trip of yours", { status: 404 });
|
|
21
|
-
const events = read(`trip:${trip.id}`, who?.member).events as
|
|
21
|
+
const events = read(`trip:${trip.id}`, who?.member).events as TripEvent[];
|
|
22
22
|
const people = read("people", who?.member).people as { id: number; name: string }[];
|
|
23
|
-
return new Response(
|
|
23
|
+
return new Response(tripIcs(events, trip.name, new Map(people.map((p) => [p.id, p.name]))), {
|
|
24
24
|
headers: { "content-type": "text/calendar; charset=utf-8" },
|
|
25
25
|
});
|
|
26
26
|
},
|
package/examples/trip/shell.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
// calendar (its ruler and days), the line, the month, the other weeks, the drawer, the modal, and the modal that asks
|
|
5
5
|
// before Remove.
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { adopt } from "joined/parts";
|
|
8
8
|
import { HOUR } from "./week.ts";
|
|
9
9
|
import { MAP_H } from "./map.ts";
|
|
10
|
-
import { TILE } from "
|
|
10
|
+
import { TILE } from "joined/geo";
|
|
11
11
|
import STYLE from "./calendar-map.css" with { type: "text" };
|
|
12
12
|
|
|
13
13
|
/** One of the shadow's parts, found once (the display keeps them): its parts are found by it, never searched for on
|
|
@@ -28,7 +28,7 @@ const HTML = `
|
|
|
28
28
|
|
|
29
29
|
/** The display's shadow made afresh: its look, its sizes, and its parts, empty until they're drawn. */
|
|
30
30
|
export function shell(host: HTMLElement, root: ShadowRoot) {
|
|
31
|
-
root
|
|
31
|
+
adopt(root, SHEET);
|
|
32
32
|
for (const [name, px] of [
|
|
33
33
|
["--hour", HOUR],
|
|
34
34
|
["--tile", TILE],
|
package/examples/trip/stays.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { hueOf } from "joined/hues";
|
|
|
8
8
|
import { said } from "joined/parts";
|
|
9
9
|
import { JStay, type JStays } from "./generated/elements.ts";
|
|
10
10
|
import { collections } from "./generated/rules.ts";
|
|
11
|
-
import { DAY, dayOf, local, stayed } from "
|
|
11
|
+
import { DAY, dayOf, local, stayed } from "joined/time";
|
|
12
12
|
|
|
13
13
|
export class Stay extends JStay {
|
|
14
14
|
#name = Object.assign(document.createElement("input"), { ariaLabel: "Name" });
|
package/examples/trip/week.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { held } from "joined/follow";
|
|
|
13
13
|
import { hueOf } from "joined/hues";
|
|
14
14
|
import { keep } from "joined/keep";
|
|
15
15
|
import { face } from "joined/parts";
|
|
16
|
-
import { DAY, dated, dayOf, hhmm, hours, MIN, on, seconds, wall } from "
|
|
16
|
+
import { DAY, dated, dayOf, hhmm, hours, MIN, on, seconds, wall } from "joined/time";
|
|
17
17
|
|
|
18
18
|
export const HOUR = 36,
|
|
19
19
|
EARLY = 6, // the hours a week shows, more if its events need them
|
package/examples/trip/writes.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { JEvent, JEvents, JEventValue } from "./generated/elements.ts";
|
|
|
8
8
|
import type { EventForm, Input } from "./event-form.ts";
|
|
9
9
|
import type { Answer } from "joined/page";
|
|
10
10
|
import { ANSWERS } from "./answers.ts";
|
|
11
|
-
import { dayOf, mondayOf } from "
|
|
11
|
+
import { dayOf, mondayOf } from "joined/time";
|
|
12
12
|
|
|
13
13
|
/** What the writes read from the drawer and its display: how to say why, draw all again, ask for a new event again
|
|
14
14
|
* (and draw it) and close the modal; the events' list, the week shown, whether a week is held and how to go to one;
|
package/examples/trips/card.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { collections } from "./generated/rules.ts";
|
|
|
9
9
|
import { JTrip } from "./generated/elements.ts";
|
|
10
10
|
import { collections as trip } from "../trip/generated/rules.ts";
|
|
11
11
|
import { JEvent, type JEvents } from "../trip/generated/elements.ts";
|
|
12
|
-
import { DAY, dated, dayOf, hhmm, now, wall } from "
|
|
12
|
+
import { DAY, dated, dayOf, hhmm, now, wall } from "joined/time";
|
|
13
13
|
import { and } from "../trip/words.ts";
|
|
14
14
|
import { mapOf } from "./map.ts";
|
|
15
15
|
|
package/examples/trips/map.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// its hue, drawn about its middle so any card's frame shows them; no places, said so.
|
|
3
3
|
|
|
4
4
|
import { hueOf } from "joined/hues";
|
|
5
|
-
import { TILE, bounds, geo, tileAt, world } from "
|
|
5
|
+
import { TILE, bounds, geo, tileAt, world } from "joined/geo";
|
|
6
6
|
|
|
7
7
|
/** The map of a trip's places, from its events: each its key (its pin's hue) and where it is, if it's settled. */
|
|
8
8
|
export function mapOf(events: { key: number; coordinates?: string }[]) {
|
package/examples/weeks/derive.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// each. Read as the member sees each trip, so a trip they aren't on has no weeks of theirs; again on a write to one.
|
|
4
4
|
|
|
5
5
|
import type { Read } from "joined/server";
|
|
6
|
-
import { weekOf } from "
|
|
6
|
+
import { weekOf } from "joined/time";
|
|
7
7
|
|
|
8
8
|
export const doc = "weeks";
|
|
9
9
|
export const from = ["trips", "trip"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blueshed/joined",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Compiled documents, talking to web components as elements in the DOM.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -22,6 +22,12 @@
|
|
|
22
22
|
"./follow": "./src/follow.ts",
|
|
23
23
|
"./icons": "./src/icons.ts",
|
|
24
24
|
"./hues": "./src/hues.ts",
|
|
25
|
+
"./ics": "./src/ics.ts",
|
|
26
|
+
"./time": "./src/time.ts",
|
|
27
|
+
"./geo": "./src/geo.ts",
|
|
28
|
+
"./places": "./src/places.ts",
|
|
29
|
+
"./place-search": "./src/place-search.ts",
|
|
30
|
+
"./rank": "./src/rank.ts",
|
|
25
31
|
"./toast": "./src/toast.ts",
|
|
26
32
|
"./demo": "./src/demo.ts",
|
|
27
33
|
"./panel": "./src/members/panel.ts",
|
package/src/attachment.ts
CHANGED
|
@@ -17,7 +17,9 @@ export async function upload(doc: string, file: Blob): Promise<{ file: string }
|
|
|
17
17
|
if (file.size > MOST) return { refused: TOO_BIG };
|
|
18
18
|
let r: Response;
|
|
19
19
|
try {
|
|
20
|
-
|
|
20
|
+
// its name, where it has one: a Markdown file is known by it
|
|
21
|
+
const named = file instanceof File ? `&name=${encodeURIComponent(file.name)}` : "";
|
|
22
|
+
r = await fetch(`/files?doc=${encodeURIComponent(doc)}${named}`, { method: "POST", body: file });
|
|
21
23
|
} catch {
|
|
22
24
|
return { refused: "Not connected just now: try again in a moment." };
|
|
23
25
|
}
|
|
@@ -32,7 +34,10 @@ export function attachment(doc: () => string, put: (file: string) => Promise<Ans
|
|
|
32
34
|
const el = Object.assign(document.createElement("div"), { className: "j-file" });
|
|
33
35
|
const shown = Object.assign(document.createElement("a"), { target: "_blank", rel: "noopener", hidden: true });
|
|
34
36
|
const picture = Object.assign(document.createElement("img"), { alt: "", loading: "lazy" });
|
|
35
|
-
const input = Object.assign(document.createElement("input"), {
|
|
37
|
+
const input = Object.assign(document.createElement("input"), {
|
|
38
|
+
type: "file",
|
|
39
|
+
accept: "image/*,application/pdf,.md,.markdown,text/markdown",
|
|
40
|
+
});
|
|
36
41
|
const words = document.createElement("span");
|
|
37
42
|
const choose = Object.assign(document.createElement("label"), { className: "act small" });
|
|
38
43
|
choose.append(icon("upload"), words, input);
|
package/src/demo.css
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
/* <joined-demo>'s look, in its shadow (with joined's parts): a quiet line in a well, a link a person, who you are
|
|
2
2
|
filled in ink. */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
3
|
+
|
|
4
|
+
@layer joined {
|
|
5
|
+
:host {
|
|
6
|
+
display: block;
|
|
7
|
+
}
|
|
8
|
+
:host([hidden]) {
|
|
9
|
+
display: none;
|
|
10
|
+
}
|
|
11
|
+
nav {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-wrap: wrap;
|
|
14
|
+
align-items: baseline;
|
|
15
|
+
gap: var(--space-4) var(--space-12);
|
|
16
|
+
padding: var(--space-8) var(--space-12);
|
|
17
|
+
border-radius: 4px;
|
|
18
|
+
background: var(--well);
|
|
19
|
+
color: var(--ink);
|
|
20
|
+
font: var(--font-row);
|
|
21
|
+
}
|
|
22
|
+
a {
|
|
23
|
+
padding: 0 var(--space-8);
|
|
24
|
+
border-radius: 99px;
|
|
25
|
+
color: inherit;
|
|
26
|
+
}
|
|
27
|
+
a[aria-current] {
|
|
28
|
+
background: var(--ink);
|
|
29
|
+
color: var(--card);
|
|
30
|
+
text-decoration: none;
|
|
31
|
+
}
|
|
29
32
|
}
|
package/src/demo.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// so being Nora or Nick always has a way back. Not a demo (the live site, a project with no members): it stays hidden.
|
|
4
4
|
// An app's home page carries one, under its head; it needs neither the group's panel nor anything of the page's.
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { adopt } from "./parts.ts";
|
|
7
7
|
import STYLE from "./demo.css" with { type: "text" };
|
|
8
8
|
|
|
9
9
|
const SHEET = new CSSStyleSheet();
|
|
@@ -14,7 +14,7 @@ class JoinedDemo extends HTMLElement {
|
|
|
14
14
|
connectedCallback() {
|
|
15
15
|
if (this.#root.childNodes.length) return;
|
|
16
16
|
this.hidden = true;
|
|
17
|
-
this.#root
|
|
17
|
+
adopt(this.#root, SHEET);
|
|
18
18
|
fetch("/as")
|
|
19
19
|
.then((r) => (r.ok ? (r.json() as Promise<{ me: number | null; people: Person[] }>) : null))
|
|
20
20
|
.then((demo) => demo && this.#draw(demo.people, demo.me));
|