@blueshed/joined 0.2.2 → 0.3.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 (237) hide show
  1. package/.claude/skills/joined/SKILL.md +9 -1
  2. package/.claude/skills/joined/reference.md +316 -63
  3. package/.claude/skills/joined-door/SKILL.md +57 -0
  4. package/README.md +19 -50
  5. package/docs/design.md +158 -37
  6. package/docs/introduction.md +27 -27
  7. package/docs/light-and-shadow.svg +2 -1
  8. package/docs/links-and-trust.svg +1 -0
  9. package/docs/stories-to-code.svg +2 -1
  10. package/docs/wire-op.svg +1 -0
  11. package/examples/README.md +20 -0
  12. package/examples/account/account.json +1 -0
  13. package/examples/account/derive.ts +41 -0
  14. package/examples/account/generated/elements.ts +52 -0
  15. package/examples/account/generated/rows.ts +22 -0
  16. package/examples/account/generated/rules.ts +32 -0
  17. package/examples/account/routes.ts +5 -0
  18. package/examples/app.css +11 -1
  19. package/examples/cafe/books.html +2 -2
  20. package/examples/cafe/cafe.css +96 -85
  21. package/examples/cafe/generated/books.rows.ts +22 -0
  22. package/examples/cafe/generated/books.rules.ts +3 -2
  23. package/examples/cafe/generated/kitchen.rows.ts +27 -0
  24. package/examples/cafe/generated/kitchen.rules.ts +11 -1
  25. package/examples/cafe/generated/menu.rows.ts +22 -0
  26. package/examples/cafe/generated/menu.rules.ts +3 -2
  27. package/examples/cafe/generated/order.rows.ts +27 -0
  28. package/examples/cafe/generated/order.rules.ts +11 -1
  29. package/examples/cafe/generated/staff.elements.ts +7 -2
  30. package/examples/cafe/generated/staff.rows.ts +22 -0
  31. package/examples/cafe/generated/staff.rules.ts +9 -1
  32. package/examples/cafe/generated/supplies.queries.ts +4 -2
  33. package/examples/cafe/generated/supplies.rows.ts +22 -0
  34. package/examples/cafe/generated/supplies.rules.ts +17 -1
  35. package/examples/cafe/generated/till.queries.ts +2 -0
  36. package/examples/cafe/generated/till.rows.ts +27 -0
  37. package/examples/cafe/generated/till.rules.ts +11 -1
  38. package/examples/cafe/index.html +14 -15
  39. package/examples/cafe/kitchen.css +11 -19
  40. package/examples/cafe/kitchen.ts +7 -3
  41. package/examples/cafe/look.ts +30 -0
  42. package/examples/cafe/menu.html +10 -26
  43. package/examples/cafe/menu.ts +8 -80
  44. package/examples/cafe/migrations/002-guard-supplies.ts +15 -0
  45. package/examples/cafe/order.html +8 -7
  46. package/examples/cafe/order.ts +6 -2
  47. package/examples/cafe/routes.ts +0 -1
  48. package/examples/cafe/staff.json +5 -0
  49. package/examples/cafe/stories.jsonl +6 -2
  50. package/examples/cafe/supplies.html +35 -34
  51. package/examples/cafe/supplies.ts +59 -39
  52. package/examples/cafe/till.ts +19 -11
  53. package/examples/cafe/views.ts +7 -5
  54. package/examples/chart/arches.ts +150 -0
  55. package/examples/chart/chart.css +11 -0
  56. package/examples/chart/chart.json +87 -0
  57. package/examples/chart/generated/elements.ts +105 -0
  58. package/examples/chart/generated/queries.ts +36 -0
  59. package/examples/chart/generated/rows.ts +27 -0
  60. package/examples/chart/generated/rules.ts +111 -0
  61. package/examples/chart/grid.ts +118 -0
  62. package/examples/chart/index.html +78 -0
  63. package/examples/chart/migrations/001-chart.ts +6 -0
  64. package/examples/chart/migrations/002-create-conditions.ts +6 -0
  65. package/examples/chart/page.ts +20 -0
  66. package/examples/chart/routes.ts +7 -0
  67. package/examples/chart/stories.jsonl +14 -0
  68. package/examples/chart/teeth.ts +57 -0
  69. package/examples/desk/desk.css +6 -10
  70. package/examples/desk/generated/elements.ts +1 -1
  71. package/examples/desk/generated/rows.ts +22 -0
  72. package/examples/desk/generated/rules.ts +34 -1
  73. package/examples/desk/index.html +10 -3
  74. package/examples/desk/lanes.css +21 -19
  75. package/examples/desk/routes.ts +0 -2
  76. package/examples/desk/stories.jsonl +4 -3
  77. package/examples/desk/tally.css +1 -1
  78. package/examples/desk/thumbs.ts +2 -2
  79. package/examples/docs.ts +7 -4
  80. package/examples/hello/generated/elements.ts +2 -2
  81. package/examples/hello/generated/rules.ts +3 -2
  82. package/examples/hello/hello.css +2 -4
  83. package/examples/hello/index.html +10 -3
  84. package/examples/hello/page.ts +4 -4
  85. package/examples/index.html +20 -12
  86. package/examples/notes/generated/elements.ts +112 -0
  87. package/examples/notes/generated/queries.ts +42 -0
  88. package/examples/notes/generated/rows.ts +27 -0
  89. package/examples/notes/generated/rules.ts +133 -0
  90. package/examples/notes/index.html +32 -0
  91. package/examples/notes/look.ts +41 -0
  92. package/examples/notes/migrations/001-notes.ts +7 -0
  93. package/examples/notes/notes.json +78 -0
  94. package/examples/notes/page.ts +21 -0
  95. package/examples/notes/routes.ts +6 -0
  96. package/examples/notes/stories.jsonl +24 -0
  97. package/examples/page.ts +9 -2
  98. package/examples/people/generated/rows.ts +22 -0
  99. package/examples/people/generated/rules.ts +11 -1
  100. package/examples/people/links.ts +8 -9
  101. package/examples/people/people.css +1 -1
  102. package/examples/people/routes.ts +1 -3
  103. package/examples/people/stories.jsonl +1 -0
  104. package/examples/people/view.ts +5 -2
  105. package/examples/trip/generated/elements.ts +5 -3
  106. package/examples/trip/generated/queries.ts +12 -1
  107. package/examples/trip/generated/rows.ts +27 -0
  108. package/examples/trip/generated/rules.ts +56 -2
  109. package/examples/trip/index.html +58 -12
  110. package/examples/trip/line.css +186 -0
  111. package/examples/trip/line.ts +51 -40
  112. package/examples/trip/page.ts +65 -71
  113. package/examples/trip/routes.ts +9 -5
  114. package/examples/trip/stays.css +13 -13
  115. package/examples/trip/stays.ts +15 -10
  116. package/examples/trip/stories.jsonl +2 -0
  117. package/examples/trip/told.ts +3 -26
  118. package/examples/trip/trip.css +16 -0
  119. package/examples/trips/generated/elements.ts +1 -1
  120. package/examples/trips/generated/rows.ts +22 -0
  121. package/examples/trips/generated/rules.ts +9 -1
  122. package/examples/trips/index.html +10 -10
  123. package/examples/trips/map.ts +3 -14
  124. package/examples/trips/new-trip.ts +14 -16
  125. package/examples/trips/trips.css +24 -23
  126. package/examples/weeks/generated/elements.ts +1 -1
  127. package/examples/weeks/generated/queries.ts +11 -0
  128. package/examples/weeks/generated/rows.ts +22 -0
  129. package/examples/weeks/generated/rules.ts +11 -5
  130. package/examples/weeks/routes.ts +3 -2
  131. package/examples/weeks/stories.jsonl +1 -0
  132. package/examples/welcome.css +43 -33
  133. package/package.json +8 -2
  134. package/src/attachment.ts +17 -2
  135. package/src/awesome.ts +103 -0
  136. package/src/board.css +76 -0
  137. package/src/board.ts +173 -0
  138. package/src/cli.ts +28 -3
  139. package/src/compile.ts +821 -109
  140. package/src/definitions.ts +113 -27
  141. package/src/demo.css +2 -5
  142. package/src/draft.ts +48 -27
  143. package/src/drawer.ts +248 -0
  144. package/src/engine.ts +253 -170
  145. package/src/fields.ts +341 -0
  146. package/src/file-value.ts +12 -2
  147. package/src/files.ts +113 -33
  148. package/src/ground.ts +110 -0
  149. package/src/icon-names.ts +19 -2
  150. package/src/keep.ts +16 -3
  151. package/src/kit.ts +51 -0
  152. package/src/link.ts +3 -3
  153. package/src/map.css +140 -0
  154. package/src/map.ts +200 -0
  155. package/src/mcp.ts +129 -24
  156. package/src/members/demo.ts +13 -12
  157. package/src/members/generated/rows.ts +22 -0
  158. package/src/members/generated/rules.ts +3 -2
  159. package/src/members/group.ts +105 -55
  160. package/src/members/keys.ts +95 -79
  161. package/src/members/panel.css +40 -35
  162. package/src/members/panel.ts +58 -37
  163. package/src/migrate.ts +178 -125
  164. package/src/migrations/005-change-kept.ts +7 -0
  165. package/src/month.css +129 -0
  166. package/src/month.ts +179 -0
  167. package/src/ops.ts +40 -1
  168. package/src/page.css +11 -2
  169. package/src/page.ts +68 -17
  170. package/src/parts.css +614 -230
  171. package/src/parts.ts +259 -36
  172. package/src/plane.css +61 -0
  173. package/src/plane.ts +153 -0
  174. package/src/postgres-server.ts +60 -0
  175. package/src/reading.css +73 -0
  176. package/src/reading.ts +238 -0
  177. package/src/rows.css +289 -0
  178. package/src/rows.ts +864 -0
  179. package/src/search.css +80 -0
  180. package/src/search.ts +130 -0
  181. package/src/server.ts +355 -137
  182. package/src/settings.ts +9 -4
  183. package/src/sheet.ts +116 -0
  184. package/src/skill.ts +40 -0
  185. package/src/slots.css +90 -0
  186. package/src/slots.ts +213 -0
  187. package/src/specs.ts +38 -0
  188. package/src/starter.ts +19 -2
  189. package/src/store.ts +224 -161
  190. package/src/stories.ts +43 -11
  191. package/src/surface.ts +164 -0
  192. package/src/time.ts +2 -0
  193. package/src/timeline.css +111 -0
  194. package/src/timeline.ts +235 -0
  195. package/src/toast.ts +21 -48
  196. package/src/together.ts +15 -24
  197. package/src/tokens.css +89 -3
  198. package/src/tokens.json +287 -7
  199. package/src/tool.ts +210 -0
  200. package/src/upkeep.ts +47 -22
  201. package/src/views.css +43 -0
  202. package/src/views.ts +111 -0
  203. package/src/week.css +150 -0
  204. package/src/week.ts +254 -0
  205. package/src/write.ts +326 -78
  206. package/starter/CHANGELOG.md +8 -0
  207. package/starter/CLAUDE.md +9 -3
  208. package/starter/bunfig +5 -0
  209. package/starter/githooks/pre-commit +13 -0
  210. package/starter/prettierignore +5 -0
  211. package/starter/tests/hello.test.ts +2 -0
  212. package/starter/tests/records.test.ts +40 -0
  213. package/starter/todo.jsonl +0 -0
  214. package/docs/learning.md +0 -76
  215. package/examples/cafe/trust.ts +0 -20
  216. package/examples/desk/trust.ts +0 -24
  217. package/examples/people/trust.ts +0 -14
  218. package/examples/trip/answer-rows.ts +0 -70
  219. package/examples/trip/bar.ts +0 -89
  220. package/examples/trip/calendar-map.css +0 -711
  221. package/examples/trip/calendar-map.ts +0 -249
  222. package/examples/trip/drags.ts +0 -143
  223. package/examples/trip/drawer.ts +0 -250
  224. package/examples/trip/event-form.ts +0 -200
  225. package/examples/trip/holding.ts +0 -61
  226. package/examples/trip/map.ts +0 -234
  227. package/examples/trip/month.ts +0 -87
  228. package/examples/trip/other-weeks.ts +0 -67
  229. package/examples/trip/peek.ts +0 -71
  230. package/examples/trip/people-chips.ts +0 -74
  231. package/examples/trip/shell.ts +0 -39
  232. package/examples/trip/trust.ts +0 -51
  233. package/examples/trip/week.ts +0 -237
  234. package/examples/trip/writes.ts +0 -91
  235. package/examples/trip/zones.ts +0 -16
  236. package/examples/weeks/derive.ts +0 -23
  237. package/src/scrim.ts +0 -81
@@ -1,4 +1,5 @@
1
1
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 880 360" font-family="system-ui, -apple-system, sans-serif">
2
+ <style>/* drawn dark on a dark page: each of its colours as joined's dark tokens have it (src/tokens.json) */ @media (prefers-color-scheme: dark) { [fill="#222"] { fill: #e5e5e5; } [fill="#444"] { fill: #e5e5e5; } [fill="#666"] { fill: #a8a8a8; } [fill="#555"] { fill: #a8a8a8; } [fill="#2c5282"] { fill: #9cbde6; } [fill="#ffffff"] { fill: #1a1b1e; } [fill="#fff"] { fill: #1a1b1e; } [fill="#f8f9fa"] { fill: #111213; } [fill="#fafafa"] { fill: #111213; } [fill="#f3f4f6"] { fill: #23262b; } [fill="#eef3f8"] { fill: #1f2a38; } [fill="#e8eff7"] { fill: #1f2a38; } [fill="#e8eef2"] { fill: #1f2a38; } [fill="#dbe6ec"] { fill: #1f2a38; } [fill="#fdf6ec"] { fill: #2e2418; } [fill="#fdebd6"] { fill: #2e2418; } [stroke="#e5e5e5"] { stroke: #2e2e33; } [stroke="#eee"] { stroke: #2e2e33; } [stroke="#f3f3f3"] { stroke: #2e2e33; } [stroke="#ddd"] { stroke: #2e2e33; } [stroke="#dde5ea"] { stroke: #2e2e33; } [stroke="#ccc"] { stroke: #60616b; } [stroke="#222"] { stroke: #e5e5e5; } [stroke="#fff"] { stroke: #1a1b1e; } }</style>
2
3
  <defs>
3
4
  <marker id="arrow-obs" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse">
4
5
  <path d="M 0 1.5 L 8.5 5 L 0 8.5 z" fill="#4e79a7"/>
@@ -10,7 +11,7 @@
10
11
 
11
12
  <!-- Outer Host Frame: <calendar-map> -->
12
13
  <rect width="880" height="360" rx="10" fill="#fafafa" stroke="#ccc"/>
13
- <text x="20" y="25" font-family="ui-monospace, SFMono-Regular, Menlo, monospace" font-size="13" font-weight="600" fill="#222">&lt;calendar-map people="people"&gt;</text>
14
+ <text x="20" y="25" font-family="ui-monospace, SFMono-Regular, Menlo, monospace" font-size="13" font-weight="600" fill="#222">&lt;calendar-map people="the-people"&gt;</text>
14
15
  <text x="860" y="25" font-size="12" fill="#666" text-anchor="end">The light DOM is the document; the shadow DOM is the display.</text>
15
16
 
16
17
  <!-- Left Panel: Light DOM (The Document) -->
@@ -1,4 +1,5 @@
1
1
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 880 320" font-family="system-ui, -apple-system, sans-serif">
2
+ <style>/* drawn dark on a dark page: each of its colours as joined's dark tokens have it (src/tokens.json) */ @media (prefers-color-scheme: dark) { [fill="#222"] { fill: #e5e5e5; } [fill="#666"] { fill: #a8a8a8; } [fill="#555"] { fill: #a8a8a8; } [fill="#ffffff"] { fill: #1a1b1e; } [fill="#fff"] { fill: #1a1b1e; } [fill="#f8f9fa"] { fill: #111213; } [fill="#fafafa"] { fill: #111213; } [fill="#f3f4f6"] { fill: #23262b; } [fill="#ccc"] { fill: #3a3b42; } [fill="#fdf6ec"] { fill: #2e2418; } [stroke="#e5e5e5"] { stroke: #2e2e33; } [stroke="#ddd"] { stroke: #2e2e33; } [stroke="#ccc"] { stroke: #60616b; } [stroke="#888"] { stroke: #6e6f78; } [stroke="#222"] { stroke: #e5e5e5; } }</style>
2
3
  <defs>
3
4
  <marker id="l-arrow" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse">
4
5
  <path d="M 0 1.5 L 8.5 5 L 0 8.5 z" fill="#e15759"/>
@@ -1,4 +1,5 @@
1
1
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 880 390" font-family="system-ui, -apple-system, sans-serif">
2
+ <style>/* drawn dark on a dark page: each of its colours as joined's dark tokens have it (src/tokens.json) */ @media (prefers-color-scheme: dark) { [fill="#222"] { fill: #e5e5e5; } [fill="#666"] { fill: #a8a8a8; } [fill="#555"] { fill: #a8a8a8; } [fill="#2c5282"] { fill: #9cbde6; } [fill="#ffffff"] { fill: #1a1b1e; } [fill="#fff"] { fill: #1a1b1e; } [fill="#fafafa"] { fill: #111213; } [fill="#f3f4f6"] { fill: #23262b; } [fill="#ddd"] { fill: #3a3b42; } [fill="#eef3f8"] { fill: #1f2a38; } [stroke="#e5e5e5"] { stroke: #2e2e33; } [stroke="#ccc"] { stroke: #60616b; } [stroke="#222"] { stroke: #e5e5e5; } [stroke="#666"] { stroke: #a8a8a8; } }</style>
2
3
  <defs>
3
4
  <marker id="arrow" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse">
4
5
  <path d="M 0 1.5 L 8.5 5 L 0 8.5 z" fill="#666"/>
@@ -43,7 +44,7 @@
43
44
  <g transform="translate(190, 160)">
44
45
  <rect width="500" height="58" rx="8" fill="#222" stroke="#222"/>
45
46
  <text x="250" y="23" font-size="13" font-weight="600" fill="#fff" text-anchor="middle">src/compile.ts — modelOf(stories)</text>
46
- <text x="250" y="43" font-family="ui-monospace, SFMono-Regular, Menlo, monospace" font-size="10.5" fill="#ddd" text-anchor="middle">
47
+ <text x="250" y="43" font-family="ui-monospace, SFMono-Regular, Menlo, monospace" font-size="10.5" fill="#ddd" text-anchor="middle" textLength="476" lengthAdjust="spacingAndGlyphs">
47
48
  events → &lt;j-events&gt;&lt;j-event&gt; · tables · required · replace · clear · links
48
49
  </text>
49
50
  </g>
package/docs/wire-op.svg CHANGED
@@ -1,4 +1,5 @@
1
1
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 880 310" font-family="system-ui, -apple-system, sans-serif">
2
+ <style>/* drawn dark on a dark page: each of its colours as joined's dark tokens have it (src/tokens.json) */ @media (prefers-color-scheme: dark) { [fill="#222"] { fill: #e5e5e5; } [fill="#666"] { fill: #a8a8a8; } [fill="#555"] { fill: #a8a8a8; } [fill="#2c5282"] { fill: #9cbde6; } [fill="#2b6e22"] { fill: #8fd17f; } [fill="#a33"] { fill: #ef6b6b; } [fill="#ffffff"] { fill: #1a1b1e; } [fill="#fff"] { fill: #1a1b1e; } [fill="#f8f9fa"] { fill: #111213; } [fill="#fafafa"] { fill: #111213; } [fill="#f3f4f6"] { fill: #23262b; } [fill="#eef3f8"] { fill: #1f2a38; } [fill="#eef7ec"] { fill: #1e2b1c; } [stroke="#e5e5e5"] { stroke: #2e2e33; } [stroke="#eee"] { stroke: #2e2e33; } [stroke="#ddd"] { stroke: #2e2e33; } [stroke="#ccc"] { stroke: #60616b; } [stroke="#222"] { stroke: #e5e5e5; } }</style>
2
3
  <defs>
3
4
  <marker id="w-arrow" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse">
4
5
  <path d="M 0 1.5 L 8.5 5 L 0 8.5 z" fill="#4e79a7"/>
@@ -0,0 +1,20 @@
1
+ # The examples
2
+
3
+ Each is an app on joined, a folder of its own, served together by `bun run dev`. Each shows something no other does;
4
+ the skill's section that leans on it is in brackets. Copy the smallest that has what you need.
5
+
6
+ | App | What it shows that no other does |
7
+ | ---------- | ---------------------------------------------------------------------------------------------------------------------------- |
8
+ | `hello/` | The smallest: one document anyone may change, no group, no collection. What `joined init` starts from (§1). |
9
+ | `notes/` | A collection drawn as rows by the compiler alone, and each member's own order (`mine` ranks) (§1, §15). |
10
+ | `people/` | The smallest with members: a document other pages hold, with no page of its own; links, adding, a grip's order (§2, §6). |
11
+ | `trip/` | The kit's readings over one document (week, month, map, timeline), a window by week, seeds (§3, §4, §14, §17). |
12
+ | `trips/` | A kind: each trip the root of a `trip:<id>` document of its own, and a stranger by its code (§15). |
13
+ | `weeks/` | A document read off others, as each member has it: no rows of its own (§15). |
14
+ | `chart/` | A dental chart: a display drawn in arches, and unique sets of fields together (§5, §15). |
15
+ | `account/` | A derived document: read off the chart by `derive.ts`, written nowhere (§15). |
16
+ | `cafe/` | Several documents on one page, displays and a drag, definitions and guests, and the kit's smallest sheet (§5, §7, §15, §17). |
17
+ | `desk/` | The recipes: lanes dragged, the moves `may` offers, thumbs, a tally, a glow (§16). |
18
+
19
+ The root's own (`routes.ts`, `index.html`, `page.ts`, `welcome.css`, `docs.ts`) is the welcome page that links them,
20
+ and the docs it serves; `app.css` is the look they share.
@@ -0,0 +1 @@
1
+ { "charges": [{ "id": 1, "what": "Examination", "band": 1 }] }
@@ -0,0 +1,41 @@
1
+ // The account: a document derived from the chart, never typed. Complete the chart and the account takes care of
2
+ // itself: a charge for each piece of this course's work, to do or done (never what the patient came in with), and the
3
+ // course of treatment's band, the highest any charge reaches. NHS England's bands: an examination band 1; a filling,
4
+ // an extraction or a root filling band 2; a crown band 3; one charge a course, at its highest band.
5
+
6
+ import type { Read } from "joined/server";
7
+
8
+ export const doc = "account";
9
+ export const from = ["chart"];
10
+
11
+ type Surface = { tooth: string; surface: string; material: string; status: string };
12
+ type Condition = { tooth: string; state: string; status: string };
13
+
14
+ const BANDS: Record<string, [string, number]> = {
15
+ extract: ["extraction", 2],
16
+ "root filling": ["root filling", 2],
17
+ crown: ["crown", 3],
18
+ };
19
+ const thisCourse = (status: string) => status === "to do" || status === "done";
20
+
21
+ /** The examination, a charge for each tooth's fillings and its condition this course, and the course's band. */
22
+ export function derive(read: Read, member: number) {
23
+ const chart = read("chart", member),
24
+ surfaces = ((chart.surfaces ?? []) as Surface[]).filter((s) => thisCourse(s.status)),
25
+ conditions = ((chart.conditions ?? []) as Condition[]).filter((c) => thisCourse(c.status) && BANDS[c.state]);
26
+ const fillings = new Map<string, Surface[]>();
27
+ for (const s of surfaces) {
28
+ const k = `${s.tooth} ${s.material} ${s.status}`;
29
+ fillings.set(k, [...(fillings.get(k) ?? []), s]);
30
+ }
31
+ const charges = [
32
+ { what: "Examination", band: 1 },
33
+ ...[...fillings.values()].map((ss) => ({
34
+ what: `${ss[0]!.tooth} ${ss.map((s) => s.surface).join("")} ${ss[0]!.material} filling, ${ss[0]!.status}`,
35
+ band: 2,
36
+ })),
37
+ ...conditions.map((c) => ({ what: `${c.tooth} ${BANDS[c.state]![0]}, ${c.status}`, band: BANDS[c.state]![1] })),
38
+ ];
39
+ const band = Math.max(...charges.map((c) => c.band));
40
+ return { charges: [...charges, { what: "Course of treatment", band }].map((c, i) => ({ id: i + 1, ...c })) };
41
+ }
@@ -0,0 +1,52 @@
1
+ // Written by src/compile.ts from examples/account/derive.ts: change it and its example, not this.
2
+
3
+ // Each collection is an element, defined here: on a page, it holds the document, and its items
4
+ // are put inside it. Each item is an element, defined by the page: as it is, or by a view that
5
+ // extends it. A field is an attribute (a list of ids as IDREFS: "1 3"), and an item's key the
6
+ // document's id for it. How an item looks is the app's: its view, or a display holding the
7
+ // collection draws it. Ops go up as an "ops" event, for the page to send to account, with why they
8
+ // were made if it's said; only the ops the stories allow can be sent. Each returns its write's answer.
9
+
10
+ import { hold, letGo, type Answer } from "joined/page";
11
+
12
+ // the document an element is of: its collection's doc attribute (an instance of a kind, shelf:1), or account
13
+ const docOf = (el: Element) => el.closest("[doc]")?.getAttribute("doc") ?? "account";
14
+ // an element's ops go up as an "ops" event; what it returns is the write's answer, done or refused
15
+ const send = (from: Element, ops: object[], why?: string) => new Promise<Answer>((answer) => from.dispatchEvent(new CustomEvent("ops", { bubbles: true, composed: true, detail: { doc: docOf(from), ops, why, answer } })));
16
+
17
+ /** A charge's fields, as the stories give them. */
18
+ export type JChargeData = { "what": string; "band": number };
19
+ /** An add of a charge, as it's sent: its fields as the stories write them. */
20
+ export type JChargeValue = { "what": string; "band": number };
21
+
22
+ /** <j-charge key>: what (string), band (integer), each an attribute. */
23
+ export class JCharge extends HTMLElement {
24
+ static observedAttributes = ["what","band","may"];
25
+ #data?: JChargeData;
26
+ /** Its id in the document. */
27
+ get key() { return Number(this.getAttribute("key")); }
28
+ get path() { return `/charges/${this.key}`; }
29
+ /** Its fields, read from its attributes once and again when one changes: frozen, since they're shared. */
30
+ get data(): JChargeData {
31
+ return (this.#data ??= Object.freeze({ "what": this.getAttribute("what") ?? "", "band": Number(this.getAttribute("band")) }) as JChargeData);
32
+ }
33
+ /** How a view shows it, drawn again whenever an attribute changes (what its person may do, its may, too). */
34
+ draw?(): void;
35
+ attributeChangedCallback() { this.#data = undefined; this.draw?.(); }
36
+ }
37
+
38
+ /** <j-charges>: the document's charges, each a <j-charge> inside it. */
39
+ export class JCharges extends HTMLElement {
40
+ connectedCallback() { hold(this, docOf(this), "charges", "j-charge", {"what":"string","band":"integer"}); }
41
+ disconnectedCallback() { letGo(this); }
42
+ /** Its charges, as the document has them. */
43
+ get items() { return [...this.children].filter((el): el is JCharge => el.localName === "j-charge"); }
44
+ }
45
+ customElements.define("j-charges", JCharges);
46
+
47
+ /** An op on account the stories allow, in any of its collections. */
48
+ export type AccountOp = never;
49
+
50
+ /** One write to account across its collections (a move with its legs): sent from an element of it, checked
51
+ * whole by its rules, and made whole or not at all. */
52
+ export function write(from: Element, ops: AccountOp[], why?: string) { return send(from, ops, why); }
@@ -0,0 +1,22 @@
1
+ // Written by src/compile.ts from examples/account/derive.ts: change it and its example, not this.
2
+
3
+ // Each collection of account 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-charges-rows><j-charges></j-charges></j-charges-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 { JCharge } from "./elements.ts";
15
+
16
+ const charges: Spec = {"doc":"account","name":"charges","place":"j-charges","tag":"j-charge","one":"charge","title":"what","fields":[{"name":"what","type":"string","needed":true},{"name":"band","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 = { "charges": charges };
20
+
21
+ /** <j-charges-rows>: account's charges as rows, each named by its what. */
22
+ export class JChargesRows extends rows(charges, { "j-charge": JCharge }) {}
@@ -0,0 +1,32 @@
1
+ // Written by src/compile.ts from examples/account/derive.ts: change it and its example, not this.
2
+
3
+ export type Op = { op: "add" | "replace" | "remove"; path: string; value?: any };
4
+
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 and what each field pops (a value with a form, its view; a reference, what it points at). */
7
+ export const doc = "account";
8
+ export const collections = {
9
+ "charges": {
10
+ "place": "j-charges",
11
+ "tag": "j-charge",
12
+ "fields": {
13
+ "what": "string",
14
+ "band": "integer"
15
+ },
16
+ "needs": [
17
+ "what",
18
+ "band"
19
+ ],
20
+ "links": {},
21
+ "pops": {}
22
+ }
23
+ } as const;
24
+ /** Whether every story is anonymous, none told as a member: where every app's is, the project has no members. */
25
+ export const anonymous = true;
26
+ /** What kind of document account is, by the flows it uses: static, changed only with a release (a page reads it, and
27
+ * never subscribes); read-only, live, but no page writes it (derived); or shared, its members' to write. */
28
+ export const type = "read-only";
29
+ /** The parts of account a page may hold alone, by its query's parameters (its definitions' window): null, none. */
30
+ export const window = null;
31
+ /** The documents this one is derived from (its derive.ts): what the server derives it again on a write to. */
32
+ export const derived = ["chart"];
@@ -0,0 +1,5 @@
1
+ // The account, derived from the chart (derive.ts): what the course of treatment costs, by its band, read by the
2
+ // chart's page.
3
+
4
+ export * as document from "./generated/rules.ts";
5
+ export { derive } from "./derive.ts";
package/examples/app.css CHANGED
@@ -14,8 +14,18 @@ footer > form.add {
14
14
  form.add .said {
15
15
  flex-basis: 100%;
16
16
  }
17
- form.add input {
17
+ form.add wa-input {
18
18
  flex: 1;
19
+ min-width: 0;
20
+ }
21
+ /* on a phone, the box takes the line and its deeds go under it, side by side: never a box cut to a word */
22
+ @media (max-width: 40rem) {
23
+ form.add wa-input {
24
+ flex-basis: 100%;
25
+ }
26
+ form.add > .act {
27
+ flex: 1 1 0;
28
+ }
19
29
  }
20
30
  .edge {
21
31
  display: flex;
@@ -27,11 +27,11 @@
27
27
  </nav>
28
28
  </header>
29
29
  <main class="cafe books">
30
- <section class="card" aria-label="Your books">
30
+ <wa-card class="card" aria-label="Your books">
31
31
  <j-entries></j-entries>
32
32
  <p class="none" hidden>Nothing delivered yet. A supply you buy or sell shows here once it's delivered.</p>
33
33
  <p class="sums"></p>
34
- </section>
34
+ </wa-card>
35
35
  </main>
36
36
  <script type="module" src="./books.ts"></script>
37
37
  </body>
@@ -63,7 +63,7 @@ body[data-flavour] {
63
63
  header.band {
64
64
  margin: 0 0 var(--space-16);
65
65
  padding: var(--space-12) var(--space-16);
66
- border-radius: 4px;
66
+ border-radius: var(--radius);
67
67
  background: var(--flavour-tint);
68
68
  color: var(--flavour-ink);
69
69
  }
@@ -75,25 +75,34 @@ header.band .lead {
75
75
  color: inherit;
76
76
  }
77
77
  nav.bar a {
78
- padding: 2px var(--space-10);
79
- border-radius: 99px;
78
+ display: inline-flex;
79
+ align-items: center;
80
+ min-height: var(--size-touch);
81
+ padding: 0 var(--space-10);
82
+ border-radius: var(--radius-pill);
80
83
  background: color-mix(in srgb, var(--card) 60%, transparent);
81
84
  color: var(--flavour-ink);
85
+ font: var(--font-tool);
82
86
  text-decoration: none;
83
87
  }
88
+ @media (max-width: 40rem), (pointer: coarse) {
89
+ nav.bar a {
90
+ min-height: var(--size-finger);
91
+ }
92
+ }
84
93
  nav.bar a[aria-current="page"] {
85
94
  background: var(--flavour-solid);
86
95
  color: var(--on-flavour);
87
96
  }
88
97
  .cafe {
89
98
  display: grid;
99
+ /* its parts the page's width, never what's in them (a field two columns wide grew the supply form past a phone) */
100
+ grid-template-columns: minmax(0, 1fr);
90
101
  gap: var(--space-16);
91
102
  }
103
+ /* each part of a page is joined's card (wa-card) */
92
104
  .cafe .card {
93
- padding: var(--space-12);
94
- border: 1px solid var(--edge);
95
- border-radius: 4px;
96
- background: var(--card);
105
+ --spacing: var(--space-12);
97
106
  }
98
107
  .cafe h2 {
99
108
  margin: 0 0 var(--space-8);
@@ -146,7 +155,7 @@ form.place j-item {
146
155
  gap: var(--space-4) var(--space-8);
147
156
  padding: var(--space-8) var(--space-12);
148
157
  border: 1px solid var(--edge);
149
- border-radius: 4px;
158
+ border-radius: var(--radius);
150
159
  background: var(--card);
151
160
  }
152
161
  form.place j-item p {
@@ -159,32 +168,26 @@ form.place j-item .price {
159
168
  color: var(--muted);
160
169
  font: var(--font-row);
161
170
  }
162
- /* one fewer, how many, one more: a thumb's size */
171
+ /* one fewer, how many, one more: each an icon alone, a control's size (a finger's under one: joined's .icon-only) */
163
172
  form.place j-item .steps {
164
173
  display: flex;
165
174
  align-items: center;
166
175
  gap: var(--space-8);
167
176
  }
168
- form.place j-item .steps .act {
169
- min-width: 40px;
170
- min-height: 40px;
171
- justify-content: center;
172
- font: var(--font-heading);
173
- }
174
177
  form.place j-item output {
175
178
  min-width: 2ch;
176
179
  text-align: center;
177
180
  font: var(--font-heading);
178
181
  }
179
182
  /* how many of what's left: a bar the whole width, and its words */
180
- form.place j-item .bar {
183
+ form.place j-item .stock {
181
184
  grid-column: 1 / -1;
182
185
  height: 6px;
183
- border-radius: 3px;
186
+ border-radius: var(--radius-inner);
184
187
  background: var(--well);
185
188
  overflow: hidden;
186
189
  }
187
- form.place j-item .bar i {
190
+ form.place j-item .stock i {
188
191
  display: block;
189
192
  height: 100%;
190
193
  background: var(--flavour-solid);
@@ -210,7 +213,7 @@ form.place .order {
210
213
  gap: var(--space-8);
211
214
  padding: var(--space-12);
212
215
  border: 1px solid var(--edge);
213
- border-radius: 4px;
216
+ border-radius: var(--radius);
214
217
  background: var(--card);
215
218
  position: sticky;
216
219
  top: var(--space-16);
@@ -242,6 +245,12 @@ form.place .total {
242
245
  grid-template-columns: repeat(3, 1fr);
243
246
  gap: var(--space-12);
244
247
  }
248
+ /* each column filled from its top: a ticket takes the first free row of its own column, not the row after the last
249
+ ticket placed in another */
250
+ .board j-orders {
251
+ grid-auto-flow: dense;
252
+ align-items: start;
253
+ }
245
254
  .board j-order {
246
255
  grid-column: 1;
247
256
  }
@@ -275,11 +284,11 @@ j-order {
275
284
  display: block;
276
285
  padding: var(--space-8) var(--space-12);
277
286
  border: 1px solid var(--line);
278
- border-radius: 4px;
287
+ border-radius: var(--radius);
279
288
  }
280
289
  j-order .state {
281
290
  padding: 1px var(--space-8);
282
- border-radius: 99px;
291
+ border-radius: var(--radius-pill);
283
292
  background: var(--flavour-tint);
284
293
  color: var(--flavour-ink);
285
294
  font: var(--font-small);
@@ -318,27 +327,38 @@ j-lines {
318
327
  display: none;
319
328
  }
320
329
 
321
- /* a customer's steps: where their order is; four across where there's room, two by two on a phone, so none wraps */
330
+ /* a customer's steps: where their order is, read not pressed. Four across, each a track over its word: the steps
331
+ it's been through and the one it's at, the track filled in the page's flavour; the one it's at, its word in ink */
322
332
  ol.steps {
323
333
  display: grid;
324
- grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
325
- gap: var(--space-8);
334
+ grid-template-columns: repeat(4, minmax(0, 1fr));
335
+ gap: var(--space-4);
336
+ margin: 0 0 var(--space-16);
326
337
  padding: 0;
327
338
  list-style: none;
328
339
  }
329
340
  ol.steps li {
330
- padding: var(--space-4) var(--space-8);
331
- border-radius: 99px;
332
- background: var(--flavour-tint);
333
- color: var(--flavour-ink);
334
- text-align: center;
341
+ padding-top: var(--space-6);
342
+ border-top: var(--size-stripe) solid var(--line);
343
+ color: var(--muted);
344
+ font: var(--font-small);
345
+ }
346
+ body[data-status="placed"] :is([data-step="placed"], li:has(~ [data-step="placed"])),
347
+ body[data-status="being made"] :is([data-step="being made"], li:has(~ [data-step="being made"])),
348
+ body[data-status="ready"] :is([data-step="ready"], li:has(~ [data-step="ready"])),
349
+ body[data-status="collected"] :is([data-step="collected"], li:has(~ [data-step="collected"])) {
350
+ border-top-color: var(--flavour-solid);
335
351
  }
336
352
  body[data-status="placed"] [data-step="placed"],
337
353
  body[data-status="being made"] [data-step="being made"],
338
354
  body[data-status="ready"] [data-step="ready"],
339
355
  body[data-status="collected"] [data-step="collected"] {
340
- background: var(--flavour-solid);
341
- color: var(--on-flavour);
356
+ color: var(--ink);
357
+ font-weight: 600;
358
+ }
359
+ /* its order under them says no step again: the steps are where it is */
360
+ main.yours j-order .state {
361
+ display: none;
342
362
  }
343
363
 
344
364
  /* the supply form: each field over its name, Order at the end of the row */
@@ -348,73 +368,65 @@ form.add.buy {
348
368
  align-items: end;
349
369
  gap: var(--space-12);
350
370
  }
371
+ /* what it's for, the field with the most to say: two columns wide (the whole width on a phone), never cut to a word */
372
+ form.add.buy > [name="title"] {
373
+ grid-column: span 2;
374
+ }
375
+ /* Order at the end of the row; on a phone, the form's whole width, as every form's main deed is there */
376
+ form.add.buy > .act {
377
+ grid-column: -2 / -1;
378
+ }
379
+ @media (max-width: 40rem) {
380
+ form.add.buy > .act {
381
+ grid-column: 1 / -1;
382
+ }
383
+ }
351
384
  form.add.buy label {
352
385
  display: grid;
353
386
  gap: var(--space-4);
354
387
  font: var(--font-label);
355
388
  }
356
- form.add.buy button {
357
- min-height: 40px;
358
- }
359
389
 
360
- /* supplies and books: a row each */
390
+ /* supplies and books: a row each (a supply is joined's Row: its look is the part's) */
361
391
  j-supplies,
362
392
  j-entries {
363
393
  display: grid;
364
394
  }
365
- j-supply,
366
395
  j-entry {
367
396
  display: block;
368
397
  padding: var(--space-12) 0;
369
398
  border-bottom: 1px solid var(--line);
370
399
  }
371
- j-supply:last-child,
372
400
  j-entry:last-child {
373
401
  border-bottom: 0;
374
402
  }
375
- /* a supply: what it is and where it is, what's in it at what terms, whose each part is, and its supplier's moves */
403
+ /* a supply's Delivered, beside its row's words; what it said, under them */
376
404
  j-supply {
377
- display: grid;
378
- gap: var(--space-4);
379
- }
380
- j-supply p {
381
- margin: 0;
382
- }
383
- j-supply .head {
384
- display: flex;
385
405
  flex-wrap: wrap;
386
- align-items: baseline;
387
- gap: var(--space-4) var(--space-12);
388
- }
389
- j-supply .head b {
390
- font: var(--font-title);
391
- }
392
- j-supply .what {
393
- font: var(--font-row);
394
406
  }
395
- j-supply .whose {
396
- color: var(--muted);
397
- font: var(--font-small);
398
- }
399
- j-supply .acts {
400
- display: flex;
401
- align-items: center;
402
- gap: var(--space-8);
407
+ j-supply > .act {
408
+ align-self: center;
409
+ margin-right: var(--space-12);
403
410
  }
404
- j-supply .acts:empty {
411
+ j-supply > .said:empty {
405
412
  display: none;
406
413
  }
414
+ j-supply > .said {
415
+ flex-basis: 100%;
416
+ margin: 0 var(--space-16) var(--space-8);
417
+ }
418
+ /* what an entry is, a tag as a row's state is drawn (joined's rows): a pill in the edge, its words muted */
407
419
  .pill {
408
- border-radius: 99px;
420
+ border-radius: var(--radius-pill);
409
421
  padding: 0 var(--space-8);
410
- border: 1px solid var(--flavour);
411
- font: var(--font-tiny);
422
+ border: 1px solid var(--edge);
423
+ color: var(--muted);
424
+ font: var(--font-small);
412
425
  }
413
- .pill.here,
426
+ /* sold, money in: told from bought by its words in ink */
414
427
  .pill.sold {
415
- background: var(--flavour-solid);
416
- border-color: var(--flavour-solid);
417
- color: var(--on-flavour);
428
+ border-color: var(--ink);
429
+ color: var(--ink);
418
430
  }
419
431
  /* a statement: what it was, bought or sold, its total at the right */
420
432
  j-entry {
@@ -431,17 +443,20 @@ j-entry small {
431
443
  color: var(--muted);
432
444
  font: var(--font-small);
433
445
  }
446
+ /* an amount, a row's words in bold, its figures lined up */
434
447
  j-entry > b,
435
448
  .sums b {
436
449
  text-align: right;
437
- font: var(--font-title);
450
+ font: var(--font-row);
451
+ font-weight: 600;
452
+ font-variant-numeric: tabular-nums;
438
453
  }
439
454
  .sums {
440
455
  display: grid;
441
456
  gap: var(--space-6);
442
457
  margin: var(--space-12) 0 0;
443
458
  padding-top: var(--space-12);
444
- border-top: 2px solid var(--ink);
459
+ border-top: 1px solid var(--edge);
445
460
  }
446
461
  .sums span {
447
462
  display: flex;
@@ -449,18 +464,9 @@ j-entry > b,
449
464
  font: var(--font-row);
450
465
  }
451
466
 
452
- /* the menu: an item a row, its words and, where its person may change it, the way into the drawer */
453
- main.menu j-item {
454
- display: flex;
455
- align-items: center;
456
- justify-content: space-between;
457
- gap: var(--space-8);
458
- padding: var(--space-4) 0;
459
- border-top: 1px solid var(--line);
460
- font: var(--font-row);
461
- }
462
- main.menu j-item:first-child {
463
- border-top: 0;
467
+ /* the menu: its items are rows (joined's Row), edge to edge in their card */
468
+ main.menu .card {
469
+ --spacing: 0;
464
470
  }
465
471
 
466
472
  /* the cafe's front page: how to try it, a card for each page saying whose it is, and what it shows */
@@ -484,7 +490,7 @@ main.menu j-item:first-child {
484
490
  gap: var(--space-4);
485
491
  padding: var(--space-12) var(--space-16);
486
492
  border: 1px solid var(--edge);
487
- border-radius: 4px;
493
+ border-radius: var(--radius);
488
494
  background: var(--card);
489
495
  color: var(--ink);
490
496
  text-decoration: none;
@@ -508,5 +514,10 @@ main.menu j-item:first-child {
508
514
  font: var(--font-row);
509
515
  }
510
516
  .front .go .act {
517
+ flex-direction: row-reverse;
511
518
  text-decoration: none;
512
519
  }
520
+ /* the menu's search, at the head of its rows */
521
+ main.menu .card > .find {
522
+ padding: var(--space-16) var(--space-12) var(--space-8);
523
+ }
@@ -0,0 +1,22 @@
1
+ // Written by src/compile.ts from examples/cafe/stories.jsonl: change the stories, not this.
2
+
3
+ // Each collection of books 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-entries-rows><j-entries></j-entries></j-entries-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 { JEntry } from "./books.elements.ts";
15
+
16
+ const entries: Spec = {"doc":"books","name":"entries","place":"j-entries","tag":"j-entry","one":"entry","title":"title","fields":[{"name":"title","type":"string","needed":true},{"name":"buyer","type":"integer","needed":true},{"name":"supplier","type":"integer","needed":true},{"name":"side","type":"string","needed":true},{"name":"total","type":"decimal","needed":true}]};
17
+
18
+ /** Each collection as joined's kit (joined/kit) is given it, by name: use(specs). */
19
+ export const specs = { "entries": entries };
20
+
21
+ /** <j-entries-rows>: books's entries as rows, each named by its title. */
22
+ export class JEntriesRows extends rows(entries, { "j-entry": JEntry }) {}