@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
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,10 +116,14 @@ 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
|
-
askFirst(
|
|
122
|
+
askFirst(
|
|
123
|
+
document.querySelector("wa-dialog.ask")!,
|
|
124
|
+
"Cancel it",
|
|
125
|
+
"Everyone sees it cancelled at once, and it can't be taken back.",
|
|
126
|
+
),
|
|
119
127
|
{ link: true }, // the customer's own link, to give them
|
|
120
128
|
),
|
|
121
129
|
);
|
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
|
? [
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// The arches, drawn once: the teeth seen from above around each jaw, each tooth's outline natural and its five surfaces
|
|
2
|
+
// wedges clipped to it (data-slot="UR6 M"), so a surface is tapped where it is and the tooth still looks like one.
|
|
3
|
+
|
|
4
|
+
import { conditionStyle, DIM, s, TEETH, type Tooth } from "./teeth.ts";
|
|
5
|
+
|
|
6
|
+
/** A tooth's outline from above, by its kind: molars squarer, incisors wider at the lip. */
|
|
7
|
+
function outline(n: number, a: number, b: number) {
|
|
8
|
+
const ne = n >= 6 ? 2.9 : n >= 4 ? 2.3 : n === 3 ? 2.05 : 2.5,
|
|
9
|
+
pts: string[] = [];
|
|
10
|
+
for (let j = 0; j < 44; j++) {
|
|
11
|
+
const th = (2 * Math.PI * j) / 44,
|
|
12
|
+
c = Math.cos(th),
|
|
13
|
+
sn = Math.sin(th);
|
|
14
|
+
let x = a * Math.sign(c) * Math.abs(c) ** (2 / ne);
|
|
15
|
+
const y = b * Math.sign(sn) * Math.abs(sn) ** (2 / ne);
|
|
16
|
+
x *= n <= 3 ? 1 + 0.22 * (y / b) : n <= 5 ? 1 + 0.1 * (y / b) : 1 + 0.05 * (y / b);
|
|
17
|
+
pts.push(`${x.toFixed(2)},${y.toFixed(2)}`);
|
|
18
|
+
}
|
|
19
|
+
return `M${pts.join(" L")} Z`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** A tooth from above at its place on the arch: its outline, its five surfaces clipped to it, its fissures. */
|
|
23
|
+
function fromAbove(t: Tooth, x: number, y: number, deg: number, w: number, d: number, mesial: number) {
|
|
24
|
+
const a = w / 2,
|
|
25
|
+
b = d / 2,
|
|
26
|
+
path = outline(t.n, a, b),
|
|
27
|
+
id = `a-${t.key}`,
|
|
28
|
+
R = 3;
|
|
29
|
+
const wedges: Record<string, number[][]> = {
|
|
30
|
+
B: [
|
|
31
|
+
[0, 0],
|
|
32
|
+
[-a * R, b * R],
|
|
33
|
+
[a * R, b * R],
|
|
34
|
+
],
|
|
35
|
+
L: [
|
|
36
|
+
[0, 0],
|
|
37
|
+
[-a * R, -b * R],
|
|
38
|
+
[a * R, -b * R],
|
|
39
|
+
],
|
|
40
|
+
M: [
|
|
41
|
+
[0, 0],
|
|
42
|
+
[mesial * a * R, -b * R],
|
|
43
|
+
[mesial * a * R, b * R],
|
|
44
|
+
],
|
|
45
|
+
D: [
|
|
46
|
+
[0, 0],
|
|
47
|
+
[-mesial * a * R, -b * R],
|
|
48
|
+
[-mesial * a * R, b * R],
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
const g = s("g", {
|
|
52
|
+
transform: `translate(${x.toFixed(1)} ${y.toFixed(1)}) rotate(${deg.toFixed(1)})`,
|
|
53
|
+
"data-slot": t.key,
|
|
54
|
+
});
|
|
55
|
+
g.append(s("clipPath", { id }, s("path", { d: path })));
|
|
56
|
+
const surfaces = s("g", { "clip-path": `url(#${id})` });
|
|
57
|
+
for (const [surface, pts] of Object.entries(wedges))
|
|
58
|
+
surfaces.append(
|
|
59
|
+
s("polygon", {
|
|
60
|
+
points: pts.map((p) => p.join(",")).join(" "),
|
|
61
|
+
"data-slot": `${t.key} ${surface}`,
|
|
62
|
+
style: "stroke-width: 0.5",
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
const c =
|
|
66
|
+
t.n >= 6
|
|
67
|
+
? [0, 0, a * 0.5, b * 0.44]
|
|
68
|
+
: t.n >= 4
|
|
69
|
+
? [0, 0, a * 0.44, b * 0.32]
|
|
70
|
+
: t.n === 3
|
|
71
|
+
? [0, b * 0.05, a * 0.32, b * 0.26]
|
|
72
|
+
: [0, b * 0.12, a * 0.72, b * 0.17];
|
|
73
|
+
surfaces.append(s("ellipse", { cx: c[0]!, cy: c[1]!, rx: c[2]!, ry: c[3]!, "data-slot": `${t.key} O` }));
|
|
74
|
+
g.append(
|
|
75
|
+
surfaces,
|
|
76
|
+
s("path", { d: path, class: "outline" }),
|
|
77
|
+
s("path", { d: path, class: "ring" }),
|
|
78
|
+
s("path", { d: `M${-a},${-b} L${a},${b} M${a},${-b} L${-a},${b}`, class: "x" }),
|
|
79
|
+
);
|
|
80
|
+
return g;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The arches: each jaw's teeth placed along half an ellipse by their widths, the upper opening down, the lower up. */
|
|
84
|
+
export function arches() {
|
|
85
|
+
const svg = s("svg", {
|
|
86
|
+
slot: "ground",
|
|
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",
|
|
89
|
+
role: "img",
|
|
90
|
+
"aria-label": "The teeth, seen from above",
|
|
91
|
+
});
|
|
92
|
+
svg.append(conditionStyle());
|
|
93
|
+
for (const row of ["U", "L"]) {
|
|
94
|
+
const cx = 340,
|
|
95
|
+
cy = row === "U" ? 190 : 222,
|
|
96
|
+
rx = 200,
|
|
97
|
+
ry = 140,
|
|
98
|
+
sg = row === "U" ? -1 : 1,
|
|
99
|
+
pt = (t: number) => [cx - rx * Math.cos(t), cy + sg * ry * Math.sin(t)] as const;
|
|
100
|
+
const N = 800,
|
|
101
|
+
ts: number[] = [],
|
|
102
|
+
ss = [0];
|
|
103
|
+
let prev = pt(0);
|
|
104
|
+
for (let j = 0; j <= N; j++) {
|
|
105
|
+
const t = (Math.PI * j) / N,
|
|
106
|
+
q = pt(t);
|
|
107
|
+
if (j > 0) ss.push(ss[j - 1]! + Math.hypot(q[0] - prev[0], q[1] - prev[1]));
|
|
108
|
+
ts.push(t);
|
|
109
|
+
prev = q;
|
|
110
|
+
}
|
|
111
|
+
const row16 = TEETH.filter((t) => t.row === row),
|
|
112
|
+
ws = row16.map((t) => DIM[t.n]![0]),
|
|
113
|
+
gap = 4,
|
|
114
|
+
k = (ss[N]! - 17 * gap) / ws.reduce((x, y) => x + y, 0);
|
|
115
|
+
let acc = gap;
|
|
116
|
+
row16.forEach((t, ix) => {
|
|
117
|
+
const w = ws[ix]! * k,
|
|
118
|
+
d = DIM[t.n]![1] * k,
|
|
119
|
+
at = acc + w / 2;
|
|
120
|
+
acc += w + gap;
|
|
121
|
+
let j = 0;
|
|
122
|
+
while (j < N && ss[j]! < at) j++;
|
|
123
|
+
const tt = ts[j]!,
|
|
124
|
+
[x, y] = pt(tt);
|
|
125
|
+
let nx = (x - cx) / (rx * rx),
|
|
126
|
+
ny = (y - cy) / (ry * ry);
|
|
127
|
+
const nl = Math.hypot(nx, ny);
|
|
128
|
+
((nx /= nl), (ny /= nl));
|
|
129
|
+
const phi = Math.atan2(-nx, ny),
|
|
130
|
+
dot = Math.cos(phi) * rx * Math.sin(tt) + Math.sin(phi) * sg * ry * Math.cos(tt);
|
|
131
|
+
svg.append(fromAbove(t, x, y, (phi * 180) / Math.PI, w, d, (t.i < 8 ? 1 : -1) * Math.sign(dot)));
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
for (const [words, x, y] of [
|
|
135
|
+
// inside the arch, between the jaws' last teeth: the patient's right on the left
|
|
136
|
+
["Right", 184, 210],
|
|
137
|
+
["Left", 496, 210],
|
|
138
|
+
] as const) {
|
|
139
|
+
const label = s("text", {
|
|
140
|
+
x,
|
|
141
|
+
y,
|
|
142
|
+
"font-size": 13,
|
|
143
|
+
style: "fill: var(--muted)",
|
|
144
|
+
"text-anchor": x > 340 ? "end" : "start",
|
|
145
|
+
});
|
|
146
|
+
label.textContent = words;
|
|
147
|
+
svg.append(label);
|
|
148
|
+
}
|
|
149
|
+
return svg;
|
|
150
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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 */
|
|
3
|
+
main.chart {
|
|
4
|
+
display: grid;
|
|
5
|
+
grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--size-list)), var(--size-list)));
|
|
6
|
+
justify-content: center;
|
|
7
|
+
gap: var(--space-16);
|
|
8
|
+
}
|
|
9
|
+
main.chart > [aria-label="The account"] {
|
|
10
|
+
grid-column: 1 / -1;
|
|
11
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"surfaces": [
|
|
4
|
+
{
|
|
5
|
+
"id": 1,
|
|
6
|
+
"tooth": "UR6",
|
|
7
|
+
"surface": "O",
|
|
8
|
+
"material": "amalgam",
|
|
9
|
+
"status": "existing"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": 2,
|
|
13
|
+
"tooth": "UR6",
|
|
14
|
+
"surface": "M",
|
|
15
|
+
"material": "amalgam",
|
|
16
|
+
"status": "to do"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": 3,
|
|
20
|
+
"tooth": "UL2",
|
|
21
|
+
"surface": "B",
|
|
22
|
+
"material": "composite",
|
|
23
|
+
"status": "existing"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": 4,
|
|
27
|
+
"tooth": "UL1",
|
|
28
|
+
"surface": "O",
|
|
29
|
+
"material": "composite",
|
|
30
|
+
"status": "existing"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": 5,
|
|
34
|
+
"tooth": "LL4",
|
|
35
|
+
"surface": "D",
|
|
36
|
+
"material": "composite",
|
|
37
|
+
"status": "to do"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": 6,
|
|
41
|
+
"tooth": "LR6",
|
|
42
|
+
"surface": "O",
|
|
43
|
+
"material": "amalgam",
|
|
44
|
+
"status": "existing"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"id": 7,
|
|
48
|
+
"tooth": "UR7",
|
|
49
|
+
"surface": "D",
|
|
50
|
+
"material": "composite",
|
|
51
|
+
"status": "to do"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": 8,
|
|
55
|
+
"tooth": "UR7",
|
|
56
|
+
"surface": "L",
|
|
57
|
+
"material": "composite",
|
|
58
|
+
"status": "to do"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"conditions": [
|
|
62
|
+
{
|
|
63
|
+
"id": 1,
|
|
64
|
+
"tooth": "UL7",
|
|
65
|
+
"state": "extract",
|
|
66
|
+
"status": "existing"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": 2,
|
|
70
|
+
"tooth": "LR8",
|
|
71
|
+
"state": "extract",
|
|
72
|
+
"status": "to do"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": 3,
|
|
76
|
+
"tooth": "LR7",
|
|
77
|
+
"state": "root filling",
|
|
78
|
+
"status": "to do"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"id": 4,
|
|
82
|
+
"tooth": "LL6",
|
|
83
|
+
"state": "crown",
|
|
84
|
+
"status": "existing"
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Written by src/compile.ts from examples/chart/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 chart, 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 chart
|
|
13
|
+
const docOf = (el: Element) => el.closest("[doc]")?.getAttribute("doc") ?? "chart";
|
|
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 surface's fields, as the stories give them. */
|
|
18
|
+
export type JSurfaceData = { "tooth": string; "surface": string; "material": string; "status": string };
|
|
19
|
+
/** An add of a surface, as it's sent: its fields as the stories write them. */
|
|
20
|
+
export type JSurfaceValue = { "tooth": string; "surface": string; "material": string; "status": string };
|
|
21
|
+
|
|
22
|
+
/** <j-surface key>: tooth (string), surface (string), material (string), status (string), each an attribute. */
|
|
23
|
+
export class JSurface extends HTMLElement {
|
|
24
|
+
static observedAttributes = ["tooth","surface","material","status","may"];
|
|
25
|
+
#data?: JSurfaceData;
|
|
26
|
+
/** Its id in the document. */
|
|
27
|
+
get key() { return Number(this.getAttribute("key")); }
|
|
28
|
+
get path() { return `/surfaces/${this.key}`; }
|
|
29
|
+
/** Its fields, read from its attributes once and again when one changes: frozen, since they're shared. */
|
|
30
|
+
get data(): JSurfaceData {
|
|
31
|
+
return (this.#data ??= Object.freeze({ "tooth": this.getAttribute("tooth") ?? "", "surface": this.getAttribute("surface") ?? "", "material": this.getAttribute("material") ?? "", "status": this.getAttribute("status") ?? "" }) as JSurfaceData);
|
|
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 (status, material): one write for all of them. */
|
|
37
|
+
replace(fields: Partial<Pick<JSurfaceData, "status" | "material">>, 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 it from the document. */
|
|
41
|
+
removeItem(why?: string) { return send(this, [{ op: "remove", path: this.path }], why); }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** <j-surfaces>: the document's surfaces, each a <j-surface> inside it. */
|
|
45
|
+
export class JSurfaces extends HTMLElement {
|
|
46
|
+
connectedCallback() { hold(this, docOf(this), "surfaces", "j-surface", {"tooth":"string","surface":"string","material":"string","status":"string"}); }
|
|
47
|
+
disconnectedCallback() { letGo(this); }
|
|
48
|
+
/** Its surfaces, as the document has them. */
|
|
49
|
+
get items() { return [...this.children].filter((el): el is JSurface => el.localName === "j-surface"); }
|
|
50
|
+
/** Add surfaces: one write for all of them. */
|
|
51
|
+
add(...values: JSurfaceValue[]) { return send(this, values.map((value) => ({ op: "add", path: "/surfaces/-", value }))); }
|
|
52
|
+
}
|
|
53
|
+
customElements.define("j-surfaces", JSurfaces);
|
|
54
|
+
|
|
55
|
+
/** A condition's fields, as the stories give them. */
|
|
56
|
+
export type JConditionData = { "tooth": string; "state": string; "status": string };
|
|
57
|
+
/** An add of a condition, as it's sent: its fields as the stories write them. */
|
|
58
|
+
export type JConditionValue = { "tooth": string; "state": string; "status": string };
|
|
59
|
+
|
|
60
|
+
/** <j-condition key>: tooth (string), state (string), status (string), each an attribute. */
|
|
61
|
+
export class JCondition extends HTMLElement {
|
|
62
|
+
static observedAttributes = ["tooth","state","status","may"];
|
|
63
|
+
#data?: JConditionData;
|
|
64
|
+
/** Its id in the document. */
|
|
65
|
+
get key() { return Number(this.getAttribute("key")); }
|
|
66
|
+
get path() { return `/conditions/${this.key}`; }
|
|
67
|
+
/** Its fields, read from its attributes once and again when one changes: frozen, since they're shared. */
|
|
68
|
+
get data(): JConditionData {
|
|
69
|
+
return (this.#data ??= Object.freeze({ "tooth": this.getAttribute("tooth") ?? "", "state": this.getAttribute("state") ?? "", "status": this.getAttribute("status") ?? "" }) as JConditionData);
|
|
70
|
+
}
|
|
71
|
+
/** How a view shows it, drawn again whenever an attribute changes (what its person may do, its may, too). */
|
|
72
|
+
draw?(): void;
|
|
73
|
+
attributeChangedCallback() { this.#data = undefined; this.draw?.(); }
|
|
74
|
+
/** Replace some of its fields (status): one write for all of them. */
|
|
75
|
+
replace(fields: Partial<Pick<JConditionData, "status">>, why?: string) {
|
|
76
|
+
return send(this, Object.entries(fields).filter(([, value]) => value !== undefined).map(([field, value]) => ({ op: "replace", path: `${this.path}/${field.replace(".", "/")}`, value })), why);
|
|
77
|
+
}
|
|
78
|
+
/** Remove it from the document. */
|
|
79
|
+
removeItem(why?: string) { return send(this, [{ op: "remove", path: this.path }], why); }
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** <j-conditions>: the document's conditions, each a <j-condition> inside it. */
|
|
83
|
+
export class JConditions extends HTMLElement {
|
|
84
|
+
connectedCallback() { hold(this, docOf(this), "conditions", "j-condition", {"tooth":"string","state":"string","status":"string"}); }
|
|
85
|
+
disconnectedCallback() { letGo(this); }
|
|
86
|
+
/** Its conditions, as the document has them. */
|
|
87
|
+
get items() { return [...this.children].filter((el): el is JCondition => el.localName === "j-condition"); }
|
|
88
|
+
/** Add conditions: one write for all of them. */
|
|
89
|
+
add(...values: JConditionValue[]) { return send(this, values.map((value) => ({ op: "add", path: "/conditions/-", value }))); }
|
|
90
|
+
}
|
|
91
|
+
customElements.define("j-conditions", JConditions);
|
|
92
|
+
|
|
93
|
+
/** An op on chart the stories allow, in any of its collections. */
|
|
94
|
+
export type ChartOp =
|
|
95
|
+
| { op: "add"; path: "/surfaces/-"; value: JSurfaceValue }
|
|
96
|
+
| { op: "replace"; path: `/surfaces/${number}/status`; value: string }
|
|
97
|
+
| { op: "replace"; path: `/surfaces/${number}/material`; value: string }
|
|
98
|
+
| { op: "remove"; path: `/surfaces/${number}` }
|
|
99
|
+
| { op: "add"; path: "/conditions/-"; value: JConditionValue }
|
|
100
|
+
| { op: "replace"; path: `/conditions/${number}/status`; value: string }
|
|
101
|
+
| { op: "remove"; path: `/conditions/${number}` };
|
|
102
|
+
|
|
103
|
+
/** One write to chart across its collections (a move with its legs): sent from an element of it, checked
|
|
104
|
+
* whole by its rules, and made whole or not at all. */
|
|
105
|
+
export function write(from: Element, ops: ChartOp[], why?: string) { return send(from, ops, why); }
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Written by src/compile.ts from examples/chart/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
|
+
"surfaces": "json_patch('{}', json_object('id', t.id,\n 'tooth', t.\"tooth\",\n 'surface', t.\"surface\",\n 'material', t.\"material\",\n 'status', t.\"status\"))",
|
|
7
|
+
"conditions": "json_patch('{}', json_object('id', t.id,\n 'tooth', t.\"tooth\",\n 'state', t.\"state\",\n 'status', t.\"status\"))"
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/** chart, 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
|
+
'surfaces', json((SELECT json_group_array(json_patch('{}', json_object('id', t.id,
|
|
13
|
+
'tooth', t."tooth",
|
|
14
|
+
'surface', t."surface",
|
|
15
|
+
'material', t."material",
|
|
16
|
+
'status', t."status")) ORDER BY t.id)
|
|
17
|
+
FROM "surfaces" t)),
|
|
18
|
+
'conditions', json((SELECT json_group_array(json_patch('{}', json_object('id', t.id,
|
|
19
|
+
'tooth', t."tooth",
|
|
20
|
+
'state', t."state",
|
|
21
|
+
'status', t."status")) ORDER BY t.id)
|
|
22
|
+
FROM "conditions" 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
|
+
|
|
28
|
+
/** Its items, its query and its triggers, as Postgres says them. */
|
|
29
|
+
export const postgres = {
|
|
30
|
+
"items": {
|
|
31
|
+
"surfaces": "json_strip_nulls(json_build_object('id', t.id,\n 'tooth', t.\"tooth\",\n 'surface', t.\"surface\",\n 'material', t.\"material\",\n 'status', t.\"status\"))",
|
|
32
|
+
"conditions": "json_strip_nulls(json_build_object('id', t.id,\n 'tooth', t.\"tooth\",\n 'state', t.\"state\",\n 'status', t.\"status\"))"
|
|
33
|
+
},
|
|
34
|
+
"query": "SELECT json_build_object('version', COALESCE((SELECT version FROM documents WHERE name = $doc), 0),\n 'surfaces', (SELECT COALESCE(json_agg(json_strip_nulls(json_build_object('id', t.id,\n 'tooth', t.\"tooth\",\n 'surface', t.\"surface\",\n 'material', t.\"material\",\n 'status', t.\"status\")) ORDER BY t.id), '[]')\n FROM \"surfaces\" t),\n 'conditions', (SELECT COALESCE(json_agg(json_strip_nulls(json_build_object('id', t.id,\n 'tooth', t.\"tooth\",\n 'state', t.\"state\",\n 'status', t.\"status\")) ORDER BY t.id), '[]')\n FROM \"conditions\" t)) AS doc",
|
|
35
|
+
"triggers": []
|
|
36
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Written by src/compile.ts from examples/chart/stories.jsonl: change the stories, not this.
|
|
2
|
+
|
|
3
|
+
// Each collection of chart 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-surfaces-rows><j-surfaces></j-surfaces></j-surfaces-rows>
|
|
6
|
+
// <j-conditions-rows><j-conditions></j-conditions></j-conditions-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 { JSurface, JCondition } from "./elements.ts";
|
|
16
|
+
|
|
17
|
+
const surfaces: Spec = {"doc":"chart","name":"surfaces","place":"j-surfaces","tag":"j-surface","one":"surface","title":"tooth","fields":[{"name":"tooth","type":"string","needed":true},{"name":"surface","type":"string","needed":true},{"name":"material","type":"string","needed":true},{"name":"status","type":"string","needed":true}]};
|
|
18
|
+
const conditions: Spec = {"doc":"chart","name":"conditions","place":"j-conditions","tag":"j-condition","one":"condition","title":"tooth","fields":[{"name":"tooth","type":"string","needed":true},{"name":"state","type":"string","needed":true},{"name":"status","type":"string","needed":true}]};
|
|
19
|
+
|
|
20
|
+
/** Each collection as joined's kit (joined/kit) is given it, by name: use(specs). */
|
|
21
|
+
export const specs = { "surfaces": surfaces, "conditions": conditions };
|
|
22
|
+
|
|
23
|
+
/** <j-surfaces-rows>: chart's surfaces as rows, each named by its tooth. */
|
|
24
|
+
export class JSurfacesRows extends rows(surfaces, { "j-surface": JSurface }) {}
|
|
25
|
+
|
|
26
|
+
/** <j-conditions-rows>: chart's conditions as rows, each named by its tooth. */
|
|
27
|
+
export class JConditionsRows extends rows(conditions, { "j-condition": JCondition }) {}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Written by src/compile.ts from examples/chart/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 = "chart";
|
|
8
|
+
export const collections = {
|
|
9
|
+
"surfaces": {
|
|
10
|
+
"place": "j-surfaces",
|
|
11
|
+
"tag": "j-surface",
|
|
12
|
+
"fields": {
|
|
13
|
+
"tooth": "string",
|
|
14
|
+
"surface": "string",
|
|
15
|
+
"material": "string",
|
|
16
|
+
"status": "string"
|
|
17
|
+
},
|
|
18
|
+
"needs": [
|
|
19
|
+
"tooth",
|
|
20
|
+
"surface",
|
|
21
|
+
"material",
|
|
22
|
+
"status"
|
|
23
|
+
],
|
|
24
|
+
"links": {},
|
|
25
|
+
"pops": {}
|
|
26
|
+
},
|
|
27
|
+
"conditions": {
|
|
28
|
+
"place": "j-conditions",
|
|
29
|
+
"tag": "j-condition",
|
|
30
|
+
"fields": {
|
|
31
|
+
"tooth": "string",
|
|
32
|
+
"state": "string",
|
|
33
|
+
"status": "string"
|
|
34
|
+
},
|
|
35
|
+
"needs": [
|
|
36
|
+
"tooth",
|
|
37
|
+
"state",
|
|
38
|
+
"status"
|
|
39
|
+
],
|
|
40
|
+
"links": {},
|
|
41
|
+
"pops": {}
|
|
42
|
+
}
|
|
43
|
+
} as const;
|
|
44
|
+
/** Whether every story is anonymous, none told as a member: where every app's is, the project has no members. */
|
|
45
|
+
export const anonymous = true;
|
|
46
|
+
/** What kind of document chart is, by the flows it uses: static, changed only with a release (a page reads it, and
|
|
47
|
+
* never subscribes); read-only, live, but no page writes it (derived); or shared, its members' to write. */
|
|
48
|
+
export const type = "shared";
|
|
49
|
+
/** The parts of chart a page may hold alone, by its query's parameters (its definitions' window): null, none. */
|
|
50
|
+
export const window = null;
|
|
51
|
+
/** The document as one statement over its tables (generated/queries.ts). */
|
|
52
|
+
export { query, postgres, items, triggers } from "./queries.ts";
|
|
53
|
+
|
|
54
|
+
/** Why the document, as a write leaves it, breaks what its definitions hold (unique, noOverlap): each item the
|
|
55
|
+
* write touched, against the rest of its collection. Null if it holds. */
|
|
56
|
+
export function holds(d: Record<string, unknown>, touched: Record<string, number[]>): string | null {
|
|
57
|
+
for (const id of touched["surfaces"] ?? []) {
|
|
58
|
+
const all = (d["surfaces"] ?? []) as any[];
|
|
59
|
+
const a = all.find((i) => i.id === id);
|
|
60
|
+
if (!a) continue;
|
|
61
|
+
{
|
|
62
|
+
const b = all.find((i) => i.id !== a.id && a["tooth"] !== undefined && i["tooth"] === a["tooth"] && a["surface"] !== undefined && i["surface"] === a["surface"]);
|
|
63
|
+
if (b) return "surfaces " + b.id + " has that tooth and surface already";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
for (const id of touched["conditions"] ?? []) {
|
|
67
|
+
const all = (d["conditions"] ?? []) as any[];
|
|
68
|
+
const a = all.find((i) => i.id === id);
|
|
69
|
+
if (!a) continue;
|
|
70
|
+
{
|
|
71
|
+
const b = all.find((i) => i.id !== a.id && a["tooth"] !== undefined && i["tooth"] === a["tooth"] && a["state"] !== undefined && i["state"] === a["state"]);
|
|
72
|
+
if (b) return "conditions " + b.id + " has that tooth and state already";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** chart is one document. */
|
|
79
|
+
export const kind = null;
|
|
80
|
+
|
|
81
|
+
/** Each grant, read off the stories: the roles whose stories do it (a member: anyone). An op no story
|
|
82
|
+
* does isn't one. */
|
|
83
|
+
export const grants: Record<string, string[]> = {
|
|
84
|
+
"add conditions": [
|
|
85
|
+
"member"
|
|
86
|
+
],
|
|
87
|
+
"add surfaces": [
|
|
88
|
+
"member"
|
|
89
|
+
],
|
|
90
|
+
"remove conditions": [
|
|
91
|
+
"member"
|
|
92
|
+
],
|
|
93
|
+
"remove surfaces": [
|
|
94
|
+
"member"
|
|
95
|
+
],
|
|
96
|
+
"replace conditions.status": [
|
|
97
|
+
"member"
|
|
98
|
+
],
|
|
99
|
+
"replace surfaces.material": [
|
|
100
|
+
"member"
|
|
101
|
+
],
|
|
102
|
+
"replace surfaces.status": [
|
|
103
|
+
"member"
|
|
104
|
+
]
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/** Who someone is to chart: a member, as it names no roles. */
|
|
108
|
+
export const rolesOf = (_m: number, _read: (doc: string) => any, _doc: string, _at?: any): string[] => [];
|
|
109
|
+
|
|
110
|
+
/** What someone sees: all of chart, as it has no owns. */
|
|
111
|
+
export const sees = null;
|