@blueshed/joined 0.1.20 → 0.2.1

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 (84) hide show
  1. package/.claude/skills/joined/SKILL.md +1 -1
  2. package/.claude/skills/joined/reference.md +99 -18
  3. package/README.md +6 -4
  4. package/docs/design.md +31 -8
  5. package/docs/introduction.md +1 -1
  6. package/docs/learning.md +1 -1
  7. package/docs/light-and-shadow.svg +119 -0
  8. package/docs/links-and-trust.svg +93 -0
  9. package/docs/logo.svg +47 -0
  10. package/docs/stories-to-code.svg +86 -0
  11. package/docs/wire-op.svg +99 -0
  12. package/examples/cafe/kitchen.ts +2 -2
  13. package/examples/desk/card.ts +43 -0
  14. package/examples/desk/desk.css +17 -0
  15. package/examples/desk/desk.json +41 -0
  16. package/examples/desk/generated/elements.ts +69 -0
  17. package/examples/desk/generated/queries.ts +33 -0
  18. package/examples/desk/generated/rules.ts +94 -0
  19. package/examples/desk/index.html +34 -0
  20. package/examples/desk/lanes.css +126 -0
  21. package/examples/desk/lanes.ts +133 -0
  22. package/examples/desk/migrations/001-desk.ts +8 -0
  23. package/examples/desk/page.ts +29 -0
  24. package/examples/desk/pulse.ts +20 -0
  25. package/examples/desk/routes.ts +9 -0
  26. package/examples/desk/steps.ts +32 -0
  27. package/examples/desk/stories.jsonl +18 -0
  28. package/examples/desk/tally.css +62 -0
  29. package/examples/desk/tally.ts +76 -0
  30. package/examples/desk/thumbs.ts +45 -0
  31. package/examples/desk/trust.ts +24 -0
  32. package/examples/desk/words.ts +17 -0
  33. package/examples/trip/bar.ts +1 -1
  34. package/examples/trip/calendar-map.css +2 -0
  35. package/examples/trip/drags.ts +3 -3
  36. package/examples/trip/drawer.ts +5 -5
  37. package/examples/trip/event-form.ts +8 -7
  38. package/examples/trip/holding.ts +1 -1
  39. package/examples/trip/ics.ts +22 -112
  40. package/examples/trip/line-stops.ts +1 -1
  41. package/examples/trip/line-words.ts +1 -1
  42. package/examples/trip/line.ts +1 -1
  43. package/examples/trip/map.ts +1 -1
  44. package/examples/trip/month.ts +1 -1
  45. package/examples/trip/other-weeks.ts +1 -1
  46. package/examples/trip/page.ts +2 -2
  47. package/examples/trip/peek.ts +1 -1
  48. package/examples/trip/routes.ts +3 -3
  49. package/examples/trip/shell.ts +3 -3
  50. package/examples/trip/stays.ts +1 -1
  51. package/examples/trip/week.ts +1 -1
  52. package/examples/trip/writes.ts +1 -1
  53. package/examples/trips/card.ts +1 -1
  54. package/examples/trips/map.ts +1 -1
  55. package/examples/weeks/derive.ts +1 -1
  56. package/package.json +9 -2
  57. package/src/attachment.ts +18 -11
  58. package/src/client.ts +7 -0
  59. package/src/demo.css +29 -26
  60. package/src/demo.ts +2 -2
  61. package/src/draft.ts +23 -8
  62. package/src/files.ts +25 -9
  63. package/{examples/trip/mercator.ts → src/geo.ts} +13 -3
  64. package/src/icon-names.ts +4 -0
  65. package/src/ics.ts +130 -0
  66. package/src/members/group.ts +3 -1
  67. package/src/members/panel.css +208 -201
  68. package/src/members/panel.ts +17 -8
  69. package/src/ops.ts +5 -0
  70. package/src/outbox.ts +70 -0
  71. package/src/page.css +76 -70
  72. package/src/page.ts +86 -15
  73. package/src/parts.css +575 -428
  74. package/src/parts.ts +18 -5
  75. package/{examples/trip → src}/place-search.ts +5 -5
  76. package/{examples/trip → src}/places.ts +9 -7
  77. package/src/rank.ts +20 -0
  78. package/src/scrim.ts +81 -0
  79. package/src/server.ts +59 -13
  80. package/{examples/trip → src}/time.ts +37 -5
  81. package/src/together.ts +2 -6
  82. package/src/tokens.css +5 -0
  83. package/src/tokens.json +35 -0
  84. package/src/write.ts +29 -14
@@ -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 "./time.ts";
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 rises into place (offsetTop leaves out the transform)
223
- const d = drawer.getBoundingClientRect(),
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 > d.left) host.style.paddingRight = `${right - d.left + 16}px`;
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 = `${d.height}px`;
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
- // (./place-search.ts), a chip for each person (./people-chips.ts) and a row for each one's answer (./answer-rows.ts).
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 "./mercator.ts";
12
+ import { geo } from "joined/geo";
13
13
  import { PeopleChips } from "./people-chips.ts";
14
- import { PlaceSearch } from "./place-search.ts";
15
- import type { Place } from "./places.ts";
16
- import { hhmm, iso, MIN, minutes, seconds, SNAP, wall } from "./time.ts";
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><button type="button" class="icon-only" name="close" title="Close" aria-label="Close" data-icon="close"></button></header>
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
- this.held.show(!d ? "new" : dirty ? "changed" : "kept");
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;
@@ -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 "./time.ts";
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 };
@@ -1,117 +1,27 @@
1
- import { answerOf, type Answer } from "./answers.ts";
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
- // .ics (RFC 5545) at the edge: the trip's events go out as a calendar file, and a file coming in
4
- // becomes events to add. A start is a wall clock, in its zone where it has one (DTSTART;TZID=Asia/Tokyo), so a
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: Record<Answer, string> = {
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
- /** The time zones the world names (Asia/Tokyo), as this runtime knows them. */
77
- const ZONES = new Set([...Intl.supportedValuesOf("timeZone"), "UTC"]);
10
+ export type TripEvent = IcsEvent & { id: number; people?: number[] } & Partial<
11
+ Record<Exclude<Answer, "yes">, number[]>
12
+ >;
78
13
 
79
- export function fromIcs(text: string): IcsEvent[] {
80
- const lines = text.replace(/\r?\n[ \t]/g, "").split(/\r?\n/);
81
- const events: IcsEvent[] = [];
82
- let at: Record<string, string> | null = null;
83
- for (const line of lines) {
84
- if (line === "BEGIN:VEVENT") at = {};
85
- else if (line === "END:VEVENT" && at) {
86
- const start = local(at.DTSTART ?? "");
87
- if (start) {
88
- const end = at.DTEND ? local(at.DTEND) : null;
89
- const day = /^\d{8}$/.test(at.DTSTART!);
90
- const duration = at.DURATION ?? (end ? `PT${minutes(start, end)}M` : day ? "P1D" : "PT0M");
91
- const geo = at.GEO?.split(";");
92
- // its zone: one the world names (an Outlook name, Tokyo Standard Time, is let go: floating), or UTC's Z, a
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 "./time.ts";
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 "./time.ts";
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. */
@@ -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 "./time.ts";
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. */
@@ -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 "./mercator.ts";
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. */
@@ -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 "./time.ts";
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 "./time.ts";
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. */
@@ -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 "./ics.ts";
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 "./time.ts";
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`;
@@ -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 "./time.ts";
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 };
@@ -3,7 +3,7 @@
3
3
  // not on is none of theirs.
4
4
 
5
5
  import type { Read } from "joined/server";
6
- import { toIcs, type IcsEvent } from "./ics.ts";
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 (IcsEvent & { id: number })[];
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(toIcs(events, trip.name, new Map(people.map((p) => [p.id, p.name]))), {
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
  },
@@ -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 { PARTS } from "joined/parts";
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 "./mercator.ts";
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.adoptedStyleSheets = [PARTS, SHEET];
31
+ adopt(root, SHEET);
32
32
  for (const [name, px] of [
33
33
  ["--hour", HOUR],
34
34
  ["--tile", TILE],
@@ -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 "./time.ts";
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" });
@@ -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 "./time.ts";
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
@@ -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 "./time.ts";
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;
@@ -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 "../trip/time.ts";
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
 
@@ -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 "../trip/mercator.ts";
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 }[]) {
@@ -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 "../trip/time.ts";
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.1.20",
3
+ "version": "0.2.1",
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",
@@ -46,7 +52,8 @@
46
52
  "docs/introduction.md",
47
53
  "docs/stories.md",
48
54
  "docs/design.md",
49
- "docs/learning.md"
55
+ "docs/learning.md",
56
+ "docs/*.svg"
50
57
  ],
51
58
  "dependencies": {
52
59
  "lucide": "^1.62.0"
package/src/attachment.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  // A file field on the page (Attachment, joined/attachment): what an item holds in it shown, a photo as its picture and
2
- // a PDF as a link, each opening the file; and, where its person may, a way to choose one, and to take it off. A file
3
- // chosen is sent to the server for the item's document (/files, src/files.ts), which keeps it and answers its value;
4
- // that's put in the field by the view's own op (`put`: the item's replace, or an add form's field), never written to
5
- // the element. Drawn again as the item is, only what changed moves: the picture stays while its file does.
2
+ // a PDF or a Markdown file as a link, each opening the file; and, where its person may, a way to choose one, and to
3
+ // take it off. A file chosen is sent to the server for the item's document (/files, src/files.ts), which keeps it and
4
+ // answers its value; that's put in the field by the view's own op (`put`: the item's replace, or an add form's field),
5
+ // never written to the element. Drawn again as the item is, only what changed moves: the picture stays while its file
6
+ // does.
6
7
 
7
8
  import { fileUrl, MOST, TOO_BIG } from "./file-value.ts";
8
9
  import { icon, iconButton } from "./icons.ts";
@@ -17,7 +18,9 @@ export async function upload(doc: string, file: Blob): Promise<{ file: string }
17
18
  if (file.size > MOST) return { refused: TOO_BIG };
18
19
  let r: Response;
19
20
  try {
20
- r = await fetch(`/files?doc=${encodeURIComponent(doc)}`, { method: "POST", body: file });
21
+ // its name, where it has one: a Markdown file is known by it
22
+ const named = file instanceof File ? `&name=${encodeURIComponent(file.name)}` : "";
23
+ r = await fetch(`/files?doc=${encodeURIComponent(doc)}${named}`, { method: "POST", body: file });
21
24
  } catch {
22
25
  return { refused: "Not connected just now: try again in a moment." };
23
26
  }
@@ -32,7 +35,10 @@ export function attachment(doc: () => string, put: (file: string) => Promise<Ans
32
35
  const el = Object.assign(document.createElement("div"), { className: "j-file" });
33
36
  const shown = Object.assign(document.createElement("a"), { target: "_blank", rel: "noopener", hidden: true });
34
37
  const picture = Object.assign(document.createElement("img"), { alt: "", loading: "lazy" });
35
- const input = Object.assign(document.createElement("input"), { type: "file", accept: "image/*,application/pdf" });
38
+ const input = Object.assign(document.createElement("input"), {
39
+ type: "file",
40
+ accept: "image/*,application/pdf,.md,.markdown,text/markdown",
41
+ });
36
42
  const words = document.createElement("span");
37
43
  const choose = Object.assign(document.createElement("label"), { className: "act small" });
38
44
  choose.append(icon("upload"), words, input);
@@ -55,11 +61,12 @@ export function attachment(doc: () => string, put: (file: string) => Promise<Ans
55
61
  draw(value: string | undefined, may: { put?: boolean; take?: boolean } = {}) {
56
62
  const url = value && fileUrl(value);
57
63
  if (url && shown.getAttribute("href") !== url) {
58
- const pdf = url.endsWith(".pdf");
59
- Object.assign(shown, { href: url, className: pdf ? "act small" : "j-file-picture" });
60
- shown.ariaLabel = pdf ? "Open the PDF" : "Open the picture";
61
- if (!pdf) picture.src = url;
62
- shown.replaceChildren(...(pdf ? [icon("download"), "PDF"] : [picture]));
64
+ // a PDF or a Markdown file, a link to it, named; a photo or an SVG, its picture
65
+ const linked = url.endsWith(".pdf") ? "PDF" : url.endsWith(".md") ? "Markdown" : undefined;
66
+ Object.assign(shown, { href: url, className: linked ? "act small" : "j-file-picture" });
67
+ shown.ariaLabel = linked ? `Open the ${linked}` : "Open the picture";
68
+ if (!linked) picture.src = url;
69
+ shown.replaceChildren(...(linked ? [icon("download"), linked] : [picture]));
63
70
  }
64
71
  shown.hidden = !url;
65
72
  words.textContent = value ? "Another file" : "Add a file";
package/src/client.ts CHANGED
@@ -26,6 +26,13 @@ export function applied(doc: Record<string, any>, o: Op): Record<string, any> {
26
26
  [coll]: items.flatMap((i) => (String(i.id) === key ? (f(i) ?? []) : [i])),
27
27
  });
28
28
  if (field === undefined) return o.op === "remove" ? changed(() => null) : changed((i) => ({ ...i, ...o.value }));
29
+ // one of an object's fields (/orders/1/terms/days): made where there's none; the object gone once it's empty
30
+ if (link !== undefined && !/^(\d+|-)$/.test(link))
31
+ return changed((i) => {
32
+ const { [link]: _, ...rest } = i[field] ?? {};
33
+ const now = o.op === "remove" ? rest : { ...rest, [link]: o.value };
34
+ return Object.keys(now).length ? { ...i, [field]: now } : (({ [field]: _, ...others }) => others)(i);
35
+ });
29
36
  // an id added to a list, or taken from it: the rest as it was
30
37
  if (link !== undefined)
31
38
  return changed((i) => {
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
- :host {
4
- display: block;
5
- }
6
- :host([hidden]) {
7
- display: none;
8
- }
9
- nav {
10
- display: flex;
11
- flex-wrap: wrap;
12
- align-items: baseline;
13
- gap: var(--space-4) var(--space-12);
14
- padding: var(--space-8) var(--space-12);
15
- border-radius: 4px;
16
- background: var(--well);
17
- color: var(--ink);
18
- font: var(--font-row);
19
- }
20
- a {
21
- padding: 0 var(--space-8);
22
- border-radius: 99px;
23
- color: inherit;
24
- }
25
- a[aria-current] {
26
- background: var(--ink);
27
- color: var(--card);
28
- text-decoration: none;
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 { PARTS } from "./parts.ts";
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.adoptedStyleSheets = [PARTS, SHEET];
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));