@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
@@ -1,70 +0,0 @@
1
- // The answers in an event's form: a row for each person on it, their face and name, their answer (yes unless said
2
- // otherwise: ./answers.ts) and whether they come or go there (the line lands them, or sends them home). A change is
3
- // the form's, until Save.
4
-
5
- import { hueOf } from "joined/hues";
6
- import { keep } from "joined/keep";
7
- import { face } from "joined/parts";
8
- import { ANSWERS, SAID, type Answer } from "./answers.ts";
9
-
10
- /** Who among an event's people comes or goes at it. */
11
- export type Gates = { arrives: Set<number>; leaves: Set<number> };
12
- /** What the rows read of their form, when drawn and when changed: who's on it, their answers, who comes and goes. */
13
- type Of = { readonly chosen: readonly number[]; readonly answers: Map<number, Answer>; readonly gates: Gates };
14
-
15
- export class AnswerRows {
16
- #kept = new Map<string, { shows: string; el: HTMLElement }>();
17
-
18
- /** Drawn in `list`, from the form `of`; a change told to `redraw`. */
19
- constructor(
20
- readonly list: HTMLElement,
21
- readonly of: Of,
22
- readonly redraw: () => void,
23
- ) {}
24
-
25
- /** A row each for those chosen, named from `people`: made again only as its name, answer or comings change. */
26
- draw(people: Map<number, string>) {
27
- keep(
28
- this.list,
29
- this.#kept,
30
- this.of.chosen.map((key) => {
31
- const name = people.get(key) ?? "",
32
- now = this.of.answers.get(key) ?? "yes";
33
- return {
34
- key: String(key),
35
- shows: `${name} ${now} ${this.of.gates.arrives.has(key)} ${this.of.gates.leaves.has(key)}`,
36
- make: () => this.#row(key, name, now),
37
- };
38
- }),
39
- );
40
- }
41
-
42
- /** One person's row: their face and name, a select of their answer, and one of whether they come or go here. */
43
- #row(key: number, name: string, now: Answer) {
44
- const row = Object.assign(document.createElement("label"), { className: "answer" });
45
- row.style.setProperty("--hue", hueOf(key));
46
- const pick = Object.assign(document.createElement("select"), { ariaLabel: `${name}'s answer` });
47
- for (const a of ["yes", ...ANSWERS] as Answer[]) pick.append(new Option(SAID[a], a, false, a === now));
48
- pick.addEventListener("change", () => {
49
- this.of.answers.set(key, pick.value as Answer);
50
- this.redraw();
51
- });
52
- // whether they come or go here: the line lands them, or sends them home
53
- const gate = Object.assign(document.createElement("select"), { ariaLabel: `Whether ${name} comes or goes here` });
54
- const was = `${+this.of.gates.arrives.has(key)}${+this.of.gates.leaves.has(key)}`;
55
- for (const [v, words] of [
56
- ["00", "Here"],
57
- ["10", "Arrives"],
58
- ["01", "Leaves"],
59
- ["11", "Arrives, leaves"],
60
- ])
61
- gate.append(new Option(words, v, false, v === was));
62
- gate.addEventListener("change", () => {
63
- for (const [i, g] of (["arrives", "leaves"] as const).entries())
64
- gate.value[i] === "1" ? this.of.gates[g].add(key) : this.of.gates[g].delete(key);
65
- this.redraw();
66
- });
67
- row.append(face(key, name), Object.assign(document.createElement("span"), { textContent: name }), pick, gate);
68
- return row;
69
- }
70
- }
@@ -1,89 +0,0 @@
1
- // The bar atop <calendar-map>: the week's name, the week before and after (read as a month, the month before and
2
- // after), how it's read (a calendar, a line or a month: its own attribute, told to the page for its address), and Add.
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
-
5
- import type { Part } from "./shell.ts";
6
- import { dated, firstOf, gridOf, mondayOf } from "joined/time";
7
-
8
- const VIEWS = ["calendar", "line", "month"] as const;
9
- /** Its panes, and how the week is read when each is shown. */
10
- const PANES = [
11
- [".cal", "calendar"],
12
- [".strip", "calendar"],
13
- [".reading", "line"],
14
- [".month", "month"],
15
- ] as const;
16
- /** How the week is read. */
17
- export type Reading = (typeof VIEWS)[number];
18
-
19
- /** What the bar reads from its display: the week shown, whether it's read as a month, and what its buttons ask. */
20
- type From = {
21
- at: () => { week: number };
22
- lined: () => boolean;
23
- monthly: () => boolean;
24
- go: (week: number) => void;
25
- hold: (by: "week" | "month", day: number) => void;
26
- read: () => void;
27
- add: () => void;
28
- };
29
-
30
- export class Bar {
31
- #name: HTMLElement;
32
- #views: Map<Reading, HTMLElement>;
33
- #panes: [HTMLElement, Reading][];
34
- #host: HTMLElement;
35
- #from: From;
36
-
37
- /** In its parts; `host` is the display, whose `view` attribute says how it's read. */
38
- constructor(host: HTMLElement, $: Part, from: From) {
39
- this.#host = host;
40
- this.#name = $(".week");
41
- this.#views = new Map(VIEWS.map((view) => [view, $(`[name=${view}]`)]));
42
- this.#panes = PANES.map(([pane, view]) => [$(pane), view]);
43
- this.#from = from;
44
- const { at } = from;
45
- // the week before and after; read as a month, the month before and after
46
- $("[name=back]").addEventListener("click", () =>
47
- from.monthly() ? from.hold("month", gridOf(firstOf(at().week + 7) - 1)) : from.go(at().week - 7),
48
- );
49
- $("[name=on]").addEventListener("click", () =>
50
- from.monthly() ? from.hold("month", gridOf(firstOf(at().week + 7) + 31)) : from.go(at().week + 7),
51
- );
52
- $("[name=new]").addEventListener("click", () => from.add());
53
- for (const [view, b] of this.#views)
54
- b.addEventListener("click", () => {
55
- const was = from.monthly();
56
- this.readAs(view);
57
- // a month is held as its six weeks, a week as itself: the month the week's in, or that month's first week
58
- if (view === "month" && !was) from.hold("month", gridOf(at().week + 3));
59
- else if (view !== "month" && was) from.hold("week", mondayOf(firstOf(at().week + 7) + 3));
60
- else from.read();
61
- });
62
- }
63
-
64
- /** Its name: the month, read as one; else the week's days, its months whole, or short on a phone, where it shares
65
- * its line with the views and Add (and leaves out its year: there's room for them beside it only so). */
66
- name(phone: boolean) {
67
- const { week } = this.#from.at(),
68
- [a, b] = [week, week + 6],
69
- month = phone ? "short" : "long",
70
- year = phone ? {} : { year: "numeric" as const };
71
- this.#name.textContent = this.#from.monthly()
72
- ? dated(firstOf(week + 7), { month, year: "numeric" })
73
- : dated(a, { month }) === dated(b, { month })
74
- ? `${dated(a, { day: "numeric" })}–${dated(b, { day: "numeric", month, ...year })}`
75
- : `${dated(a, { day: "numeric", month })} – ${dated(b, { day: "numeric", month, ...year })}`;
76
- }
77
- /** Read as a calendar, a line or a month: its own attribute, and told to the page, for its address. */
78
- readAs(view: Reading) {
79
- this.#host.setAttribute("view", view);
80
- this.#host.dispatchEvent(new CustomEvent("view", { bubbles: true, detail: view }));
81
- }
82
- /** How it's read, shown: its pane, and its button pressed. */
83
- show(): Reading {
84
- const shown = this.#from.monthly() ? "month" : this.#from.lined() ? "line" : "calendar";
85
- for (const [pane, view] of this.#panes) pane.hidden = view !== shown;
86
- for (const [view, b] of this.#views) b.setAttribute("aria-pressed", String(view === shown));
87
- return shown;
88
- }
89
- }