@blueshed/joined 0.3.0 → 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/reference.md +57 -18
- package/docs/design.md +93 -38
- package/docs/introduction.md +9 -9
- package/docs/light-and-shadow.svg +1 -0
- 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/app.css +9 -0
- package/examples/cafe/cafe.css +87 -69
- package/examples/cafe/generated/staff.elements.ts +7 -2
- package/examples/cafe/generated/staff.rules.ts +3 -0
- package/examples/cafe/generated/supplies.rules.ts +5 -0
- package/examples/cafe/kitchen.css +11 -19
- package/examples/cafe/kitchen.ts +6 -2
- package/examples/cafe/migrations/002-guard-supplies.ts +15 -0
- package/examples/cafe/order.html +2 -1
- package/examples/cafe/order.ts +1 -1
- package/examples/cafe/staff.json +5 -0
- package/examples/cafe/stories.jsonl +4 -2
- package/examples/cafe/supplies.html +1 -0
- package/examples/cafe/supplies.ts +45 -28
- package/examples/cafe/till.ts +14 -10
- package/examples/cafe/views.ts +7 -5
- package/examples/chart/arches.ts +5 -3
- package/examples/chart/chart.css +7 -2
- package/examples/desk/desk.css +6 -10
- package/examples/desk/generated/elements.ts +1 -1
- package/examples/desk/index.html +1 -1
- package/examples/desk/lanes.css +21 -19
- package/examples/desk/stories.jsonl +1 -1
- package/examples/desk/tally.css +1 -1
- package/examples/docs.ts +7 -4
- package/examples/index.html +16 -7
- package/examples/notes/generated/queries.ts +8 -2
- package/examples/notes/index.html +1 -1
- package/examples/notes/stories.jsonl +3 -0
- package/examples/page.ts +9 -2
- package/examples/people/links.ts +7 -9
- package/examples/people/people.css +1 -1
- package/examples/people/view.ts +1 -1
- package/examples/trip/generated/elements.ts +1 -1
- package/examples/trip/stays.css +1 -1
- package/examples/trip/stays.ts +1 -1
- package/examples/trips/generated/elements.ts +1 -1
- package/examples/trips/trips.css +24 -23
- package/examples/welcome.css +41 -33
- package/package.json +1 -1
- package/src/attachment.ts +17 -2
- package/src/board.css +2 -1
- package/src/board.ts +4 -4
- package/src/cli.ts +14 -2
- package/src/compile.ts +255 -77
- package/src/definitions.ts +62 -14
- package/src/demo.css +2 -5
- package/src/draft.ts +10 -4
- package/src/drawer.ts +30 -4
- package/src/engine.ts +14 -5
- package/src/fields.ts +88 -15
- package/src/file-value.ts +12 -2
- package/src/files.ts +113 -35
- package/src/icon-names.ts +4 -0
- package/src/keep.ts +16 -3
- package/src/map.css +23 -16
- package/src/map.ts +3 -3
- package/src/mcp.ts +24 -3
- package/src/members/group.ts +41 -17
- package/src/members/keys.ts +3 -3
- package/src/members/panel.css +17 -18
- package/src/members/panel.ts +9 -2
- package/src/migrate.ts +58 -21
- package/src/migrations/005-change-kept.ts +7 -0
- package/src/month.css +6 -2
- package/src/month.ts +5 -5
- package/src/ops.ts +40 -1
- package/src/page.css +3 -2
- package/src/page.ts +64 -16
- package/src/parts.css +178 -86
- package/src/parts.ts +60 -20
- package/src/plane.css +9 -4
- package/src/plane.ts +4 -2
- package/src/reading.css +1 -5
- package/src/rows.css +2 -21
- package/src/rows.ts +123 -39
- package/src/server.ts +157 -30
- package/src/sheet.ts +4 -2
- package/src/slots.css +0 -4
- package/src/specs.ts +1 -1
- package/src/starter.ts +15 -1
- package/src/store.ts +40 -18
- package/src/surface.ts +7 -2
- package/src/time.ts +2 -0
- package/src/timeline.ts +14 -5
- package/src/together.ts +15 -17
- package/src/tokens.css +12 -3
- package/src/tokens.json +38 -7
- package/src/tool.ts +6 -7
- package/src/upkeep.ts +31 -4
- package/src/views.css +8 -9
- package/src/views.ts +23 -6
- package/src/week.css +1 -2
- package/src/week.ts +11 -7
- package/src/write.ts +130 -15
- package/starter/CHANGELOG.md +8 -0
- package/starter/CLAUDE.md +7 -1
- package/starter/bunfig +2 -1
- package/starter/githooks/pre-commit +13 -0
- package/starter/prettierignore +1 -0
- package/starter/tests/records.test.ts +40 -0
- package/starter/todo.jsonl +0 -0
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
// The supplies page: the supplies its person is party to, as buyer or supplier, each read from their side
|
|
2
|
-
// whose each part is.
|
|
3
|
-
// #supply=1) and says it's delivered, as its may says; the buyer is
|
|
1
|
+
// The supplies page: the supplies its person is party to, as buyer or supplier, each a row (Row) read from their side
|
|
2
|
+
// and saying whose each part is. Its supplier opens it to set the price and the days to pay (in a drawer: a Draft, in
|
|
3
|
+
// the hash as #supply=1) and says it's delivered by its own button, as its may says; to the buyer each is its words. Delivered, the menu has more
|
|
4
4
|
// (its gives), and both sides' books have it. Anyone orders one, as its buyer, from another member.
|
|
5
5
|
|
|
6
6
|
import { members, signedIn } from "joined/panel";
|
|
7
7
|
import "joined/toast";
|
|
8
8
|
import { Draft } from "joined/draft";
|
|
9
|
-
import {
|
|
10
|
-
import { inHash, said } from "joined/parts";
|
|
9
|
+
import { iconify } from "joined/icons";
|
|
10
|
+
import { docked, inHash, row, said } from "joined/parts";
|
|
11
11
|
import { Surface } from "joined/surface";
|
|
12
12
|
import * as menu from "./generated/menu.rules.ts";
|
|
13
13
|
import { JItem } from "./generated/menu.elements.ts";
|
|
14
|
+
import * as staff from "./generated/staff.rules.ts";
|
|
15
|
+
import { JPost } from "./generated/staff.elements.ts";
|
|
14
16
|
import * as supplies from "./generated/supplies.rules.ts";
|
|
15
17
|
import { JSupply, type JSupplies } from "./generated/supplies.elements.ts";
|
|
16
18
|
import { money, nameOf } from "./views.ts";
|
|
@@ -24,15 +26,14 @@ const items = document.getElementsByTagName(menu.collections.items.tag) as HTMLC
|
|
|
24
26
|
/** Who's who on a supply, from this page's side: you, or their name. */
|
|
25
27
|
const who = (id?: number) => (id === me ? "you" : nameOf(members, id));
|
|
26
28
|
|
|
27
|
-
/** A supply:
|
|
28
|
-
*
|
|
29
|
+
/** A supply, a row: its title, and under it where it is, how many at what price and terms, and whose each part is.
|
|
30
|
+
* Its supplier opens it, for its price and days to pay, until it's delivered (then both books have them, kept:
|
|
31
|
+
* trust.ts); to anyone else it's its words alone. Delivered is a button of its own, for it does what opening doesn't. */
|
|
29
32
|
class Supply extends JSupply {
|
|
30
|
-
#
|
|
31
|
-
#what =
|
|
32
|
-
#whose = Object.assign(document.createElement("
|
|
33
|
-
#acts = Object.assign(document.createElement("p"), { className: "acts" });
|
|
33
|
+
#row = row(() => show(this));
|
|
34
|
+
#what = this.#row.el.querySelector(".j-words > span")!;
|
|
35
|
+
#whose = Object.assign(document.createElement("span"), { className: "whose" });
|
|
34
36
|
#said = Object.assign(document.createElement("p"), { className: "said", role: "status" });
|
|
35
|
-
#edit = iconButton("edit", "", () => show(this));
|
|
36
37
|
#delivered = Object.assign(document.createElement("button"), {
|
|
37
38
|
type: "button",
|
|
38
39
|
className: "act ink",
|
|
@@ -40,7 +41,11 @@ class Supply extends JSupply {
|
|
|
40
41
|
onclick: () => said(this.#said, this.replace({ delivered: true })),
|
|
41
42
|
});
|
|
42
43
|
connectedCallback() {
|
|
43
|
-
if (!this.childElementCount)
|
|
44
|
+
if (!this.childElementCount) {
|
|
45
|
+
this.#what.className = "what";
|
|
46
|
+
this.#what.after(this.#whose);
|
|
47
|
+
this.append(this.#row.el, this.#said);
|
|
48
|
+
}
|
|
44
49
|
this.draw();
|
|
45
50
|
hash.again(); // named in the address before it was on the page: opened now it is
|
|
46
51
|
}
|
|
@@ -48,24 +53,20 @@ class Supply extends JSupply {
|
|
|
48
53
|
if (!this.isConnected) return;
|
|
49
54
|
const d = this.data;
|
|
50
55
|
const item = [...items].find((i) => i.key === d.item)?.data.name ?? `item ${d.item}`;
|
|
51
|
-
this.#
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
className: `pill${d.delivered ? " here" : ""}`,
|
|
55
|
-
textContent: d.delivered ? "delivered" : "on its way",
|
|
56
|
-
}),
|
|
56
|
+
this.#row.say(
|
|
57
|
+
d.title,
|
|
58
|
+
`${d.delivered ? "Delivered" : "On its way"} · ${d.qty} × ${item} at ${money(d.price)} each, ${money(d.qty * d.price)} · ${d["terms.days"]} days to pay`,
|
|
57
59
|
);
|
|
58
|
-
this.#what.textContent = `${d.qty} × ${item} at ${money(d.price)} each, ${money(d.qty * d.price)} · ${d["terms.days"]} days to pay`;
|
|
59
60
|
// whose each part is, as this page's person reads it
|
|
60
61
|
const buying = d.buyer === me,
|
|
61
62
|
supplying = d.supplier === me;
|
|
62
63
|
this.#whose.textContent = `${cap(who(d.buyer))} ${buying ? "buy" : "buys"} from ${who(d.supplier)}. ${cap(who(d.supplier))} ${supplying ? "set" : "sets"} the price and the days to pay, and ${supplying ? "say" : "says"} when it's delivered.`;
|
|
63
|
-
|
|
64
|
-
this.#
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
);
|
|
64
|
+
// its terms, until it's delivered: the row opens them; to anyone else, its words alone
|
|
65
|
+
this.#row.el.disabled = !this.matches('[may~="replace:price"], [may~="replace:terms.days"]') || !!d.delivered;
|
|
66
|
+
this.#row.mark(this === open);
|
|
67
|
+
const delivers = this.matches('[may~="replace:delivered"]') && !d.delivered;
|
|
68
|
+
if (delivers && !this.#delivered.isConnected) this.#row.el.after(this.#delivered);
|
|
69
|
+
if (!delivers) this.#delivered.remove();
|
|
69
70
|
// the one in the drawer, changed elsewhere: what isn't being typed in follows it
|
|
70
71
|
if (this === open) (draft.fill(fields(this)), shown());
|
|
71
72
|
}
|
|
@@ -85,7 +86,12 @@ const fields = (s: Supply) => ({ price: (s.data.price / 100).toFixed(2), days: S
|
|
|
85
86
|
const shown = () => draft.show(Object.keys(draft.edits()).length ? "changed" : "kept");
|
|
86
87
|
/** The drawer, with a supply in it, or closed; marked in the hash as it's opened or closed. */
|
|
87
88
|
function show(s: Supply | null, mark = true) {
|
|
89
|
+
const was = open;
|
|
88
90
|
open = s;
|
|
91
|
+
// docked at the screen's side, the page keeps clear of it (joined/page.css)
|
|
92
|
+
docked(!!s);
|
|
93
|
+
was?.draw();
|
|
94
|
+
s?.draw();
|
|
89
95
|
drawer.open = !!s;
|
|
90
96
|
if (s) {
|
|
91
97
|
drawer.title.textContent = `Your terms: ${s.data.title}`;
|
|
@@ -131,12 +137,18 @@ const fill = () => {
|
|
|
131
137
|
"item",
|
|
132
138
|
[...items].map((i) => ({ value: i.key, text: i.data.name })),
|
|
133
139
|
);
|
|
140
|
+
// a supplier is one of staff's supplier posts (the stories' links, holds): no one else is offered
|
|
141
|
+
const sellers = new Set(
|
|
142
|
+
[...posts].filter((p) => p.data.role === "supplier").flatMap((p) => p.data.members as number[]),
|
|
143
|
+
);
|
|
134
144
|
options(
|
|
135
145
|
"supplier",
|
|
136
|
-
[...members].filter((m) => m.key !== me).map((m) => ({ value: m.key, text: m.data.name })),
|
|
146
|
+
[...members].filter((m) => m.key !== me && sellers.has(m.key)).map((m) => ({ value: m.key, text: m.data.name })),
|
|
137
147
|
);
|
|
138
148
|
for (const s of listed) s.draw();
|
|
139
149
|
};
|
|
150
|
+
/** The staff's posts, a live list: who supplies. */
|
|
151
|
+
const posts = document.getElementsByTagName(staff.collections.posts.tag) as HTMLCollectionOf<JPost>;
|
|
140
152
|
/** The supplies on the page, a live list. */
|
|
141
153
|
const listed = document.getElementsByTagName(supplies.collections.supplies.tag) as HTMLCollectionOf<Supply>;
|
|
142
154
|
const hash = inHash(
|
|
@@ -147,7 +159,11 @@ const hash = inHash(
|
|
|
147
159
|
);
|
|
148
160
|
// (the menu and the members, not the supplies it draws: those it draws again, and never watches)
|
|
149
161
|
const watching = new MutationObserver(fill);
|
|
150
|
-
for (const el of [
|
|
162
|
+
for (const el of [
|
|
163
|
+
document.querySelector(menu.collections.items.place),
|
|
164
|
+
document.querySelector(staff.collections.posts.place),
|
|
165
|
+
document.querySelector("members-panel"),
|
|
166
|
+
])
|
|
151
167
|
if (el) watching.observe(el, { subtree: true, childList: true, attributes: true });
|
|
152
168
|
form.addEventListener("submit", (e) => {
|
|
153
169
|
e.preventDefault();
|
|
@@ -170,4 +186,5 @@ form.addEventListener("submit", (e) => {
|
|
|
170
186
|
|
|
171
187
|
// defined last, once all they draw with is made: the items first, so a supply drawn as it's defined names its item
|
|
172
188
|
customElements.define(menu.collections.items.tag, class extends JItem {});
|
|
189
|
+
customElements.define(staff.collections.posts.tag, class extends JPost {});
|
|
173
190
|
customElements.define(supplies.collections.supplies.tag, Supply);
|
package/examples/cafe/till.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import "joined/panel";
|
|
8
8
|
import "joined/toast";
|
|
9
|
-
import { iconify } from "joined/icons";
|
|
9
|
+
import { icon, iconify } from "joined/icons";
|
|
10
10
|
import { askFirst, said } from "joined/parts";
|
|
11
11
|
import * as menu from "./generated/menu.rules.ts";
|
|
12
12
|
import { JItem } from "./generated/menu.elements.ts";
|
|
@@ -20,24 +20,26 @@ class Item extends JItem {
|
|
|
20
20
|
#name = document.createElement("b");
|
|
21
21
|
#price = Object.assign(document.createElement("span"), { className: "price" });
|
|
22
22
|
#count = Object.assign(document.createElement("output"), { value: "0" });
|
|
23
|
-
#less = this.#step(-1, "
|
|
24
|
-
#more = this.#step(1, "
|
|
23
|
+
#less = this.#step(-1, "less", "act icon-only");
|
|
24
|
+
#more = this.#step(1, "add", "act ink icon-only");
|
|
25
25
|
#bar = document.createElement("i");
|
|
26
|
+
#stock = Object.assign(document.createElement("span"), { className: "stock" });
|
|
26
27
|
#left = Object.assign(document.createElement("p"), { className: "left" });
|
|
27
28
|
connectedCallback() {
|
|
28
29
|
if (!this.childElementCount) {
|
|
29
30
|
const head = Object.assign(document.createElement("p"), { className: "head" }),
|
|
30
|
-
steps = Object.assign(document.createElement("p"), { className: "steps" })
|
|
31
|
-
bar = Object.assign(document.createElement("span"), { className: "bar" });
|
|
31
|
+
steps = Object.assign(document.createElement("p"), { className: "steps" });
|
|
32
32
|
head.append(this.#name, " ", this.#price);
|
|
33
33
|
steps.append(this.#less, this.#count, this.#more);
|
|
34
|
-
|
|
35
|
-
this.append(head, steps,
|
|
34
|
+
this.#stock.append(this.#bar);
|
|
35
|
+
this.append(head, steps, this.#stock, this.#left);
|
|
36
36
|
}
|
|
37
37
|
this.draw();
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
/** One fewer or one more: its icon alone (lucide's, as every plus in joined), its label said by draw(). */
|
|
40
|
+
#step(by: number, name: "less" | "add", className: string) {
|
|
41
|
+
const b = Object.assign(document.createElement("button"), { type: "button", className });
|
|
42
|
+
b.append(icon(name));
|
|
41
43
|
b.addEventListener("click", () => ((this.qty += by), this.draw()));
|
|
42
44
|
return b;
|
|
43
45
|
}
|
|
@@ -52,6 +54,8 @@ class Item extends JItem {
|
|
|
52
54
|
this.#more.ariaLabel = `One more ${name}`;
|
|
53
55
|
this.#less.disabled = this.qty === 0;
|
|
54
56
|
this.#more.disabled = this.qty >= stock;
|
|
57
|
+
// how many of what's left are wanted, a bar: none wanted, none drawn (an empty bar says nothing)
|
|
58
|
+
this.#stock.hidden = !this.qty;
|
|
55
59
|
this.#bar.style.width = `${stock ? (this.qty / stock) * 100 : 0}%`;
|
|
56
60
|
this.#left.textContent = !stock
|
|
57
61
|
? "none left"
|
|
@@ -112,7 +116,7 @@ customElements.define(
|
|
|
112
116
|
orderView(
|
|
113
117
|
JOrder,
|
|
114
118
|
[
|
|
115
|
-
{ words: "Cancel", from: "placed", to: "cancelled", ask: "
|
|
119
|
+
{ words: "Cancel", from: "placed", to: "cancelled", ask: "This order will be cancelled." },
|
|
116
120
|
{ words: "Hand over", from: "ready", to: "collected" },
|
|
117
121
|
],
|
|
118
122
|
askFirst(
|
package/examples/cafe/views.ts
CHANGED
|
@@ -93,16 +93,18 @@ export function orderView<T extends new (...a: any[]) => Order>(
|
|
|
93
93
|
if (!this.isConnected) return;
|
|
94
94
|
const { customer, status = "", total = 0, placed = "" } = this.data;
|
|
95
95
|
const waited = waitedSince(placed);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
);
|
|
96
|
+
const isLate =
|
|
97
|
+
late && status !== "ready" && waited >= 10 && !this.matches("[status=collected],[status=cancelled]");
|
|
98
|
+
this.toggleAttribute("late", isLate);
|
|
100
99
|
this.#head.replaceChildren(
|
|
101
100
|
Object.assign(document.createElement("b"), { textContent: `#${this.key} ${customer}` }),
|
|
102
101
|
` ${money(total)} `,
|
|
103
102
|
Object.assign(document.createElement("span"), {
|
|
104
103
|
className: "state",
|
|
105
|
-
textContent:
|
|
104
|
+
textContent:
|
|
105
|
+
status === "placed" || status === "being made"
|
|
106
|
+
? `${status} · ${isLate ? "late, " : ""}${waitOf(waited)}`
|
|
107
|
+
: status,
|
|
106
108
|
}),
|
|
107
109
|
...(link && this.data.code
|
|
108
110
|
? [
|
package/examples/chart/arches.ts
CHANGED
|
@@ -84,7 +84,8 @@ function fromAbove(t: Tooth, x: number, y: number, deg: number, w: number, d: nu
|
|
|
84
84
|
export function arches() {
|
|
85
85
|
const svg = s("svg", {
|
|
86
86
|
slot: "ground",
|
|
87
|
-
|
|
87
|
+
// the teeth's own extent (84 to 596 across, 9 to 403 down), so the arches take all the width they're given
|
|
88
|
+
viewBox: "80 4 520 404",
|
|
88
89
|
role: "img",
|
|
89
90
|
"aria-label": "The teeth, seen from above",
|
|
90
91
|
});
|
|
@@ -131,8 +132,9 @@ export function arches() {
|
|
|
131
132
|
});
|
|
132
133
|
}
|
|
133
134
|
for (const [words, x, y] of [
|
|
134
|
-
|
|
135
|
-
["
|
|
135
|
+
// inside the arch, between the jaws' last teeth: the patient's right on the left
|
|
136
|
+
["Right", 184, 210],
|
|
137
|
+
["Left", 496, 210],
|
|
136
138
|
] as const) {
|
|
137
139
|
const label = s("text", {
|
|
138
140
|
x,
|
package/examples/chart/chart.css
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
/* The chart's page: the two drawings side by side where there's room, the account beneath
|
|
1
|
+
/* The chart's page: the two drawings side by side where there's room, the account beneath, all one width, a list's
|
|
2
|
+
(as joined's rows are), in the middle of a wide page: a drawing the page's whole width stood taller than the screen */
|
|
2
3
|
main.chart {
|
|
3
4
|
display: grid;
|
|
4
|
-
grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--size-list)),
|
|
5
|
+
grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--size-list)), var(--size-list)));
|
|
6
|
+
justify-content: center;
|
|
5
7
|
gap: var(--space-16);
|
|
6
8
|
}
|
|
9
|
+
main.chart > [aria-label="The account"] {
|
|
10
|
+
grid-column: 1 / -1;
|
|
11
|
+
}
|
package/examples/desk/desk.css
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
/* The desk's page: the tally in
|
|
1
|
+
/* The desk's page: the tally in joined's card over the lanes, and the form to add a task under them. */
|
|
2
2
|
main.desk {
|
|
3
3
|
display: grid;
|
|
4
4
|
gap: var(--space-24);
|
|
5
5
|
}
|
|
6
6
|
.card.tally {
|
|
7
|
-
|
|
8
|
-
border: 1px solid var(--edge);
|
|
9
|
-
border-radius: 4px;
|
|
10
|
-
background: var(--card);
|
|
7
|
+
--spacing: var(--space-16);
|
|
11
8
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
flex-basis: 12rem;
|
|
9
|
+
/* its points, a number of one or two figures between its − and +: three fingers wide, never the task box's width */
|
|
10
|
+
form.add wa-number-input {
|
|
11
|
+
flex: none;
|
|
12
|
+
width: calc(3 * var(--size-finger));
|
|
17
13
|
}
|
|
@@ -17,7 +17,7 @@ const send = (from: Element, ops: object[], why?: string) => new Promise<Answer>
|
|
|
17
17
|
/** A task's fields, as the stories give them. */
|
|
18
18
|
export type JTaskData = { "title": string; "points": number; "rank": number; "status"?: string; "ups"?: number[]; "downs"?: number[]; "by"?: number; "added"?: string };
|
|
19
19
|
/** An add of a task, as it's sent: its fields as the stories write them. */
|
|
20
|
-
export type JTaskValue = { "title": string; "points": number; "rank": number; "status"?: string; "ups"?: number[]; "downs"?: number[]; "by"?: number | `$${number}`; "added"?: string };
|
|
20
|
+
export type JTaskValue = { "title": string; "points": number; "rank": number; "status"?: string; "ups"?: (number | `$${number}`)[]; "downs"?: (number | `$${number}`)[]; "by"?: number | `$${number}`; "added"?: string };
|
|
21
21
|
|
|
22
22
|
/** <j-task key>: title (string), points (integer), rank (decimal), status (string), ups (ids in members), downs (ids in members), by (an id in members), added (instant), each an attribute. */
|
|
23
23
|
export class JTask extends HTMLElement {
|
package/examples/desk/index.html
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
<nav class="bar"><members-panel></members-panel></nav>
|
|
21
21
|
</header>
|
|
22
22
|
<main class="desk">
|
|
23
|
-
<
|
|
23
|
+
<wa-card class="card tally" aria-label="How it's going"><desk-tally></desk-tally></wa-card>
|
|
24
24
|
<desk-lanes><j-tasks></j-tasks></desk-lanes>
|
|
25
25
|
<form class="add">
|
|
26
26
|
<wa-input
|
package/examples/desk/lanes.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* <desk-lanes>'s look, in its shadow (with joined's parts): a lane for each status side by side
|
|
2
|
-
|
|
1
|
+
/* <desk-lanes>'s look, in its shadow (with joined's parts): a lane for each status side by side, one under another
|
|
2
|
+
on a phone (below the one breakpoint); each its name and how many, and its cards, each a card in its edge: its title, who
|
|
3
3
|
put it there and its points, its thumbs, its moves. The lane a card may go to is marked as it's held over it; a
|
|
4
4
|
card just changed glows a moment (./pulse.ts), and doesn't where the device asks for less motion. */
|
|
5
5
|
:host {
|
|
@@ -10,23 +10,18 @@
|
|
|
10
10
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
11
11
|
gap: var(--space-12);
|
|
12
12
|
}
|
|
13
|
-
@media (max-width:
|
|
14
|
-
.lanes {
|
|
15
|
-
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
@media (max-width: 30rem) {
|
|
13
|
+
@media (max-width: 40rem) {
|
|
19
14
|
.lanes {
|
|
20
15
|
grid-template-columns: minmax(0, 1fr);
|
|
21
16
|
}
|
|
22
17
|
}
|
|
23
18
|
section {
|
|
24
19
|
min-height: 6rem;
|
|
25
|
-
border-radius:
|
|
20
|
+
border-radius: var(--radius);
|
|
26
21
|
}
|
|
27
22
|
section[over] {
|
|
28
|
-
outline:
|
|
29
|
-
outline-offset:
|
|
23
|
+
outline: var(--size-ring) dashed var(--ink);
|
|
24
|
+
outline-offset: var(--size-ring);
|
|
30
25
|
}
|
|
31
26
|
h3 {
|
|
32
27
|
display: flex;
|
|
@@ -47,7 +42,7 @@ ol {
|
|
|
47
42
|
gap: var(--space-8);
|
|
48
43
|
padding: var(--space-12);
|
|
49
44
|
border: 1px solid var(--edge);
|
|
50
|
-
border-radius:
|
|
45
|
+
border-radius: var(--radius);
|
|
51
46
|
background: var(--card);
|
|
52
47
|
color: var(--ink);
|
|
53
48
|
touch-action: pan-y;
|
|
@@ -57,7 +52,8 @@ ol {
|
|
|
57
52
|
position: relative;
|
|
58
53
|
z-index: 1;
|
|
59
54
|
cursor: grabbing;
|
|
60
|
-
|
|
55
|
+
/* held: outlined in ink, as picked is (no shadows: design.md, Layout) */
|
|
56
|
+
outline: var(--size-ring) solid var(--ink);
|
|
61
57
|
}
|
|
62
58
|
.card p {
|
|
63
59
|
margin: 0;
|
|
@@ -77,13 +73,13 @@ ol {
|
|
|
77
73
|
display: inline-flex;
|
|
78
74
|
align-items: center;
|
|
79
75
|
gap: var(--space-4);
|
|
80
|
-
min-height:
|
|
76
|
+
min-height: var(--size-touch);
|
|
81
77
|
padding: 0 var(--space-8);
|
|
82
|
-
border: 1px solid var(--
|
|
83
|
-
border-radius:
|
|
78
|
+
border: 1px solid var(--control-edge);
|
|
79
|
+
border-radius: var(--radius);
|
|
84
80
|
background: none;
|
|
85
81
|
color: var(--muted);
|
|
86
|
-
font: var(--font-
|
|
82
|
+
font: var(--font-tool);
|
|
87
83
|
}
|
|
88
84
|
button.thumb {
|
|
89
85
|
cursor: pointer;
|
|
@@ -113,10 +109,16 @@ button.thumb {
|
|
|
113
109
|
}
|
|
114
110
|
@keyframes pulse {
|
|
115
111
|
from {
|
|
116
|
-
|
|
112
|
+
outline: var(--size-ring) solid var(--accent);
|
|
117
113
|
}
|
|
118
114
|
to {
|
|
119
|
-
|
|
115
|
+
outline: var(--size-ring) solid transparent;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/* under a finger, a thumb is a finger tall */
|
|
119
|
+
@media (max-width: 40rem), (pointer: coarse) {
|
|
120
|
+
.thumb {
|
|
121
|
+
min-height: var(--size-finger);
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
{"moves":{"tasks":"status"}}
|
|
6
6
|
{"mine":{"tasks":[["ups","downs"]]}}
|
|
7
7
|
{"story":"Peter puts a task on the desk: it's queued, his, and dated","as":"peter","does":{"doc":"desk","ops":[{"op":"add","path":"/tasks/-","value":{"title":"Print the badges","points":1,"rank":5}}]},"seen":["peter","phone","agent"],"then":{"/tasks/5/status":"queued","/tasks/5/by":1}}
|
|
8
|
-
{"story":"Peter can't say whose a task is: the desk fills it","as":"peter","cannot":{"doc":"desk","ops":[{"op":"add","path":"/tasks/-","value":{"title":"Print the badges","by":2}}]},"refused":"by is the server's to fill"}
|
|
8
|
+
{"story":"Peter can't say whose a task is: the desk fills it","as":"peter","cannot":{"doc":"desk","ops":[{"op":"add","path":"/tasks/-","value":{"title":"Print the badges","points":1,"rank":5,"by":2}}]},"refused":"by is the server's to fill"}
|
|
9
9
|
{"story":"The agent starts the welcome","as":"agent","does":{"doc":"desk","ops":[{"op":"replace","path":"/tasks/1/status","value":"working"}]},"seen":["peter","agent"]}
|
|
10
10
|
{"story":"The agent puts the rota up for review","as":"agent","does":{"doc":"desk","ops":[{"op":"replace","path":"/tasks/2/status","value":"review"}]},"seen":["peter","agent"]}
|
|
11
11
|
{"story":"Peter approves the hall: it's done","as":"peter","does":{"doc":"desk","ops":[{"op":"replace","path":"/tasks/3/status","value":"done"}]},"seen":["peter","agent"]}
|
package/examples/desk/tally.css
CHANGED
package/examples/docs.ts
CHANGED
|
@@ -15,12 +15,15 @@ export async function docs(req: { params: { file: string } }) {
|
|
|
15
15
|
return new Response(
|
|
16
16
|
`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>joined — ${name}</title><style>${tokens}${page}${style}
|
|
17
17
|
img { max-width: 100%; height: auto; display: block; margin: var(--space-20) 0; }
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
/* the doc's own logo: the page's head is joined's brand line, as every page's */
|
|
19
|
+
img[src="logo.svg"] { display: none; }
|
|
20
|
+
pre { padding: var(--space-12) var(--space-16); background: var(--well); border: 1px solid var(--edge); border-radius: var(--radius); overflow-x: auto; font: var(--font-small); }
|
|
21
|
+
code { font-family: var(--mono); }
|
|
22
|
+
pre code { font: inherit; font-family: var(--mono); }
|
|
20
23
|
hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-24) 0; }
|
|
21
|
-
table { width: 100%; border-collapse: collapse; margin: var(--space-16) 0; font
|
|
24
|
+
table { width: 100%; border-collapse: collapse; margin: var(--space-16) 0; font: var(--font-row); }
|
|
22
25
|
th, td { text-align: left; padding: var(--space-8) var(--space-10); border-bottom: 1px solid var(--line); }
|
|
23
|
-
</style></head><body><
|
|
26
|
+
</style></head><body><a class="brand" href="/"><img src="/apple-touch-icon.png" alt="" width="28" height="28" />joined</a>${Bun.markdown.html(await md.text(), { tables: true })}</body></html>`,
|
|
24
27
|
{ headers: { "content-type": "text/html; charset=utf-8" } },
|
|
25
28
|
);
|
|
26
29
|
const raw = Bun.file(`${DOCS}/${req.params.file}`);
|
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,11 +67,12 @@
|
|
|
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>
|
|
@@ -133,7 +140,9 @@
|
|
|
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
147
|
One change, from Peter's finger to Nick's screen (1:50), filmed before the trip's calendar and map were the
|
|
139
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
|
|
@@ -23,7 +23,10 @@ export const query = `SELECT json_object('version', COALESCE((SELECT version FRO
|
|
|
23
23
|
|
|
24
24
|
/** Its rules over values (definitions' takes, gives and totals), as triggers the store makes in its database: run in
|
|
25
25
|
* each write's transaction, and told as any change is. */
|
|
26
|
-
export const triggers: string[] = [
|
|
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
|
+
];
|
|
27
30
|
|
|
28
31
|
/** Its items, its query and its triggers, as Postgres says them. */
|
|
29
32
|
export const postgres = {
|
|
@@ -32,5 +35,8 @@ export const postgres = {
|
|
|
32
35
|
"ranks": "json_strip_nulls(json_build_object('id', t.id,\n 'note', t.\"note\",\n 'rank', t.\"rank\",\n 'by', t.\"by\"))"
|
|
33
36
|
},
|
|
34
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",
|
|
35
|
-
"triggers": [
|
|
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
|
+
]
|
|
36
42
|
};
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
<body>
|
|
12
12
|
<a class="brand" href="/"><img src="joined/icon.png" alt="" width="28" height="28" />joined</a>
|
|
13
13
|
<h1>Notes</h1>
|
|
14
|
-
<nav class="bar"><members-panel></members-panel></nav>
|
|
15
14
|
<p class="lead">
|
|
16
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
|
|
17
16
|
few lines.
|
|
18
17
|
</p>
|
|
18
|
+
<nav class="bar"><members-panel></members-panel></nav>
|
|
19
19
|
<main>
|
|
20
20
|
<j-search for="notes"></j-search>
|
|
21
21
|
<j-views>
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{"cast":{"phone":"peter"}}
|
|
2
2
|
{"links":{"note":{"to":"notes","one":true,"gone":"with"},"by":{"to":"members","one":true}}}
|
|
3
3
|
{"mine":{"ranks":{"of":"note","by":"by"}}}
|
|
4
|
+
{"notEmpty":{"notes":["text"]}}
|
|
4
5
|
{"story":"Someone writes a note, and every page shows it","as":"peter","does":{"doc":"notes","ops":[{"op":"add","path":"/notes/-","value":{"text":"Water the plants"}}]},"seen":["peter","phone"]}
|
|
5
6
|
{"story":"A note is reworded","as":"peter","does":{"doc":"notes","ops":[{"op":"replace","path":"/notes/1/text","value":"Buy rice and miso"}]},"seen":["peter","phone"]}
|
|
6
7
|
{"story":"A note is given more to say","as":"peter","does":{"doc":"notes","ops":[{"op":"replace","path":"/notes/1/more","value":"The short-grain kind, two kilos."}]},"seen":["peter","phone"]}
|
|
7
8
|
{"story":"What a note says more is taken off","as":"peter","does":{"doc":"notes","ops":[{"op":"remove","path":"/notes/2/more"}]},"seen":["peter","phone"]}
|
|
8
9
|
{"story":"A note is thrown away","as":"peter","does":{"doc":"notes","ops":[{"op":"remove","path":"/notes/3"}]},"seen":["peter","phone"]}
|
|
9
10
|
{"story":"A note needs its words","as":"peter","cannot":{"doc":"notes","ops":[{"op":"add","path":"/notes/-","value":{"more":"Nothing it says"}}]}}
|
|
11
|
+
{"story":"A note can't be saved with no words","as":"peter","cannot":{"doc":"notes","ops":[{"op":"replace","path":"/notes/1/text","value":""}]},"refused":"text cannot be empty"}
|
|
12
|
+
{"story":"Spaces are no words: a note can't be written of them","as":"peter","cannot":{"doc":"notes","ops":[{"op":"add","path":"/notes/-","value":{"text":" "}}]},"refused":"text cannot be empty"}
|
|
10
13
|
{"story":"A note is words, not a number","as":"peter","cannot":{"doc":"notes","ops":[{"op":"replace","path":"/notes/1/text","value":7}]}}
|
|
11
14
|
{"story":"A note is ticked done","as":"peter","does":{"doc":"notes","ops":[{"op":"replace","path":"/notes/1/done","value":true}]},"seen":["peter","phone"]}
|
|
12
15
|
{"story":"A note done is not, after all: its tick is taken off","as":"peter","does":{"doc":"notes","ops":[{"op":"remove","path":"/notes/3/done"}]},"seen":["peter","phone"]}
|
package/examples/page.ts
CHANGED
|
@@ -6,6 +6,13 @@ import "joined/demo";
|
|
|
6
6
|
import "joined/toast";
|
|
7
7
|
import { iconify } from "joined/icons";
|
|
8
8
|
|
|
9
|
-
// the film, from the root's /film.mp4, answered in ranges
|
|
10
|
-
document.querySelector<HTMLVideoElement>("figure.film video")
|
|
9
|
+
// the film, from the root's /film.mp4, answered in ranges; its controls once it's played from its own button
|
|
10
|
+
const film = document.querySelector<HTMLVideoElement>("figure.film video")!,
|
|
11
|
+
play = document.querySelector<HTMLButtonElement>("figure.film .play")!;
|
|
12
|
+
film.src = "/film.mp4";
|
|
13
|
+
play.addEventListener("click", () => {
|
|
14
|
+
play.hidden = true;
|
|
15
|
+
film.controls = true;
|
|
16
|
+
void film.play();
|
|
17
|
+
});
|
|
11
18
|
iconify();
|
package/examples/people/links.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// many things link to them. Pressing a link sends its element a "pick" event, for whatever holds it to act on.
|
|
6
6
|
|
|
7
7
|
import { keep, type Row } from "joined/keep";
|
|
8
|
+
import { mention } from "joined/parts";
|
|
8
9
|
|
|
9
10
|
/** A person's row, as the links know it: its key, and how it's told one link changed. */
|
|
10
11
|
type Linked = HTMLElement & { key: number; linked(el: Element): void };
|
|
@@ -63,24 +64,21 @@ export class Links {
|
|
|
63
64
|
k ? k.el.replaceWith(made) : this.el.append(made);
|
|
64
65
|
this.#kept.set(key, { shows: row.shows, el: made });
|
|
65
66
|
}
|
|
66
|
-
/** An element linking to them, as its row: its title,
|
|
67
|
+
/** An element linking to them, as its row: its title, a mention (a thing named away from its own place, joined's
|
|
68
|
+
* pill), which picks it. */
|
|
67
69
|
#row(el: Element): Row {
|
|
68
70
|
const title = el.getAttribute("title") ?? el.localName;
|
|
69
71
|
return {
|
|
70
72
|
key: keyOf(el),
|
|
71
73
|
shows: title,
|
|
72
74
|
make: () => {
|
|
73
|
-
const go =
|
|
74
|
-
type: "button",
|
|
75
|
-
className: "act small",
|
|
76
|
-
textContent: title,
|
|
77
|
-
});
|
|
78
|
-
go.addEventListener("click", () => {
|
|
75
|
+
const go = mention((by) => {
|
|
79
76
|
el.dispatchEvent(new CustomEvent("pick", { bubbles: true }));
|
|
80
77
|
// the sheet it's in closes (joined/surface)
|
|
81
|
-
|
|
78
|
+
by.dispatchEvent(new Event("j-close", { bubbles: true }));
|
|
82
79
|
});
|
|
83
|
-
|
|
80
|
+
go.say(title);
|
|
81
|
+
return go.el;
|
|
84
82
|
},
|
|
85
83
|
};
|
|
86
84
|
}
|