@blueshed/joined 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/joined/SKILL.md +9 -1
- package/.claude/skills/joined/reference.md +267 -53
- package/.claude/skills/joined-door/SKILL.md +57 -0
- package/README.md +19 -50
- package/docs/design.md +76 -10
- package/docs/introduction.md +18 -18
- package/docs/light-and-shadow.svg +1 -1
- 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 +2 -1
- package/examples/cafe/books.html +2 -2
- package/examples/cafe/cafe.css +9 -16
- 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.rows.ts +22 -0
- package/examples/cafe/generated/staff.rules.ts +6 -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 +12 -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.ts +1 -1
- package/examples/cafe/look.ts +30 -0
- package/examples/cafe/menu.html +10 -26
- package/examples/cafe/menu.ts +8 -80
- package/examples/cafe/order.html +6 -6
- package/examples/cafe/order.ts +5 -1
- package/examples/cafe/routes.ts +0 -1
- package/examples/cafe/stories.jsonl +3 -1
- package/examples/cafe/supplies.html +34 -34
- package/examples/cafe/supplies.ts +14 -11
- package/examples/cafe/till.ts +5 -1
- package/examples/chart/arches.ts +148 -0
- package/examples/chart/chart.css +6 -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/generated/rows.ts +22 -0
- package/examples/desk/generated/rules.ts +34 -1
- package/examples/desk/index.html +9 -2
- package/examples/desk/routes.ts +0 -2
- package/examples/desk/stories.jsonl +3 -2
- package/examples/desk/thumbs.ts +2 -2
- 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 +4 -5
- package/examples/notes/generated/elements.ts +112 -0
- package/examples/notes/generated/queries.ts +36 -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 +21 -0
- package/examples/people/generated/rows.ts +22 -0
- package/examples/people/generated/rules.ts +11 -1
- package/examples/people/links.ts +2 -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 +4 -2
- 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 +12 -12
- 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/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/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 +7 -5
- package/package.json +8 -2
- package/src/awesome.ts +103 -0
- package/src/board.css +75 -0
- package/src/board.ts +173 -0
- package/src/cli.ts +15 -2
- package/src/compile.ts +569 -35
- package/src/definitions.ts +53 -15
- package/src/draft.ts +38 -23
- package/src/drawer.ts +222 -0
- package/src/engine.ts +240 -166
- package/src/fields.ts +268 -0
- package/src/files.ts +6 -4
- package/src/ground.ts +110 -0
- package/src/icon-names.ts +15 -2
- package/src/kit.ts +51 -0
- package/src/link.ts +3 -3
- package/src/map.css +133 -0
- package/src/map.ts +200 -0
- package/src/mcp.ts +106 -22
- 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 +65 -39
- package/src/members/keys.ts +93 -77
- package/src/members/panel.css +23 -17
- package/src/members/panel.ts +49 -35
- package/src/migrate.ts +120 -104
- package/src/month.css +125 -0
- package/src/month.ts +179 -0
- package/src/page.css +8 -0
- package/src/page.ts +7 -4
- package/src/parts.css +462 -170
- package/src/parts.ts +209 -26
- package/src/plane.css +56 -0
- package/src/plane.ts +151 -0
- package/src/postgres-server.ts +60 -0
- package/src/reading.css +77 -0
- package/src/reading.ts +238 -0
- package/src/rows.css +308 -0
- package/src/rows.ts +780 -0
- package/src/search.css +80 -0
- package/src/search.ts +130 -0
- package/src/server.ts +205 -114
- package/src/settings.ts +9 -4
- package/src/sheet.ts +114 -0
- package/src/skill.ts +40 -0
- package/src/slots.css +94 -0
- package/src/slots.ts +213 -0
- package/src/specs.ts +38 -0
- package/src/starter.ts +5 -2
- package/src/store.ts +184 -143
- package/src/stories.ts +43 -11
- package/src/surface.ts +159 -0
- package/src/timeline.css +111 -0
- package/src/timeline.ts +226 -0
- package/src/toast.ts +21 -48
- package/src/together.ts +0 -7
- package/src/tokens.css +78 -1
- package/src/tokens.json +249 -0
- package/src/tool.ts +211 -0
- package/src/upkeep.ts +18 -20
- package/src/views.css +44 -0
- package/src/views.ts +94 -0
- package/src/week.css +151 -0
- package/src/week.ts +250 -0
- package/src/write.ts +202 -69
- package/starter/CLAUDE.md +3 -3
- package/starter/bunfig +4 -0
- package/starter/prettierignore +4 -0
- package/starter/tests/hello.test.ts +2 -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/menu.ts
CHANGED
|
@@ -1,84 +1,12 @@
|
|
|
1
|
-
// The menu's page
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// change an item, as its may says: no one else is offered the drawer.
|
|
1
|
+
// The menu's page, composed of joined's kit alone (joined/kit, the skill's §17): its items as rows (joined/rows), a
|
|
2
|
+
// search among them, and an item's sheet, each bound to the menu by the collection's name. What the page says is in
|
|
3
|
+
// its markup: the price is money, in pence kept and in pounds typed and read; what's left is said, never changed
|
|
4
|
+
// there. Only the manager may change an item, as its may says: to anyone else a row is its words alone.
|
|
6
5
|
|
|
7
6
|
import "joined/panel";
|
|
8
7
|
import "joined/toast";
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import * as menu from "./generated/menu.rules.ts";
|
|
13
|
-
import { JItem } from "./generated/menu.elements.ts";
|
|
14
|
-
import { money } from "./views.ts";
|
|
8
|
+
import "joined/kit";
|
|
9
|
+
import { define } from "joined/rows";
|
|
10
|
+
import { JItemsRows } from "./generated/menu.rows.ts";
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
form = drawer.querySelector("form")!,
|
|
18
|
-
draft = new Draft(form, form.querySelector(".note")!);
|
|
19
|
-
/** The item in the drawer, if one is. */
|
|
20
|
-
let open: Item | null = null;
|
|
21
|
-
/** An item as the drawer holds it: its name, and its price in pounds, as it's typed. */
|
|
22
|
-
const fields = (it: Item) => ({ name: it.data.name, price: (it.data.price / 100).toFixed(2) });
|
|
23
|
-
/** Whether what's typed differs from the item: Save and Never mind offered then, and said. */
|
|
24
|
-
const shown = () => draft.show(Object.keys(draft.edits()).length ? "changed" : "kept");
|
|
25
|
-
|
|
26
|
-
/** An item's row: its name, price and what's left, and a way into the drawer where its person may change it. */
|
|
27
|
-
class Item extends JItem {
|
|
28
|
-
#words = document.createElement("span");
|
|
29
|
-
#edit = iconButton("edit", "", () => show(this));
|
|
30
|
-
connectedCallback() {
|
|
31
|
-
if (!this.childElementCount) this.append(this.#words, this.#edit);
|
|
32
|
-
this.draw();
|
|
33
|
-
hash.again(); // named in the address before it was on the page: opened now it is
|
|
34
|
-
}
|
|
35
|
-
draw() {
|
|
36
|
-
this.#words.textContent = `${this.data.name} ${money(this.data.price)} (${this.data.stock} left)`;
|
|
37
|
-
this.#edit.ariaLabel = `Change ${this.data.name}`;
|
|
38
|
-
this.#edit.hidden = !this.matches('[may~="replace:name"], [may~="replace:price"]');
|
|
39
|
-
// the one in the drawer, changed elsewhere: what isn't being typed in follows it
|
|
40
|
-
if (this === open) (draft.fill(fields(this)), shown());
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** The drawer, with an item in it, or closed; marked in the hash as it's opened or closed. */
|
|
45
|
-
function show(it: Item | null, mark = true) {
|
|
46
|
-
open = it;
|
|
47
|
-
drawer.hidden = !it;
|
|
48
|
-
if (it) {
|
|
49
|
-
drawer.querySelector("h2")!.textContent = it.data.name;
|
|
50
|
-
draft.refuse("");
|
|
51
|
-
draft.fill(fields(it), true);
|
|
52
|
-
shown();
|
|
53
|
-
}
|
|
54
|
-
if (mark) hash.mark(it?.key ?? null);
|
|
55
|
-
}
|
|
56
|
-
const items = document.getElementsByTagName(menu.collections.items.tag) as HTMLCollectionOf<Item>;
|
|
57
|
-
const hash = inHash(
|
|
58
|
-
"item",
|
|
59
|
-
() => [...items],
|
|
60
|
-
() => open,
|
|
61
|
-
(it) => show(it, false),
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
form.addEventListener("input", shown);
|
|
65
|
-
form.addEventListener("submit", async (e) => {
|
|
66
|
-
e.preventDefault();
|
|
67
|
-
if (!open) return;
|
|
68
|
-
const { name, price } = draft.edits() as { name?: string; price?: string };
|
|
69
|
-
const why = await open.replace({
|
|
70
|
-
...(name !== undefined ? { name: name.trim() } : {}),
|
|
71
|
-
...(price !== undefined ? { price: Math.round(Number(price) * 100) } : {}),
|
|
72
|
-
});
|
|
73
|
-
draft.refuse(why ?? "");
|
|
74
|
-
// kept: what the drawer holds is the item as it is now
|
|
75
|
-
if (!why && open) (draft.fill(fields(open), true), shown());
|
|
76
|
-
});
|
|
77
|
-
draft.inside(
|
|
78
|
-
drawer,
|
|
79
|
-
() => show(null),
|
|
80
|
-
() => open && (draft.refuse(""), draft.fill(fields(open), true), shown()),
|
|
81
|
-
);
|
|
82
|
-
iconify();
|
|
83
|
-
// defined last, once all it draws with is made
|
|
84
|
-
customElements.define(menu.collections.items.tag, Item);
|
|
12
|
+
define(JItemsRows);
|
package/examples/cafe/order.html
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<h1>Your order</h1>
|
|
15
15
|
</header>
|
|
16
16
|
<main class="cafe yours">
|
|
17
|
-
<
|
|
17
|
+
<wa-card class="card" aria-label="Your order">
|
|
18
18
|
<ol class="steps">
|
|
19
19
|
<li data-step="placed">Placed</li>
|
|
20
20
|
<li data-step="being made">Being made</li>
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
</ol>
|
|
24
24
|
<j-orders doc="order?code="></j-orders>
|
|
25
25
|
<j-lines doc="order?code="></j-lines>
|
|
26
|
-
</
|
|
26
|
+
</wa-card>
|
|
27
27
|
</main>
|
|
28
|
-
<dialog class="ask">
|
|
29
|
-
<h2></h2>
|
|
30
|
-
<footer>
|
|
28
|
+
<wa-dialog class="ask" light-dismiss>
|
|
29
|
+
<h2 slot="label"></h2>
|
|
30
|
+
<footer slot="footer">
|
|
31
31
|
<button type="button" class="act" name="keep">Never mind</button>
|
|
32
32
|
<button type="button" class="act danger" name="sure">Cancel it</button>
|
|
33
33
|
</footer>
|
|
34
|
-
</dialog>
|
|
34
|
+
</wa-dialog>
|
|
35
35
|
<script type="module" src="./order.ts"></script>
|
|
36
36
|
</body>
|
|
37
37
|
</html>
|
package/examples/cafe/order.ts
CHANGED
|
@@ -23,7 +23,11 @@ const SAYS: Record<string, string> = {
|
|
|
23
23
|
const Order = orderView(
|
|
24
24
|
JOrder,
|
|
25
25
|
[{ words: "Cancel my order", from: "placed", to: "cancelled", ask: "Cancel your order?" }],
|
|
26
|
-
askFirst(
|
|
26
|
+
askFirst(
|
|
27
|
+
document.querySelector("wa-dialog.ask")!,
|
|
28
|
+
"Cancel it",
|
|
29
|
+
"The cafe sees it at once, and it can't be taken back.",
|
|
30
|
+
),
|
|
27
31
|
{ late: false }, // a customer is never told it's late: that's the staff's to know
|
|
28
32
|
);
|
|
29
33
|
/** Where the order is, and what the cafe says of it: the order this page holds, as it is now. */
|
package/examples/cafe/routes.ts
CHANGED
|
@@ -20,7 +20,6 @@ import * as suppliesDoc from "./generated/supplies.rules.ts";
|
|
|
20
20
|
import * as booksDoc from "./generated/books.rules.ts";
|
|
21
21
|
|
|
22
22
|
export const documents = [staffDoc, menuDoc, tillDoc, kitchenDoc, orderDoc, suppliesDoc, booksDoc];
|
|
23
|
-
export { trust } from "./trust.ts";
|
|
24
23
|
export const routes = {
|
|
25
24
|
"/cafe": front,
|
|
26
25
|
"/cafe/till": till,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{"cast":{"wai":"nora","cook":"dev","manager":"peter","buyer":"peter","roaster":"nick"}}
|
|
2
|
-
{"links":{"item":{"to":"items","one":true},"order":{"to":"orders","one":true},"buyer":{"to":"members","one":true},"supplier":{"to":"members","one":true}}}
|
|
2
|
+
{"links":{"item":{"to":"items","one":true},"order":{"to":"orders","one":true,"part":true},"buyer":{"to":"members","one":true},"supplier":{"to":"members","one":true}}}
|
|
3
3
|
{"roles":{"manager":"staff/posts[role=manager]@members","till":"staff/posts[role=till]@members","kitchen":"staff/posts[role=kitchen]@members","buyer":"@buyer","supplier":"@supplier"}}
|
|
4
4
|
{"owns":{"supplies":"@buyer | @supplier"}}
|
|
5
5
|
{"fills":{"orders":{"status":"placed","placed":"now","code":"random","total":0}}}
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
{"takes":{"lines":{"qty":"item.stock","while":"order.status!=cancelled","refused":"The kitchen has {stock} of {name}: not enough to take {qty}."}}}
|
|
13
13
|
{"gives":{"supplies":{"qty":"item.stock","while":"delivered","refused":"The kitchen has {stock} of {name}: not enough to take {qty}."}}}
|
|
14
14
|
{"documents":{"books":{"entries":{"from":"supplies","when":"delivered","sides":{"buyer":"bought","supplier":"sold"},"fields":["title","buyer","supplier"],"total":{"sum":"qty","times":"price"}}}}}
|
|
15
|
+
{"addedWith":{"lines":{"order":"an order's lines are set when it's placed"}}}
|
|
16
|
+
{"frozen":{"supplies":{"by":"delivered","fields":["price","terms"],"refused":"a delivered supply keeps its price and terms"}}}
|
|
15
17
|
{"story":"Peter puts Dev in the kitchen too","as":"manager","does":{"doc":"staff","ops":[{"op":"add","path":"/posts/-","value":{"role":"kitchen","members":[4]}}]},"seen":["manager"]}
|
|
16
18
|
{"story":"Wai can't give anyone a role","as":"wai","cannot":{"doc":"staff","ops":[{"op":"add","path":"/posts/-","value":{"role":"till","members":[4]}}]},"refused":"you may not add at /posts/-"}
|
|
17
19
|
{"story":"Peter puts muffins on the menu","as":"manager","does":{"doc":"menu","ops":[{"op":"add","path":"/items/-","value":{"name":"Muffin","price":300,"stock":12}}]},"seen":["manager","wai"]}
|
|
@@ -28,50 +28,50 @@
|
|
|
28
28
|
</nav>
|
|
29
29
|
</header>
|
|
30
30
|
<main class="cafe supplies">
|
|
31
|
-
<
|
|
31
|
+
<wa-card class="card" aria-label="Order a supply">
|
|
32
32
|
<h2>Order a supply</h2>
|
|
33
33
|
<form class="add buy">
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
<
|
|
34
|
+
<wa-input
|
|
35
|
+
name="title"
|
|
36
|
+
label="What it's for"
|
|
37
|
+
placeholder="Croissants, Monday"
|
|
38
|
+
required
|
|
39
|
+
autocomplete="off"
|
|
40
|
+
></wa-input>
|
|
41
|
+
<wa-select name="item" label="Of"></wa-select>
|
|
42
|
+
<wa-number-input name="qty" label="How many" min="1" value="10"></wa-number-input>
|
|
43
|
+
<wa-number-input
|
|
44
|
+
name="price"
|
|
45
|
+
label="Price each, £"
|
|
46
|
+
min="0"
|
|
47
|
+
step="0.01"
|
|
48
|
+
value="1.00"
|
|
49
|
+
inputmode="decimal"
|
|
50
|
+
without-steppers
|
|
51
|
+
></wa-number-input>
|
|
52
|
+
<wa-select name="supplier" label="From"></wa-select>
|
|
43
53
|
<button class="act ink" data-icon="add">Order</button>
|
|
44
54
|
<p class="said" role="status"></p>
|
|
45
55
|
</form>
|
|
46
56
|
<j-items doc="menu" hidden></j-items>
|
|
47
|
-
</
|
|
48
|
-
<
|
|
57
|
+
</wa-card>
|
|
58
|
+
<wa-card class="card" aria-label="Supplies">
|
|
49
59
|
<h2>Supplies</h2>
|
|
50
60
|
<j-supplies doc="supplies"></j-supplies>
|
|
51
|
-
</
|
|
61
|
+
</wa-card>
|
|
52
62
|
</main>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
class="icon-only"
|
|
60
|
-
name="close"
|
|
61
|
-
aria-label="Close"
|
|
62
|
-
title="Close"
|
|
63
|
-
data-icon="close"
|
|
64
|
-
></button>
|
|
65
|
-
</header>
|
|
66
|
-
<label>Price each, £<input name="price" required inputmode="decimal" pattern="\d+(\.\d{1,2})?" /></label>
|
|
67
|
-
<label>Days to pay<input name="days" required type="number" min="0" step="1" /></label>
|
|
68
|
-
<p class="note" role="status"></p>
|
|
69
|
-
<footer>
|
|
70
|
-
<button type="button" class="act" name="never">Never mind</button>
|
|
71
|
-
<button class="act ink" name="go" data-icon="check">Save</button>
|
|
72
|
-
</footer>
|
|
63
|
+
<!-- a supply's terms: the drawer (joined/surface) is made of these -->
|
|
64
|
+
<template class="terms">
|
|
65
|
+
<form class="terms" id="terms">
|
|
66
|
+
<wa-input name="price" label="Price each, £" required inputmode="decimal" pattern="\d+(\.\d{1,2})?"></wa-input>
|
|
67
|
+
<wa-number-input name="days" label="Days to pay" required min="0" step="1"></wa-number-input>
|
|
68
|
+
<wa-callout class="note" role="status" size="small" hidden></wa-callout>
|
|
73
69
|
</form>
|
|
74
|
-
|
|
70
|
+
<footer>
|
|
71
|
+
<button type="button" class="act" name="never" form="terms">Never mind</button>
|
|
72
|
+
<button class="act ink" name="go" form="terms" data-icon="check">Save</button>
|
|
73
|
+
</footer>
|
|
74
|
+
</template>
|
|
75
75
|
<script type="module" src="./supplies.ts"></script>
|
|
76
76
|
</body>
|
|
77
77
|
</html>
|
|
@@ -8,6 +8,7 @@ import "joined/toast";
|
|
|
8
8
|
import { Draft } from "joined/draft";
|
|
9
9
|
import { iconButton, iconify } from "joined/icons";
|
|
10
10
|
import { inHash, said } from "joined/parts";
|
|
11
|
+
import { Surface } from "joined/surface";
|
|
11
12
|
import * as menu from "./generated/menu.rules.ts";
|
|
12
13
|
import { JItem } from "./generated/menu.elements.ts";
|
|
13
14
|
import * as supplies from "./generated/supplies.rules.ts";
|
|
@@ -72,8 +73,9 @@ class Supply extends JSupply {
|
|
|
72
73
|
const cap = (s: string) => s[0]!.toUpperCase() + s.slice(1);
|
|
73
74
|
|
|
74
75
|
// the supplier's terms, in a drawer, as the menu's item is: held until Save, put back by Never mind
|
|
75
|
-
const
|
|
76
|
-
terms =
|
|
76
|
+
const made = document.querySelector<HTMLTemplateElement>("template.terms")!.content,
|
|
77
|
+
terms = made.querySelector("form")!,
|
|
78
|
+
drawer = new Surface("drawer", terms, made.querySelector("footer")!, () => show(null), { label: "A supply's terms" }),
|
|
77
79
|
draft = new Draft(terms, terms.querySelector(".note")!);
|
|
78
80
|
/** The supply in the drawer, if one is. */
|
|
79
81
|
let open: Supply | null = null;
|
|
@@ -84,9 +86,9 @@ const shown = () => draft.show(Object.keys(draft.edits()).length ? "changed" : "
|
|
|
84
86
|
/** The drawer, with a supply in it, or closed; marked in the hash as it's opened or closed. */
|
|
85
87
|
function show(s: Supply | null, mark = true) {
|
|
86
88
|
open = s;
|
|
87
|
-
drawer.
|
|
89
|
+
drawer.open = !!s;
|
|
88
90
|
if (s) {
|
|
89
|
-
drawer.
|
|
91
|
+
drawer.title.textContent = `Your terms: ${s.data.title}`;
|
|
90
92
|
draft.refuse("");
|
|
91
93
|
draft.fill(fields(s), true);
|
|
92
94
|
shown();
|
|
@@ -106,11 +108,8 @@ terms.addEventListener("submit", async (e) => {
|
|
|
106
108
|
// kept: what the drawer holds is the supply as it is now
|
|
107
109
|
if (!why && open) (draft.fill(fields(open), true), shown());
|
|
108
110
|
});
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
() => show(null),
|
|
112
|
-
() => open && (draft.refuse(""), draft.fill(fields(open), true), shown()),
|
|
113
|
-
);
|
|
111
|
+
document.body.append(...drawer.els);
|
|
112
|
+
draft.never(() => open && (draft.refuse(""), draft.fill(fields(open), true), shown()));
|
|
114
113
|
iconify();
|
|
115
114
|
|
|
116
115
|
const form = document.querySelector<HTMLFormElement>("form.buy")!;
|
|
@@ -119,10 +118,14 @@ const fill = () => {
|
|
|
119
118
|
const options = (sel: string, list: { value: number; text: string }[]) => {
|
|
120
119
|
const s = form.elements.namedItem(sel) as HTMLSelectElement;
|
|
121
120
|
const was = s.value;
|
|
122
|
-
s.replaceChildren(
|
|
121
|
+
s.replaceChildren(
|
|
122
|
+
...list.map((o) =>
|
|
123
|
+
Object.assign(document.createElement("wa-option"), { value: String(o.value), textContent: o.text }),
|
|
124
|
+
),
|
|
125
|
+
);
|
|
123
126
|
if (was) s.value = was;
|
|
124
127
|
// what was chosen gone from the list (you, before the page knew you): the first chosen, never none
|
|
125
|
-
if (s.
|
|
128
|
+
if (!list.some((o) => String(o.value) === s.value) && list[0]) s.value = String(list[0].value);
|
|
126
129
|
};
|
|
127
130
|
options(
|
|
128
131
|
"item",
|
package/examples/cafe/till.ts
CHANGED
|
@@ -115,7 +115,11 @@ customElements.define(
|
|
|
115
115
|
{ words: "Cancel", from: "placed", to: "cancelled", ask: "Cancel this order?" },
|
|
116
116
|
{ words: "Hand over", from: "ready", to: "collected" },
|
|
117
117
|
],
|
|
118
|
-
askFirst(
|
|
118
|
+
askFirst(
|
|
119
|
+
document.querySelector("wa-dialog.ask")!,
|
|
120
|
+
"Cancel it",
|
|
121
|
+
"Everyone sees it cancelled at once, and it can't be taken back.",
|
|
122
|
+
),
|
|
119
123
|
{ link: true }, // the customer's own link, to give them
|
|
120
124
|
),
|
|
121
125
|
);
|
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
viewBox: "0 0 680 420",
|
|
88
|
+
role: "img",
|
|
89
|
+
"aria-label": "The teeth, seen from above",
|
|
90
|
+
});
|
|
91
|
+
svg.append(conditionStyle());
|
|
92
|
+
for (const row of ["U", "L"]) {
|
|
93
|
+
const cx = 340,
|
|
94
|
+
cy = row === "U" ? 190 : 222,
|
|
95
|
+
rx = 200,
|
|
96
|
+
ry = 140,
|
|
97
|
+
sg = row === "U" ? -1 : 1,
|
|
98
|
+
pt = (t: number) => [cx - rx * Math.cos(t), cy + sg * ry * Math.sin(t)] as const;
|
|
99
|
+
const N = 800,
|
|
100
|
+
ts: number[] = [],
|
|
101
|
+
ss = [0];
|
|
102
|
+
let prev = pt(0);
|
|
103
|
+
for (let j = 0; j <= N; j++) {
|
|
104
|
+
const t = (Math.PI * j) / N,
|
|
105
|
+
q = pt(t);
|
|
106
|
+
if (j > 0) ss.push(ss[j - 1]! + Math.hypot(q[0] - prev[0], q[1] - prev[1]));
|
|
107
|
+
ts.push(t);
|
|
108
|
+
prev = q;
|
|
109
|
+
}
|
|
110
|
+
const row16 = TEETH.filter((t) => t.row === row),
|
|
111
|
+
ws = row16.map((t) => DIM[t.n]![0]),
|
|
112
|
+
gap = 4,
|
|
113
|
+
k = (ss[N]! - 17 * gap) / ws.reduce((x, y) => x + y, 0);
|
|
114
|
+
let acc = gap;
|
|
115
|
+
row16.forEach((t, ix) => {
|
|
116
|
+
const w = ws[ix]! * k,
|
|
117
|
+
d = DIM[t.n]![1] * k,
|
|
118
|
+
at = acc + w / 2;
|
|
119
|
+
acc += w + gap;
|
|
120
|
+
let j = 0;
|
|
121
|
+
while (j < N && ss[j]! < at) j++;
|
|
122
|
+
const tt = ts[j]!,
|
|
123
|
+
[x, y] = pt(tt);
|
|
124
|
+
let nx = (x - cx) / (rx * rx),
|
|
125
|
+
ny = (y - cy) / (ry * ry);
|
|
126
|
+
const nl = Math.hypot(nx, ny);
|
|
127
|
+
((nx /= nl), (ny /= nl));
|
|
128
|
+
const phi = Math.atan2(-nx, ny),
|
|
129
|
+
dot = Math.cos(phi) * rx * Math.sin(tt) + Math.sin(phi) * sg * ry * Math.cos(tt);
|
|
130
|
+
svg.append(fromAbove(t, x, y, (phi * 180) / Math.PI, w, d, (t.i < 8 ? 1 : -1) * Math.sign(dot)));
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
for (const [words, x, y] of [
|
|
134
|
+
["Right", 24, 210],
|
|
135
|
+
["Left", 656, 210],
|
|
136
|
+
] as const) {
|
|
137
|
+
const label = s("text", {
|
|
138
|
+
x,
|
|
139
|
+
y,
|
|
140
|
+
"font-size": 13,
|
|
141
|
+
style: "fill: var(--muted)",
|
|
142
|
+
"text-anchor": x > 340 ? "end" : "start",
|
|
143
|
+
});
|
|
144
|
+
label.textContent = words;
|
|
145
|
+
svg.append(label);
|
|
146
|
+
}
|
|
147
|
+
return svg;
|
|
148
|
+
}
|
|
@@ -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
|
+
}
|