@biolibs/bionet-panels 0.2.0 → 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/README.md +12 -0
- package/dist/backup.d.ts +10 -0
- package/dist/backup.d.ts.map +1 -0
- package/dist/backup.js +50 -0
- package/dist/backup.js.map +1 -0
- package/dist/freezer.d.ts.map +1 -1
- package/dist/freezer.js +3 -2
- package/dist/freezer.js.map +1 -1
- package/dist/history.d.ts +1 -1
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +11 -0
- package/dist/history.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/people.d.ts.map +1 -1
- package/dist/people.js +2 -1
- package/dist/people.js.map +1 -1
- package/dist/places.d.ts +41 -0
- package/dist/places.d.ts.map +1 -0
- package/dist/places.js +96 -0
- package/dist/places.js.map +1 -0
- package/dist/window.d.ts +29 -6
- package/dist/window.d.ts.map +1 -1
- package/dist/window.js +18 -10
- package/dist/window.js.map +1 -1
- package/package.json +5 -4
- package/panels.css +7 -0
- package/src/backup.tsx +72 -0
- package/src/freezer.tsx +3 -1
- package/src/history.tsx +12 -1
- package/src/index.ts +2 -0
- package/src/people.tsx +2 -0
- package/src/places.tsx +170 -0
- package/src/window.tsx +32 -10
package/README.md
CHANGED
|
@@ -46,6 +46,18 @@ used on its own inside one:
|
|
|
46
46
|
|
|
47
47
|
Every colour comes from `@biolibs/bionet-theme`, and no rule reaches outside `.bionet`.
|
|
48
48
|
|
|
49
|
+
## Places, and a view of your own
|
|
50
|
+
|
|
51
|
+
`Places` shows the tree of places and adds to it; each tube in `Freezer` says where it is and can be
|
|
52
|
+
put somewhere, by place and by position (`C4`). `BackUpKey` and `RestoreKey` seal the device's key to
|
|
53
|
+
a file and take one up again.
|
|
54
|
+
|
|
55
|
+
`LabWindow` takes views of the host's own, shown as tabs after its own:
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
<LabWindow extra={[{ id: "scene", label: "Lab", view: <MyDrawingOfTheLab /> }]} />
|
|
59
|
+
```
|
|
60
|
+
|
|
49
61
|
## A lab's public page
|
|
50
62
|
|
|
51
63
|
What a lab shows the world, and what it can see of another lab. These take what was fetched and
|
package/dist/backup.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How to hand the person a file to keep. A host that cannot use the browser's own way supplies one.
|
|
3
|
+
* The default offers it as a download.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SaveContext: import("react").Context<(name: string, text: string) => Promise<void>>;
|
|
6
|
+
/** Seal this device's key under a passphrase and hand it over as a file. */
|
|
7
|
+
export declare function BackUpKey(): import("react").JSX.Element | null;
|
|
8
|
+
/** Take up a key from a backup, on a device that is not in a lab yet. */
|
|
9
|
+
export declare function RestoreKey(): import("react").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=backup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backup.d.ts","sourceRoot":"","sources":["../src/backup.tsx"],"names":[],"mappings":"AAOA;;;GAGG;AACH,eAAO,MAAM,WAAW,iCAAwB,MAAM,QAAQ,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAMpF,CAAC;AAEH,4EAA4E;AAC5E,wBAAgB,SAAS,uCA+BxB;AAED,yEAAyE;AACzE,wBAAgB,UAAU,gCAiBzB"}
|
package/dist/backup.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/** Keeping this device's key somewhere else, and taking one up again on a new device. */
|
|
4
|
+
import { createContext, useContext, useState } from "react";
|
|
5
|
+
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
6
|
+
import { Ask } from "./parts.js";
|
|
7
|
+
/**
|
|
8
|
+
* How to hand the person a file to keep. A host that cannot use the browser's own way supplies one.
|
|
9
|
+
* The default offers it as a download.
|
|
10
|
+
*/
|
|
11
|
+
export const SaveContext = createContext(async (name, text) => {
|
|
12
|
+
const link = document.createElement("a");
|
|
13
|
+
link.href = URL.createObjectURL(new Blob([text], { type: "application/json" }));
|
|
14
|
+
link.download = name;
|
|
15
|
+
link.click();
|
|
16
|
+
URL.revokeObjectURL(link.href);
|
|
17
|
+
});
|
|
18
|
+
/** Seal this device's key under a passphrase and hand it over as a file. */
|
|
19
|
+
export function BackUpKey() {
|
|
20
|
+
const state = useLab();
|
|
21
|
+
const act = useAct();
|
|
22
|
+
const save = useContext(SaveContext);
|
|
23
|
+
const [note, setNote] = useState(null);
|
|
24
|
+
if (state === null)
|
|
25
|
+
return null;
|
|
26
|
+
return (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "Back up this device's key" }), _jsx("p", { className: "dim small", children: "Everything you sign is signed by a key that exists only on this computer. If the computer is lost, so is the key, and a lab with nobody else in it is lost with it. This writes the key to a file, sealed under a passphrase. Keep the file somewhere that is not this computer, and the passphrase somewhere that is not the file. Nothing here remembers the passphrase." }), _jsxs(Ask, { className: "stack", onAsk: async (data) => {
|
|
27
|
+
setNote(null);
|
|
28
|
+
const [first, again] = [String(data.get("passphrase") ?? ""), String(data.get("again") ?? "")];
|
|
29
|
+
if (first !== again) {
|
|
30
|
+
setNote("Those two passphrases are not the same.");
|
|
31
|
+
return { ok: false };
|
|
32
|
+
}
|
|
33
|
+
const answer = await act("backUp", first);
|
|
34
|
+
if (!answer.ok)
|
|
35
|
+
return answer;
|
|
36
|
+
await save(`bionet-key-${state.device.fingerprint}.json`, String(answer.result));
|
|
37
|
+
setNote("Sealed and handed over. Open it only on a new device, before that device joins a lab.");
|
|
38
|
+
return answer;
|
|
39
|
+
}, children: [_jsxs("label", { children: ["Passphrase", _jsx("input", { name: "passphrase", type: "password", required: true, minLength: 12, autoComplete: "new-password" })] }), _jsxs("label", { children: ["And again", _jsx("input", { name: "again", type: "password", required: true, minLength: 12, autoComplete: "new-password" })] }), _jsx("button", { type: "submit", children: "Seal and save" })] }), note !== null && _jsx("p", { className: "small", role: "status", children: note })] }));
|
|
40
|
+
}
|
|
41
|
+
/** Take up a key from a backup, on a device that is not in a lab yet. */
|
|
42
|
+
export function RestoreKey() {
|
|
43
|
+
const act = useAct();
|
|
44
|
+
return (_jsxs("details", { className: "restore", children: [_jsx("summary", { children: "Replacing a lost device? Restore its key" }), _jsx("p", { className: "dim small", children: "Choose the backup file and give its passphrase. This device then signs as the lost one did. Do this before joining, and only if the old device is really gone: one key on two devices writes two histories the lab cannot tell apart." }), _jsxs(Ask, { className: "stack", onAsk: async (data) => {
|
|
45
|
+
const file = data.get("backup");
|
|
46
|
+
const backup = file instanceof File ? await file.text() : "";
|
|
47
|
+
return act("restore", { backup, passphrase: String(data.get("passphrase") ?? "") });
|
|
48
|
+
}, children: [_jsxs("label", { children: ["Backup file", _jsx("input", { name: "backup", type: "file", accept: "application/json,.json", required: true })] }), _jsxs("label", { children: ["Passphrase", _jsx("input", { name: "passphrase", type: "password", required: true, autoComplete: "off" })] }), _jsx("button", { type: "submit", className: "quiet", children: "Restore key" })] })] }));
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=backup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backup.js","sourceRoot":"","sources":["../src/backup.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,yFAAyF;AACzF,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAgD,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAC3G,MAAM,IAAI,GAAG,QAAQ,CAAC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EAAE,CAAC;oBAC7D,OAAO,GAAG,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;gBACtF,CAAC,aACC,2CAAkB,gBAAO,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,wBAAwB,EAAC,QAAQ,SAAG,IAAQ,EACtG,0CAAiB,gBAAO,IAAI,EAAC,YAAY,EAAC,IAAI,EAAC,UAAU,EAAC,QAAQ,QAAC,YAAY,EAAC,KAAK,GAAG,IAAQ,EAChG,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,OAAO,4BAAqB,IACxD,IACE,CACX,CAAC;AACJ,CAAC"}
|
package/dist/freezer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"freezer.d.ts","sourceRoot":"","sources":["../src/freezer.tsx"],"names":[],"mappings":"AAEA,wEAAwE;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"freezer.d.ts","sourceRoot":"","sources":["../src/freezer.tsx"],"names":[],"mappings":"AAEA,wEAAwE;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAO5D;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,MAAM,IAAI,CAAC,SAAS,EAAE,QAAQ,GAAG,MAAM,CAAC,KAAG,MAAsE,CAAC;AAE3I,oGAAoG;AACpG,wBAAgB,OAAO,uCAoBtB;AAED,8BAA8B;AAC9B,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,SAAS,EAAE,CAAA;CAAE,+BA4BhF;AAED,gEAAgE;AAChE,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,+BA6BpD"}
|
package/dist/freezer.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
4
4
|
import { Ask } from "./parts.js";
|
|
5
|
+
import { PutItem } from "./places.js";
|
|
5
6
|
const whole = (data, name) => Number(String(data.get(name) ?? "").trim());
|
|
6
7
|
/**
|
|
7
8
|
* How much of an item there is, with its unit.
|
|
@@ -22,11 +23,11 @@ export function Freezer() {
|
|
|
22
23
|
export function PartCard({ part, items }) {
|
|
23
24
|
const act = useAct();
|
|
24
25
|
const live = items.filter((item) => !item.retired);
|
|
25
|
-
return (_jsxs("section", { className: "card part", children: [_jsxs("div", { className: "parthead", children: [_jsxs("div", { children: [_jsx("h2", { children: part.name }), _jsxs("p", { className: "dim small", children: [part.length, " bp", part.circular ? " · circular" : "", " \u00B7 ", _jsxs("code", { children: [part.checksum.slice(0, 26), "\u2026"] })] })] }), _jsxs("label", { className: "check", title: "Whether other labs are told this part can be asked for", children: [_jsx("input", { type: "checkbox", checked: part.offered, onChange: (event) => void act("offer", { part: part.checksum, available: event.target.checked }) }), "On offer to other labs"] })] }), live.length === 0 ? _jsx("p", { className: "dim small", children: "No tubes of this." }) : (_jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Tube" }), _jsx("th", { children: "Amount" }), _jsx("th", { children: "Use or add" }), _jsx("th", { children: "Count" }), _jsx("th", {})] }) }), _jsx("tbody", { children: live.map((item) => _jsx(ItemRow, { item: item }, item.item)) })] })), _jsxs(Ask, { onAsk: (data) => act("addItem", { part: part.checksum, amount: whole(data, "amount"), unit: String(data.get("unit") ?? "") }), className: "row tight", children: [_jsx("input", { name: "amount", type: "number", min: 0, step: 1, placeholder: "Amount", required: true }), _jsx("input", { name: "unit", placeholder: "Unit, e.g. \u00B5L", maxLength: 20 }), _jsx("button", { type: "submit", className: "quiet", children: "Add a tube" })] })] }));
|
|
26
|
+
return (_jsxs("section", { className: "card part", children: [_jsxs("div", { className: "parthead", children: [_jsxs("div", { children: [_jsx("h2", { children: part.name }), _jsxs("p", { className: "dim small", children: [part.length, " bp", part.circular ? " · circular" : "", " \u00B7 ", _jsxs("code", { children: [part.checksum.slice(0, 26), "\u2026"] })] })] }), _jsxs("label", { className: "check", title: "Whether other labs are told this part can be asked for", children: [_jsx("input", { type: "checkbox", checked: part.offered, onChange: (event) => void act("offer", { part: part.checksum, available: event.target.checked }) }), "On offer to other labs"] })] }), live.length === 0 ? _jsx("p", { className: "dim small", children: "No tubes of this." }) : (_jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Tube" }), _jsx("th", { children: "Amount" }), _jsx("th", { children: "Where" }), _jsx("th", { children: "Use or add" }), _jsx("th", { children: "Count" }), _jsx("th", {})] }) }), _jsx("tbody", { children: live.map((item) => _jsx(ItemRow, { item: item }, item.item)) })] })), _jsxs(Ask, { onAsk: (data) => act("addItem", { part: part.checksum, amount: whole(data, "amount"), unit: String(data.get("unit") ?? "") }), className: "row tight", children: [_jsx("input", { name: "amount", type: "number", min: 0, step: 1, placeholder: "Amount", required: true }), _jsx("input", { name: "unit", placeholder: "Unit, e.g. \u00B5L", maxLength: 20 }), _jsx("button", { type: "submit", className: "quiet", children: "Add a tube" })] })] }));
|
|
26
27
|
}
|
|
27
28
|
/** One tube: how much there is, and the ways to change that. */
|
|
28
29
|
export function ItemRow({ item }) {
|
|
29
30
|
const act = useAct();
|
|
30
|
-
return (_jsxs("tr", { className: item.needsRecount ? "flagged" : undefined, children: [_jsx("td", { children: _jsxs("code", { children: [item.item.slice(0, 10), "\u2026"] }) }), _jsxs("td", { children: [_jsx("strong", { children: amountOf(item) }), item.needsRecount && _jsx("span", { className: "badge", title: "The log has lost track of this tube: it went below zero, or two people counted it at once.", children: "needs a count" })] }), _jsx("td", { children: _jsxs("div", { className: "row tight", children: [_jsx("button", { type: "button", className: "quiet", onClick: () => void act("adjust", { item: item.item, by: -1 }), children: "\u22121" }), _jsx("button", { type: "button", className: "quiet", onClick: () => void act("adjust", { item: item.item, by: 1 }), children: "+1" }), _jsxs(Ask, { onAsk: (data) => act("adjust", { item: item.item, by: whole(data, "by") }), className: "row tight", children: [_jsx("input", { name: "by", type: "number", step: 1, placeholder: "\u00B1", required: true, className: "num", "aria-label": "Change by" }), _jsx("button", { type: "submit", className: "quiet", children: "Apply" })] })] }) }), _jsx("td", { children: _jsxs(Ask, { onAsk: (data) => act("recount", { item: item.item, amount: whole(data, "amount") }), className: "row tight", children: [_jsx("input", { name: "amount", type: "number", min: 0, step: 1, placeholder: "There is", required: true, className: "num", "aria-label": "Amount there is" }), _jsx("button", { type: "submit", className: "quiet", children: "Set" })] }) }), _jsx("td", { children: _jsx("button", { type: "button", className: "plain", onClick: () => void act("retire", { item: item.item }), children: "retire" }) })] }));
|
|
31
|
+
return (_jsxs("tr", { className: item.needsRecount ? "flagged" : undefined, children: [_jsx("td", { children: _jsxs("code", { children: [item.item.slice(0, 10), "\u2026"] }) }), _jsxs("td", { children: [_jsx("strong", { children: amountOf(item) }), item.needsRecount && _jsx("span", { className: "badge", title: "The log has lost track of this tube: it went below zero, or two people counted it at once.", children: "needs a count" })] }), _jsx("td", { children: _jsx(PutItem, { item: item }) }), _jsx("td", { children: _jsxs("div", { className: "row tight", children: [_jsx("button", { type: "button", className: "quiet", onClick: () => void act("adjust", { item: item.item, by: -1 }), children: "\u22121" }), _jsx("button", { type: "button", className: "quiet", onClick: () => void act("adjust", { item: item.item, by: 1 }), children: "+1" }), _jsxs(Ask, { onAsk: (data) => act("adjust", { item: item.item, by: whole(data, "by") }), className: "row tight", children: [_jsx("input", { name: "by", type: "number", step: 1, placeholder: "\u00B1", required: true, className: "num", "aria-label": "Change by" }), _jsx("button", { type: "submit", className: "quiet", children: "Apply" })] })] }) }), _jsx("td", { children: _jsxs(Ask, { onAsk: (data) => act("recount", { item: item.item, amount: whole(data, "amount") }), className: "row tight", children: [_jsx("input", { name: "amount", type: "number", min: 0, step: 1, placeholder: "There is", required: true, className: "num", "aria-label": "Amount there is" }), _jsx("button", { type: "submit", className: "quiet", children: "Set" })] }) }), _jsx("td", { children: _jsx("button", { type: "button", className: "plain", onClick: () => void act("retire", { item: item.item }), children: "retire" }) })] }));
|
|
31
32
|
}
|
|
32
33
|
//# sourceMappingURL=freezer.js.map
|
package/dist/freezer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"freezer.js","sourceRoot":"","sources":["../src/freezer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAIb,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"freezer.js","sourceRoot":"","sources":["../src/freezer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAIb,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,KAAK,GAAG,CAAC,IAAc,EAAE,IAAY,EAAU,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAEpG;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAwC,EAAU,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC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,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,EAAC,WAAW,aAC7G,gBAAO,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAC,QAAQ,EAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,WAAW,EAAC,UAAU,EAAC,QAAQ,QAAC,SAAS,EAAC,KAAK,gBAAY,iBAAiB,GAAG,EACnI,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,OAAO,oBAAa,IAChD,GACH,EACL,uBAAI,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,OAAO,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,uBAAiB,GAAK,IACrH,CACN,CAAC;AACJ,CAAC"}
|
package/dist/history.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { EntryView, LabView } from "@biolibs/bionet-client";
|
|
|
6
6
|
* @param lab - The lab, to name the parts, tubes and people it refers to.
|
|
7
7
|
* @returns A phrase that follows the name of whoever made it, like `used 2 µL of a tube of f1`.
|
|
8
8
|
*/
|
|
9
|
-
export declare function describeEntry(entry: Pick<EntryView, "op">, lab: Pick<LabView, "parts" | "items" | "roster">): string;
|
|
9
|
+
export declare function describeEntry(entry: Pick<EntryView, "op">, lab: Pick<LabView, "parts" | "items" | "roster"> & Partial<Pick<LabView, "places">>): string;
|
|
10
10
|
/** Every change, newest first, with what became of each. Draws nothing until the lab has arrived. */
|
|
11
11
|
export declare function History({ first }: {
|
|
12
12
|
first?: number;
|
package/dist/history.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../src/history.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../src/history.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAIjE;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,GAAG,MAAM,CAkCvJ;AAED,qGAAqG;AACrG,wBAAgB,OAAO,CAAC,EAAE,KAAU,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,sCA4BzD"}
|
package/dist/history.js
CHANGED
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
/** The history: every signed change, and what became of it. */
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
import { useLab } from "@biolibs/bionet-react";
|
|
6
|
+
import { slotName } from "@biolibs/bionet-space";
|
|
6
7
|
/**
|
|
7
8
|
* What one change was, in words.
|
|
8
9
|
*
|
|
@@ -19,6 +20,7 @@ export function describeEntry(entry, lab) {
|
|
|
19
20
|
};
|
|
20
21
|
const unit = (id) => lab.items.find((one) => one.item === id)?.unit ?? "";
|
|
21
22
|
const who = (key) => lab.roster.find((one) => one.key === key)?.person ?? "a device";
|
|
23
|
+
const place = (id) => lab.places?.find((one) => one.place === id)?.name ?? "a place";
|
|
22
24
|
const tidy = (words) => words.replace(/\s+/g, " ").trim();
|
|
23
25
|
switch (op.type) {
|
|
24
26
|
case "roster.found": return `founded ${String(op["name"])}`;
|
|
@@ -31,6 +33,15 @@ export function describeEntry(entry, lab) {
|
|
|
31
33
|
case "item.adjust": return tidy(`${Number(op["by"]) < 0 ? "used" : "added"} ${Math.abs(Number(op["by"]))} ${unit(op["item"])} ${Number(op["by"]) < 0 ? "of" : "to"} ${tube(op["item"])}`);
|
|
32
34
|
case "item.recount": return tidy(`counted ${String(op["amount"])} ${unit(op["item"])} in ${tube(op["item"])}`);
|
|
33
35
|
case "item.retire": return `retired ${tube(op["item"])}`;
|
|
36
|
+
case "place.add": return `added the ${String(op["kind"])} ${String(op["name"])}${op["parent"] === null ? "" : ` in ${place(op["parent"])}`}`;
|
|
37
|
+
case "place.move": return op["parent"] === null ? `took ${place(op["place"])} out of where it was` : `moved ${place(op["place"])} into ${place(op["parent"])}`;
|
|
38
|
+
case "place.stand": return op["standing"] === null ? `cleared where ${place(op["place"])} stands` : `said where ${place(op["place"])} stands`;
|
|
39
|
+
case "place.retire": return `retired ${place(op["place"])}`;
|
|
40
|
+
case "item.put": {
|
|
41
|
+
const slot = op["slot"];
|
|
42
|
+
return op["place"] === null ? `took ${tube(op["item"])} out of where it was`
|
|
43
|
+
: `put ${tube(op["item"])} in ${place(op["place"])}${slot === null ? "" : `, ${slotName(slot)}`}`;
|
|
44
|
+
}
|
|
34
45
|
case "field.set": return `set ${String(op["field"])} to ${String(op["value"])}`;
|
|
35
46
|
default: return `did something this version does not know (${op.type})`;
|
|
36
47
|
}
|
package/dist/history.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.js","sourceRoot":"","sources":["../src/history.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,+DAA+D;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../src/history.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,+DAA+D;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AA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IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,GAAM,EACjI,uBAAK,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,IAAI,SAAS,GAAM,EAClG,uBAAK,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,GAAM,EACpC,uBAAK,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,eAAM,SAAS,EAAC,OAAO,EAAC,KAAK,EAAE,KAAK,CAAC,MAAM,IAAI,EAAE,YAAG,KAAK,CAAC,MAAM,GAAQ,GAAM,KAJ1G,KAAK,CAAC,EAAE,CAKZ,CACN,CAAC,GACI,IACF,EACP,CAAC,GAAG,IAAI,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,kBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,OAAO,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,0BAAY,MAAM,CAAC,MAAM,IAAU,IACvI,CACX,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/people.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"people.d.ts","sourceRoot":"","sources":["../src/people.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"people.d.ts","sourceRoot":"","sources":["../src/people.tsx"],"names":[],"mappings":"AAOA,qGAAqG;AACrG,wBAAgB,MAAM,uCA6CrB"}
|
package/dist/people.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
/** The people: who is in the lab, and letting somebody in. */
|
|
4
4
|
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
5
|
+
import { BackUpKey } from "./backup.js";
|
|
5
6
|
import { Ask, Copy } from "./parts.js";
|
|
6
7
|
/** The roster, and for a keeper the way to add somebody. Draws nothing until the lab has arrived. */
|
|
7
8
|
export function People() {
|
|
@@ -10,6 +11,6 @@ export function People() {
|
|
|
10
11
|
const lab = state?.lab;
|
|
11
12
|
if (state === null || lab === null || lab === undefined)
|
|
12
13
|
return null;
|
|
13
|
-
return (_jsxs(_Fragment, { children: [_jsxs("section", { className: "card", children: [_jsx("h2", { children: "Who is in the lab" }), _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Person" }), _jsx("th", { children: "Role" }), _jsx("th", { children: "Device" }), _jsx("th", {})] }) }), _jsx("tbody", { children: lab.roster.map((one) => (_jsxs("tr", { className: one.removed === null ? undefined : "gone", children: [_jsxs("td", { children: [one.person, one.you && _jsx("span", { className: "badge calm", children: "this device" })] }), _jsx("td", { children: one.removed !== null ? "removed" : one.founder ? "keeper · founder" : one.role }), _jsx("td", { children: _jsx("code", { children: one.fingerprint }) }), _jsx("td", { children: one.removed !== null && _jsxs("span", { className: "dim small", children: ["log kept up to entry ", one.removed.cutoff + 1] }) })] }, one.key))) })] }), _jsx("p", { className: "dim small", children: "A device is known by its key. One person with two computers appears twice, once for each." })] }), lab.keeper ? (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "Add somebody" }), _jsx("p", { className: "dim small", children: "Ask them for their device's key, add it here, and send them the invitation. Their app fills in once this change has reached the lab's peer." }), _jsxs(Ask, { onAsk: (data) => act("addMember", { key: String(data.get("key") ?? ""), person: String(data.get("person") ?? ""), role: String(data.get("role") ?? "member") }), className: "stack", children: [_jsxs("label", { children: ["Their device's key", _jsx("input", { name: "key", placeholder: "43 letters and digits", required: true, spellCheck: false })] }), _jsxs("label", { children: ["Their name", _jsx("input", { name: "person", required: true, maxLength: 200 })] }), _jsxs("label", { children: ["As", _jsxs("select", { name: "role", children: [_jsx("option", { value: "member", children: "a member, who can change the freezer" }), _jsx("option", { value: "keeper", children: "a keeper, who can also change who is in the lab" })] })] }), _jsx("button", { type: "submit", children: "Add to the lab" })] }), state.peer.invite !== null ? (_jsxs("div", { className: "keybox", children: [_jsxs("div", { children: [_jsx("span", { className: "label", children: "Invitation to send them" }), _jsx(Copy, { words: state.peer.invite, label: "Copy invitation" })] }), _jsx("code", { className: "wrap", children: state.peer.invite })] })) : _jsx("p", { className: "dim small", children: "Set the lab's web peer under Sharing to have an invitation to send." })] })) : _jsx("p", { className: "dim small", children: "Only a keeper can change who is in the lab." })] }));
|
|
14
|
+
return (_jsxs(_Fragment, { children: [_jsxs("section", { className: "card", children: [_jsx("h2", { children: "Who is in the lab" }), _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Person" }), _jsx("th", { children: "Role" }), _jsx("th", { children: "Device" }), _jsx("th", {})] }) }), _jsx("tbody", { children: lab.roster.map((one) => (_jsxs("tr", { className: one.removed === null ? undefined : "gone", children: [_jsxs("td", { children: [one.person, one.you && _jsx("span", { className: "badge calm", children: "this device" })] }), _jsx("td", { children: one.removed !== null ? "removed" : one.founder ? "keeper · founder" : one.role }), _jsx("td", { children: _jsx("code", { children: one.fingerprint }) }), _jsx("td", { children: one.removed !== null && _jsxs("span", { className: "dim small", children: ["log kept up to entry ", one.removed.cutoff + 1] }) })] }, one.key))) })] }), _jsx("p", { className: "dim small", children: "A device is known by its key. One person with two computers appears twice, once for each." })] }), lab.keeper ? (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "Add somebody" }), _jsx("p", { className: "dim small", children: "Ask them for their device's key, add it here, and send them the invitation. Their app fills in once this change has reached the lab's peer." }), _jsxs(Ask, { onAsk: (data) => act("addMember", { key: String(data.get("key") ?? ""), person: String(data.get("person") ?? ""), role: String(data.get("role") ?? "member") }), className: "stack", children: [_jsxs("label", { children: ["Their device's key", _jsx("input", { name: "key", placeholder: "43 letters and digits", required: true, spellCheck: false })] }), _jsxs("label", { children: ["Their name", _jsx("input", { name: "person", required: true, maxLength: 200 })] }), _jsxs("label", { children: ["As", _jsxs("select", { name: "role", children: [_jsx("option", { value: "member", children: "a member, who can change the freezer" }), _jsx("option", { value: "keeper", children: "a keeper, who can also change who is in the lab" })] })] }), _jsx("button", { type: "submit", children: "Add to the lab" })] }), state.peer.invite !== null ? (_jsxs("div", { className: "keybox", children: [_jsxs("div", { children: [_jsx("span", { className: "label", children: "Invitation to send them" }), _jsx(Copy, { words: state.peer.invite, label: "Copy invitation" })] }), _jsx("code", { className: "wrap", children: state.peer.invite })] })) : _jsx("p", { className: "dim small", children: "Set the lab's web peer under Sharing to have an invitation to send." })] })) : _jsx("p", { className: "dim small", children: "Only a keeper can change who is in the lab." }), _jsx(BackUpKey, {})] }));
|
|
14
15
|
}
|
|
15
16
|
//# sourceMappingURL=people.js.map
|
package/dist/people.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"people.js","sourceRoot":"","sources":["../src/people.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,8DAA8D;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,qGAAqG;AACrG,MAAM,UAAU,MAAM;IACpB,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC;IACvB,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,MAAM,GAAG,GAAG,KAAK,EAAE,GAAG,CAAC;IACvB,IAAI,KAAK,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,IAAI,CAA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C,CAAC,YAAG,SAAS,EAAC,WAAW,oFAAwE,IAC5F,CACX,CAAC,CAAC,CAAC,YAAG,SAAS,EAAC,WAAW,4DAAgD,EAC5E,KAAC,SAAS,KAAG,IACZ,CACJ,CAAC;AACJ,CAAC"}
|
package/dist/places.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** The places: where things are kept, which is inside which, and putting a tube somewhere. */
|
|
2
|
+
import type { ItemState, PlaceState } from "@biolibs/bionet";
|
|
3
|
+
/** The kinds of place offered when adding one. Any other kind a lab's log holds is shown as it is. */
|
|
4
|
+
export declare const PLACE_KINDS: readonly ["room", "freezer", "fridge", "shelf", "rack", "box", "bench", "instrument"];
|
|
5
|
+
/**
|
|
6
|
+
* Where a place is, said the way a person would: every place it is inside, then itself.
|
|
7
|
+
*
|
|
8
|
+
* @param places - The lab's places.
|
|
9
|
+
* @param id - The place.
|
|
10
|
+
* @returns Something like `Main lab › −80 › Shelf 2 › Box 7`, or `""` if the lab has no such place.
|
|
11
|
+
*/
|
|
12
|
+
export declare function placePath(places: readonly Pick<PlaceState, "place" | "name" | "parent">[], id: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Where an item is, in words.
|
|
15
|
+
*
|
|
16
|
+
* @param item - The item.
|
|
17
|
+
* @param places - The lab's places.
|
|
18
|
+
* @returns Something like `−80 › Box 7 · C4`, or `nowhere recorded`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function whereWords(item: Pick<ItemState, "where">, places: readonly Pick<PlaceState, "place" | "name" | "parent">[]): string;
|
|
21
|
+
/**
|
|
22
|
+
* The places in the order a tree is read: each one followed by what is inside it.
|
|
23
|
+
*
|
|
24
|
+
* @param places - The lab's places.
|
|
25
|
+
* @returns Each place still in use, with how deep it is.
|
|
26
|
+
*/
|
|
27
|
+
export declare function placeTree(places: readonly PlaceState[]): {
|
|
28
|
+
place: PlaceState;
|
|
29
|
+
depth: number;
|
|
30
|
+
}[];
|
|
31
|
+
/** Every place as a tree, what needs looking at, and a form to add a place. Draws nothing until the lab has arrived. */
|
|
32
|
+
export declare function Places(): import("react").JSX.Element | null;
|
|
33
|
+
/**
|
|
34
|
+
* Where one tube is, and a way to put it somewhere.
|
|
35
|
+
*
|
|
36
|
+
* @param props - `item` is the tube.
|
|
37
|
+
*/
|
|
38
|
+
export declare function PutItem({ item }: {
|
|
39
|
+
item: ItemState;
|
|
40
|
+
}): import("react").JSX.Element | null;
|
|
41
|
+
//# sourceMappingURL=places.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"places.d.ts","sourceRoot":"","sources":["../src/places.tsx"],"names":[],"mappings":"AAEA,8FAA8F;AAC9F,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAK7D,sGAAsG;AACtG,eAAO,MAAM,WAAW,uFAAwF,CAAC;AAEjH;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAW9G;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC,EAAE,GAAG,MAAM,CAInI;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,GAAG;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CAW/F;AAED,wHAAwH;AACxH,wBAAgB,MAAM,uCAwErB;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,sCA0BpD"}
|
package/dist/places.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
4
|
+
import { slotFrom, slotName } from "@biolibs/bionet-space";
|
|
5
|
+
import { Ask } from "./parts.js";
|
|
6
|
+
/** The kinds of place offered when adding one. Any other kind a lab's log holds is shown as it is. */
|
|
7
|
+
export const PLACE_KINDS = ["room", "freezer", "fridge", "shelf", "rack", "box", "bench", "instrument"];
|
|
8
|
+
/**
|
|
9
|
+
* Where a place is, said the way a person would: every place it is inside, then itself.
|
|
10
|
+
*
|
|
11
|
+
* @param places - The lab's places.
|
|
12
|
+
* @param id - The place.
|
|
13
|
+
* @returns Something like `Main lab › −80 › Shelf 2 › Box 7`, or `""` if the lab has no such place.
|
|
14
|
+
*/
|
|
15
|
+
export function placePath(places, id) {
|
|
16
|
+
const names = [];
|
|
17
|
+
const passed = new Set();
|
|
18
|
+
for (let at = id; at !== null && !passed.has(at);) {
|
|
19
|
+
const one = places.find((each) => each.place === at);
|
|
20
|
+
if (one === undefined)
|
|
21
|
+
break;
|
|
22
|
+
passed.add(at);
|
|
23
|
+
names.unshift(one.name);
|
|
24
|
+
at = one.parent;
|
|
25
|
+
}
|
|
26
|
+
return names.join(" › ");
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Where an item is, in words.
|
|
30
|
+
*
|
|
31
|
+
* @param item - The item.
|
|
32
|
+
* @param places - The lab's places.
|
|
33
|
+
* @returns Something like `−80 › Box 7 · C4`, or `nowhere recorded`.
|
|
34
|
+
*/
|
|
35
|
+
export function whereWords(item, places) {
|
|
36
|
+
if (item.where === null)
|
|
37
|
+
return "nowhere recorded";
|
|
38
|
+
const path = placePath(places, item.where.place) || "a place the lab no longer has";
|
|
39
|
+
return item.where.slot === null ? path : `${path} · ${slotName(item.where.slot)}`;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The places in the order a tree is read: each one followed by what is inside it.
|
|
43
|
+
*
|
|
44
|
+
* @param places - The lab's places.
|
|
45
|
+
* @returns Each place still in use, with how deep it is.
|
|
46
|
+
*/
|
|
47
|
+
export function placeTree(places) {
|
|
48
|
+
const out = [];
|
|
49
|
+
const walk = (parent, depth) => {
|
|
50
|
+
for (const place of places) {
|
|
51
|
+
if (place.parent !== parent || place.retired)
|
|
52
|
+
continue;
|
|
53
|
+
out.push({ place, depth });
|
|
54
|
+
walk(place.place, depth + 1);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
walk(null, 0);
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
/** Every place as a tree, what needs looking at, and a form to add a place. Draws nothing until the lab has arrived. */
|
|
61
|
+
export function Places() {
|
|
62
|
+
const lab = useLab()?.lab;
|
|
63
|
+
const act = useAct();
|
|
64
|
+
if (lab === null || lab === undefined)
|
|
65
|
+
return null;
|
|
66
|
+
const tree = placeTree(lab.places);
|
|
67
|
+
const live = lab.items.filter((item) => !item.retired);
|
|
68
|
+
const holding = (id) => live.filter((item) => item.where?.place === id).length;
|
|
69
|
+
return (_jsxs(_Fragment, { children: [lab.crowded.length > 0 && (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "Somebody needs to look" }), _jsx("p", { className: "dim small", children: "The lab has more than one tube recorded in each of these positions. Two people put them there without knowing of each other. Move whichever is not really there." }), _jsx("ul", { className: "plainlist", children: lab.crowded.map((one) => (_jsxs("li", { className: "flagged", children: [_jsxs("strong", { children: [placePath(lab.places, one.place), " \u00B7 ", slotName(one.slot)] }), " ", _jsxs("span", { className: "badge", children: [one.items.length, " tubes"] })] }, `${one.place} ${one.slot.row} ${one.slot.column}`))) })] })), _jsxs("section", { className: "card", children: [_jsx("h2", { children: "Where things are kept" }), tree.length === 0 ? _jsx("p", { className: "empty", children: "No places yet. Add the first below: a freezer, then the boxes in it." }) : (_jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Place" }), _jsx("th", { children: "Kind" }), _jsx("th", { children: "Positions" }), _jsx("th", { children: "Tubes here" }), _jsx("th", {})] }) }), _jsx("tbody", { children: tree.map(({ place, depth }) => (_jsxs("tr", { className: place.adrift ? "flagged" : undefined, children: [_jsxs("td", { style: { paddingLeft: `${0.6 + depth * 1.2}rem` }, children: [place.name, place.adrift && _jsx("span", { className: "badge", title: "Two people each moved this place and another into one another. Move one of them to settle it.", children: "needs moving" })] }), _jsx("td", { className: "dim", children: place.kind }), _jsx("td", { className: "dim", children: place.grid === null ? "" : `${place.grid.rows} × ${place.grid.columns}` }), _jsx("td", { children: holding(place.place) || "" }), _jsx("td", { children: _jsx("button", { type: "button", className: "plain", onClick: () => void act("retirePlace", { place: place.place }), children: "retire" }) })] }, place.place))) })] }))] }), _jsxs("section", { className: "card", children: [_jsx("h2", { children: "Add a place" }), _jsx("p", { className: "dim small", children: "A place is anything something is kept in or on. Only a box has positions; give it rows and columns and its tubes can be found by letter and number." }), _jsxs(Ask, { className: "stack", onAsk: (data) => {
|
|
70
|
+
const rows = Number(data.get("rows") ?? "");
|
|
71
|
+
const columns = Number(data.get("columns") ?? "");
|
|
72
|
+
const parent = String(data.get("parent") ?? "");
|
|
73
|
+
return act("addPlace", { kind: String(data.get("kind") ?? ""), name: String(data.get("name") ?? ""), parent: parent === "" ? null : parent,
|
|
74
|
+
grid: rows > 0 && columns > 0 ? { rows, columns } : null });
|
|
75
|
+
}, children: [_jsxs("label", { children: ["Kind", _jsx("select", { name: "kind", defaultValue: "box", children: PLACE_KINDS.map((kind) => _jsx("option", { value: kind, children: kind }, kind)) })] }), _jsxs("label", { children: ["Name", _jsx("input", { name: "name", placeholder: "Box 7", required: true, maxLength: 200 })] }), _jsxs("label", { children: ["Inside", _jsxs("select", { name: "parent", defaultValue: "", children: [_jsx("option", { value: "", children: "nothing" }), tree.map(({ place, depth }) => _jsxs("option", { value: place.place, children: [" ".repeat(depth), place.name] }, place.place))] })] }), _jsxs("div", { className: "row tight", children: [_jsx("input", { name: "rows", type: "number", min: 1, max: 100, step: 1, placeholder: "Rows", "aria-label": "Rows", className: "num" }), _jsx("input", { name: "columns", type: "number", min: 1, max: 100, step: 1, placeholder: "Columns", "aria-label": "Columns", className: "num" }), _jsx("span", { className: "dim small", children: "for a box" })] }), _jsx("button", { type: "submit", children: "Add place" })] })] })] }));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Where one tube is, and a way to put it somewhere.
|
|
79
|
+
*
|
|
80
|
+
* @param props - `item` is the tube.
|
|
81
|
+
*/
|
|
82
|
+
export function PutItem({ item }) {
|
|
83
|
+
const lab = useLab()?.lab;
|
|
84
|
+
const act = useAct();
|
|
85
|
+
if (lab === null || lab === undefined)
|
|
86
|
+
return null;
|
|
87
|
+
const tree = placeTree(lab.places);
|
|
88
|
+
return (_jsxs("div", { className: "where", children: [_jsx("span", { className: item.where === null ? "dim small" : "small", children: whereWords(item, lab.places) }), tree.length > 0 && (_jsxs(Ask, { className: "row tight", onAsk: async (data) => {
|
|
89
|
+
const place = String(data.get("place") ?? "");
|
|
90
|
+
const written = String(data.get("slot") ?? "").trim();
|
|
91
|
+
const slot = written === "" ? null : slotFrom(written);
|
|
92
|
+
// A position that is not written like one is sent as it is not: the lab refuses it and says why.
|
|
93
|
+
return act("putItem", { item: item.item, place: place === "" ? null : place, slot: written !== "" && slot === null ? { row: -1, column: -1 } : slot });
|
|
94
|
+
}, children: [_jsxs("select", { name: "place", defaultValue: item.where?.place ?? "", "aria-label": "Place", children: [_jsx("option", { value: "", children: "nowhere" }), tree.map(({ place, depth }) => _jsxs("option", { value: place.place, children: [" ".repeat(depth), place.name] }, place.place))] }), _jsx("input", { name: "slot", placeholder: "A1", "aria-label": "Position", className: "num", maxLength: 5 }), _jsx("button", { type: "submit", className: "quiet", children: "Put" })] }))] }));
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=places.js.map
|
|
@@ -0,0 +1 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
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* A whole lab application, in one component.
|
|
3
|
+
*
|
|
4
|
+
* It holds no state of its own about the lab. It is told the lab as it stands, every time it
|
|
5
|
+
* changes, and draws it; a button asks for one thing to be done and waits to be told how the lab
|
|
6
|
+
* changed. So what is on screen is always what the signed logs say, and never what a form hoped.
|
|
7
|
+
*
|
|
8
|
+
* It walks a person through the three places they can be: nobody has said who is at this device,
|
|
9
|
+
* the device is in no lab, the device is waiting to be let into one — and then the lab itself.
|
|
10
|
+
*/
|
|
11
|
+
import { type ReactNode } from "react";
|
|
12
|
+
/** The things a member looks at. */
|
|
13
|
+
export declare const TABS: readonly ["freezer", "places", "people", "history", "sharing"];
|
|
3
14
|
/** One of them. */
|
|
4
15
|
export type Tab = (typeof TABS)[number];
|
|
16
|
+
/** A view a host adds to the window beside its own, such as a drawing of the lab. */
|
|
17
|
+
export interface ExtraTab {
|
|
18
|
+
/** What tells it apart. */
|
|
19
|
+
id: string;
|
|
20
|
+
/** What its tab says. */
|
|
21
|
+
label: string;
|
|
22
|
+
/** What it shows. It is inside the lab's provider, so it may use the hooks. */
|
|
23
|
+
view: ReactNode;
|
|
24
|
+
}
|
|
5
25
|
/**
|
|
6
26
|
* The window.
|
|
7
27
|
*
|
|
8
|
-
* @param props - `tab` is which view to open on; `copy` puts words on the clipboard
|
|
9
|
-
* cannot use the browser's own way
|
|
28
|
+
* @param props - `tab` is which view to open on; `copy` puts words on the clipboard and `save` hands
|
|
29
|
+
* over a file, for a host that cannot use the browser's own way; `extra` are views the host adds,
|
|
30
|
+
* shown after the window's own.
|
|
10
31
|
*/
|
|
11
|
-
export declare function LabWindow({ tab: first, copy }: {
|
|
12
|
-
tab?: Tab;
|
|
32
|
+
export declare function LabWindow({ tab: first, copy, save, extra }: {
|
|
33
|
+
tab?: Tab | string;
|
|
13
34
|
copy?: (words: string) => Promise<void>;
|
|
35
|
+
save?: (name: string, text: string) => Promise<void>;
|
|
36
|
+
extra?: readonly ExtraTab[];
|
|
14
37
|
}): import("react").JSX.Element;
|
|
15
38
|
/** Asking who is at this device, before anything else. */
|
|
16
39
|
export declare function Who(): import("react").JSX.Element;
|
package/dist/window.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../src/window.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../src/window.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAUjD,oCAAoC;AACpC,eAAO,MAAM,IAAI,gEAAiE,CAAC;AAEnF,mBAAmB;AACnB,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AAExC,qFAAqF;AACrF,MAAM,WAAW,QAAQ;IACvB,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,IAAI,EAAE,SAAS,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,EAAE,GAAG,EAAE,KAAiB,EAAE,IAAI,EAAE,IAAI,EAAE,KAAU,EAAE,EAAE;IAC5E,GAAG,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;CAChJ,+BAKA;AA+CD,0DAA0D;AAC1D,wBAAgB,GAAG,gCAYlB;AAED,sCAAsC;AACtC,wBAAgB,KAAK,uCA2BpB;AAED,+CAA+C;AAC/C,wBAAgB,OAAO,uCAYtB"}
|
package/dist/window.js
CHANGED
|
@@ -15,21 +15,28 @@ import { Logo, Mark, useAct, useLab } from "@biolibs/bionet-react";
|
|
|
15
15
|
import { Freezer } from "./freezer.js";
|
|
16
16
|
import { History } from "./history.js";
|
|
17
17
|
import { Ask, CopyContext, DeviceKey, SyncStatus, Trouble } from "./parts.js";
|
|
18
|
+
import { RestoreKey, SaveContext } from "./backup.js";
|
|
18
19
|
import { People } from "./people.js";
|
|
20
|
+
import { Places } from "./places.js";
|
|
19
21
|
import { Sharing } from "./sharing.js";
|
|
20
|
-
/** The
|
|
21
|
-
export const TABS = ["freezer", "people", "history", "sharing"];
|
|
22
|
+
/** The things a member looks at. */
|
|
23
|
+
export const TABS = ["freezer", "places", "people", "history", "sharing"];
|
|
22
24
|
/**
|
|
23
25
|
* The window.
|
|
24
26
|
*
|
|
25
|
-
* @param props - `tab` is which view to open on; `copy` puts words on the clipboard
|
|
26
|
-
* cannot use the browser's own way
|
|
27
|
+
* @param props - `tab` is which view to open on; `copy` puts words on the clipboard and `save` hands
|
|
28
|
+
* over a file, for a host that cannot use the browser's own way; `extra` are views the host adds,
|
|
29
|
+
* shown after the window's own.
|
|
27
30
|
*/
|
|
28
|
-
export function LabWindow({ tab: first = "freezer", copy }) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
export function LabWindow({ tab: first = "freezer", copy, save, extra = [] }) {
|
|
32
|
+
let window = _jsx(Body, { first: first, extra: extra });
|
|
33
|
+
if (save !== undefined)
|
|
34
|
+
window = _jsx(SaveContext.Provider, { value: save, children: window });
|
|
35
|
+
if (copy !== undefined)
|
|
36
|
+
window = _jsx(CopyContext.Provider, { value: copy, children: window });
|
|
37
|
+
return _jsx("div", { className: "bionet", children: window });
|
|
31
38
|
}
|
|
32
|
-
function Body({ first }) {
|
|
39
|
+
function Body({ first, extra }) {
|
|
33
40
|
const state = useLab();
|
|
34
41
|
const [tab, setTab] = useState(first);
|
|
35
42
|
if (state === null)
|
|
@@ -43,11 +50,12 @@ function Body({ first }) {
|
|
|
43
50
|
const lab = state.lab;
|
|
44
51
|
const label = {
|
|
45
52
|
freezer: `Freezer · ${lab.items.filter((item) => !item.retired).length}`,
|
|
53
|
+
places: `Places · ${lab.places.filter((place) => !place.retired).length}`,
|
|
46
54
|
people: `People · ${lab.roster.filter((key) => key.removed === null).length}`,
|
|
47
55
|
history: `History · ${lab.entries.length}`,
|
|
48
56
|
sharing: "Sharing",
|
|
49
57
|
};
|
|
50
|
-
return (_jsxs("div", { className: "shell", children: [_jsxs("header", { children: [_jsxs("div", { className: "title", children: [_jsx(Mark, { size: 34 }), _jsxs("div", { children: [_jsx("h1", { children: lab.name ?? "A lab" }), _jsxs("p", { className: "dim small", children: [state.device.person, " \u00B7 ", lab.keeper ? "keeper" : "member", " \u00B7 this device ", _jsx("code", { children: state.device.fingerprint })] })] })] }), _jsx(SyncStatus, { peer: state.peer })] }),
|
|
58
|
+
return (_jsxs("div", { className: "shell", children: [_jsxs("header", { children: [_jsxs("div", { className: "title", children: [_jsx(Mark, { size: 34 }), _jsxs("div", { children: [_jsx("h1", { children: lab.name ?? "A lab" }), _jsxs("p", { className: "dim small", children: [state.device.person, " \u00B7 ", lab.keeper ? "keeper" : "member", " \u00B7 this device ", _jsx("code", { children: state.device.fingerprint })] })] })] }), _jsx(SyncStatus, { peer: state.peer })] }), _jsxs("nav", { children: [TABS.map((one) => _jsx("button", { type: "button", className: one === tab ? "tab on" : "tab", onClick: () => setTab(one), children: label[one] }, one)), extra.map((one) => _jsx("button", { type: "button", className: one.id === tab ? "tab on" : "tab", onClick: () => setTab(one.id), children: one.label }, one.id))] }), _jsxs("main", { children: [_jsx(Trouble, {}), tab === "freezer" && _jsx(Freezer, {}), tab === "places" && _jsx(Places, {}), tab === "people" && _jsx(People, {}), tab === "history" && _jsx(History, {}), tab === "sharing" && _jsx(Sharing, {}), extra.find((one) => one.id === tab)?.view] })] }));
|
|
51
59
|
}
|
|
52
60
|
/** Asking who is at this device, before anything else. */
|
|
53
61
|
export function Who() {
|
|
@@ -60,7 +68,7 @@ export function NoLab() {
|
|
|
60
68
|
const act = useAct();
|
|
61
69
|
if (state === null)
|
|
62
70
|
return null;
|
|
63
|
-
return (_jsxs("div", { className: "pair", children: [_jsxs("section", { className: "card", children: [_jsx("h2", { children: "Found a lab" }), _jsx("p", { className: "dim", children: "You become its first keeper. It works on this device straight away, with or without a network." }), _jsxs(Ask, { onAsk: (data) => act("found", { name: String(data.get("name") ?? ""), peer: String(data.get("peer") ?? "") }), className: "stack", children: [_jsxs("label", { children: ["What is it called?", _jsx("input", { name: "name", placeholder: "The Wren Lab", required: true, maxLength: 200 })] }), _jsxs("label", { children: [_jsx("span", { children: "Its web peer, if it has one (optional)" }), _jsx("input", { name: "peer", placeholder: "wss://your-lab.example/sync" })] }), _jsx("button", { type: "submit", children: "Found the lab" })] })] }), _jsxs("section", { className: "card", children: [_jsx("h2", { children: "Join a lab" }), _jsx("p", { className: "dim", children: "Send a keeper this device's key, and paste the invitation they send back. The lab arrives once they have added you." }), _jsx(DeviceKey, { device: state.device }), _jsxs(Ask, { onAsk: (data) => act("join", String(data.get("invite") ?? "")), className: "stack", children: [_jsxs("label", { children: ["Invitation", _jsx("input", { name: "invite", placeholder: "wss://your-lab.example/sync#\u2026", required: true })] }), _jsx("button", { type: "submit", children: "Join" })] })] })] }));
|
|
71
|
+
return (_jsxs("div", { className: "pair", children: [_jsxs("section", { className: "card", children: [_jsx("h2", { children: "Found a lab" }), _jsx("p", { className: "dim", children: "You become its first keeper. It works on this device straight away, with or without a network." }), _jsxs(Ask, { onAsk: (data) => act("found", { name: String(data.get("name") ?? ""), peer: String(data.get("peer") ?? "") }), className: "stack", children: [_jsxs("label", { children: ["What is it called?", _jsx("input", { name: "name", placeholder: "The Wren Lab", required: true, maxLength: 200 })] }), _jsxs("label", { children: [_jsx("span", { children: "Its web peer, if it has one (optional)" }), _jsx("input", { name: "peer", placeholder: "wss://your-lab.example/sync" })] }), _jsx("button", { type: "submit", children: "Found the lab" })] })] }), _jsxs("section", { className: "card", children: [_jsx("h2", { children: "Join a lab" }), _jsx("p", { className: "dim", children: "Send a keeper this device's key, and paste the invitation they send back. The lab arrives once they have added you." }), _jsx(DeviceKey, { device: state.device }), _jsxs(Ask, { onAsk: (data) => act("join", String(data.get("invite") ?? "")), className: "stack", children: [_jsxs("label", { children: ["Invitation", _jsx("input", { name: "invite", placeholder: "wss://your-lab.example/sync#\u2026", required: true })] }), _jsx("button", { type: "submit", children: "Join" })] }), _jsx(RestoreKey, {})] })] }));
|
|
64
72
|
}
|
|
65
73
|
/** Waiting for a keeper to add this device. */
|
|
66
74
|
export function Waiting() {
|
package/dist/window.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"window.js","sourceRoot":"","sources":["../src/window.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb;;;;;;;;;GASG;AACH,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"window.js","sourceRoot":"","sources":["../src/window.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb;;;;;;;;;GASG;AACH,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE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ionet": "^1.
|
|
7
|
-
"@biolibs/bionet-client": "^0.
|
|
8
|
-
"@biolibs/bionet-react": "^0.
|
|
6
|
+
"@biolibs/bionet": "^1.3.0",
|
|
7
|
+
"@biolibs/bionet-client": "^0.2.0",
|
|
8
|
+
"@biolibs/bionet-react": "^0.2.0",
|
|
9
|
+
"@biolibs/bionet-space": "^0.2.0",
|
|
9
10
|
"@biolibs/opencloning": "^2.0.0"
|
|
10
11
|
},
|
|
11
12
|
"description": "The parts of a Bionet lab application, ready to place: the freezer, the people, the history, what other labs are shown, and a whole window that puts them together, in a light theme and a dark one",
|
|
@@ -53,5 +54,5 @@
|
|
|
53
54
|
],
|
|
54
55
|
"type": "module",
|
|
55
56
|
"types": "dist/index.d.ts",
|
|
56
|
-
"version": "0.
|
|
57
|
+
"version": "0.3.0"
|
|
57
58
|
}
|
package/panels.css
CHANGED
|
@@ -59,3 +59,10 @@
|
|
|
59
59
|
.bionet main.page { max-width: 46rem; margin: 0 auto; padding: 3rem 1.25rem 6rem; overflow: visible; font-size: 15px; line-height: 1.65 }
|
|
60
60
|
.bionet main.page .title { margin-bottom: .6rem } .bionet main.page h1 { font-size: 1.6rem }
|
|
61
61
|
.bionet main.page h2 { font-size: 1.1rem; margin: 2.4rem 0 .6rem; padding-bottom: .3rem; border-bottom: 1px solid var(--bionet-rule) }
|
|
62
|
+
/* Places, where a tube is, and restoring a key. */
|
|
63
|
+
.bionet .where { display: grid; gap: .25rem }
|
|
64
|
+
.bionet .where select { max-width: 11rem }
|
|
65
|
+
.bionet .plainlist { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem }
|
|
66
|
+
.bionet details.restore { margin-top: .9rem }
|
|
67
|
+
.bionet details.restore summary { cursor: pointer; color: var(--bionet-dim) }
|
|
68
|
+
.bionet details.restore summary:hover { color: var(--bionet-ink) }
|
package/src/backup.tsx
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
/** Keeping this device's key somewhere else, and taking one up again on a new device. */
|
|
4
|
+
import { createContext, useContext, useState } from "react";
|
|
5
|
+
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
6
|
+
import { Ask } from "./parts.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* How to hand the person a file to keep. A host that cannot use the browser's own way supplies one.
|
|
10
|
+
* The default offers it as a download.
|
|
11
|
+
*/
|
|
12
|
+
export const SaveContext = createContext<(name: string, text: string) => Promise<void>>(async (name, text) => {
|
|
13
|
+
const link = document.createElement("a");
|
|
14
|
+
link.href = URL.createObjectURL(new Blob([text], { type: "application/json" }));
|
|
15
|
+
link.download = name;
|
|
16
|
+
link.click();
|
|
17
|
+
URL.revokeObjectURL(link.href);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/** Seal this device's key under a passphrase and hand it over as a file. */
|
|
21
|
+
export function BackUpKey() {
|
|
22
|
+
const state = useLab();
|
|
23
|
+
const act = useAct();
|
|
24
|
+
const save = useContext(SaveContext);
|
|
25
|
+
const [note, setNote] = useState<string | null>(null);
|
|
26
|
+
if (state === null) return null;
|
|
27
|
+
return (
|
|
28
|
+
<section className="card">
|
|
29
|
+
<h2>Back up this device's key</h2>
|
|
30
|
+
<p className="dim small">
|
|
31
|
+
Everything you sign is signed by a key that exists only on this computer. If the computer is lost, so is the key, and a lab with
|
|
32
|
+
nobody else in it is lost with it. This writes the key to a file, sealed under a passphrase. Keep the file somewhere that is not
|
|
33
|
+
this computer, and the passphrase somewhere that is not the file. Nothing here remembers the passphrase.
|
|
34
|
+
</p>
|
|
35
|
+
<Ask className="stack" onAsk={async (data) => {
|
|
36
|
+
setNote(null);
|
|
37
|
+
const [first, again] = [String(data.get("passphrase") ?? ""), String(data.get("again") ?? "")];
|
|
38
|
+
if (first !== again) { setNote("Those two passphrases are not the same."); return { ok: false }; }
|
|
39
|
+
const answer = await act("backUp", first);
|
|
40
|
+
if (!answer.ok) return answer;
|
|
41
|
+
await save(`bionet-key-${state.device.fingerprint}.json`, String(answer.result));
|
|
42
|
+
setNote("Sealed and handed over. Open it only on a new device, before that device joins a lab.");
|
|
43
|
+
return answer;
|
|
44
|
+
}}>
|
|
45
|
+
<label>Passphrase<input name="passphrase" type="password" required minLength={12} autoComplete="new-password" /></label>
|
|
46
|
+
<label>And again<input name="again" type="password" required minLength={12} autoComplete="new-password" /></label>
|
|
47
|
+
<button type="submit">Seal and save</button>
|
|
48
|
+
</Ask>
|
|
49
|
+
{note !== null && <p className="small" role="status">{note}</p>}
|
|
50
|
+
</section>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Take up a key from a backup, on a device that is not in a lab yet. */
|
|
55
|
+
export function RestoreKey() {
|
|
56
|
+
const act = useAct();
|
|
57
|
+
return (
|
|
58
|
+
<details className="restore">
|
|
59
|
+
<summary>Replacing a lost device? Restore its key</summary>
|
|
60
|
+
<p className="dim small">Choose the backup file and give its passphrase. This device then signs as the lost one did. Do this before joining, and only if the old device is really gone: one key on two devices writes two histories the lab cannot tell apart.</p>
|
|
61
|
+
<Ask className="stack" onAsk={async (data) => {
|
|
62
|
+
const file = data.get("backup");
|
|
63
|
+
const backup = file instanceof File ? await file.text() : "";
|
|
64
|
+
return act("restore", { backup, passphrase: String(data.get("passphrase") ?? "") });
|
|
65
|
+
}}>
|
|
66
|
+
<label>Backup file<input name="backup" type="file" accept="application/json,.json" required /></label>
|
|
67
|
+
<label>Passphrase<input name="passphrase" type="password" required autoComplete="off" /></label>
|
|
68
|
+
<button type="submit" className="quiet">Restore key</button>
|
|
69
|
+
</Ask>
|
|
70
|
+
</details>
|
|
71
|
+
);
|
|
72
|
+
}
|
package/src/freezer.tsx
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import type { ItemState, PartState } from "@biolibs/bionet";
|
|
5
5
|
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
6
6
|
import { Ask } from "./parts.js";
|
|
7
|
+
import { PutItem } from "./places.js";
|
|
7
8
|
|
|
8
9
|
const whole = (data: FormData, name: string): number => Number(String(data.get(name) ?? "").trim());
|
|
9
10
|
|
|
@@ -56,7 +57,7 @@ export function PartCard({ part, items }: { part: PartState; items: ItemState[]
|
|
|
56
57
|
</div>
|
|
57
58
|
{live.length === 0 ? <p className="dim small">No tubes of this.</p> : (
|
|
58
59
|
<table>
|
|
59
|
-
<thead><tr><th>Tube</th><th>Amount</th><th>Use or add</th><th>Count</th><th /></tr></thead>
|
|
60
|
+
<thead><tr><th>Tube</th><th>Amount</th><th>Where</th><th>Use or add</th><th>Count</th><th /></tr></thead>
|
|
60
61
|
<tbody>{live.map((item) => <ItemRow key={item.item} item={item} />)}</tbody>
|
|
61
62
|
</table>
|
|
62
63
|
)}
|
|
@@ -79,6 +80,7 @@ export function ItemRow({ item }: { item: ItemState }) {
|
|
|
79
80
|
<strong>{amountOf(item)}</strong>
|
|
80
81
|
{item.needsRecount && <span className="badge" title="The log has lost track of this tube: it went below zero, or two people counted it at once.">needs a count</span>}
|
|
81
82
|
</td>
|
|
83
|
+
<td><PutItem item={item} /></td>
|
|
82
84
|
<td>
|
|
83
85
|
<div className="row tight">
|
|
84
86
|
<button type="button" className="quiet" onClick={() => void act("adjust", { item: item.item, by: -1 })}>−1</button>
|
package/src/history.tsx
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
import type { EntryView, LabView } from "@biolibs/bionet-client";
|
|
6
6
|
import { useLab } from "@biolibs/bionet-react";
|
|
7
|
+
import { slotName } from "@biolibs/bionet-space";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* What one change was, in words.
|
|
@@ -12,7 +13,7 @@ import { useLab } from "@biolibs/bionet-react";
|
|
|
12
13
|
* @param lab - The lab, to name the parts, tubes and people it refers to.
|
|
13
14
|
* @returns A phrase that follows the name of whoever made it, like `used 2 µL of a tube of f1`.
|
|
14
15
|
*/
|
|
15
|
-
export function describeEntry(entry: Pick<EntryView, "op">, lab: Pick<LabView, "parts" | "items" | "roster">): string {
|
|
16
|
+
export function describeEntry(entry: Pick<EntryView, "op">, lab: Pick<LabView, "parts" | "items" | "roster"> & Partial<Pick<LabView, "places">>): string {
|
|
16
17
|
const op = entry.op;
|
|
17
18
|
const part = (checksum: unknown): string => lab.parts.find((one) => one.checksum === checksum)?.name ?? "a part";
|
|
18
19
|
const tube = (id: unknown): string => {
|
|
@@ -21,6 +22,7 @@ export function describeEntry(entry: Pick<EntryView, "op">, lab: Pick<LabView, "
|
|
|
21
22
|
};
|
|
22
23
|
const unit = (id: unknown): string => lab.items.find((one) => one.item === id)?.unit ?? "";
|
|
23
24
|
const who = (key: unknown): string => lab.roster.find((one) => one.key === key)?.person ?? "a device";
|
|
25
|
+
const place = (id: unknown): string => lab.places?.find((one) => one.place === id)?.name ?? "a place";
|
|
24
26
|
const tidy = (words: string): string => words.replace(/\s+/g, " ").trim();
|
|
25
27
|
switch (op.type) {
|
|
26
28
|
case "roster.found": return `founded ${String(op["name"])}`;
|
|
@@ -33,6 +35,15 @@ export function describeEntry(entry: Pick<EntryView, "op">, lab: Pick<LabView, "
|
|
|
33
35
|
case "item.adjust": return tidy(`${Number(op["by"]) < 0 ? "used" : "added"} ${Math.abs(Number(op["by"]))} ${unit(op["item"])} ${Number(op["by"]) < 0 ? "of" : "to"} ${tube(op["item"])}`);
|
|
34
36
|
case "item.recount": return tidy(`counted ${String(op["amount"])} ${unit(op["item"])} in ${tube(op["item"])}`);
|
|
35
37
|
case "item.retire": return `retired ${tube(op["item"])}`;
|
|
38
|
+
case "place.add": return `added the ${String(op["kind"])} ${String(op["name"])}${op["parent"] === null ? "" : ` in ${place(op["parent"])}`}`;
|
|
39
|
+
case "place.move": return op["parent"] === null ? `took ${place(op["place"])} out of where it was` : `moved ${place(op["place"])} into ${place(op["parent"])}`;
|
|
40
|
+
case "place.stand": return op["standing"] === null ? `cleared where ${place(op["place"])} stands` : `said where ${place(op["place"])} stands`;
|
|
41
|
+
case "place.retire": return `retired ${place(op["place"])}`;
|
|
42
|
+
case "item.put": {
|
|
43
|
+
const slot = op["slot"] as { row: number; column: number } | null;
|
|
44
|
+
return op["place"] === null ? `took ${tube(op["item"])} out of where it was`
|
|
45
|
+
: `put ${tube(op["item"])} in ${place(op["place"])}${slot === null ? "" : `, ${slotName(slot)}`}`;
|
|
46
|
+
}
|
|
36
47
|
case "field.set": return `set ${String(op["field"])} to ${String(op["value"])}`;
|
|
37
48
|
default: return `did something this version does not know (${op.type})`;
|
|
38
49
|
}
|
package/src/index.ts
CHANGED
package/src/people.tsx
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/** The people: who is in the lab, and letting somebody in. */
|
|
4
4
|
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
5
|
+
import { BackUpKey } from "./backup.js";
|
|
5
6
|
import { Ask, Copy } from "./parts.js";
|
|
6
7
|
|
|
7
8
|
/** The roster, and for a keeper the way to add somebody. Draws nothing until the lab has arrived. */
|
|
@@ -47,6 +48,7 @@ export function People() {
|
|
|
47
48
|
) : <p className="dim small">Set the lab's web peer under Sharing to have an invitation to send.</p>}
|
|
48
49
|
</section>
|
|
49
50
|
) : <p className="dim small">Only a keeper can change who is in the lab.</p>}
|
|
51
|
+
<BackUpKey />
|
|
50
52
|
</>
|
|
51
53
|
);
|
|
52
54
|
}
|
package/src/places.tsx
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
/** The places: where things are kept, which is inside which, and putting a tube somewhere. */
|
|
4
|
+
import type { ItemState, PlaceState } from "@biolibs/bionet";
|
|
5
|
+
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
6
|
+
import { slotFrom, slotName } from "@biolibs/bionet-space";
|
|
7
|
+
import { Ask } from "./parts.js";
|
|
8
|
+
|
|
9
|
+
/** The kinds of place offered when adding one. Any other kind a lab's log holds is shown as it is. */
|
|
10
|
+
export const PLACE_KINDS = ["room", "freezer", "fridge", "shelf", "rack", "box", "bench", "instrument"] as const;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Where a place is, said the way a person would: every place it is inside, then itself.
|
|
14
|
+
*
|
|
15
|
+
* @param places - The lab's places.
|
|
16
|
+
* @param id - The place.
|
|
17
|
+
* @returns Something like `Main lab › −80 › Shelf 2 › Box 7`, or `""` if the lab has no such place.
|
|
18
|
+
*/
|
|
19
|
+
export function placePath(places: readonly Pick<PlaceState, "place" | "name" | "parent">[], id: string): string {
|
|
20
|
+
const names: string[] = [];
|
|
21
|
+
const passed = new Set<string>();
|
|
22
|
+
for (let at: string | null = id; at !== null && !passed.has(at);) {
|
|
23
|
+
const one = places.find((each) => each.place === at);
|
|
24
|
+
if (one === undefined) break;
|
|
25
|
+
passed.add(at);
|
|
26
|
+
names.unshift(one.name);
|
|
27
|
+
at = one.parent;
|
|
28
|
+
}
|
|
29
|
+
return names.join(" › ");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Where an item is, in words.
|
|
34
|
+
*
|
|
35
|
+
* @param item - The item.
|
|
36
|
+
* @param places - The lab's places.
|
|
37
|
+
* @returns Something like `−80 › Box 7 · C4`, or `nowhere recorded`.
|
|
38
|
+
*/
|
|
39
|
+
export function whereWords(item: Pick<ItemState, "where">, places: readonly Pick<PlaceState, "place" | "name" | "parent">[]): string {
|
|
40
|
+
if (item.where === null) return "nowhere recorded";
|
|
41
|
+
const path = placePath(places, item.where.place) || "a place the lab no longer has";
|
|
42
|
+
return item.where.slot === null ? path : `${path} · ${slotName(item.where.slot)}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The places in the order a tree is read: each one followed by what is inside it.
|
|
47
|
+
*
|
|
48
|
+
* @param places - The lab's places.
|
|
49
|
+
* @returns Each place still in use, with how deep it is.
|
|
50
|
+
*/
|
|
51
|
+
export function placeTree(places: readonly PlaceState[]): { place: PlaceState; depth: number }[] {
|
|
52
|
+
const out: { place: PlaceState; depth: number }[] = [];
|
|
53
|
+
const walk = (parent: string | null, depth: number): void => {
|
|
54
|
+
for (const place of places) {
|
|
55
|
+
if (place.parent !== parent || place.retired) continue;
|
|
56
|
+
out.push({ place, depth });
|
|
57
|
+
walk(place.place, depth + 1);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
walk(null, 0);
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Every place as a tree, what needs looking at, and a form to add a place. Draws nothing until the lab has arrived. */
|
|
65
|
+
export function Places() {
|
|
66
|
+
const lab = useLab()?.lab;
|
|
67
|
+
const act = useAct();
|
|
68
|
+
if (lab === null || lab === undefined) return null;
|
|
69
|
+
const tree = placeTree(lab.places);
|
|
70
|
+
const live = lab.items.filter((item) => !item.retired);
|
|
71
|
+
const holding = (id: string): number => live.filter((item) => item.where?.place === id).length;
|
|
72
|
+
return (
|
|
73
|
+
<>
|
|
74
|
+
{lab.crowded.length > 0 && (
|
|
75
|
+
<section className="card">
|
|
76
|
+
<h2>Somebody needs to look</h2>
|
|
77
|
+
<p className="dim small">The lab has more than one tube recorded in each of these positions. Two people put them there without knowing of each other. Move whichever is not really there.</p>
|
|
78
|
+
<ul className="plainlist">
|
|
79
|
+
{lab.crowded.map((one) => (
|
|
80
|
+
<li key={`${one.place} ${one.slot.row} ${one.slot.column}`} className="flagged">
|
|
81
|
+
<strong>{placePath(lab.places, one.place)} · {slotName(one.slot)}</strong> <span className="badge">{one.items.length} tubes</span>
|
|
82
|
+
</li>
|
|
83
|
+
))}
|
|
84
|
+
</ul>
|
|
85
|
+
</section>
|
|
86
|
+
)}
|
|
87
|
+
<section className="card">
|
|
88
|
+
<h2>Where things are kept</h2>
|
|
89
|
+
{tree.length === 0 ? <p className="empty">No places yet. Add the first below: a freezer, then the boxes in it.</p> : (
|
|
90
|
+
<table>
|
|
91
|
+
<thead><tr><th>Place</th><th>Kind</th><th>Positions</th><th>Tubes here</th><th /></tr></thead>
|
|
92
|
+
<tbody>
|
|
93
|
+
{tree.map(({ place, depth }) => (
|
|
94
|
+
<tr key={place.place} className={place.adrift ? "flagged" : undefined}>
|
|
95
|
+
<td style={{ paddingLeft: `${0.6 + depth * 1.2}rem` }}>
|
|
96
|
+
{place.name}
|
|
97
|
+
{place.adrift && <span className="badge" title="Two people each moved this place and another into one another. Move one of them to settle it.">needs moving</span>}
|
|
98
|
+
</td>
|
|
99
|
+
<td className="dim">{place.kind}</td>
|
|
100
|
+
<td className="dim">{place.grid === null ? "" : `${place.grid.rows} × ${place.grid.columns}`}</td>
|
|
101
|
+
<td>{holding(place.place) || ""}</td>
|
|
102
|
+
<td><button type="button" className="plain" onClick={() => void act("retirePlace", { place: place.place })}>retire</button></td>
|
|
103
|
+
</tr>
|
|
104
|
+
))}
|
|
105
|
+
</tbody>
|
|
106
|
+
</table>
|
|
107
|
+
)}
|
|
108
|
+
</section>
|
|
109
|
+
<section className="card">
|
|
110
|
+
<h2>Add a place</h2>
|
|
111
|
+
<p className="dim small">A place is anything something is kept in or on. Only a box has positions; give it rows and columns and its tubes can be found by letter and number.</p>
|
|
112
|
+
<Ask className="stack" onAsk={(data) => {
|
|
113
|
+
const rows = Number(data.get("rows") ?? "");
|
|
114
|
+
const columns = Number(data.get("columns") ?? "");
|
|
115
|
+
const parent = String(data.get("parent") ?? "");
|
|
116
|
+
return act("addPlace", { kind: String(data.get("kind") ?? ""), name: String(data.get("name") ?? ""), parent: parent === "" ? null : parent,
|
|
117
|
+
grid: rows > 0 && columns > 0 ? { rows, columns } : null });
|
|
118
|
+
}}>
|
|
119
|
+
<label>Kind<select name="kind" defaultValue="box">{PLACE_KINDS.map((kind) => <option key={kind} value={kind}>{kind}</option>)}</select></label>
|
|
120
|
+
<label>Name<input name="name" placeholder="Box 7" required maxLength={200} /></label>
|
|
121
|
+
<label>Inside
|
|
122
|
+
<select name="parent" defaultValue="">
|
|
123
|
+
<option value="">nothing</option>
|
|
124
|
+
{tree.map(({ place, depth }) => <option key={place.place} value={place.place}>{" ".repeat(depth)}{place.name}</option>)}
|
|
125
|
+
</select>
|
|
126
|
+
</label>
|
|
127
|
+
<div className="row tight">
|
|
128
|
+
<input name="rows" type="number" min={1} max={100} step={1} placeholder="Rows" aria-label="Rows" className="num" />
|
|
129
|
+
<input name="columns" type="number" min={1} max={100} step={1} placeholder="Columns" aria-label="Columns" className="num" />
|
|
130
|
+
<span className="dim small">for a box</span>
|
|
131
|
+
</div>
|
|
132
|
+
<button type="submit">Add place</button>
|
|
133
|
+
</Ask>
|
|
134
|
+
</section>
|
|
135
|
+
</>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Where one tube is, and a way to put it somewhere.
|
|
141
|
+
*
|
|
142
|
+
* @param props - `item` is the tube.
|
|
143
|
+
*/
|
|
144
|
+
export function PutItem({ item }: { item: ItemState }) {
|
|
145
|
+
const lab = useLab()?.lab;
|
|
146
|
+
const act = useAct();
|
|
147
|
+
if (lab === null || lab === undefined) return null;
|
|
148
|
+
const tree = placeTree(lab.places);
|
|
149
|
+
return (
|
|
150
|
+
<div className="where">
|
|
151
|
+
<span className={item.where === null ? "dim small" : "small"}>{whereWords(item, lab.places)}</span>
|
|
152
|
+
{tree.length > 0 && (
|
|
153
|
+
<Ask className="row tight" onAsk={async (data) => {
|
|
154
|
+
const place = String(data.get("place") ?? "");
|
|
155
|
+
const written = String(data.get("slot") ?? "").trim();
|
|
156
|
+
const slot = written === "" ? null : slotFrom(written);
|
|
157
|
+
// A position that is not written like one is sent as it is not: the lab refuses it and says why.
|
|
158
|
+
return act("putItem", { item: item.item, place: place === "" ? null : place, slot: written !== "" && slot === null ? { row: -1, column: -1 } : slot });
|
|
159
|
+
}}>
|
|
160
|
+
<select name="place" defaultValue={item.where?.place ?? ""} aria-label="Place">
|
|
161
|
+
<option value="">nowhere</option>
|
|
162
|
+
{tree.map(({ place, depth }) => <option key={place.place} value={place.place}>{" ".repeat(depth)}{place.name}</option>)}
|
|
163
|
+
</select>
|
|
164
|
+
<input name="slot" placeholder="A1" aria-label="Position" className="num" maxLength={5} />
|
|
165
|
+
<button type="submit" className="quiet">Put</button>
|
|
166
|
+
</Ask>
|
|
167
|
+
)}
|
|
168
|
+
</div>
|
|
169
|
+
);
|
|
170
|
+
}
|
package/src/window.tsx
CHANGED
|
@@ -10,34 +10,51 @@
|
|
|
10
10
|
* It walks a person through the three places they can be: nobody has said who is at this device,
|
|
11
11
|
* the device is in no lab, the device is waiting to be let into one — and then the lab itself.
|
|
12
12
|
*/
|
|
13
|
-
import { useState } from "react";
|
|
13
|
+
import { useState, type ReactNode } from "react";
|
|
14
14
|
import { Logo, Mark, useAct, useLab } from "@biolibs/bionet-react";
|
|
15
15
|
import { Freezer } from "./freezer.js";
|
|
16
16
|
import { History } from "./history.js";
|
|
17
17
|
import { Ask, CopyContext, DeviceKey, SyncStatus, Trouble } from "./parts.js";
|
|
18
|
+
import { RestoreKey, SaveContext } from "./backup.js";
|
|
18
19
|
import { People } from "./people.js";
|
|
20
|
+
import { Places } from "./places.js";
|
|
19
21
|
import { Sharing } from "./sharing.js";
|
|
20
22
|
|
|
21
|
-
/** The
|
|
22
|
-
export const TABS = ["freezer", "people", "history", "sharing"] as const;
|
|
23
|
+
/** The things a member looks at. */
|
|
24
|
+
export const TABS = ["freezer", "places", "people", "history", "sharing"] as const;
|
|
23
25
|
|
|
24
26
|
/** One of them. */
|
|
25
27
|
export type Tab = (typeof TABS)[number];
|
|
26
28
|
|
|
29
|
+
/** A view a host adds to the window beside its own, such as a drawing of the lab. */
|
|
30
|
+
export interface ExtraTab {
|
|
31
|
+
/** What tells it apart. */
|
|
32
|
+
id: string;
|
|
33
|
+
/** What its tab says. */
|
|
34
|
+
label: string;
|
|
35
|
+
/** What it shows. It is inside the lab's provider, so it may use the hooks. */
|
|
36
|
+
view: ReactNode;
|
|
37
|
+
}
|
|
38
|
+
|
|
27
39
|
/**
|
|
28
40
|
* The window.
|
|
29
41
|
*
|
|
30
|
-
* @param props - `tab` is which view to open on; `copy` puts words on the clipboard
|
|
31
|
-
* cannot use the browser's own way
|
|
42
|
+
* @param props - `tab` is which view to open on; `copy` puts words on the clipboard and `save` hands
|
|
43
|
+
* over a file, for a host that cannot use the browser's own way; `extra` are views the host adds,
|
|
44
|
+
* shown after the window's own.
|
|
32
45
|
*/
|
|
33
|
-
export function LabWindow({ tab: first = "freezer", copy
|
|
34
|
-
|
|
35
|
-
|
|
46
|
+
export function LabWindow({ tab: first = "freezer", copy, save, extra = [] }: {
|
|
47
|
+
tab?: Tab | string; copy?: (words: string) => Promise<void>; save?: (name: string, text: string) => Promise<void>; extra?: readonly ExtraTab[];
|
|
48
|
+
}) {
|
|
49
|
+
let window = <Body first={first} extra={extra} />;
|
|
50
|
+
if (save !== undefined) window = <SaveContext.Provider value={save}>{window}</SaveContext.Provider>;
|
|
51
|
+
if (copy !== undefined) window = <CopyContext.Provider value={copy}>{window}</CopyContext.Provider>;
|
|
52
|
+
return <div className="bionet">{window}</div>;
|
|
36
53
|
}
|
|
37
54
|
|
|
38
|
-
function Body({ first }: { first:
|
|
55
|
+
function Body({ first, extra }: { first: string; extra: readonly ExtraTab[] }) {
|
|
39
56
|
const state = useLab();
|
|
40
|
-
const [tab, setTab] = useState<
|
|
57
|
+
const [tab, setTab] = useState<string>(first);
|
|
41
58
|
if (state === null) return <main className="centre"><p className="dim">Opening the lab…</p></main>;
|
|
42
59
|
if (state.device.person === null) return <main className="centre"><Logo /><Trouble /><Who /></main>;
|
|
43
60
|
if (state.lab === null) return <main className="centre"><Logo /><Trouble /><NoLab /></main>;
|
|
@@ -46,6 +63,7 @@ function Body({ first }: { first: Tab }) {
|
|
|
46
63
|
const lab = state.lab;
|
|
47
64
|
const label: Record<Tab, string> = {
|
|
48
65
|
freezer: `Freezer · ${lab.items.filter((item) => !item.retired).length}`,
|
|
66
|
+
places: `Places · ${lab.places.filter((place) => !place.retired).length}`,
|
|
49
67
|
people: `People · ${lab.roster.filter((key) => key.removed === null).length}`,
|
|
50
68
|
history: `History · ${lab.entries.length}`,
|
|
51
69
|
sharing: "Sharing",
|
|
@@ -64,13 +82,16 @@ function Body({ first }: { first: Tab }) {
|
|
|
64
82
|
</header>
|
|
65
83
|
<nav>
|
|
66
84
|
{TABS.map((one) => <button key={one} type="button" className={one === tab ? "tab on" : "tab"} onClick={() => setTab(one)}>{label[one]}</button>)}
|
|
85
|
+
{extra.map((one) => <button key={one.id} type="button" className={one.id === tab ? "tab on" : "tab"} onClick={() => setTab(one.id)}>{one.label}</button>)}
|
|
67
86
|
</nav>
|
|
68
87
|
<main>
|
|
69
88
|
<Trouble />
|
|
70
89
|
{tab === "freezer" && <Freezer />}
|
|
90
|
+
{tab === "places" && <Places />}
|
|
71
91
|
{tab === "people" && <People />}
|
|
72
92
|
{tab === "history" && <History />}
|
|
73
93
|
{tab === "sharing" && <Sharing />}
|
|
94
|
+
{extra.find((one) => one.id === tab)?.view}
|
|
74
95
|
</main>
|
|
75
96
|
</div>
|
|
76
97
|
);
|
|
@@ -115,6 +136,7 @@ export function NoLab() {
|
|
|
115
136
|
<label>Invitation<input name="invite" placeholder="wss://your-lab.example/sync#…" required /></label>
|
|
116
137
|
<button type="submit">Join</button>
|
|
117
138
|
</Ask>
|
|
139
|
+
<RestoreKey />
|
|
118
140
|
</section>
|
|
119
141
|
</div>
|
|
120
142
|
);
|