@biolibs/bionet-panels 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -2
- package/dist/backup.d.ts +14 -0
- package/dist/backup.d.ts.map +1 -0
- package/dist/backup.js +86 -0
- package/dist/backup.js.map +1 -0
- package/dist/freezer.d.ts +10 -0
- package/dist/freezer.d.ts.map +1 -1
- package/dist/freezer.js +24 -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 +23 -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 +6 -5
- package/panels.css +8 -0
- package/src/backup.tsx +126 -0
- package/src/freezer.tsx +29 -2
- package/src/history.tsx +24 -1
- package/src/index.ts +2 -0
- package/src/people.tsx +3 -0
- package/src/places.tsx +170 -0
- package/src/window.tsx +33 -10
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# @biolibs/bionet-panels
|
|
2
2
|
|
|
3
|
-
The parts of a Bionet lab application, ready to place: the freezer,
|
|
4
|
-
other labs are shown,
|
|
3
|
+
The parts of a Bionet lab application, ready to place: the freezer, where things are kept, the
|
|
4
|
+
people, the history, what other labs are shown, backing up the key and the lab, and a whole window
|
|
5
|
+
that puts them together. Light and dark.
|
|
5
6
|
|
|
6
7
|
## Install
|
|
7
8
|
|
|
@@ -46,6 +47,20 @@ used on its own inside one:
|
|
|
46
47
|
|
|
47
48
|
Every colour comes from `@biolibs/bionet-theme`, and no rule reaches outside `.bionet`.
|
|
48
49
|
|
|
50
|
+
## Places, and a view of your own
|
|
51
|
+
|
|
52
|
+
`Places` shows the tree of places and adds to it; each tube in `Freezer` says where it is and can be
|
|
53
|
+
put somewhere, by place and by position (`C4`). `BackUpKey` and `RestoreKey` seal the device's key to
|
|
54
|
+
a file and take one up again; `BackUpLab` and `RestoreLab` do the same for the lab itself. A host
|
|
55
|
+
that cannot offer a download supplies `save` to `LabWindow`, and may answer `false` if the person
|
|
56
|
+
chose not to save.
|
|
57
|
+
|
|
58
|
+
`LabWindow` takes views of the host's own, shown as tabs after its own:
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
<LabWindow extra={[{ id: "scene", label: "Lab", view: <MyDrawingOfTheLab /> }]} />
|
|
62
|
+
```
|
|
63
|
+
|
|
49
64
|
## A lab's public page
|
|
50
65
|
|
|
51
66
|
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,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How to hand the person a file to keep. A host that cannot use the browser's own way supplies one,
|
|
3
|
+
* and may answer `false` if the person chose not to save it. The default offers it as a download.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SaveContext: import("react").Context<(name: string, text: string) => Promise<boolean | 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
|
+
/** Write everything this device holds of the lab to a file. */
|
|
11
|
+
export declare function BackUpLab(): import("react").JSX.Element | null;
|
|
12
|
+
/** Bring a lab back from a copy, on a device that is in no lab. */
|
|
13
|
+
export declare function RestoreLab(): import("react").JSX.Element;
|
|
14
|
+
//# 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,OAAO,GAAG,IAAI,CAAC,CAM9F,CAAC;AAEH,4EAA4E;AAC5E,wBAAgB,SAAS,uCAgCxB;AAED,yEAAyE;AACzE,wBAAgB,UAAU,gCAiBzB;AAED,+DAA+D;AAC/D,wBAAgB,SAAS,uCAgCxB;AAED,mEAAmE;AACnE,wBAAgB,UAAU,gCAezB"}
|
package/dist/backup.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
* and may answer `false` if the person chose not to save it. 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
|
+
const saved = await save(`bionet-key-${state.device.fingerprint}.json`, String(answer.result));
|
|
37
|
+
if (saved === false) {
|
|
38
|
+
setNote("Not saved. Nothing has been written anywhere.");
|
|
39
|
+
return { ok: false };
|
|
40
|
+
}
|
|
41
|
+
setNote("Sealed and saved. Keep it somewhere that is not this computer. Open it only on a new device, before that device joins a lab.");
|
|
42
|
+
return answer;
|
|
43
|
+
}, 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 })] }));
|
|
44
|
+
}
|
|
45
|
+
/** Take up a key from a backup, on a device that is not in a lab yet. */
|
|
46
|
+
export function RestoreKey() {
|
|
47
|
+
const act = useAct();
|
|
48
|
+
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) => {
|
|
49
|
+
const file = data.get("backup");
|
|
50
|
+
const backup = file instanceof File ? await file.text() : "";
|
|
51
|
+
return act("restore", { backup, passphrase: String(data.get("passphrase") ?? "") });
|
|
52
|
+
}, 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" })] })] }));
|
|
53
|
+
}
|
|
54
|
+
/** Write everything this device holds of the lab to a file. */
|
|
55
|
+
export function BackUpLab() {
|
|
56
|
+
const state = useLab();
|
|
57
|
+
const act = useAct();
|
|
58
|
+
const save = useContext(SaveContext);
|
|
59
|
+
const [note, setNote] = useState(null);
|
|
60
|
+
const [busy, setBusy] = useState(false);
|
|
61
|
+
const lab = state?.lab;
|
|
62
|
+
if (state === null || lab === null || lab === undefined)
|
|
63
|
+
return null;
|
|
64
|
+
return (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "Keep a copy of the lab" }), _jsxs("p", { className: "dim small", children: ["The key says who you are; this is the lab itself: every change anybody has signed, ", lab.entries.length, " so far. With the key's backup and this copy, the lab can be brought back on a new computer with nothing else to ask. It is not sealed: every change in it is signed, so it cannot be altered without that showing, but whoever reads the file reads the lab. Make a new copy as the lab grows."] }), _jsx("button", { type: "button", disabled: busy, onClick: () => {
|
|
65
|
+
setBusy(true);
|
|
66
|
+
setNote(null);
|
|
67
|
+
void (async () => {
|
|
68
|
+
const answer = await act("exportLab");
|
|
69
|
+
if (answer.ok) {
|
|
70
|
+
const name = (lab.name ?? "lab").replace(/[^A-Za-z0-9]+/g, "-").replace(/^-|-$/g, "").toLowerCase() || "lab";
|
|
71
|
+
const saved = await save(`bionet-lab-${name}-${new Date().toISOString().slice(0, 10)}.json`, String(answer.result));
|
|
72
|
+
setNote(saved === false ? "Not saved. Nothing has been written anywhere." : `Saved a copy holding ${lab.entries.length} ${lab.entries.length === 1 ? "change" : "changes"}.`);
|
|
73
|
+
}
|
|
74
|
+
setBusy(false);
|
|
75
|
+
})();
|
|
76
|
+
}, children: "Save a copy" }), note !== null && _jsx("p", { className: "small", role: "status", children: note })] }));
|
|
77
|
+
}
|
|
78
|
+
/** Bring a lab back from a copy, on a device that is in no lab. */
|
|
79
|
+
export function RestoreLab() {
|
|
80
|
+
const act = useAct();
|
|
81
|
+
return (_jsxs("details", { className: "restore", children: [_jsx("summary", { children: "Have a copy of a lab? Bring it back" }), _jsx("p", { className: "dim small", children: "Choose a file saved with \"Keep a copy of the lab\". If this device signs with a key on that lab's roster \u2014 restore the key first \u2014 it carries on where the lab left off. If not, the lab can be read here and not changed." }), _jsxs(Ask, { className: "stack", onAsk: async (data) => {
|
|
82
|
+
const file = data.get("copy");
|
|
83
|
+
return act("importLab", file instanceof File ? await file.text() : "");
|
|
84
|
+
}, children: [_jsxs("label", { children: ["Copy of the lab", _jsx("input", { name: "copy", type: "file", accept: "application/json,.json", required: true })] }), _jsx("button", { type: "submit", className: "quiet", children: "Bring it back" })] })] }));
|
|
85
|
+
}
|
|
86
|
+
//# 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,CAA0D,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IACrH,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,C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AAU;IACxB,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,OAAO,CACL,mBAAS,SAAS,EAAC,SAAS,aAC1B,oEAAsD,EACtD,YAAG,SAAS,EAAC,WAAW,sPAA8N,EACtP,MAAC,GAAG,IAAC,SAAS,EAAC,OAAO,EAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;oBAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;oBAC9B,OAAO,GAAG,CAAC,WAAW,EAAE,IAAI,YAAY,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBACzE,CAAC,aACC,+CAAsB,gBAAO,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,wBAAwB,EAAC,QAAQ,SAAG,IAAQ,EACxG,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,OAAO,8BAAuB,IAC1D,IACE,CACX,CAAC;AACJ,CAAC"}
|
package/dist/freezer.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** The freezer: every part, its tubes, and what can be done to them. */
|
|
2
2
|
import type { ItemState, PartState } from "@biolibs/bionet";
|
|
3
|
+
import type { LabView } from "@biolibs/bionet-client";
|
|
3
4
|
/**
|
|
4
5
|
* How much of an item there is, with its unit.
|
|
5
6
|
*
|
|
@@ -7,6 +8,15 @@ import type { ItemState, PartState } from "@biolibs/bionet";
|
|
|
7
8
|
* @returns Something like `7 µL`.
|
|
8
9
|
*/
|
|
9
10
|
export declare const amountOf: (item: Pick<ItemState, "amount" | "unit">) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Where a tube came from, if a run made it.
|
|
13
|
+
*
|
|
14
|
+
* @param item - The tube.
|
|
15
|
+
* @param lab - The lab's runs, items and parts.
|
|
16
|
+
* @returns Something like `made by a PCR from pWren-402, fwd-1 and rev-1`, or `null` for a tube
|
|
17
|
+
* that was simply added.
|
|
18
|
+
*/
|
|
19
|
+
export declare function madeFrom(item: Pick<ItemState, "from">, lab: Pick<LabView, "runs" | "items" | "parts">): string | null;
|
|
10
20
|
/** Every part with its tubes, and a form to add a part. Draws nothing until the lab has arrived. */
|
|
11
21
|
export declare function Freezer(): import("react").JSX.Element | null;
|
|
12
22
|
/** One part and its tubes. */
|
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;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAOtD;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,MAAM,IAAI,CAAC,SAAS,EAAE,QAAQ,GAAG,MAAM,CAAC,KAAG,MAAsE,CAAC;AAE3I;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,CASrH;AAED,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,+BAkCpD"}
|
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.
|
|
@@ -10,6 +11,25 @@ const whole = (data, name) => Number(String(data.get(name) ?? "").trim());
|
|
|
10
11
|
* @returns Something like `7 µL`.
|
|
11
12
|
*/
|
|
12
13
|
export const amountOf = (item) => `${item.amount}${item.unit === null ? "" : ` ${item.unit}`}`;
|
|
14
|
+
/**
|
|
15
|
+
* Where a tube came from, if a run made it.
|
|
16
|
+
*
|
|
17
|
+
* @param item - The tube.
|
|
18
|
+
* @param lab - The lab's runs, items and parts.
|
|
19
|
+
* @returns Something like `made by a PCR from pWren-402, fwd-1 and rev-1`, or `null` for a tube
|
|
20
|
+
* that was simply added.
|
|
21
|
+
*/
|
|
22
|
+
export function madeFrom(item, lab) {
|
|
23
|
+
const run = item.from === null ? undefined : lab.runs.find((one) => one.run === item.from);
|
|
24
|
+
if (run === undefined)
|
|
25
|
+
return null;
|
|
26
|
+
const names = run.inputs.map((input) => {
|
|
27
|
+
const tube = lab.items.find((one) => one.item === input.item);
|
|
28
|
+
return lab.parts.find((part) => part.checksum === tube?.part)?.name ?? "a tube";
|
|
29
|
+
});
|
|
30
|
+
const from = names.length === 0 ? "" : ` from ${names.length === 1 ? names[0] : `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`}`;
|
|
31
|
+
return `made by ${run.kind === "pcr" ? "a PCR" : `a ${run.kind} run`}${from}`;
|
|
32
|
+
}
|
|
13
33
|
/** Every part with its tubes, and a form to add a part. Draws nothing until the lab has arrived. */
|
|
14
34
|
export function Freezer() {
|
|
15
35
|
const lab = useLab()?.lab;
|
|
@@ -22,11 +42,13 @@ export function Freezer() {
|
|
|
22
42
|
export function PartCard({ part, items }) {
|
|
23
43
|
const act = useAct();
|
|
24
44
|
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" })] })] }));
|
|
45
|
+
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
46
|
}
|
|
27
47
|
/** One tube: how much there is, and the ways to change that. */
|
|
28
48
|
export function ItemRow({ item }) {
|
|
29
49
|
const act = useAct();
|
|
30
|
-
|
|
50
|
+
const lab = useLab()?.lab;
|
|
51
|
+
const origin = lab === null || lab === undefined ? null : madeFrom(item, lab);
|
|
52
|
+
return (_jsxs("tr", { className: item.needsRecount ? "flagged" : undefined, children: [_jsxs("td", { children: [_jsxs("code", { children: [item.item.slice(0, 10), "\u2026"] }), origin !== null && _jsx("div", { className: "dim small origin", children: origin })] }), _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
53
|
}
|
|
32
54
|
//# 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;;
|
|
1
|
+
{"version":3,"file":"freezer.js","sourceRoot":"","sources":["../src/freezer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAKb,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,GAA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EAAE,EAAE,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,SAAS,EAAC,WAAW,aACpG,gBAAO,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAE,CAAC,EAAE,WAAW,EAAC,QAAG,EAAC,QAAQ,QAAC,SAAS,EAAC,KAAK,gBAAY,WAAW,GAAG,EAC1G,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,OAAO,sBAAe,IAClD,IACF,GACH,EACL,uBACE,MAAC,GAAG,IAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,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,CA8CvJ;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,27 @@ 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
|
+
}
|
|
45
|
+
case "run.record": {
|
|
46
|
+
const made = Array.isArray(op["outputs"]) ? op["outputs"] : [];
|
|
47
|
+
const at = op["instrument"] === null ? "" : ` at ${place(op["instrument"])}`;
|
|
48
|
+
if (op["kind"] === "digest") {
|
|
49
|
+
const settings = (typeof op["settings"] === "object" && op["settings"] !== null ? op["settings"] : {});
|
|
50
|
+
const cut = Array.isArray(op["inputs"]) ? tube(op["inputs"][0]?.item) : "a tube";
|
|
51
|
+
const enzymes = typeof settings["enzymes"] === "string" ? ` with ${settings["enzymes"].replace(/\+/g, " and ")}` : "";
|
|
52
|
+
return `digested ${cut}${enzymes}${at}: the gel ${op["outcome"] === "worked" ? "matched" : "did not match"}`;
|
|
53
|
+
}
|
|
54
|
+
const what = op["kind"] === "pcr" ? "a PCR" : `a ${String(op["kind"])} run`;
|
|
55
|
+
return op["outcome"] === "worked" ? `ran ${what}${at}, which made ${made.map((one) => String(one.name)).join(" and ") || "nothing"}` : `ran ${what}${at}, which did not work`;
|
|
56
|
+
}
|
|
34
57
|
case "field.set": return `set ${String(op["field"])} to ${String(op["value"])}`;
|
|
35
58
|
default: return `did something this version does not know (${op.type})`;
|
|
36
59
|
}
|
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;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAA4B,EAAE,GAAmF;IAC7I,MA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;;;;;;;;;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,uCA8CrB"}
|
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, BackUpLab } 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, {}), _jsx(BackUpLab, {})] }));
|
|
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;AAE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,CAC5B,eAAK,SAAS,EAAC,QAAQ,aACrB,0BAAK,eAAM,SAAS,EAAC,OAAO,wCAA+B,EAAA,KAAC,IAAI,IAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAC,iBAAiB,GAAG,IAAM,EAC3H,eAAM,SAAS,EAAC,MAAM,YAAE,KAAK,CAAC,IAAI,CAAC,MAAM,GAAQ,IAC7C,CACP,CAAC,CAAC,CAAC,YAAG,SAAS,EAAC,WAAW,oFAAwE,IAC5F,CACX,CAAC,CAAC,CAAC,YAAG,SAAS,EAAC,WAAW,4DAAgD,EAC5E,KAAC,SAAS,KAAG,EACb,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
|