@blueshed/joined 0.2.1 → 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 +270 -55
- 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 +176 -38
- 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 +11 -7
- 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 +211 -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 +219 -73
- 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/src/board.ts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// <j-board for="plans" by="done"> (joined/kit): a collection in lanes by a field, a board. A lane for each value the
|
|
2
|
+
// field has (yes and no; a step each, of a field the stories move; each item a link may be to, and none; or those
|
|
3
|
+
// `lanes` names, in its order: "idea,booked,done"), each item a card in its lane, the way into it. A card dragged to another lane moves it there, where its
|
|
4
|
+
// `may` lets it (a field the stories move step by step, only to the steps it offers); let go where it may not go, it
|
|
5
|
+
// goes back. Each lane's foot adds one in it, where this person may add (the sheet offered that lane's value, still
|
|
6
|
+
// asked). On a phone the lanes are side by side to swipe between, each nearly the screen's width.
|
|
7
|
+
|
|
8
|
+
import { icon } from "./icons.ts";
|
|
9
|
+
import { keep, type Row } from "./keep.ts";
|
|
10
|
+
import { el, Reading } from "./reading.ts";
|
|
11
|
+
import type { Item } from "./rows.ts";
|
|
12
|
+
import { dated, dayOf } from "./time.ts";
|
|
13
|
+
import STYLE from "./board.css" with { type: "text" };
|
|
14
|
+
|
|
15
|
+
const SHEET = new CSSStyleSheet();
|
|
16
|
+
SHEET.replaceSync(STYLE);
|
|
17
|
+
type Lane = { value: unknown; words: string; its: Item[] };
|
|
18
|
+
type Drawn = {
|
|
19
|
+
el: HTMLElement;
|
|
20
|
+
count: HTMLElement;
|
|
21
|
+
list: HTMLElement;
|
|
22
|
+
add: HTMLButtonElement;
|
|
23
|
+
kept: Map<string, { shows: string; el: HTMLElement }>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export class JBoard extends Reading {
|
|
27
|
+
static override sheets = [SHEET];
|
|
28
|
+
#row = el("div", { className: "lanes" });
|
|
29
|
+
#lanes = new Map<string, Drawn>();
|
|
30
|
+
|
|
31
|
+
get #by() {
|
|
32
|
+
return this.field("by");
|
|
33
|
+
}
|
|
34
|
+
protected made() {
|
|
35
|
+
this.root.append(this.#row);
|
|
36
|
+
}
|
|
37
|
+
/** Its lanes, each a value of its field, in order; and what isn't any of them, last. */
|
|
38
|
+
#values(): Lane[] {
|
|
39
|
+
const f = this.#by!,
|
|
40
|
+
words = (v: string) => (v[0]!.toUpperCase() + v.slice(1)).replaceAll("-", " "),
|
|
41
|
+
named = this.getAttribute("lanes");
|
|
42
|
+
if (named)
|
|
43
|
+
return named
|
|
44
|
+
.split(",")
|
|
45
|
+
.map((v) => v.trim())
|
|
46
|
+
.filter(Boolean)
|
|
47
|
+
.map((v) => ({ value: v, words: words(v), its: [] }));
|
|
48
|
+
// a field the stories move: a lane each step, in their order
|
|
49
|
+
if (f.how === "moves" && f.steps?.length) return f.steps.map((v) => ({ value: v, words: words(v), its: [] }));
|
|
50
|
+
if (f.type === "boolean") {
|
|
51
|
+
const label = this.label(f.name);
|
|
52
|
+
return [
|
|
53
|
+
{ value: false, words: `Not ${label.toLowerCase()}`, its: [] },
|
|
54
|
+
{ value: true, words: label, its: [] },
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
if (f.to)
|
|
58
|
+
return [
|
|
59
|
+
...[...document.querySelectorAll(f.to.tag)].map((t) => ({
|
|
60
|
+
value: Number(t.getAttribute("key")),
|
|
61
|
+
words: t.getAttribute(f.to!.title ?? "name") ?? `#${t.getAttribute("key")}`,
|
|
62
|
+
its: [],
|
|
63
|
+
})),
|
|
64
|
+
...(f.needed ? [] : [{ value: undefined, words: `No ${this.label(f.name).toLowerCase()}`, its: [] }]),
|
|
65
|
+
];
|
|
66
|
+
const seen = [
|
|
67
|
+
...new Set(
|
|
68
|
+
this.items()
|
|
69
|
+
.map((it) => it.data[f.name])
|
|
70
|
+
.filter((v) => v !== undefined && v !== null && v !== ""),
|
|
71
|
+
),
|
|
72
|
+
];
|
|
73
|
+
return seen.map((v) => ({ value: v, words: words(String(v)), its: [] }));
|
|
74
|
+
}
|
|
75
|
+
protected draw() {
|
|
76
|
+
const f = this.#by;
|
|
77
|
+
if (!f) return;
|
|
78
|
+
const lanes = this.#values(),
|
|
79
|
+
key = (v: unknown) => JSON.stringify(v ?? null),
|
|
80
|
+
of = (it: Item) => (f.type === "boolean" ? it.data[f.name] === true : it.data[f.name]);
|
|
81
|
+
for (const it of this.items()) (lanes.find((l) => key(l.value) === key(of(it))) ?? lanes.at(-1))?.its.push(it);
|
|
82
|
+
const wanted = new Set(lanes.map((l) => key(l.value)));
|
|
83
|
+
for (const [k, d] of this.#lanes) if (!wanted.has(k)) (d.el.remove(), this.#lanes.delete(k));
|
|
84
|
+
const when = this.spec!.fields.find((f) => f.type === "date-time"),
|
|
85
|
+
adds = this.adds;
|
|
86
|
+
lanes.forEach((lane, i) => {
|
|
87
|
+
const k = key(lane.value);
|
|
88
|
+
let d = this.#lanes.get(k);
|
|
89
|
+
if (!d) {
|
|
90
|
+
const count = el("span", { className: "count" }),
|
|
91
|
+
list = el("ol"),
|
|
92
|
+
add = el("button", { type: "button", className: "act small adding" }, icon("add"), "Add");
|
|
93
|
+
add.addEventListener("click", () => this.add(lane.value === undefined ? {} : { [f.name]: lane.value }));
|
|
94
|
+
const section = el(
|
|
95
|
+
"section",
|
|
96
|
+
{ className: "lane", ariaLabel: lane.words },
|
|
97
|
+
el("h3", {}, lane.words, count),
|
|
98
|
+
list,
|
|
99
|
+
add,
|
|
100
|
+
);
|
|
101
|
+
section.dataset.lane = k;
|
|
102
|
+
d = { el: section, count, list, add, kept: new Map() };
|
|
103
|
+
this.#lanes.set(k, d);
|
|
104
|
+
}
|
|
105
|
+
if (this.#row.children[i] !== d.el) this.#row.insertBefore(d.el, this.#row.children[i] ?? null);
|
|
106
|
+
d.count.textContent = String(lane.its.length);
|
|
107
|
+
d.add.hidden = !adds;
|
|
108
|
+
d.add.ariaLabel = `Add to ${lane.words}`;
|
|
109
|
+
keep(
|
|
110
|
+
d.list,
|
|
111
|
+
d.kept,
|
|
112
|
+
lane.its.map((it): Row => ({
|
|
113
|
+
key: String(it.key),
|
|
114
|
+
shows: JSON.stringify([this.named(it), when && it.data[when.name], this.opened(it), it.getAttribute("may")]),
|
|
115
|
+
make: () => el("li", {}, this.#card(it, f.name, when?.name, lanes)),
|
|
116
|
+
})),
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/** Whether an item may go to a lane: a field the stories move, only to a step it offers; another, where it may. */
|
|
121
|
+
#goes(it: Item, field: string, value: unknown) {
|
|
122
|
+
// into none: a field emptied, which a drag doesn't do
|
|
123
|
+
if (value === undefined) return false;
|
|
124
|
+
const may = (it.getAttribute("may") ?? "").split(" ");
|
|
125
|
+
return this.#by!.how === "moves"
|
|
126
|
+
? may.includes(`replace:${field}>${encodeURIComponent(String(value))}`)
|
|
127
|
+
: may.includes(`replace:${field}`);
|
|
128
|
+
}
|
|
129
|
+
/** A card: its words and when it is; dragged to another lane, moved there where it may go. */
|
|
130
|
+
#card(it: Item, field: string, when: string | undefined, lanes: Lane[]) {
|
|
131
|
+
const w = when ? it.data[when] : undefined,
|
|
132
|
+
card = el(
|
|
133
|
+
"button",
|
|
134
|
+
{ type: "button", className: "item card" },
|
|
135
|
+
el("span", { className: "what" }, this.named(it)),
|
|
136
|
+
...(typeof w === "string"
|
|
137
|
+
? [
|
|
138
|
+
el(
|
|
139
|
+
"span",
|
|
140
|
+
{ className: "at" },
|
|
141
|
+
`${dated(dayOf(w), { weekday: "short", day: "numeric", month: "short" })}, ${w.slice(11, 16)}`,
|
|
142
|
+
),
|
|
143
|
+
]
|
|
144
|
+
: []),
|
|
145
|
+
);
|
|
146
|
+
const laneAt = (e: PointerEvent) =>
|
|
147
|
+
[...this.#lanes.values()].find((d) => {
|
|
148
|
+
const r = d.el.getBoundingClientRect();
|
|
149
|
+
return e.clientX >= r.left && e.clientX < r.right && e.clientY >= r.top && e.clientY < r.bottom;
|
|
150
|
+
});
|
|
151
|
+
const valueOf = (d: Drawn) => lanes.find((l) => JSON.stringify(l.value ?? null) === d.el.dataset.lane)?.value;
|
|
152
|
+
const moves = lanes.some((l) => this.#goes(it, field, l.value));
|
|
153
|
+
this.press(
|
|
154
|
+
card,
|
|
155
|
+
it,
|
|
156
|
+
moves
|
|
157
|
+
? (dx, dy, done, e) => {
|
|
158
|
+
card.style.translate = done ? "" : `${dx}px ${dy}px`;
|
|
159
|
+
const over = e ? laneAt(e) : undefined;
|
|
160
|
+
for (const d of this.#lanes.values())
|
|
161
|
+
d.el.toggleAttribute(
|
|
162
|
+
"over",
|
|
163
|
+
!done && d === over && this.#goes(it, field, valueOf(d)) && !d.list.contains(card),
|
|
164
|
+
);
|
|
165
|
+
if (!done || !over || over.list.contains(card)) return;
|
|
166
|
+
const to = valueOf(over);
|
|
167
|
+
if (this.#goes(it, field, to)) void this.change(it, { [field]: to });
|
|
168
|
+
}
|
|
169
|
+
: undefined,
|
|
170
|
+
);
|
|
171
|
+
return card;
|
|
172
|
+
}
|
|
173
|
+
}
|
package/src/cli.ts
CHANGED
|
@@ -25,7 +25,7 @@ export async function run([command, arg, ...rest]: string[], dir = arg ? resolve
|
|
|
25
25
|
if (command === "init") return init(process.cwd());
|
|
26
26
|
if (command === "upgrade") return upgrade(arg, process.cwd());
|
|
27
27
|
if (command === "compile") return [await writeAll(dir)];
|
|
28
|
-
if (command === "start") return startUp(await start({ dir }));
|
|
28
|
+
if (command === "start") return await startUp(await start({ dir }));
|
|
29
29
|
if (command === "link") return [await linkFor(arg, {})];
|
|
30
30
|
if (command === "page") return paged(arg, rest);
|
|
31
31
|
throw new Error(USAGE);
|
|
@@ -49,4 +49,17 @@ async function paged(what: string | undefined, [doc, ops, why]: string[]) {
|
|
|
49
49
|
return [];
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
/** A command run and said, and how it ended: what it refuses (the stories' mistake, a name it doesn't know) in its
|
|
53
|
+
* words alone, as whoever reads it (a person, an agent) is to act on them; a mistake of joined's own keeps its trace. */
|
|
54
|
+
export async function main(argv: string[], say = console.log, refuse = console.error) {
|
|
55
|
+
try {
|
|
56
|
+
for (const line of await run(argv)) say(line);
|
|
57
|
+
return 0;
|
|
58
|
+
} catch (e) {
|
|
59
|
+
if (!(e instanceof Error) || e.constructor !== Error) throw e;
|
|
60
|
+
refuse(e.message);
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (import.meta.main) process.exitCode = await main(Bun.argv.slice(2));
|