@blueshed/joined 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/.claude/skills/joined/SKILL.md +9 -1
  2. package/.claude/skills/joined/reference.md +270 -55
  3. package/.claude/skills/joined-door/SKILL.md +57 -0
  4. package/README.md +19 -50
  5. package/docs/design.md +76 -10
  6. package/docs/introduction.md +18 -18
  7. package/docs/light-and-shadow.svg +1 -1
  8. package/examples/README.md +20 -0
  9. package/examples/account/account.json +1 -0
  10. package/examples/account/derive.ts +41 -0
  11. package/examples/account/generated/elements.ts +52 -0
  12. package/examples/account/generated/rows.ts +22 -0
  13. package/examples/account/generated/rules.ts +32 -0
  14. package/examples/account/routes.ts +5 -0
  15. package/examples/app.css +2 -1
  16. package/examples/cafe/books.html +2 -2
  17. package/examples/cafe/cafe.css +9 -16
  18. package/examples/cafe/generated/books.rows.ts +22 -0
  19. package/examples/cafe/generated/books.rules.ts +3 -2
  20. package/examples/cafe/generated/kitchen.rows.ts +27 -0
  21. package/examples/cafe/generated/kitchen.rules.ts +11 -1
  22. package/examples/cafe/generated/menu.rows.ts +22 -0
  23. package/examples/cafe/generated/menu.rules.ts +3 -2
  24. package/examples/cafe/generated/order.rows.ts +27 -0
  25. package/examples/cafe/generated/order.rules.ts +11 -1
  26. package/examples/cafe/generated/staff.rows.ts +22 -0
  27. package/examples/cafe/generated/staff.rules.ts +6 -1
  28. package/examples/cafe/generated/supplies.queries.ts +4 -2
  29. package/examples/cafe/generated/supplies.rows.ts +22 -0
  30. package/examples/cafe/generated/supplies.rules.ts +12 -1
  31. package/examples/cafe/generated/till.queries.ts +2 -0
  32. package/examples/cafe/generated/till.rows.ts +27 -0
  33. package/examples/cafe/generated/till.rules.ts +11 -1
  34. package/examples/cafe/index.html +14 -15
  35. package/examples/cafe/kitchen.ts +1 -1
  36. package/examples/cafe/look.ts +30 -0
  37. package/examples/cafe/menu.html +10 -26
  38. package/examples/cafe/menu.ts +8 -80
  39. package/examples/cafe/order.html +6 -6
  40. package/examples/cafe/order.ts +5 -1
  41. package/examples/cafe/routes.ts +0 -1
  42. package/examples/cafe/stories.jsonl +3 -1
  43. package/examples/cafe/supplies.html +34 -34
  44. package/examples/cafe/supplies.ts +14 -11
  45. package/examples/cafe/till.ts +5 -1
  46. package/examples/chart/arches.ts +148 -0
  47. package/examples/chart/chart.css +6 -0
  48. package/examples/chart/chart.json +87 -0
  49. package/examples/chart/generated/elements.ts +105 -0
  50. package/examples/chart/generated/queries.ts +36 -0
  51. package/examples/chart/generated/rows.ts +27 -0
  52. package/examples/chart/generated/rules.ts +111 -0
  53. package/examples/chart/grid.ts +118 -0
  54. package/examples/chart/index.html +78 -0
  55. package/examples/chart/migrations/001-chart.ts +6 -0
  56. package/examples/chart/migrations/002-create-conditions.ts +6 -0
  57. package/examples/chart/page.ts +20 -0
  58. package/examples/chart/routes.ts +7 -0
  59. package/examples/chart/stories.jsonl +14 -0
  60. package/examples/chart/teeth.ts +57 -0
  61. package/examples/desk/generated/rows.ts +22 -0
  62. package/examples/desk/generated/rules.ts +34 -1
  63. package/examples/desk/index.html +9 -2
  64. package/examples/desk/routes.ts +0 -2
  65. package/examples/desk/stories.jsonl +3 -2
  66. package/examples/desk/thumbs.ts +2 -2
  67. package/examples/hello/generated/elements.ts +2 -2
  68. package/examples/hello/generated/rules.ts +3 -2
  69. package/examples/hello/hello.css +2 -4
  70. package/examples/hello/index.html +10 -3
  71. package/examples/hello/page.ts +4 -4
  72. package/examples/index.html +4 -5
  73. package/examples/notes/generated/elements.ts +112 -0
  74. package/examples/notes/generated/queries.ts +36 -0
  75. package/examples/notes/generated/rows.ts +27 -0
  76. package/examples/notes/generated/rules.ts +133 -0
  77. package/examples/notes/index.html +32 -0
  78. package/examples/notes/look.ts +41 -0
  79. package/examples/notes/migrations/001-notes.ts +7 -0
  80. package/examples/notes/notes.json +78 -0
  81. package/examples/notes/page.ts +21 -0
  82. package/examples/notes/routes.ts +6 -0
  83. package/examples/notes/stories.jsonl +21 -0
  84. package/examples/people/generated/rows.ts +22 -0
  85. package/examples/people/generated/rules.ts +11 -1
  86. package/examples/people/links.ts +2 -1
  87. package/examples/people/routes.ts +1 -3
  88. package/examples/people/stories.jsonl +1 -0
  89. package/examples/people/view.ts +5 -2
  90. package/examples/trip/generated/elements.ts +4 -2
  91. package/examples/trip/generated/queries.ts +12 -1
  92. package/examples/trip/generated/rows.ts +27 -0
  93. package/examples/trip/generated/rules.ts +56 -2
  94. package/examples/trip/index.html +58 -12
  95. package/examples/trip/line.css +186 -0
  96. package/examples/trip/line.ts +51 -40
  97. package/examples/trip/page.ts +65 -71
  98. package/examples/trip/routes.ts +9 -5
  99. package/examples/trip/stays.css +12 -12
  100. package/examples/trip/stays.ts +15 -10
  101. package/examples/trip/stories.jsonl +2 -0
  102. package/examples/trip/told.ts +3 -26
  103. package/examples/trip/trip.css +16 -0
  104. package/examples/trips/generated/rows.ts +22 -0
  105. package/examples/trips/generated/rules.ts +9 -1
  106. package/examples/trips/index.html +10 -10
  107. package/examples/trips/map.ts +3 -14
  108. package/examples/trips/new-trip.ts +14 -16
  109. package/examples/weeks/generated/elements.ts +1 -1
  110. package/examples/weeks/generated/queries.ts +11 -0
  111. package/examples/weeks/generated/rows.ts +22 -0
  112. package/examples/weeks/generated/rules.ts +11 -5
  113. package/examples/weeks/routes.ts +3 -2
  114. package/examples/weeks/stories.jsonl +1 -0
  115. package/examples/welcome.css +7 -5
  116. package/package.json +8 -2
  117. package/src/awesome.ts +103 -0
  118. package/src/board.css +75 -0
  119. package/src/board.ts +173 -0
  120. package/src/cli.ts +15 -2
  121. package/src/compile.ts +569 -35
  122. package/src/definitions.ts +53 -15
  123. package/src/draft.ts +38 -23
  124. package/src/drawer.ts +222 -0
  125. package/src/engine.ts +240 -166
  126. package/src/fields.ts +268 -0
  127. package/src/files.ts +6 -4
  128. package/src/ground.ts +110 -0
  129. package/src/icon-names.ts +15 -2
  130. package/src/kit.ts +51 -0
  131. package/src/link.ts +3 -3
  132. package/src/map.css +133 -0
  133. package/src/map.ts +200 -0
  134. package/src/mcp.ts +176 -38
  135. package/src/members/demo.ts +13 -12
  136. package/src/members/generated/rows.ts +22 -0
  137. package/src/members/generated/rules.ts +3 -2
  138. package/src/members/group.ts +65 -39
  139. package/src/members/keys.ts +93 -77
  140. package/src/members/panel.css +23 -17
  141. package/src/members/panel.ts +49 -35
  142. package/src/migrate.ts +120 -104
  143. package/src/month.css +125 -0
  144. package/src/month.ts +179 -0
  145. package/src/page.css +8 -0
  146. package/src/page.ts +11 -7
  147. package/src/parts.css +462 -170
  148. package/src/parts.ts +209 -26
  149. package/src/plane.css +56 -0
  150. package/src/plane.ts +151 -0
  151. package/src/postgres-server.ts +60 -0
  152. package/src/reading.css +77 -0
  153. package/src/reading.ts +238 -0
  154. package/src/rows.css +308 -0
  155. package/src/rows.ts +780 -0
  156. package/src/search.css +80 -0
  157. package/src/search.ts +130 -0
  158. package/src/server.ts +211 -114
  159. package/src/settings.ts +9 -4
  160. package/src/sheet.ts +114 -0
  161. package/src/skill.ts +40 -0
  162. package/src/slots.css +94 -0
  163. package/src/slots.ts +213 -0
  164. package/src/specs.ts +38 -0
  165. package/src/starter.ts +5 -2
  166. package/src/store.ts +184 -143
  167. package/src/stories.ts +43 -11
  168. package/src/surface.ts +159 -0
  169. package/src/timeline.css +111 -0
  170. package/src/timeline.ts +226 -0
  171. package/src/toast.ts +21 -48
  172. package/src/together.ts +0 -7
  173. package/src/tokens.css +78 -1
  174. package/src/tokens.json +249 -0
  175. package/src/tool.ts +211 -0
  176. package/src/upkeep.ts +18 -20
  177. package/src/views.css +44 -0
  178. package/src/views.ts +94 -0
  179. package/src/week.css +151 -0
  180. package/src/week.ts +250 -0
  181. package/src/write.ts +219 -73
  182. package/starter/CLAUDE.md +3 -3
  183. package/starter/bunfig +4 -0
  184. package/starter/prettierignore +4 -0
  185. package/starter/tests/hello.test.ts +2 -0
  186. package/docs/learning.md +0 -76
  187. package/examples/cafe/trust.ts +0 -20
  188. package/examples/desk/trust.ts +0 -24
  189. package/examples/people/trust.ts +0 -14
  190. package/examples/trip/answer-rows.ts +0 -70
  191. package/examples/trip/bar.ts +0 -89
  192. package/examples/trip/calendar-map.css +0 -711
  193. package/examples/trip/calendar-map.ts +0 -249
  194. package/examples/trip/drags.ts +0 -143
  195. package/examples/trip/drawer.ts +0 -250
  196. package/examples/trip/event-form.ts +0 -200
  197. package/examples/trip/holding.ts +0 -61
  198. package/examples/trip/map.ts +0 -234
  199. package/examples/trip/month.ts +0 -87
  200. package/examples/trip/other-weeks.ts +0 -67
  201. package/examples/trip/peek.ts +0 -71
  202. package/examples/trip/people-chips.ts +0 -74
  203. package/examples/trip/shell.ts +0 -39
  204. package/examples/trip/trust.ts +0 -51
  205. package/examples/trip/week.ts +0 -237
  206. package/examples/trip/writes.ts +0 -91
  207. package/examples/trip/zones.ts +0 -16
  208. package/examples/weeks/derive.ts +0 -23
  209. package/src/scrim.ts +0 -81
@@ -5,6 +5,8 @@
5
5
  {"window":{"events":{"week":{"from":"start","for":"P7D","length":"duration"},"month":{"from":"start","for":"P42D","length":"duration"}}}}
6
6
  {"links":{"keen":"people","asked":"people","declined":"people","arrives":"people","leaves":"people"}}
7
7
  {"noOverlap":{"stays":{"range":["from","until"]}}}
8
+ {"within":{"events":[{"lists":["keen","asked","declined"],"of":"people","refused":"an answer is from someone on the event"},{"lists":["arrives","leaves"],"of":"people","refused":"who comes or goes at an event is on it"}]}}
9
+ {"apart":{"events":[{"lists":["keen","asked","declined"],"refused":"one answer each"}]}}
8
10
  {"story":"Nora adds dinner in Gion, and Peter's phone shows it on the calendar and on the map","as":"nora","does":{"doc":"trip:1","ops":[{"op":"add","path":"/events/-","value":{"title":"Dinner in Gion","start":"2026-11-07T19:00:00","duration":"PT2H","location":"Gion, Kyoto","coordinates":"geo:35.0037,135.7788","people":[1,2]}}]},"seen":["peter","phone","nick","nora"],"unseen":["dev"]}
9
11
  {"story":"Peter adds a day to rest: with no place yet, it is on the calendar alone","as":"peter","does":{"doc":"trip:1","ops":[{"op":"add","path":"/events/-","value":{"title":"A day to rest","start":"2026-11-05T10:00:00","duration":"PT6H"}}]},"seen":["peter","phone","nora"]}
10
12
  {"story":"The shinkansen leaves an hour later: Nick moves it, and it moves on every calendar","as":"nick","does":{"doc":"trip:1","ops":[{"op":"replace","path":"/events/3/start","value":"2026-11-06T10:00:00"}]},"seen":["peter","phone","nick"]}
@@ -1,7 +1,6 @@
1
- // The lists <calendar-map> is told of by id, beyond it on the page, each read from a live list, never a search: the
2
- // people (people="…"), who give each event its people's colours and the form a chip for each, watched for a person
3
- // renamed, come or gone, or said to be someone; and the stays (stays="…"), drawn on the line, watched for one booked,
4
- // changed or cancelled.
1
+ // The lists the line (./line.ts) is told of by id, beyond it on the page (each where its sheet holds it, so never the
2
+ // sheet itself), each read from a live list, never a search: the people (people="…"), who give the line its faces, and
3
+ // the stays (stays="…"), drawn on it.
5
4
 
6
5
  import type { JPerson } from "../people/generated/elements.ts";
7
6
  import type { JStay } from "./generated/elements.ts";
@@ -23,26 +22,4 @@ export class Told {
23
22
  persons = () => (this.#list("people")?.getElementsByTagName(people.people.tag) ?? []) as Iterable<JPerson>;
24
23
  /** The stays, as their elements. */
25
24
  stays = () => [...((this.#list("stays")?.getElementsByTagName(trip.stays.tag) ?? []) as Iterable<JStay>)];
26
-
27
- /** Both watched, by `watch` (let go with the display): the keys of the people changed, and that a stay has. */
28
- watch(watch: <O extends MutationObserver>(o: O) => O, changed: (keys: Set<number>) => void, stayed: () => void) {
29
- const list = this.#list("people");
30
- if (list)
31
- watch(
32
- new MutationObserver((records) => {
33
- const keys = new Set(
34
- records.flatMap((r) =>
35
- r.type === "attributes"
36
- ? [(r.target as JPerson).key]
37
- : (r.target as Element).localName === people.people.place
38
- ? [...r.addedNodes, ...r.removedNodes].map((n) => (n as JPerson).key)
39
- : [],
40
- ),
41
- );
42
- if (keys.size) changed(keys);
43
- }),
44
- ).observe(list, { childList: true, subtree: true, attributeFilter: ["name", "member"] });
45
- const stays = this.#list("stays");
46
- if (stays) watch(new MutationObserver(stayed)).observe(stays, { childList: true, subtree: true, attributes: true });
47
- }
48
25
  }
@@ -0,0 +1,16 @@
1
+ /* The trip's page: its readings (joined's kit, and its line) with the map beside them, narrow; above them, as wide as
2
+ the page, where there's no room beside. */
3
+ .beside {
4
+ display: flex;
5
+ flex-wrap: wrap-reverse;
6
+ gap: var(--space-16);
7
+ align-items: flex-end; /* wrapped in reverse, the end is the top */
8
+ }
9
+ .beside j-views {
10
+ flex: 3 1 calc(var(--space-64) * 8);
11
+ min-width: 0;
12
+ }
13
+ .beside j-map {
14
+ flex: 1 1 calc(var(--space-64) * 4);
15
+ min-width: 0;
16
+ }
@@ -0,0 +1,22 @@
1
+ // Written by src/compile.ts from examples/trips/stories.jsonl: change the stories, not this.
2
+
3
+ // Each collection of trips as rows (joined/rows, the skill's §3): a page defines the ones it shows, as they are or
4
+ // extended, by define() from joined/rows, and holds each collection's element in its rows:
5
+ // <j-trips-rows><j-trips></j-trips></j-trips-rows>
6
+ // A collection whose items are each of one of another's is drawn under it there, where its element is put in too.
7
+ // To change what one says or does, extend its class and override a part (label, named, says, facts, deeds, row,
8
+ // step, asks); to change how it looks, style its parts (::part(row), title, state, facts, deeds, mine, step, add,
9
+ // under, drawer). Its sheet, a search of it and how a field reads are joined/kit's, given these collections by
10
+ // use(specs) (define() gives a display's own). To draw something else altogether, don't define it: a display of the app's own holds the same
11
+ // elements. Never change this file: change the stories.
12
+
13
+ import { rows, type Spec } from "joined/rows";
14
+ import { JTrip } from "./elements.ts";
15
+
16
+ const trips: Spec = {"doc":"trips","name":"trips","place":"j-trips","tag":"j-trip","one":"trip","title":"name","fields":[{"name":"name","type":"string","needed":true},{"name":"organisers","type":"ids","needed":true,"how":"ids","to":{"tag":"j-member","people":true},"ref":true},{"name":"travellers","type":"ids","needed":true,"how":"ids","to":{"tag":"j-member","people":true},"ref":true}]};
17
+
18
+ /** Each collection as joined's kit (joined/kit) is given it, by name: use(specs). */
19
+ export const specs = { "trips": trips };
20
+
21
+ /** <j-trips-rows>: trips's trips as rows, each named by its name. */
22
+ export class JTripsRows extends rows(trips, { "j-trip": JTrip }) {}
@@ -3,7 +3,7 @@
3
3
  export type Op = { op: "add" | "replace" | "remove"; path: string; value?: any };
4
4
 
5
5
  /** The document, and each collection: its element, the element its items are, their fields, those an add needs, and
6
- * what each link is to. */
6
+ * what each link is to and what each field pops (a value with a form, its view; a reference, what it points at). */
7
7
  export const doc = "trips";
8
8
  export const collections = {
9
9
  "trips": {
@@ -22,6 +22,14 @@ export const collections = {
22
22
  "links": {
23
23
  "organisers": "members",
24
24
  "travellers": "members"
25
+ },
26
+ "pops": {
27
+ "organisers": {
28
+ "to": "members"
29
+ },
30
+ "travellers": {
31
+ "to": "members"
32
+ }
25
33
  }
26
34
  }
27
35
  } as const;
@@ -27,21 +27,21 @@
27
27
  <div class="held" hidden></div>
28
28
  </main>
29
29
  <p class="note">Only the trips you're on are here. <a href="/">← joined</a></p>
30
- <dialog class="modal new-trip">
31
- <form method="dialog">
32
- <header><h2>A new trip</h2></header>
33
- <label>Its name<input name="name" required autocomplete="off" /></label>
30
+ <wa-dialog class="new-trip" light-dismiss>
31
+ <h2 slot="label">A new trip</h2>
32
+ <form id="new-trip">
33
+ <wa-input name="name" label="Its name" required autocomplete="off"></wa-input>
34
34
  <fieldset>
35
35
  <legend>Who travels</legend>
36
36
  <div class="who"></div>
37
37
  </fieldset>
38
- <p class="said" role="status"></p>
39
- <footer>
40
- <button type="button" class="act" name="never">Never mind</button>
41
- <button class="act ink" name="go" data-icon="add">Start it</button>
42
- </footer>
38
+ <wa-callout class="said" variant="danger" size="small" role="status" hidden></wa-callout>
43
39
  </form>
44
- </dialog>
40
+ <footer slot="footer">
41
+ <button type="button" class="act" name="never" form="new-trip">Never mind</button>
42
+ <button class="act ink" name="go" form="new-trip" data-icon="add">Start it</button>
43
+ </footer>
44
+ </wa-dialog>
45
45
  <script type="module" src="./page.ts"></script>
46
46
  </body>
47
47
  </html>
@@ -2,7 +2,8 @@
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 "joined/geo";
5
+ import { bounds, geo, world } from "joined/geo";
6
+ import { tiles } from "joined/ground";
6
7
 
7
8
  /** 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
9
  export function mapOf(events: { key: number; coordinates?: string }[]) {
@@ -27,19 +28,7 @@ export function mapOf(events: { key: number; coordinates?: string }[]) {
27
28
  const [left, right, top, bottom] = bounds(xy);
28
29
  const [x0, y0] = [(left + right) / 2 - W / 2, (top + bottom) / 2 - H / 2];
29
30
  const ground = Object.assign(document.createElement("div"), { className: "ground" });
30
- const n = 2 ** z;
31
- for (let ty = Math.floor(y0 / TILE); ty * TILE < y0 + H; ty++)
32
- for (let tx = Math.floor(x0 / TILE); tx * TILE < x0 + W; tx++) {
33
- if (ty < 0 || ty >= n) continue;
34
- const img = Object.assign(document.createElement("img"), {
35
- src: tileAt(z, tx, ty),
36
- alt: "",
37
- loading: "lazy",
38
- });
39
- img.style.left = `${tx * TILE - x0}px`;
40
- img.style.top = `${ty * TILE - y0}px`;
41
- ground.append(img);
42
- }
31
+ ground.append(...tiles(z, x0, y0, W, H));
43
32
  for (const p of xy) {
44
33
  const pin = Object.assign(document.createElement("i"), { className: "pin" });
45
34
  pin.style.left = `${p.x - x0}px`;
@@ -9,7 +9,7 @@ import { collections } from "./generated/rules.ts";
9
9
  let me: number | undefined;
10
10
  signedIn((m) => (me = m));
11
11
 
12
- const dialog = document.querySelector<HTMLDialogElement>("dialog.new-trip")!,
12
+ const dialog = document.querySelector<HTMLElement & { open: boolean }>("wa-dialog.new-trip")!,
13
13
  form = dialog.querySelector("form")!,
14
14
  who = dialog.querySelector<HTMLElement>(".who")!;
15
15
  document.querySelector("button.new")!.addEventListener("click", () => {
@@ -18,29 +18,27 @@ document.querySelector("button.new")!.addEventListener("click", () => {
18
18
  ...[...members]
19
19
  .filter((m) => m.key !== me)
20
20
  .map((m) => {
21
- const label = Object.assign(document.createElement("label"), { className: "tick" });
22
- const box = Object.assign(document.createElement("input"), {
23
- type: "checkbox",
24
- name: "traveller",
25
- value: String(m.key),
26
- });
27
- label.append(m.data.name, box);
28
- return label;
21
+ // named and valued as attributes, so the form finds it at once (Web Awesome reflects them only as it draws)
22
+ const box = document.createElement("wa-checkbox");
23
+ box.setAttribute("name", "traveller");
24
+ box.setAttribute("value", String(m.key));
25
+ box.append(m.data.name);
26
+ return box;
29
27
  }),
30
28
  );
31
- dialog.showModal();
29
+ dialog.open = true;
32
30
  });
33
- dialog.querySelector("[name=never]")!.addEventListener("click", () => dialog.close());
31
+ dialog.querySelector("[name=never]")!.addEventListener("click", () => (dialog.open = false));
34
32
  form.addEventListener("submit", (e) => {
35
33
  e.preventDefault();
36
- const name = (form.elements.namedItem("name") as HTMLInputElement).value.trim();
34
+ const name = ((form.elements.namedItem("name") as HTMLInputElement).value ?? "").trim();
37
35
  if (!name || me === undefined) return;
38
- const travellers = [...form.querySelectorAll<HTMLInputElement>("[name=traveller]:checked")].map((b) =>
39
- Number(b.value),
40
- );
36
+ const travellers = [...form.querySelectorAll<HTMLInputElement>("[name=traveller]")]
37
+ .filter((b) => b.checked)
38
+ .map((b) => Number(b.value));
41
39
  // refused, it stays open with what was typed, and why is said in it; kept, it closes
42
40
  said(
43
41
  form.querySelector(".said")!,
44
42
  document.querySelector<JTrips>(collections.trips.place)!.add({ name, organisers: [me], travellers }),
45
- ).then((why) => why || dialog.close());
43
+ ).then((why) => why || (dialog.open = false));
46
44
  });
@@ -1,4 +1,4 @@
1
- // Written by src/compile.ts from examples/weeks/derive.ts: change it and its example, not this.
1
+ // Written by src/compile.ts from examples/weeks/stories.jsonl: change the stories, not this.
2
2
 
3
3
  // Each collection is an element, defined here: on a page, it holds the document, and its items
4
4
  // are put inside it. Each item is an element, defined by the page: as it is, or by a view that
@@ -0,0 +1,11 @@
1
+ // Written by src/compile.ts from examples/weeks/stories.jsonl: change the stories, not this.
2
+
3
+ /** weeks, as a member has it, one statement over the app's tables (SQLite): its parameters $doc and $member. */
4
+ export const query = `SELECT json_object('version', COALESCE((SELECT version FROM documents WHERE name = $doc), 0),
5
+ 'weeks', json((SELECT json_group_array(json_object('id', w.id, 'trip', w.item, 'week', w.week, 'events', w.n) ORDER BY w.id)
6
+ FROM (SELECT ROW_NUMBER() OVER (ORDER BY o."trip", date(o."start", 'weekday 0', '-6 days')) AS id, o."trip" AS item, date(o."start", 'weekday 0', '-6 days') AS week, COUNT(*) AS n FROM "events" o WHERE (EXISTS (SELECT 1 FROM "trips_organisers" p WHERE p."trips" = o."trip" AND p."organisers" = $member) OR EXISTS (SELECT 1 FROM "trips_travellers" p WHERE p."trips" = o."trip" AND p."travellers" = $member)) GROUP BY o."trip", date(o."start", 'weekday 0', '-6 days')) w))) AS doc`;
7
+
8
+ /** Its query, as Postgres says it. */
9
+ export const postgres = {
10
+ "query": "SELECT json_build_object('version', COALESCE((SELECT version FROM documents WHERE name = $doc), 0),\n 'weeks', (SELECT COALESCE(json_agg(json_build_object('id', w.id, 'trip', w.item, 'week', w.week, 'events', w.n) ORDER BY w.id), '[]')\n FROM (SELECT ROW_NUMBER() OVER (ORDER BY o.\"trip\", to_char(date_trunc('week', CAST(o.\"start\" AS timestamp)), 'YYYY-MM-DD')) AS id, o.\"trip\" AS item, to_char(date_trunc('week', CAST(o.\"start\" AS timestamp)), 'YYYY-MM-DD') AS week, COUNT(*) AS n FROM \"events\" o WHERE (EXISTS (SELECT 1 FROM \"trips_organisers\" p WHERE p.\"trips\" = o.\"trip\" AND p.\"organisers\" = $member) OR EXISTS (SELECT 1 FROM \"trips_travellers\" p WHERE p.\"trips\" = o.\"trip\" AND p.\"travellers\" = $member)) GROUP BY o.\"trip\", to_char(date_trunc('week', CAST(o.\"start\" AS timestamp)), 'YYYY-MM-DD')) w)) AS doc"
11
+ };
@@ -0,0 +1,22 @@
1
+ // Written by src/compile.ts from examples/weeks/stories.jsonl: change the stories, not this.
2
+
3
+ // Each collection of weeks as rows (joined/rows, the skill's §3): a page defines the ones it shows, as they are or
4
+ // extended, by define() from joined/rows, and holds each collection's element in its rows:
5
+ // <j-weeks-rows><j-weeks></j-weeks></j-weeks-rows>
6
+ // A collection whose items are each of one of another's is drawn under it there, where its element is put in too.
7
+ // To change what one says or does, extend its class and override a part (label, named, says, facts, deeds, row,
8
+ // step, asks); to change how it looks, style its parts (::part(row), title, state, facts, deeds, mine, step, add,
9
+ // under, drawer). Its sheet, a search of it and how a field reads are joined/kit's, given these collections by
10
+ // use(specs) (define() gives a display's own). To draw something else altogether, don't define it: a display of the app's own holds the same
11
+ // elements. Never change this file: change the stories.
12
+
13
+ import { rows, type Spec } from "joined/rows";
14
+ import { JWeek } from "./elements.ts";
15
+
16
+ const weeks: Spec = {"doc":"weeks","name":"weeks","place":"j-weeks","tag":"j-week","one":"week","title":"week","fields":[{"name":"trip","type":"integer","needed":true},{"name":"week","type":"string","needed":true},{"name":"events","type":"integer","needed":true}]};
17
+
18
+ /** Each collection as joined's kit (joined/kit) is given it, by name: use(specs). */
19
+ export const specs = { "weeks": weeks };
20
+
21
+ /** <j-weeks-rows>: weeks's weeks as rows, each named by its week. */
22
+ export class JWeeksRows extends rows(weeks, { "j-week": JWeek }) {}
@@ -1,9 +1,9 @@
1
- // Written by src/compile.ts from examples/weeks/derive.ts: change it and its example, not this.
1
+ // Written by src/compile.ts from examples/weeks/stories.jsonl: change the stories, not this.
2
2
 
3
3
  export type Op = { op: "add" | "replace" | "remove"; path: string; value?: any };
4
4
 
5
5
  /** The document, and each collection: its element, the element its items are, their fields, those an add needs, and
6
- * what each link is to. */
6
+ * what each link is to and what each field pops (a value with a form, its view; a reference, what it points at). */
7
7
  export const doc = "weeks";
8
8
  export const collections = {
9
9
  "weeks": {
@@ -19,7 +19,8 @@ export const collections = {
19
19
  "week",
20
20
  "events"
21
21
  ],
22
- "links": {}
22
+ "links": {},
23
+ "pops": {}
23
24
  }
24
25
  } as const;
25
26
  /** Whether every story is anonymous, none told as a member: where every app's is, the project has no members. */
@@ -27,7 +28,12 @@ export const anonymous = true;
27
28
  /** What kind of document weeks is, by the flows it uses: static, changed only with a release (a page reads it, and
28
29
  * never subscribes); read-only, live, but no page writes it (derived); or shared, its members' to write. */
29
30
  export const type = "read-only";
31
+ /** The tables its query reads: a change to any of them moves its version, and is told to each page holding it, as
32
+ * its member has it. */
33
+ export const reads = ["events","trips_organisers","trips_travellers"];
34
+ /** It's read as each member has it: a parameter of its query. */
35
+ export const member = true;
30
36
  /** The parts of weeks a page may hold alone, by its query's parameters (its definitions' window): null, none. */
31
37
  export const window = null;
32
- /** The documents this one is derived from (its derive.ts): what the server derives it again on a write to. */
33
- export const derived = ["trips","trip"];
38
+ /** The document as one statement over its tables (generated/queries.ts). */
39
+ export { query, postgres } from "./queries.ts";
@@ -1,4 +1,5 @@
1
- // The weeks of each trip a member is on: a document derived from the trips (derive.ts), read by a trip's page.
1
+ // The weeks of each trip a member is on, and how many of its events each holds: a read-only document, its query
2
+ // written from its definition (stories.jsonl), the member its parameter. A trip's page holds one week
3
+ // (trip:1?week=2026-11-02) and says beneath it what's on its other weeks, a way to each.
2
4
 
3
5
  export * as document from "./generated/rules.ts";
4
- export { derive } from "./derive.ts";
@@ -0,0 +1 @@
1
+ {"documents":{"weeks":{"weeks":{"from":"events","by":{"trip":"trips"},"seen":["organisers","travellers"],"week":"start","count":"events"}}}}
@@ -83,9 +83,10 @@
83
83
  display: grid;
84
84
  gap: var(--space-10);
85
85
  }
86
- /* the trip's picture, cut to its map and its week: its page's margins and its drawer left out */
86
+ /* the trip's picture (docs/trip.png, 1440 by 1240, by bun run design), cut to its page from the top of its head to
87
+ the dinner: its margins and its drawer left out */
87
88
  .hero .frame {
88
- aspect-ratio: 1280 / 1208;
89
+ aspect-ratio: 1096 / 1128;
89
90
  overflow: hidden;
90
91
  border: 1px solid var(--edge);
91
92
  border-radius: 4px;
@@ -93,9 +94,9 @@
93
94
  }
94
95
  .hero .frame img {
95
96
  display: block;
96
- width: 148.7%;
97
+ width: 131.4%;
97
98
  height: auto;
98
- margin: -1.5% 0 0 -14.5%;
99
+ margin: -1.1% 0 0 -1.46%;
99
100
  }
100
101
  .hero figcaption {
101
102
  font: var(--font-small);
@@ -148,7 +149,8 @@
148
149
  .picture.hello {
149
150
  background: color-mix(in srgb, var(--hue-4) var(--tint), var(--card));
150
151
  }
151
- .picture.cafe {
152
+ /* (not .cafe: the cafe's own page has that, and the design system holds both) */
153
+ .picture.tickets {
152
154
  background: color-mix(in srgb, var(--hue-1) var(--tint), var(--card));
153
155
  }
154
156
  /* the trip read as a line, its beads and their events */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueshed/joined",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Compiled documents, talking to web components as elements in the DOM.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,6 +18,10 @@
18
18
  "./draft": "./src/draft.ts",
19
19
  "./client": "./src/client.ts",
20
20
  "./parts": "./src/parts.ts",
21
+ "./surface": "./src/surface.ts",
22
+ "./awesome": "./src/awesome.ts",
23
+ "./rows": "./src/rows.ts",
24
+ "./kit": "./src/kit.ts",
21
25
  "./attachment": "./src/attachment.ts",
22
26
  "./follow": "./src/follow.ts",
23
27
  "./icons": "./src/icons.ts",
@@ -25,6 +29,7 @@
25
29
  "./ics": "./src/ics.ts",
26
30
  "./time": "./src/time.ts",
27
31
  "./geo": "./src/geo.ts",
32
+ "./ground": "./src/ground.ts",
28
33
  "./places": "./src/places.ts",
29
34
  "./place-search": "./src/place-search.ts",
30
35
  "./rank": "./src/rank.ts",
@@ -46,16 +51,17 @@
46
51
  "!src/release.ts",
47
52
  "starter",
48
53
  ".claude/skills/joined",
54
+ ".claude/skills/joined-door",
49
55
  "examples",
50
56
  "!examples/film.mp4",
51
57
  "!examples/backups",
52
58
  "docs/introduction.md",
53
59
  "docs/stories.md",
54
60
  "docs/design.md",
55
- "docs/learning.md",
56
61
  "docs/*.svg"
57
62
  ],
58
63
  "dependencies": {
64
+ "@awesome.me/webawesome": "3.15.0",
59
65
  "lucide": "^1.62.0"
60
66
  },
61
67
  "optionalDependencies": {
package/src/awesome.ts ADDED
@@ -0,0 +1,103 @@
1
+ // Web Awesome (MIT, @awesome.me/webawesome), joined's UI library: the surfaces and the simple controls (a drawer, a
2
+ // modal, a toast, a popover, a box, a tick, a choice of a few, tabs), each a component of its own file, imported here
3
+ // once for every page and display that uses one. joined keeps what knows its meanings: the binding (<j-sheet>,
4
+ // <j-field>, <j-search>), the controls of its kinds (a length, a zone, a place, money, people, a typeahead) and the
5
+ // readings. Its look is joined's: src/tokens.css sets the --wa- tokens to joined's own (tokens.json's "wa"), so
6
+ // light and dark follow the device as joined's do. Its icons are lucide's, for both of its libraries: "default"
7
+ // (<wa-icon name="close">, by joined's own names, src/icon-names.ts) and "system" (the chevrons, ×s and ticks inside
8
+ // its components, by Font Awesome's names, each given lucide's outline here); each drawn as a data: URL, so there's
9
+ // nothing to fetch and no route to serve.
10
+
11
+ import "@awesome.me/webawesome/dist/components/callout/callout.js";
12
+ import "@awesome.me/webawesome/dist/components/card/card.js";
13
+ import "@awesome.me/webawesome/dist/components/checkbox/checkbox.js";
14
+ import "@awesome.me/webawesome/dist/components/dialog/dialog.js";
15
+ import "@awesome.me/webawesome/dist/components/drawer/drawer.js";
16
+ import "@awesome.me/webawesome/dist/components/icon/icon.js";
17
+ import "@awesome.me/webawesome/dist/components/input/input.js";
18
+ import "@awesome.me/webawesome/dist/components/number-input/number-input.js";
19
+ import "@awesome.me/webawesome/dist/components/option/option.js";
20
+ import "@awesome.me/webawesome/dist/components/popover/popover.js";
21
+ import "@awesome.me/webawesome/dist/components/select/select.js";
22
+ import "@awesome.me/webawesome/dist/components/switch/switch.js";
23
+ import "@awesome.me/webawesome/dist/components/tab/tab.js";
24
+ import "@awesome.me/webawesome/dist/components/tab-group/tab-group.js";
25
+ import "@awesome.me/webawesome/dist/components/tab-panel/tab-panel.js";
26
+ import "@awesome.me/webawesome/dist/components/textarea/textarea.js";
27
+ import "@awesome.me/webawesome/dist/components/toast/toast.js";
28
+ import "@awesome.me/webawesome/dist/components/tooltip/tooltip.js";
29
+ import { registerIconLibrary } from "@awesome.me/webawesome/dist/components/icon/library.js";
30
+ import {
31
+ Check,
32
+ ChevronDown,
33
+ ChevronLeft,
34
+ ChevronRight,
35
+ CircleHelp,
36
+ CircleX,
37
+ Clock,
38
+ Copy,
39
+ Ellipsis,
40
+ Eye,
41
+ EyeOff,
42
+ GripVertical,
43
+ Image,
44
+ Menu,
45
+ Minus,
46
+ Pause,
47
+ Pipette,
48
+ Play,
49
+ Plus,
50
+ Star,
51
+ User,
52
+ X,
53
+ ZoomIn,
54
+ ZoomOut,
55
+ type IconNode,
56
+ } from "lucide";
57
+ import { ICONS } from "./icon-names.ts";
58
+
59
+ /** The names Web Awesome's components ask the system library for (Font Awesome's), each as lucide draws it:
60
+ * tests/awesome.test.ts holds this to every name its components ask for. */
61
+ export const SYSTEM: Record<string, IconNode> = {
62
+ bars: Menu,
63
+ check: Check,
64
+ "chevron-down": ChevronDown,
65
+ "chevron-left": ChevronLeft,
66
+ "chevron-right": ChevronRight,
67
+ "circle-xmark": CircleX,
68
+ clock: Clock,
69
+ copy: Copy,
70
+ ellipsis: Ellipsis,
71
+ eye: Eye,
72
+ eyedropper: Pipette,
73
+ "eye-slash": EyeOff,
74
+ "grip-vertical": GripVertical,
75
+ image: Image,
76
+ indeterminate: Minus,
77
+ "magnifying-glass-minus": ZoomOut,
78
+ "magnifying-glass-plus": ZoomIn,
79
+ minus: Minus,
80
+ pause: Pause,
81
+ play: Play,
82
+ plus: Plus,
83
+ star: Star,
84
+ user: User,
85
+ xmark: X,
86
+ };
87
+
88
+ /** An outline as an SVG file's words, as lucide draws it: a 2px stroke on a 24 grid, in the words' colour. */
89
+ export const svgOf = (node: IconNode) =>
90
+ `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${node
91
+ .map(
92
+ ([tag, attrs]) =>
93
+ `<${tag} ${Object.entries(attrs)
94
+ .map(([k, v]) => `${k}="${v}"`)
95
+ .join(" ")}/>`,
96
+ )
97
+ .join("")}</svg>`;
98
+ const url = (node: IconNode) => `data:image/svg+xml,${encodeURIComponent(svgOf(node))}`;
99
+
100
+ registerIconLibrary("default", {
101
+ resolver: (name) => url(ICONS[name as keyof typeof ICONS] ?? CircleHelp),
102
+ });
103
+ registerIconLibrary("system", { resolver: (name) => url(SYSTEM[name] ?? CircleHelp) });
package/src/board.css ADDED
@@ -0,0 +1,75 @@
1
+ /* <j-board> (./board.ts), in its shadow: its lanes side by side, each its name and how many, its cards, and Add at
2
+ its foot; a lane a card may go to marked as it's dragged over. On a phone, lanes to swipe between. */
3
+ .lanes {
4
+ display: grid;
5
+ grid-auto-columns: minmax(0, 1fr);
6
+ grid-auto-flow: column;
7
+ gap: var(--space-12);
8
+ padding: var(--space-12) var(--space-16) var(--space-16);
9
+ overflow-x: auto;
10
+ }
11
+ .lane {
12
+ display: flex;
13
+ flex-direction: column;
14
+ gap: var(--space-8);
15
+ min-width: calc(var(--space-64) * 3);
16
+ padding: var(--space-8);
17
+ border-radius: var(--radius);
18
+ background: var(--well);
19
+ }
20
+ .lane[over] {
21
+ box-shadow: inset 0 0 0 calc(var(--space-4) / 2) var(--accent);
22
+ }
23
+ .lane h3 {
24
+ display: flex;
25
+ align-items: center;
26
+ gap: var(--space-8);
27
+ margin: 0;
28
+ padding: var(--space-4) var(--space-4) 0;
29
+ font: var(--font-label);
30
+ }
31
+ .count {
32
+ color: var(--muted);
33
+ font: var(--font-small);
34
+ font-variant-numeric: tabular-nums;
35
+ }
36
+ .lane ol {
37
+ display: grid;
38
+ gap: var(--space-8);
39
+ margin: 0;
40
+ padding: 0;
41
+ list-style: none;
42
+ }
43
+ .card {
44
+ display: grid;
45
+ gap: var(--space-4);
46
+ width: 100%;
47
+ padding: var(--space-8) var(--space-12);
48
+ background: var(--card);
49
+ font: var(--font-row);
50
+ white-space: normal;
51
+ }
52
+ .card:hover,
53
+ .card[aria-current="true"] {
54
+ background: var(--card-hover);
55
+ }
56
+ .card .at {
57
+ font: var(--font-small);
58
+ }
59
+ .adding {
60
+ align-self: flex-start;
61
+ }
62
+ @media (max-width: 40rem) {
63
+ .lanes {
64
+ grid-auto-columns: 85%;
65
+ scroll-snap-type: x mandatory;
66
+ overscroll-behavior-x: contain;
67
+ }
68
+ .lane {
69
+ scroll-snap-align: start;
70
+ }
71
+ .card,
72
+ .adding {
73
+ min-height: var(--size-finger);
74
+ }
75
+ }