@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.
- package/.claude/skills/joined/SKILL.md +9 -1
- package/.claude/skills/joined/reference.md +316 -63
- package/.claude/skills/joined-door/SKILL.md +57 -0
- package/README.md +19 -50
- package/docs/design.md +158 -37
- package/docs/introduction.md +27 -27
- package/docs/light-and-shadow.svg +2 -1
- package/docs/links-and-trust.svg +1 -0
- package/docs/stories-to-code.svg +2 -1
- package/docs/wire-op.svg +1 -0
- package/examples/README.md +20 -0
- package/examples/account/account.json +1 -0
- package/examples/account/derive.ts +41 -0
- package/examples/account/generated/elements.ts +52 -0
- package/examples/account/generated/rows.ts +22 -0
- package/examples/account/generated/rules.ts +32 -0
- package/examples/account/routes.ts +5 -0
- package/examples/app.css +11 -1
- package/examples/cafe/books.html +2 -2
- package/examples/cafe/cafe.css +96 -85
- package/examples/cafe/generated/books.rows.ts +22 -0
- package/examples/cafe/generated/books.rules.ts +3 -2
- package/examples/cafe/generated/kitchen.rows.ts +27 -0
- package/examples/cafe/generated/kitchen.rules.ts +11 -1
- package/examples/cafe/generated/menu.rows.ts +22 -0
- package/examples/cafe/generated/menu.rules.ts +3 -2
- package/examples/cafe/generated/order.rows.ts +27 -0
- package/examples/cafe/generated/order.rules.ts +11 -1
- package/examples/cafe/generated/staff.elements.ts +7 -2
- package/examples/cafe/generated/staff.rows.ts +22 -0
- package/examples/cafe/generated/staff.rules.ts +9 -1
- package/examples/cafe/generated/supplies.queries.ts +4 -2
- package/examples/cafe/generated/supplies.rows.ts +22 -0
- package/examples/cafe/generated/supplies.rules.ts +17 -1
- package/examples/cafe/generated/till.queries.ts +2 -0
- package/examples/cafe/generated/till.rows.ts +27 -0
- package/examples/cafe/generated/till.rules.ts +11 -1
- package/examples/cafe/index.html +14 -15
- package/examples/cafe/kitchen.css +11 -19
- package/examples/cafe/kitchen.ts +7 -3
- package/examples/cafe/look.ts +30 -0
- package/examples/cafe/menu.html +10 -26
- package/examples/cafe/menu.ts +8 -80
- package/examples/cafe/migrations/002-guard-supplies.ts +15 -0
- package/examples/cafe/order.html +8 -7
- package/examples/cafe/order.ts +6 -2
- package/examples/cafe/routes.ts +0 -1
- package/examples/cafe/staff.json +5 -0
- package/examples/cafe/stories.jsonl +6 -2
- package/examples/cafe/supplies.html +35 -34
- package/examples/cafe/supplies.ts +59 -39
- package/examples/cafe/till.ts +19 -11
- package/examples/cafe/views.ts +7 -5
- package/examples/chart/arches.ts +150 -0
- package/examples/chart/chart.css +11 -0
- package/examples/chart/chart.json +87 -0
- package/examples/chart/generated/elements.ts +105 -0
- package/examples/chart/generated/queries.ts +36 -0
- package/examples/chart/generated/rows.ts +27 -0
- package/examples/chart/generated/rules.ts +111 -0
- package/examples/chart/grid.ts +118 -0
- package/examples/chart/index.html +78 -0
- package/examples/chart/migrations/001-chart.ts +6 -0
- package/examples/chart/migrations/002-create-conditions.ts +6 -0
- package/examples/chart/page.ts +20 -0
- package/examples/chart/routes.ts +7 -0
- package/examples/chart/stories.jsonl +14 -0
- package/examples/chart/teeth.ts +57 -0
- package/examples/desk/desk.css +6 -10
- package/examples/desk/generated/elements.ts +1 -1
- package/examples/desk/generated/rows.ts +22 -0
- package/examples/desk/generated/rules.ts +34 -1
- package/examples/desk/index.html +10 -3
- package/examples/desk/lanes.css +21 -19
- package/examples/desk/routes.ts +0 -2
- package/examples/desk/stories.jsonl +4 -3
- package/examples/desk/tally.css +1 -1
- package/examples/desk/thumbs.ts +2 -2
- package/examples/docs.ts +7 -4
- package/examples/hello/generated/elements.ts +2 -2
- package/examples/hello/generated/rules.ts +3 -2
- package/examples/hello/hello.css +2 -4
- package/examples/hello/index.html +10 -3
- package/examples/hello/page.ts +4 -4
- package/examples/index.html +20 -12
- package/examples/notes/generated/elements.ts +112 -0
- package/examples/notes/generated/queries.ts +42 -0
- package/examples/notes/generated/rows.ts +27 -0
- package/examples/notes/generated/rules.ts +133 -0
- package/examples/notes/index.html +32 -0
- package/examples/notes/look.ts +41 -0
- package/examples/notes/migrations/001-notes.ts +7 -0
- package/examples/notes/notes.json +78 -0
- package/examples/notes/page.ts +21 -0
- package/examples/notes/routes.ts +6 -0
- package/examples/notes/stories.jsonl +24 -0
- package/examples/page.ts +9 -2
- package/examples/people/generated/rows.ts +22 -0
- package/examples/people/generated/rules.ts +11 -1
- package/examples/people/links.ts +8 -9
- package/examples/people/people.css +1 -1
- package/examples/people/routes.ts +1 -3
- package/examples/people/stories.jsonl +1 -0
- package/examples/people/view.ts +5 -2
- package/examples/trip/generated/elements.ts +5 -3
- package/examples/trip/generated/queries.ts +12 -1
- package/examples/trip/generated/rows.ts +27 -0
- package/examples/trip/generated/rules.ts +56 -2
- package/examples/trip/index.html +58 -12
- package/examples/trip/line.css +186 -0
- package/examples/trip/line.ts +51 -40
- package/examples/trip/page.ts +65 -71
- package/examples/trip/routes.ts +9 -5
- package/examples/trip/stays.css +13 -13
- package/examples/trip/stays.ts +15 -10
- package/examples/trip/stories.jsonl +2 -0
- package/examples/trip/told.ts +3 -26
- package/examples/trip/trip.css +16 -0
- package/examples/trips/generated/elements.ts +1 -1
- package/examples/trips/generated/rows.ts +22 -0
- package/examples/trips/generated/rules.ts +9 -1
- package/examples/trips/index.html +10 -10
- package/examples/trips/map.ts +3 -14
- package/examples/trips/new-trip.ts +14 -16
- package/examples/trips/trips.css +24 -23
- package/examples/weeks/generated/elements.ts +1 -1
- package/examples/weeks/generated/queries.ts +11 -0
- package/examples/weeks/generated/rows.ts +22 -0
- package/examples/weeks/generated/rules.ts +11 -5
- package/examples/weeks/routes.ts +3 -2
- package/examples/weeks/stories.jsonl +1 -0
- package/examples/welcome.css +43 -33
- package/package.json +8 -2
- package/src/attachment.ts +17 -2
- package/src/awesome.ts +103 -0
- package/src/board.css +76 -0
- package/src/board.ts +173 -0
- package/src/cli.ts +28 -3
- package/src/compile.ts +821 -109
- package/src/definitions.ts +113 -27
- package/src/demo.css +2 -5
- package/src/draft.ts +48 -27
- package/src/drawer.ts +248 -0
- package/src/engine.ts +253 -170
- package/src/fields.ts +341 -0
- package/src/file-value.ts +12 -2
- package/src/files.ts +113 -33
- package/src/ground.ts +110 -0
- package/src/icon-names.ts +19 -2
- package/src/keep.ts +16 -3
- package/src/kit.ts +51 -0
- package/src/link.ts +3 -3
- package/src/map.css +140 -0
- package/src/map.ts +200 -0
- package/src/mcp.ts +129 -24
- package/src/members/demo.ts +13 -12
- package/src/members/generated/rows.ts +22 -0
- package/src/members/generated/rules.ts +3 -2
- package/src/members/group.ts +105 -55
- package/src/members/keys.ts +95 -79
- package/src/members/panel.css +40 -35
- package/src/members/panel.ts +58 -37
- package/src/migrate.ts +178 -125
- package/src/migrations/005-change-kept.ts +7 -0
- package/src/month.css +129 -0
- package/src/month.ts +179 -0
- package/src/ops.ts +40 -1
- package/src/page.css +11 -2
- package/src/page.ts +68 -17
- package/src/parts.css +614 -230
- package/src/parts.ts +259 -36
- package/src/plane.css +61 -0
- package/src/plane.ts +153 -0
- package/src/postgres-server.ts +60 -0
- package/src/reading.css +73 -0
- package/src/reading.ts +238 -0
- package/src/rows.css +289 -0
- package/src/rows.ts +864 -0
- package/src/search.css +80 -0
- package/src/search.ts +130 -0
- package/src/server.ts +355 -137
- package/src/settings.ts +9 -4
- package/src/sheet.ts +116 -0
- package/src/skill.ts +40 -0
- package/src/slots.css +90 -0
- package/src/slots.ts +213 -0
- package/src/specs.ts +38 -0
- package/src/starter.ts +19 -2
- package/src/store.ts +224 -161
- package/src/stories.ts +43 -11
- package/src/surface.ts +164 -0
- package/src/time.ts +2 -0
- package/src/timeline.css +111 -0
- package/src/timeline.ts +235 -0
- package/src/toast.ts +21 -48
- package/src/together.ts +15 -24
- package/src/tokens.css +89 -3
- package/src/tokens.json +287 -7
- package/src/tool.ts +210 -0
- package/src/upkeep.ts +47 -22
- package/src/views.css +43 -0
- package/src/views.ts +111 -0
- package/src/week.css +150 -0
- package/src/week.ts +254 -0
- package/src/write.ts +326 -78
- package/starter/CHANGELOG.md +8 -0
- package/starter/CLAUDE.md +9 -3
- package/starter/bunfig +5 -0
- package/starter/githooks/pre-commit +13 -0
- package/starter/prettierignore +5 -0
- package/starter/tests/hello.test.ts +2 -0
- package/starter/tests/records.test.ts +40 -0
- package/starter/todo.jsonl +0 -0
- package/docs/learning.md +0 -76
- package/examples/cafe/trust.ts +0 -20
- package/examples/desk/trust.ts +0 -24
- package/examples/people/trust.ts +0 -14
- package/examples/trip/answer-rows.ts +0 -70
- package/examples/trip/bar.ts +0 -89
- package/examples/trip/calendar-map.css +0 -711
- package/examples/trip/calendar-map.ts +0 -249
- package/examples/trip/drags.ts +0 -143
- package/examples/trip/drawer.ts +0 -250
- package/examples/trip/event-form.ts +0 -200
- package/examples/trip/holding.ts +0 -61
- package/examples/trip/map.ts +0 -234
- package/examples/trip/month.ts +0 -87
- package/examples/trip/other-weeks.ts +0 -67
- package/examples/trip/peek.ts +0 -71
- package/examples/trip/people-chips.ts +0 -74
- package/examples/trip/shell.ts +0 -39
- package/examples/trip/trust.ts +0 -51
- package/examples/trip/week.ts +0 -237
- package/examples/trip/writes.ts +0 -91
- package/examples/trip/zones.ts +0 -16
- package/examples/weeks/derive.ts +0 -23
- package/src/scrim.ts +0 -81
|
@@ -15,7 +15,7 @@ const docOf = (el: Element) => el.closest("[doc]")?.getAttribute("doc") ?? "hell
|
|
|
15
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
16
|
|
|
17
17
|
/** hello's own fields, as the stories give them. */
|
|
18
|
-
export type JHelloData = { "greeting"
|
|
18
|
+
export type JHelloData = { "greeting": string };
|
|
19
19
|
|
|
20
20
|
/** <j-hello>: hello itself, holding it, its own fields each an attribute. */
|
|
21
21
|
export class JHello extends HTMLElement {
|
|
@@ -23,7 +23,7 @@ export class JHello extends HTMLElement {
|
|
|
23
23
|
#data?: JHelloData;
|
|
24
24
|
/** Its fields, read from its attributes once and again when one changes: frozen, since they're shared. */
|
|
25
25
|
get data(): JHelloData {
|
|
26
|
-
return (this.#data ??= Object.freeze({ "greeting": this.getAttribute("greeting") ??
|
|
26
|
+
return (this.#data ??= Object.freeze({ "greeting": this.getAttribute("greeting") ?? "" }));
|
|
27
27
|
}
|
|
28
28
|
/** How a view shows it, drawn again whenever an attribute changes (what its person may do, its may, too). */
|
|
29
29
|
draw?(): void;
|
|
@@ -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 = "hello";
|
|
8
8
|
export const collections = {
|
|
9
9
|
"hello": {
|
|
@@ -14,7 +14,8 @@ export const collections = {
|
|
|
14
14
|
"greeting": "string"
|
|
15
15
|
},
|
|
16
16
|
"needs": [],
|
|
17
|
-
"links": {}
|
|
17
|
+
"links": {},
|
|
18
|
+
"pops": {}
|
|
18
19
|
}
|
|
19
20
|
} as const;
|
|
20
21
|
/** Whether every story is anonymous, none told as a member: where every app's is, the project has no members. */
|
package/examples/hello/hello.css
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/* hello's look: its one greeting, large, in a card with the box to change it at its foot. */
|
|
2
2
|
|
|
3
|
+
/* its card is joined's (wa-card), edge to edge inside */
|
|
3
4
|
.card {
|
|
4
5
|
max-width: 40rem;
|
|
5
|
-
|
|
6
|
-
border-radius: 4px;
|
|
7
|
-
overflow: hidden;
|
|
8
|
-
background: var(--card);
|
|
6
|
+
--spacing: 0;
|
|
9
7
|
}
|
|
10
8
|
j-hello {
|
|
11
9
|
display: block;
|
|
@@ -17,15 +17,22 @@
|
|
|
17
17
|
it change there.
|
|
18
18
|
</p>
|
|
19
19
|
<main>
|
|
20
|
-
<
|
|
20
|
+
<wa-card class="card" aria-label="The greeting">
|
|
21
21
|
<j-hello></j-hello>
|
|
22
22
|
<form class="add say">
|
|
23
|
-
<input
|
|
23
|
+
<wa-input
|
|
24
|
+
class="j-bare"
|
|
25
|
+
name="greeting"
|
|
26
|
+
placeholder="Say hello"
|
|
27
|
+
label="The greeting"
|
|
28
|
+
required
|
|
29
|
+
autocomplete="off"
|
|
30
|
+
></wa-input>
|
|
24
31
|
<button type="button" class="act" name="never">Never mind</button>
|
|
25
32
|
<button class="act ink" name="go" data-icon="check">Save</button>
|
|
26
33
|
<p class="said" role="status"></p>
|
|
27
34
|
</form>
|
|
28
|
-
</
|
|
35
|
+
</wa-card>
|
|
29
36
|
</main>
|
|
30
37
|
<script type="module" src="./page.ts"></script>
|
|
31
38
|
</body>
|
package/examples/hello/page.ts
CHANGED
|
@@ -21,13 +21,13 @@ class Hello extends JHello {
|
|
|
21
21
|
connectedCallback() {
|
|
22
22
|
super.connectedCallback();
|
|
23
23
|
if (!this.childElementCount) this.append(this.#shown);
|
|
24
|
-
draft.fill({ greeting: this.data.greeting
|
|
24
|
+
draft.fill({ greeting: this.data.greeting }, true);
|
|
25
25
|
this.draw();
|
|
26
26
|
}
|
|
27
27
|
/** The greeting, as its attribute has it; and the box, unless it's being changed. */
|
|
28
28
|
draw() {
|
|
29
|
-
this.#shown.textContent = this.data.greeting
|
|
30
|
-
draft.fill({ greeting: this.data.greeting
|
|
29
|
+
this.#shown.textContent = this.data.greeting;
|
|
30
|
+
draft.fill({ greeting: this.data.greeting });
|
|
31
31
|
shown();
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -41,7 +41,7 @@ form.addEventListener("submit", async (e) => {
|
|
|
41
41
|
(form.elements.namedItem("never") as HTMLButtonElement).addEventListener("click", () => {
|
|
42
42
|
const hello = document.querySelector<Hello>(collections.hello.tag)!;
|
|
43
43
|
draft.refuse("");
|
|
44
|
-
draft.fill({ greeting: hello.data.greeting
|
|
44
|
+
draft.fill({ greeting: hello.data.greeting }, true);
|
|
45
45
|
shown();
|
|
46
46
|
});
|
|
47
47
|
iconify();
|
package/examples/index.html
CHANGED
|
@@ -34,7 +34,13 @@
|
|
|
34
34
|
<figure>
|
|
35
35
|
<div class="frame">
|
|
36
36
|
<picture
|
|
37
|
-
><source
|
|
37
|
+
><source
|
|
38
|
+
media="(max-width: 40rem) and (prefers-color-scheme: dark)"
|
|
39
|
+
srcset="../docs/trip-line-dark.png" /><source
|
|
40
|
+
media="(max-width: 40rem)"
|
|
41
|
+
srcset="../docs/trip-line.png" /><source
|
|
42
|
+
media="(prefers-color-scheme: dark)"
|
|
43
|
+
srcset="../docs/trip-dark.png" /><img
|
|
38
44
|
src="../docs/trip.png"
|
|
39
45
|
alt="A trip's week as a calendar beside its map, the dinner picked on both"
|
|
40
46
|
/></picture>
|
|
@@ -61,17 +67,18 @@
|
|
|
61
67
|
<span class="open">Open Hello →</span>
|
|
62
68
|
</a>
|
|
63
69
|
<a href="/trips">
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
<picture
|
|
71
|
+
><source media="(prefers-color-scheme: dark)" srcset="../docs/trip-line-dark.png" /><img
|
|
72
|
+
class="picture shot"
|
|
73
|
+
src="../docs/trip-line.png"
|
|
74
|
+
alt="The Japan trip read as a line: a bead for each event, Tuesday to Saturday"
|
|
75
|
+
/></picture>
|
|
69
76
|
<b>The trips</b>
|
|
70
77
|
<span>Each trip its week and its map. Drag an event to another day, or its pin to another place.</span>
|
|
71
78
|
<span class="open">Open the trips →</span>
|
|
72
79
|
</a>
|
|
73
80
|
<a href="/cafe">
|
|
74
|
-
<div class="picture
|
|
81
|
+
<div class="picture tickets">
|
|
75
82
|
<div class="mini ticket">
|
|
76
83
|
<b>#1 Ann · £6.40</b><span>1 × Latte</span><span>1 × Pot of tea</span><span class="pill">being made</span>
|
|
77
84
|
</div>
|
|
@@ -133,12 +140,13 @@
|
|
|
133
140
|
|
|
134
141
|
<figure class="film" id="film">
|
|
135
142
|
<!-- its src is set by page.ts: the bundler would serve the film whole, and Safari plays a video only in ranges -->
|
|
136
|
-
<video
|
|
143
|
+
<video preload="none" playsinline poster="./film.jpg" width="1280" height="720"></video>
|
|
144
|
+
<!-- the film's own play: at the poster's foot, never over its words, as a browser's own would be -->
|
|
145
|
+
<button type="button" class="act ink play" data-icon="play">Play the film · 1:50</button>
|
|
137
146
|
<figcaption class="note">
|
|
138
|
-
One change, from Peter's finger to Nick's screen (1:50)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
young: no ecosystem, one person and an AI.
|
|
147
|
+
One change, from Peter's finger to Nick's screen (1:50), filmed before the trip's calendar and map were the
|
|
148
|
+
kit's. What it isn't, yet: used by many, its largest test a trip of 100,000 events (a change there costs at most
|
|
149
|
+
twice what it does at 1,000); and it's young: no ecosystem, one person and an AI.
|
|
142
150
|
</figcaption>
|
|
143
151
|
</figure>
|
|
144
152
|
<script type="module" src="./page.ts"></script>
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Written by src/compile.ts from examples/notes/stories.jsonl: change the stories, 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 notes, 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 notes
|
|
13
|
+
const docOf = (el: Element) => el.closest("[doc]")?.getAttribute("doc") ?? "notes";
|
|
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 note's fields, as the stories give them. */
|
|
18
|
+
export type JNoteData = { "text": string; "more"?: string; "done"?: boolean; "when"?: string };
|
|
19
|
+
/** An add of a note, as it's sent: its fields as the stories write them. */
|
|
20
|
+
export type JNoteValue = { "text": string; "more"?: string; "done"?: boolean; "when"?: string };
|
|
21
|
+
|
|
22
|
+
/** <j-note key>: text (string), more (string), done (boolean), when (date-time), each an attribute. */
|
|
23
|
+
export class JNote extends HTMLElement {
|
|
24
|
+
static observedAttributes = ["text","more","done","when","may"];
|
|
25
|
+
#data?: JNoteData & Required<Pick<JNoteData, "done">>;
|
|
26
|
+
/** Its id in the document. */
|
|
27
|
+
get key() { return Number(this.getAttribute("key")); }
|
|
28
|
+
get path() { return `/notes/${this.key}`; }
|
|
29
|
+
/** Its fields, read from its attributes once and again when one changes: frozen, since they're shared. */
|
|
30
|
+
get data(): JNoteData & Required<Pick<JNoteData, "done">> {
|
|
31
|
+
return (this.#data ??= Object.freeze({ "text": this.getAttribute("text") ?? "", "more": this.getAttribute("more") ?? undefined, "done": this.hasAttribute("done"), "when": this.getAttribute("when") ?? undefined }) as JNoteData & Required<Pick<JNoteData, "done">>);
|
|
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
|
+
/** Replace some of its fields (text, more, done, when): one write for all of them. */
|
|
37
|
+
replace(fields: Partial<Pick<JNoteData, "text" | "more" | "done" | "when">>, why?: string) {
|
|
38
|
+
return send(this, Object.entries(fields).filter(([, value]) => value !== undefined).map(([field, value]) => ({ op: "replace", path: `${this.path}/${field.replace(".", "/")}`, value })), why);
|
|
39
|
+
}
|
|
40
|
+
/** Remove some of its fields (more, done, when), so that it has none. */
|
|
41
|
+
removeField(...fields: ("more" | "done" | "when")[]) { return send(this, fields.map((field) => ({ op: "remove", path: `${this.path}/${field}` }))); }
|
|
42
|
+
/** Remove it from the document. */
|
|
43
|
+
removeItem(why?: string) { return send(this, [{ op: "remove", path: this.path }], why); }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** <j-notes>: the document's notes, each a <j-note> inside it. */
|
|
47
|
+
export class JNotes extends HTMLElement {
|
|
48
|
+
connectedCallback() { hold(this, docOf(this), "notes", "j-note", {"text":"string","more":"string","done":"boolean","when":"date-time"}); }
|
|
49
|
+
disconnectedCallback() { letGo(this); }
|
|
50
|
+
/** Its notes, as the document has them. */
|
|
51
|
+
get items() { return [...this.children].filter((el): el is JNote => el.localName === "j-note"); }
|
|
52
|
+
/** Add notes: one write for all of them. */
|
|
53
|
+
add(...values: JNoteValue[]) { return send(this, values.map((value) => ({ op: "add", path: "/notes/-", value }))); }
|
|
54
|
+
}
|
|
55
|
+
customElements.define("j-notes", JNotes);
|
|
56
|
+
|
|
57
|
+
/** A rank's fields, as the stories give them. */
|
|
58
|
+
export type JRankData = { "note": number; "rank": number; "by"?: number };
|
|
59
|
+
/** An add of a rank, as it's sent: its fields as the stories write them. */
|
|
60
|
+
export type JRankValue = { "note": number | `$${number}`; "rank": number; "by"?: number | `$${number}` };
|
|
61
|
+
|
|
62
|
+
/** <j-rank key>: note (an id in notes), rank (decimal), by (an id in members), each an attribute. */
|
|
63
|
+
export class JRank extends HTMLElement {
|
|
64
|
+
static observedAttributes = ["note","rank","by","may"];
|
|
65
|
+
#data?: JRankData;
|
|
66
|
+
/** Its id in the document. */
|
|
67
|
+
get key() { return Number(this.getAttribute("key")); }
|
|
68
|
+
get path() { return `/ranks/${this.key}`; }
|
|
69
|
+
/** Its fields, read from its attributes once and again when one changes: frozen, since they're shared. */
|
|
70
|
+
get data(): JRankData {
|
|
71
|
+
return (this.#data ??= Object.freeze({ "note": Number(this.getAttribute("note")), "rank": Number(this.getAttribute("rank")), "by": this.hasAttribute("by") ? Number(this.getAttribute("by")) : undefined }) as JRankData);
|
|
72
|
+
}
|
|
73
|
+
/** How a view shows it, drawn again whenever an attribute changes (what its person may do, its may, too). */
|
|
74
|
+
draw?(): void;
|
|
75
|
+
attributeChangedCallback() { this.#data = undefined; this.draw?.(); }
|
|
76
|
+
/** Replace some of its fields (rank): one write for all of them. */
|
|
77
|
+
replace(fields: Partial<Pick<JRankData, "rank">>, why?: string) {
|
|
78
|
+
return send(this, Object.entries(fields).filter(([, value]) => value !== undefined).map(([field, value]) => ({ op: "replace", path: `${this.path}/${field.replace(".", "/")}`, value })), why);
|
|
79
|
+
}
|
|
80
|
+
/** Remove it from the document. */
|
|
81
|
+
removeItem(why?: string) { return send(this, [{ op: "remove", path: this.path }], why); }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** <j-ranks>: the document's ranks, each a <j-rank> inside it. */
|
|
85
|
+
export class JRanks extends HTMLElement {
|
|
86
|
+
connectedCallback() { hold(this, docOf(this), "ranks", "j-rank", {"note":"integer","rank":"decimal","by":"integer"}); }
|
|
87
|
+
disconnectedCallback() { letGo(this); }
|
|
88
|
+
/** Its ranks, as the document has them. */
|
|
89
|
+
get items() { return [...this.children].filter((el): el is JRank => el.localName === "j-rank"); }
|
|
90
|
+
/** Add ranks: one write for all of them. */
|
|
91
|
+
add(...values: JRankValue[]) { return send(this, values.map((value) => ({ op: "add", path: "/ranks/-", value }))); }
|
|
92
|
+
}
|
|
93
|
+
customElements.define("j-ranks", JRanks);
|
|
94
|
+
|
|
95
|
+
/** An op on notes the stories allow, in any of its collections. */
|
|
96
|
+
export type NotesOp =
|
|
97
|
+
| { op: "add"; path: "/notes/-"; value: JNoteValue }
|
|
98
|
+
| { op: "replace"; path: `/notes/${number}/text`; value: string }
|
|
99
|
+
| { op: "replace"; path: `/notes/${number}/more`; value: string }
|
|
100
|
+
| { op: "replace"; path: `/notes/${number}/done`; value: boolean }
|
|
101
|
+
| { op: "replace"; path: `/notes/${number}/when`; value: string }
|
|
102
|
+
| { op: "remove"; path: `/notes/${number}/more` }
|
|
103
|
+
| { op: "remove"; path: `/notes/${number}/done` }
|
|
104
|
+
| { op: "remove"; path: `/notes/${number}/when` }
|
|
105
|
+
| { op: "remove"; path: `/notes/${number}` }
|
|
106
|
+
| { op: "add"; path: "/ranks/-"; value: JRankValue }
|
|
107
|
+
| { op: "replace"; path: `/ranks/${number}/rank`; value: number }
|
|
108
|
+
| { op: "remove"; path: `/ranks/${number}` };
|
|
109
|
+
|
|
110
|
+
/** One write to notes across its collections (a move with its legs): sent from an element of it, checked
|
|
111
|
+
* whole by its rules, and made whole or not at all. */
|
|
112
|
+
export function write(from: Element, ops: NotesOp[], why?: string) { return send(from, ops, why); }
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Written by src/compile.ts from examples/notes/stories.jsonl: change the stories, not this.
|
|
2
|
+
|
|
3
|
+
/** Each collection's item, as one row of its table (`t`) is it: what the query gathers, and what the store keeps of a
|
|
4
|
+
* row a write changes, before and after, to tell each document holding it. */
|
|
5
|
+
export const items: Record<string, string> = {
|
|
6
|
+
"notes": "json_patch('{}', json_object('id', t.id,\n 'text', t.\"text\",\n 'more', t.\"more\",\n 'done', json(CASE t.\"done\" WHEN 1 THEN 'true' WHEN 0 THEN 'false' END),\n 'when', t.\"when\"))",
|
|
7
|
+
"ranks": "json_patch('{}', json_object('id', t.id,\n 'note', t.\"note\",\n 'rank', t.\"rank\",\n 'by', t.\"by\"))"
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/** notes, whole, as one statement over its tables (SQLite): its parameters $doc. */
|
|
11
|
+
export const query = `SELECT json_object('version', COALESCE((SELECT version FROM documents WHERE name = $doc), 0),
|
|
12
|
+
'notes', json((SELECT json_group_array(json_patch('{}', json_object('id', t.id,
|
|
13
|
+
'text', t."text",
|
|
14
|
+
'more', t."more",
|
|
15
|
+
'done', json(CASE t."done" WHEN 1 THEN 'true' WHEN 0 THEN 'false' END),
|
|
16
|
+
'when', t."when")) ORDER BY t.id)
|
|
17
|
+
FROM "notes" t)),
|
|
18
|
+
'ranks', json((SELECT json_group_array(json_patch('{}', json_object('id', t.id,
|
|
19
|
+
'note', t."note",
|
|
20
|
+
'rank', t."rank",
|
|
21
|
+
'by', t."by")) ORDER BY t.id)
|
|
22
|
+
FROM "ranks" t))) AS doc`;
|
|
23
|
+
|
|
24
|
+
/** Its rules over values (definitions' takes, gives and totals), as triggers the store makes in its database: run in
|
|
25
|
+
* each write's transaction, and told as any change is. */
|
|
26
|
+
export const triggers: string[] = [
|
|
27
|
+
"CREATE TEMP TRIGGER IF NOT EXISTS \"joined_empty_notes_text_insert\" BEFORE INSERT ON main.\"notes\" BEGIN SELECT RAISE(ABORT, 'text cannot be empty') WHERE NEW.id = (SELECT last FROM joined_sequences WHERE collection = 'notes') AND trim(NEW.\"text\", ' \t\r\n') = ''; END",
|
|
28
|
+
"CREATE TEMP TRIGGER IF NOT EXISTS \"joined_empty_notes_text_update\" BEFORE UPDATE ON main.\"notes\" BEGIN SELECT RAISE(ABORT, 'text cannot be empty') WHERE NEW.\"text\" IS NOT OLD.\"text\" AND trim(NEW.\"text\", ' \t\r\n') = ''; END"
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
/** Its items, its query and its triggers, as Postgres says them. */
|
|
32
|
+
export const postgres = {
|
|
33
|
+
"items": {
|
|
34
|
+
"notes": "json_strip_nulls(json_build_object('id', t.id,\n 'text', t.\"text\",\n 'more', t.\"more\",\n 'done', (CASE t.\"done\" WHEN 1 THEN true WHEN 0 THEN false END),\n 'when', t.\"when\"))",
|
|
35
|
+
"ranks": "json_strip_nulls(json_build_object('id', t.id,\n 'note', t.\"note\",\n 'rank', t.\"rank\",\n 'by', t.\"by\"))"
|
|
36
|
+
},
|
|
37
|
+
"query": "SELECT json_build_object('version', COALESCE((SELECT version FROM documents WHERE name = $doc), 0),\n 'notes', (SELECT COALESCE(json_agg(json_strip_nulls(json_build_object('id', t.id,\n 'text', t.\"text\",\n 'more', t.\"more\",\n 'done', (CASE t.\"done\" WHEN 1 THEN true WHEN 0 THEN false END),\n 'when', t.\"when\")) ORDER BY t.id), '[]')\n FROM \"notes\" t),\n 'ranks', (SELECT COALESCE(json_agg(json_strip_nulls(json_build_object('id', t.id,\n 'note', t.\"note\",\n 'rank', t.\"rank\",\n 'by', t.\"by\")) ORDER BY t.id), '[]')\n FROM \"ranks\" t)) AS doc",
|
|
38
|
+
"triggers": [
|
|
39
|
+
"CREATE OR REPLACE FUNCTION \"joined_empty_notes_text_insert_fn\"() RETURNS trigger LANGUAGE plpgsql AS $joined$ BEGIN IF NEW.id = (SELECT last FROM joined_sequences WHERE collection = 'notes') AND trim(NEW.\"text\", ' \t\r\n') = '' THEN RAISE EXCEPTION '%', 'text cannot be empty'; END IF; IF TG_OP = 'DELETE' THEN RETURN OLD; END IF; RETURN NEW; END $joined$; CREATE OR REPLACE TRIGGER \"joined_empty_notes_text_insert\" BEFORE INSERT ON \"notes\" FOR EACH ROW EXECUTE FUNCTION \"joined_empty_notes_text_insert_fn\"()",
|
|
40
|
+
"CREATE OR REPLACE FUNCTION \"joined_empty_notes_text_update_fn\"() RETURNS trigger LANGUAGE plpgsql AS $joined$ BEGIN IF NEW.\"text\" IS DISTINCT FROM OLD.\"text\" AND trim(NEW.\"text\", ' \t\r\n') = '' THEN RAISE EXCEPTION '%', 'text cannot be empty'; END IF; IF TG_OP = 'DELETE' THEN RETURN OLD; END IF; RETURN NEW; END $joined$; CREATE OR REPLACE TRIGGER \"joined_empty_notes_text_update\" BEFORE UPDATE ON \"notes\" FOR EACH ROW EXECUTE FUNCTION \"joined_empty_notes_text_update_fn\"()"
|
|
41
|
+
]
|
|
42
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Written by src/compile.ts from examples/notes/stories.jsonl: change the stories, not this.
|
|
2
|
+
|
|
3
|
+
// Each collection of notes 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-notes-rows><j-notes></j-notes><j-ranks></j-ranks></j-notes-rows>
|
|
6
|
+
// <j-ranks-rows><j-ranks></j-ranks></j-ranks-rows>
|
|
7
|
+
// A collection whose items are each of one of another's is drawn under it there, where its element is put in too.
|
|
8
|
+
// To change what one says or does, extend its class and override a part (label, named, says, facts, deeds, row,
|
|
9
|
+
// step, asks); to change how it looks, style its parts (::part(row), title, state, facts, deeds, mine, step, add,
|
|
10
|
+
// under, drawer). Its sheet, a search of it and how a field reads are joined/kit's, given these collections by
|
|
11
|
+
// 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
|
|
12
|
+
// elements. Never change this file: change the stories.
|
|
13
|
+
|
|
14
|
+
import { rows, type Spec } from "joined/rows";
|
|
15
|
+
import { JNote, JRank } from "./elements.ts";
|
|
16
|
+
|
|
17
|
+
const notes: Spec = {"doc":"notes","name":"notes","place":"j-notes","tag":"j-note","one":"note","title":"text","fields":[{"name":"text","type":"string","needed":true},{"name":"more","type":"string"},{"name":"done","type":"boolean"},{"name":"when","type":"date-time"}]};
|
|
18
|
+
const ranks: Spec = {"doc":"notes","name":"ranks","place":"j-ranks","tag":"j-rank","one":"rank","under":{"field":"note","in":"notes"},"mine":{"of":"note","by":"by"},"fields":[{"name":"note","type":"integer","needed":true,"how":"one","to":{"tag":"j-note","title":"text"}},{"name":"rank","type":"decimal","needed":true},{"name":"by","type":"integer","how":"filled","to":{"tag":"j-member","people":true},"ref":true}]};
|
|
19
|
+
|
|
20
|
+
/** Each collection as joined's kit (joined/kit) is given it, by name: use(specs). */
|
|
21
|
+
export const specs = { "notes": notes, "ranks": ranks };
|
|
22
|
+
|
|
23
|
+
/** <j-notes-rows>: notes's notes as rows, each named by its text, its ranks under it. */
|
|
24
|
+
export class JNotesRows extends rows(notes, { "j-note": JNote, "j-rank": JRank }, ranks) {}
|
|
25
|
+
|
|
26
|
+
/** <j-ranks-rows>: notes's ranks as rows. */
|
|
27
|
+
export class JRanksRows extends rows(ranks, { "j-rank": JRank }) {}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Written by src/compile.ts from examples/notes/stories.jsonl: change the stories, 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 = "notes";
|
|
8
|
+
export const collections = {
|
|
9
|
+
"notes": {
|
|
10
|
+
"place": "j-notes",
|
|
11
|
+
"tag": "j-note",
|
|
12
|
+
"fields": {
|
|
13
|
+
"text": "string",
|
|
14
|
+
"more": "string",
|
|
15
|
+
"done": "boolean",
|
|
16
|
+
"when": "date-time"
|
|
17
|
+
},
|
|
18
|
+
"needs": [
|
|
19
|
+
"text"
|
|
20
|
+
],
|
|
21
|
+
"links": {},
|
|
22
|
+
"pops": {
|
|
23
|
+
"when": {
|
|
24
|
+
"form": "date-time"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"ranks": {
|
|
29
|
+
"place": "j-ranks",
|
|
30
|
+
"tag": "j-rank",
|
|
31
|
+
"fields": {
|
|
32
|
+
"note": "integer",
|
|
33
|
+
"rank": "decimal",
|
|
34
|
+
"by": "integer"
|
|
35
|
+
},
|
|
36
|
+
"needs": [
|
|
37
|
+
"note",
|
|
38
|
+
"rank"
|
|
39
|
+
],
|
|
40
|
+
"links": {
|
|
41
|
+
"note": "notes",
|
|
42
|
+
"by": "members"
|
|
43
|
+
},
|
|
44
|
+
"pops": {
|
|
45
|
+
"by": {
|
|
46
|
+
"to": "members"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"goes": [
|
|
50
|
+
"note"
|
|
51
|
+
],
|
|
52
|
+
"fills": {
|
|
53
|
+
"by": "me"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} as const;
|
|
57
|
+
/** Whether every story is anonymous, none told as a member: where every app's is, the project has no members. */
|
|
58
|
+
export const anonymous = false;
|
|
59
|
+
/** What kind of document notes is, by the flows it uses: static, changed only with a release (a page reads it, and
|
|
60
|
+
* never subscribes); read-only, live, but no page writes it (derived); or shared, its members' to write. */
|
|
61
|
+
export const type = "shared";
|
|
62
|
+
/** The parts of notes a page may hold alone, by its query's parameters (its definitions' window): null, none. */
|
|
63
|
+
export const window = null;
|
|
64
|
+
/** The document as one statement over its tables (generated/queries.ts). */
|
|
65
|
+
export { query, postgres, items, triggers } from "./queries.ts";
|
|
66
|
+
|
|
67
|
+
/** Why the document, as a write leaves it, breaks what its definitions hold (unique, noOverlap): each item the
|
|
68
|
+
* write touched, against the rest of its collection. Null if it holds. */
|
|
69
|
+
export function holds(d: Record<string, unknown>, touched: Record<string, number[]>): string | null {
|
|
70
|
+
for (const id of touched["ranks"] ?? []) {
|
|
71
|
+
const all = (d["ranks"] ?? []) as any[];
|
|
72
|
+
const a = all.find((i) => i.id === id);
|
|
73
|
+
if (!a) continue;
|
|
74
|
+
{
|
|
75
|
+
const b = all.find((i) => i.id !== a.id && a["note"] !== undefined && i["note"] === a["note"] && a["by"] !== undefined && i["by"] === a["by"]);
|
|
76
|
+
if (b) return "ranks " + b.id + " has that note and by already";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** The collections of values that are each member's own (its definitions' mine): the link to the item each is of, and to its member, who alone changes or removes it. */
|
|
83
|
+
export const own: Record<string, { of: string; by: string }> = {"ranks":{"of":"note","by":"by"}};
|
|
84
|
+
|
|
85
|
+
/** notes is one document. */
|
|
86
|
+
export const kind = null;
|
|
87
|
+
|
|
88
|
+
/** Each grant, read off the stories: the roles whose stories do it (a member: anyone). An op no story
|
|
89
|
+
* does isn't one. */
|
|
90
|
+
export const grants: Record<string, string[]> = {
|
|
91
|
+
"add notes": [
|
|
92
|
+
"member"
|
|
93
|
+
],
|
|
94
|
+
"add ranks": [
|
|
95
|
+
"member"
|
|
96
|
+
],
|
|
97
|
+
"remove notes": [
|
|
98
|
+
"member"
|
|
99
|
+
],
|
|
100
|
+
"remove notes.done": [
|
|
101
|
+
"member"
|
|
102
|
+
],
|
|
103
|
+
"remove notes.more": [
|
|
104
|
+
"member"
|
|
105
|
+
],
|
|
106
|
+
"remove notes.when": [
|
|
107
|
+
"member"
|
|
108
|
+
],
|
|
109
|
+
"remove ranks": [
|
|
110
|
+
"member"
|
|
111
|
+
],
|
|
112
|
+
"replace notes.done": [
|
|
113
|
+
"member"
|
|
114
|
+
],
|
|
115
|
+
"replace notes.more": [
|
|
116
|
+
"member"
|
|
117
|
+
],
|
|
118
|
+
"replace notes.text": [
|
|
119
|
+
"member"
|
|
120
|
+
],
|
|
121
|
+
"replace notes.when": [
|
|
122
|
+
"member"
|
|
123
|
+
],
|
|
124
|
+
"replace ranks.rank": [
|
|
125
|
+
"member"
|
|
126
|
+
]
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/** Who someone is to notes: a member, as it names no roles. */
|
|
130
|
+
export const rolesOf = (_m: number, _read: (doc: string) => any, _doc: string, _at?: any): string[] => [];
|
|
131
|
+
|
|
132
|
+
/** What someone sees: all of notes, as it has no owns. */
|
|
133
|
+
export const sees = null;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>joined: notes</title>
|
|
7
|
+
<link rel="stylesheet" href="joined/tokens.css" />
|
|
8
|
+
<link rel="stylesheet" href="joined/page.css" />
|
|
9
|
+
<link rel="stylesheet" href="../app.css" />
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<a class="brand" href="/"><img src="joined/icon.png" alt="" width="28" height="28" />joined</a>
|
|
13
|
+
<h1>Notes</h1>
|
|
14
|
+
<p class="lead">
|
|
15
|
+
The notes are everyone's; the order you'd take them in is your own. This page is its stories, joined's kit and a
|
|
16
|
+
few lines.
|
|
17
|
+
</p>
|
|
18
|
+
<nav class="bar"><members-panel></members-panel></nav>
|
|
19
|
+
<main>
|
|
20
|
+
<j-search for="notes"></j-search>
|
|
21
|
+
<j-views>
|
|
22
|
+
<j-notes-rows label="List"><j-notes></j-notes><j-ranks></j-ranks></j-notes-rows>
|
|
23
|
+
<j-week for="notes"></j-week>
|
|
24
|
+
<j-month for="notes"></j-month>
|
|
25
|
+
<j-timeline for="notes"></j-timeline>
|
|
26
|
+
<j-board for="notes" by="done"></j-board>
|
|
27
|
+
</j-views>
|
|
28
|
+
</main>
|
|
29
|
+
<j-sheet for="notes"></j-sheet>
|
|
30
|
+
<script type="module" src="./page.ts"></script>
|
|
31
|
+
</body>
|
|
32
|
+
</html>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// What bun run look notes draws: the notes' page (drawn by joined from the stories) in each state it has, each put
|
|
2
|
+
// there as a person would (act), from the one before (they're played in order, on one store). Looked at wide and on
|
|
3
|
+
// a phone, light and dark.
|
|
4
|
+
|
|
5
|
+
import { collections } from "./generated/rules.ts";
|
|
6
|
+
|
|
7
|
+
const rows = `document.querySelector("${collections.notes.place}-rows")`,
|
|
8
|
+
R = `${rows}.shadowRoot`;
|
|
9
|
+
const row = (n: number) => `${R}.querySelectorAll('ul[part="list"] > li[data-key]')[${n - 1}]`;
|
|
10
|
+
const drawer = `${R}.querySelector("aside.drawer")`;
|
|
11
|
+
const tab = (name: string) => `${R}.querySelector('[role=tab][name=${name}]').click()`;
|
|
12
|
+
|
|
13
|
+
export const page = "/notes";
|
|
14
|
+
export const ready = `(${R}.querySelectorAll("li[data-key]").length > 0 || document.querySelector("${collections.notes.place}[may]")) && ${rows}.dataset.order`;
|
|
15
|
+
export const states = [
|
|
16
|
+
{ name: "The list, in my order" },
|
|
17
|
+
{ name: "In Nora's order", act: `${R}.querySelector('.whose [name="3"]').click()` },
|
|
18
|
+
{ name: "In everyone's order", act: `${R}.querySelector('.whose [name="all"]').click()` },
|
|
19
|
+
{ name: "Read as a board", act: tab("board") },
|
|
20
|
+
{ name: "Read as a calendar", act: tab("calendar") },
|
|
21
|
+
{ name: "A note's day popped", act: `${row(1)}.querySelector(".j-mention").click()` },
|
|
22
|
+
{ name: "A note open", act: `${row(2)}.querySelector("button.open").click()` },
|
|
23
|
+
{
|
|
24
|
+
name: "Typed, not kept",
|
|
25
|
+
act: `${row(2)}.querySelector("button.open").click(); (() => { const b = ${drawer}.querySelector("[name=text]"); b.value = "Call the plumber about the tap"; b.dispatchEvent(new Event("input", { bubbles: true })); })()`,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "Asked before it goes",
|
|
29
|
+
act: `${row(2)}.querySelector("button.open").click(); ${drawer}.querySelector("[name=gone]").click()`,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "Long words",
|
|
33
|
+
act: `(() => { const f = ${R}.querySelector("form.adding"); f.querySelector("input").value = "Ask the neighbours whether they would water the plants on the balcony while we are away in November, and leave them a key"; f.requestSubmit(); })()`,
|
|
34
|
+
settle: `${R}.querySelectorAll("li[data-key]").length === 4`,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "None",
|
|
38
|
+
act: `document.querySelectorAll("${collections.notes.tag}").forEach((n) => n.removeItem())`,
|
|
39
|
+
settle: `${R}.querySelectorAll("li[data-key]").length === 0`,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Made by `bun run compile` from the stories: what they say beyond the migrations before it.
|
|
2
|
+
import { createTable } from "joined/migrate";
|
|
3
|
+
|
|
4
|
+
export const changes = [
|
|
5
|
+
createTable("notes", { columns: { text: { type: "text", is: { type: "string", said: "text is a string" } }, more: { type: "text", nullable: true, is: { type: "string", said: "more is a string" } }, done: { type: "boolean", nullable: true, is: { type: "boolean", said: "done is a boolean" } }, when: { type: "text", nullable: true, is: { type: "form", form: "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])T([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d$", said: "when is a date and time (YYYY-MM-DDTHH:MM:SS)" } } }, strict: true, needs: { columns: ["text"], said: "a note needs text (string); may have more (string), done (boolean), when (date-time)" } }),
|
|
6
|
+
createTable("ranks", { columns: { note: { type: "integer", is: { type: "integer", said: "note is a whole number" }, to: { table: "notes", said: "note links only to notes the notes document holds", held: ["rank in notes links to it", "ranks in notes link to it"] } }, rank: { type: "real", is: { type: "decimal", said: "rank is a number" } }, by: { type: "integer", nullable: true, is: { type: "integer", said: "by is a whole number" }, to: { table: "members", said: "by links only to members the members document holds", onDelete: "set null" } } }, strict: true, needs: { columns: ["note", "rank"], said: "a rank needs note (an id in notes), rank (decimal); may have by (an id in members)" } }),
|
|
7
|
+
];
|