@copilotz/work 0.0.0-stage → 1.0.0-rc.35
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/LICENSE +21 -0
- package/README.md +56 -2
- package/boards/actions/create-board.d.ts +1 -0
- package/boards/actions/create-board.js +47 -0
- package/boards/actions/create-card.d.ts +1 -0
- package/boards/actions/create-card.js +83 -0
- package/boards/actions/delete-board.d.ts +1 -0
- package/boards/actions/delete-board.js +30 -0
- package/boards/actions/delete-card.d.ts +1 -0
- package/boards/actions/delete-card.js +24 -0
- package/boards/actions/move-card.d.ts +1 -0
- package/boards/actions/move-card.js +85 -0
- package/boards/actions/update-board.d.ts +1 -0
- package/boards/actions/update-board.js +110 -0
- package/boards/actions/update-card.d.ts +1 -0
- package/boards/actions/update-card.js +67 -0
- package/boards/collections/board.d.ts +71 -0
- package/boards/collections/board.js +32 -0
- package/boards/collections/card.d.ts +74 -0
- package/boards/collections/card.js +29 -0
- package/boards/contract.d.ts +67 -0
- package/boards/contract.js +20 -0
- package/boards/mod.d.ts +34 -0
- package/boards/mod.js +72 -0
- package/boards/resources/tools.d.ts +2 -0
- package/boards/resources/tools.js +414 -0
- package/boards/shared/columns.d.ts +39 -0
- package/boards/shared/columns.js +88 -0
- package/boards/shared/dates.d.ts +11 -0
- package/boards/shared/dates.js +22 -0
- package/boards/shared/errors.d.ts +24 -0
- package/boards/shared/errors.js +20 -0
- package/boards/shared/fields.d.ts +65 -0
- package/boards/shared/fields.js +44 -0
- package/boards/shared/load.d.ts +22 -0
- package/boards/shared/load.js +32 -0
- package/boards/shared/order.d.ts +30 -0
- package/boards/shared/order.js +47 -0
- package/boards/shared/people.d.ts +30 -0
- package/boards/shared/people.js +87 -0
- package/boards/shared/said.d.ts +28 -0
- package/boards/shared/said.js +30 -0
- package/boards/views/web/board-head.d.ts +62 -0
- package/boards/views/web/board-head.js +170 -0
- package/boards/views/web/board-page.d.ts +17 -0
- package/boards/views/web/board-page.js +97 -0
- package/boards/views/web/board-view.d.ts +40 -0
- package/boards/views/web/board-view.js +341 -0
- package/boards/views/web/boards-tab.d.ts +13 -0
- package/boards/views/web/boards-tab.js +109 -0
- package/boards/views/web/card-sheet.d.ts +47 -0
- package/boards/views/web/card-sheet.js +314 -0
- package/boards/views/web/card-tile.d.ts +29 -0
- package/boards/views/web/card-tile.js +20 -0
- package/boards/views/web/column.d.ts +38 -0
- package/boards/views/web/column.js +171 -0
- package/boards/views/web/drag.d.ts +36 -0
- package/boards/views/web/drag.js +276 -0
- package/boards/views/web/glyphs.d.ts +29 -0
- package/boards/views/web/glyphs.js +25 -0
- package/boards/views/web/load.d.ts +32 -0
- package/boards/views/web/load.js +33 -0
- package/boards/views/web/palette.d.ts +15 -0
- package/boards/views/web/palette.js +180 -0
- package/boards/views/web/pickers.d.ts +45 -0
- package/boards/views/web/pickers.js +83 -0
- package/boards/views/web/shown.d.ts +77 -0
- package/boards/views/web/shown.js +136 -0
- package/boards/views/web/step.d.ts +13 -0
- package/boards/views/web/step.js +41 -0
- package/boards/views/web/style.d.ts +10 -0
- package/boards/views/web/style.js +380 -0
- package/boards/views/web/toolbar.d.ts +21 -0
- package/boards/views/web/toolbar.js +39 -0
- package/boards/web.d.ts +26 -0
- package/boards/web.js +52 -0
- package/contract.d.ts +7 -0
- package/contract.js +7 -0
- package/documents/actions/create.d.ts +1 -0
- package/documents/actions/create.js +28 -0
- package/documents/actions/delete.d.ts +1 -0
- package/documents/actions/delete.js +32 -0
- package/documents/actions/presence.d.ts +1 -0
- package/documents/actions/presence.js +45 -0
- package/documents/actions/rename.d.ts +1 -0
- package/documents/actions/rename.js +33 -0
- package/documents/actions/restore.d.ts +1 -0
- package/documents/actions/restore.js +39 -0
- package/documents/actions/save.d.ts +1 -0
- package/documents/actions/save.js +78 -0
- package/documents/collections/document-presence.d.ts +79 -0
- package/documents/collections/document-presence.js +25 -0
- package/documents/collections/document-version.d.ts +166 -0
- package/documents/collections/document-version.js +60 -0
- package/documents/collections/document.d.ts +131 -0
- package/documents/collections/document.js +72 -0
- package/documents/contract.d.ts +17 -0
- package/documents/contract.js +1 -0
- package/documents/mod.d.ts +38 -0
- package/documents/mod.js +75 -0
- package/documents/resources/tools.d.ts +2 -0
- package/documents/resources/tools.js +253 -0
- package/documents/shared/diff.d.ts +37 -0
- package/documents/shared/diff.js +148 -0
- package/documents/shared/merge.d.ts +29 -0
- package/documents/shared/merge.js +120 -0
- package/documents/shared/presence.d.ts +7 -0
- package/documents/shared/presence.js +7 -0
- package/documents/shared/text.d.ts +36 -0
- package/documents/shared/text.js +67 -0
- package/documents/shared/who.d.ts +23 -0
- package/documents/shared/who.js +39 -0
- package/documents/shared/write.d.ts +54 -0
- package/documents/shared/write.js +123 -0
- package/documents/views/web/changes.d.ts +22 -0
- package/documents/views/web/changes.js +57 -0
- package/documents/views/web/conflict.d.ts +38 -0
- package/documents/views/web/conflict.js +96 -0
- package/documents/views/web/draft.d.ts +18 -0
- package/documents/views/web/draft.js +32 -0
- package/documents/views/web/editor.d.ts +57 -0
- package/documents/views/web/editor.js +268 -0
- package/documents/views/web/format.d.ts +56 -0
- package/documents/views/web/format.js +245 -0
- package/documents/views/web/history.d.ts +23 -0
- package/documents/views/web/history.js +118 -0
- package/documents/views/web/list.d.ts +37 -0
- package/documents/views/web/list.js +211 -0
- package/documents/views/web/page.d.ts +35 -0
- package/documents/views/web/page.js +416 -0
- package/documents/views/web/palette.d.ts +16 -0
- package/documents/views/web/palette.js +168 -0
- package/documents/views/web/people.d.ts +60 -0
- package/documents/views/web/people.js +63 -0
- package/documents/views/web/presence.d.ts +30 -0
- package/documents/views/web/presence.js +75 -0
- package/documents/views/web/step.d.ts +25 -0
- package/documents/views/web/step.js +81 -0
- package/documents/views/web/style.d.ts +7 -0
- package/documents/views/web/style.js +266 -0
- package/documents/web.d.ts +18 -0
- package/documents/web.js +46 -0
- package/mod.d.ts +18 -0
- package/mod.js +18 -0
- package/package.json +61 -4
- package/web.d.ts +13 -0
- package/web.js +13 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A card's details, over the board: a dialog, or a sheet from the bottom on
|
|
3
|
+
* a phone. Its title (changed in place), its column, owner (the space's
|
|
4
|
+
* people and agents), labels and due date, each saved as it's chosen; its
|
|
5
|
+
* description, Markdown, written and previewed; who made it and who changed
|
|
6
|
+
* it last; deleting it, after a question. Live: what others change shows at
|
|
7
|
+
* once, and what you're writing stays yours until you save it.
|
|
8
|
+
*
|
|
9
|
+
* Making a card is the same sheet with nothing saved until "Create card".
|
|
10
|
+
*/
|
|
11
|
+
import { type ReactNode } from "react";
|
|
12
|
+
import type { Board, Card } from "../../contract.js";
|
|
13
|
+
import { type Names, type Someone, type Team } from "./shown.js";
|
|
14
|
+
type Call = <R = unknown>(action: string, input?: unknown) => Promise<R>;
|
|
15
|
+
/** The key that sends with Enter: ⌘ on Apple's, Ctrl elsewhere. */
|
|
16
|
+
export declare const MOD: string;
|
|
17
|
+
/** Whether the screen is a phone's: sheets come from the bottom there. */
|
|
18
|
+
export declare const usePhone: () => boolean;
|
|
19
|
+
/** A dialog, or on a phone a sheet from the bottom. */
|
|
20
|
+
export declare function Sheet({ open, onClose, label, children }: {
|
|
21
|
+
open: boolean;
|
|
22
|
+
onClose(): void;
|
|
23
|
+
label: string;
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
}): ReactNode;
|
|
26
|
+
export declare function CardSheet({ board, card, column: startIn, people, team, names, me, labels, today, can, space, call, onClose, onMove, }: {
|
|
27
|
+
board: Board;
|
|
28
|
+
/** The card, live; none to make one. */
|
|
29
|
+
card?: Card;
|
|
30
|
+
/** Where a new card starts. */
|
|
31
|
+
column?: string;
|
|
32
|
+
people: Someone[];
|
|
33
|
+
team?: Team;
|
|
34
|
+
/** People's names by id (their profiles'): who made and changed it, too. */
|
|
35
|
+
names?: Names;
|
|
36
|
+
me?: string;
|
|
37
|
+
/** The board's labels, to choose from. */
|
|
38
|
+
labels: string[];
|
|
39
|
+
today: string;
|
|
40
|
+
can: boolean;
|
|
41
|
+
space?: string;
|
|
42
|
+
call: Call;
|
|
43
|
+
onClose(): void;
|
|
44
|
+
/** Moves the card to a column, the way the board does it (at its bottom). */
|
|
45
|
+
onMove(card: Card, column: string, at?: "top" | "bottom"): Promise<void>;
|
|
46
|
+
}): ReactNode;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A card's details, over the board: a dialog, or a sheet from the bottom on
|
|
4
|
+
* a phone. Its title (changed in place), its column, owner (the space's
|
|
5
|
+
* people and agents), labels and due date, each saved as it's chosen; its
|
|
6
|
+
* description, Markdown, written and previewed; who made it and who changed
|
|
7
|
+
* it last; deleting it, after a question. Live: what others change shows at
|
|
8
|
+
* once, and what you're writing stays yours until you save it.
|
|
9
|
+
*
|
|
10
|
+
* Making a card is the same sheet with nothing saved until "Create card".
|
|
11
|
+
*/
|
|
12
|
+
import { useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
13
|
+
import { Button, Dialog, Drawer, Icon, IconButton, Input, Kbd, Markdown, Menu, message, Tabs, Textarea, Time, } from "copilotz/web";
|
|
14
|
+
import { boardPath } from "../../contract.js";
|
|
15
|
+
import { stageOf } from "../../shared/columns.js";
|
|
16
|
+
import { Glyph, StageMark } from "./glyphs.js";
|
|
17
|
+
import { AssigneePicker, Face, LabelPicker } from "./pickers.js";
|
|
18
|
+
import { dayOf, dueShown, hueOf, someoneOf } from "./shown.js";
|
|
19
|
+
/** The key that sends with Enter: ⌘ on Apple's, Ctrl elsewhere. */
|
|
20
|
+
export const MOD = /Mac|iP(hone|ad|od)/.test(globalThis.navigator?.platform ?? "") ? "⌘" : "Ctrl";
|
|
21
|
+
const PHONE = "(max-width: 640px)";
|
|
22
|
+
const phone = {
|
|
23
|
+
subscribe(changed) {
|
|
24
|
+
const query = matchMedia(PHONE);
|
|
25
|
+
query.addEventListener("change", changed);
|
|
26
|
+
return () => query.removeEventListener("change", changed);
|
|
27
|
+
},
|
|
28
|
+
matches: () => matchMedia(PHONE).matches,
|
|
29
|
+
};
|
|
30
|
+
/** Whether the screen is a phone's: sheets come from the bottom there. */
|
|
31
|
+
export const usePhone = () => useSyncExternalStore(phone.subscribe, phone.matches, () => false);
|
|
32
|
+
/** A dialog, or on a phone a sheet from the bottom. */
|
|
33
|
+
export function Sheet({ open, onClose, label, children }) {
|
|
34
|
+
const narrow = usePhone();
|
|
35
|
+
return narrow
|
|
36
|
+
? (_jsx(Drawer, { open: open, onClose: onClose, side: "bottom", label: label, children: children }))
|
|
37
|
+
: (_jsx(Dialog, { open: open, onClose: onClose, label: label, size: "lg", bare: true, children: children }));
|
|
38
|
+
}
|
|
39
|
+
const draftOf = (card) => ({
|
|
40
|
+
title: card.title,
|
|
41
|
+
column: card.column,
|
|
42
|
+
description: card.description ?? "",
|
|
43
|
+
...(card.assignee ? { assignee: card.assignee } : {}),
|
|
44
|
+
labels: card.labels ?? [],
|
|
45
|
+
...(card.due ? { due: card.due } : {}),
|
|
46
|
+
});
|
|
47
|
+
export function CardSheet({ board, card, column: startIn, people, team, names, me, labels, today, can, space, call, onClose, onMove, }) {
|
|
48
|
+
const making = !card;
|
|
49
|
+
const [draft, setDraft] = useState(() => card ? draftOf(card) : {
|
|
50
|
+
title: "",
|
|
51
|
+
column: startIn ?? board.columns[0]?.id ?? "",
|
|
52
|
+
description: "",
|
|
53
|
+
labels: [],
|
|
54
|
+
});
|
|
55
|
+
const [writing, setWriting] = useState(false);
|
|
56
|
+
const [tab, setTab] = useState("write");
|
|
57
|
+
const [error, setError] = useState();
|
|
58
|
+
const [busy, setBusy] = useState(false);
|
|
59
|
+
const [deleting, setDeleting] = useState(false);
|
|
60
|
+
const titleRef = useRef(null);
|
|
61
|
+
/** Escape in the title puts it back: the blur that follows saves nothing. */
|
|
62
|
+
const reverting = useRef(false);
|
|
63
|
+
// Others' changes show at once, except in what's being written here.
|
|
64
|
+
const live = card ? draftOf(card) : undefined;
|
|
65
|
+
const shown = live
|
|
66
|
+
? {
|
|
67
|
+
...live,
|
|
68
|
+
title: titleRef.current === document.activeElement ? draft.title : live.title,
|
|
69
|
+
description: writing ? draft.description : live.description,
|
|
70
|
+
}
|
|
71
|
+
: draft;
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (live && titleRef.current !== document.activeElement) {
|
|
74
|
+
setDraft((d) => ({ ...d, title: live.title }));
|
|
75
|
+
}
|
|
76
|
+
}, [live?.title]);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
// Drawn before its dialog opened, the title measured nothing: it grows to its text once shown.
|
|
79
|
+
requestAnimationFrame(() => {
|
|
80
|
+
const field = titleRef.current;
|
|
81
|
+
if (!field)
|
|
82
|
+
return;
|
|
83
|
+
field.style.height = "auto";
|
|
84
|
+
field.style.height = `${field.scrollHeight}px`;
|
|
85
|
+
if (making)
|
|
86
|
+
field.focus();
|
|
87
|
+
});
|
|
88
|
+
}, []);
|
|
89
|
+
const column = board.columns.find((c) => c.id === shown.column) ?? board.columns[0];
|
|
90
|
+
const owner = shown.assignee
|
|
91
|
+
? people.find((p) => p.key === shown.assignee) ??
|
|
92
|
+
someoneOf(shown.assignee, team, me, names)
|
|
93
|
+
: undefined;
|
|
94
|
+
/** Saves a change to a card at once; a new card keeps it in its draft. */
|
|
95
|
+
const save = async (change) => {
|
|
96
|
+
setError(undefined);
|
|
97
|
+
if (making)
|
|
98
|
+
return setDraft((d) => ({ ...d, ...change }));
|
|
99
|
+
try {
|
|
100
|
+
await call("card.update", { card: card._id, ...change });
|
|
101
|
+
}
|
|
102
|
+
catch (e) {
|
|
103
|
+
setError(message(e));
|
|
104
|
+
throw e;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const set = (change) => void save(change).catch(() => { });
|
|
108
|
+
const saveTitle = async () => {
|
|
109
|
+
const title = draft.title.trim();
|
|
110
|
+
if (reverting.current) {
|
|
111
|
+
reverting.current = false;
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (making || !card)
|
|
115
|
+
return;
|
|
116
|
+
if (!title)
|
|
117
|
+
return setDraft((d) => ({ ...d, title: card.title }));
|
|
118
|
+
if (title !== card.title)
|
|
119
|
+
await save({ title }).catch(() => { });
|
|
120
|
+
};
|
|
121
|
+
const create = async () => {
|
|
122
|
+
const title = draft.title.trim();
|
|
123
|
+
if (!title || busy) {
|
|
124
|
+
titleRef.current?.focus();
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
setBusy(true);
|
|
128
|
+
setError(undefined);
|
|
129
|
+
try {
|
|
130
|
+
await call("card.create", {
|
|
131
|
+
board: board._id,
|
|
132
|
+
title,
|
|
133
|
+
column: draft.column,
|
|
134
|
+
...(draft.description.trim() ? { description: draft.description } : {}),
|
|
135
|
+
...(draft.assignee ? { assignee: draft.assignee } : {}),
|
|
136
|
+
...(draft.labels.length ? { labels: draft.labels } : {}),
|
|
137
|
+
...(draft.due ? { due: draft.due } : {}),
|
|
138
|
+
});
|
|
139
|
+
onClose();
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
setError(message(e));
|
|
143
|
+
setBusy(false);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const saveDescription = async () => {
|
|
147
|
+
if (making)
|
|
148
|
+
return setWriting(false);
|
|
149
|
+
setBusy(true);
|
|
150
|
+
try {
|
|
151
|
+
await save({ description: draft.description.trim() ? draft.description : null });
|
|
152
|
+
setWriting(false);
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
// Said already.
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
setBusy(false);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const remove = async () => {
|
|
162
|
+
if (!card)
|
|
163
|
+
return;
|
|
164
|
+
setBusy(true);
|
|
165
|
+
try {
|
|
166
|
+
await call("card.delete", { card: card._id });
|
|
167
|
+
onClose();
|
|
168
|
+
}
|
|
169
|
+
catch (e) {
|
|
170
|
+
setError(message(e));
|
|
171
|
+
setBusy(false);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
const moveTo = (to) => {
|
|
175
|
+
if (making)
|
|
176
|
+
return setDraft((d) => ({ ...d, column: to.id }));
|
|
177
|
+
if (to.id === card.column)
|
|
178
|
+
return;
|
|
179
|
+
void onMove(card, to.id).catch((e) => setError(message(e)));
|
|
180
|
+
};
|
|
181
|
+
const columnItems = board.columns.map((c) => ({
|
|
182
|
+
label: c.name,
|
|
183
|
+
...(c.id === shown.column ? { icon: "check" } : {}),
|
|
184
|
+
onSelect: () => moveTo(c),
|
|
185
|
+
}));
|
|
186
|
+
const more = card
|
|
187
|
+
? [
|
|
188
|
+
{
|
|
189
|
+
label: "Copy link",
|
|
190
|
+
icon: "copy",
|
|
191
|
+
onSelect: () => void navigator.clipboard?.writeText(new URL(boardPath(board._id, space, card._id), location.href).href),
|
|
192
|
+
},
|
|
193
|
+
...(can
|
|
194
|
+
? [
|
|
195
|
+
{
|
|
196
|
+
label: "Move to the top",
|
|
197
|
+
icon: "send",
|
|
198
|
+
onSelect: () => void onMove(card, card.column, "top"),
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
label: "Move to the bottom",
|
|
202
|
+
icon: "down",
|
|
203
|
+
onSelect: () => void onMove(card, card.column, "bottom"),
|
|
204
|
+
},
|
|
205
|
+
"separator",
|
|
206
|
+
{
|
|
207
|
+
label: "Delete card…",
|
|
208
|
+
icon: "trash",
|
|
209
|
+
tone: "destructive",
|
|
210
|
+
onSelect: () => setDeleting(true),
|
|
211
|
+
},
|
|
212
|
+
]
|
|
213
|
+
: []),
|
|
214
|
+
]
|
|
215
|
+
: [];
|
|
216
|
+
const due = shown.due ? dueShown(shown.due, today, stageOf(column) === "done") : undefined;
|
|
217
|
+
const editable = can;
|
|
218
|
+
return (_jsxs("div", { className: "card-sheet", children: [_jsxs("header", { className: "card-sheet-head", children: [_jsxs("span", { className: "card-sheet-where", children: [_jsx(Glyph, { name: "board", size: 15 }), _jsx("a", { href: boardPath(board._id, space), children: board.name }), making ? _jsx("span", { children: "\u00B7 New card" }) : null] }), _jsxs("span", { className: "card-sheet-head-end", children: [card ? _jsx(Menu, { label: "This card: more", align: "end", size: "sm", items: more }) : null, _jsx(IconButton, { icon: "close", label: "Close", size: "sm", onClick: onClose })] })] }), _jsxs("div", { className: "card-sheet-body", children: [_jsx(Textarea, { ref: titleRef, bare: true, autoGrow: true, rows: 1, maxLength: 300, className: "card-sheet-title", "aria-label": "The card's title", placeholder: making ? "What's the outcome?" : "Title", readOnly: !editable, value: shown.title, onChange: (event) => setDraft((d) => ({ ...d, title: event.target.value.replace(/\n/g, " ") })), onBlur: () => void saveTitle(), onKeyDown: (event) => {
|
|
219
|
+
if (event.key === "Enter") {
|
|
220
|
+
event.preventDefault();
|
|
221
|
+
if (making && (event.metaKey || event.ctrlKey))
|
|
222
|
+
void create();
|
|
223
|
+
else if (making) {
|
|
224
|
+
document.querySelector(".card-props .card-prop")?.focus();
|
|
225
|
+
}
|
|
226
|
+
else
|
|
227
|
+
event.currentTarget.blur();
|
|
228
|
+
}
|
|
229
|
+
if (event.key === "Escape" && !making && card && draft.title !== card.title) {
|
|
230
|
+
event.preventDefault();
|
|
231
|
+
event.stopPropagation();
|
|
232
|
+
reverting.current = true;
|
|
233
|
+
setDraft((d) => ({ ...d, title: card.title }));
|
|
234
|
+
event.currentTarget.blur();
|
|
235
|
+
}
|
|
236
|
+
} }), _jsxs("dl", { className: "card-props", children: [_jsxs("dt", { children: [_jsx(StageMark, { stage: stageOf(column), size: 14 }), "Column"] }), _jsx("dd", { children: editable
|
|
237
|
+
? (_jsx(Menu, { label: "Column", items: columnItems, trigger: (props) => (_jsxs("button", { type: "button", className: "card-prop", ...props, children: [_jsx("span", { children: column?.name }), _jsx(Icon, { name: "chevron-down", size: 14 })] })) }))
|
|
238
|
+
: _jsx("span", { children: column?.name }) }), _jsxs("dt", { children: [_jsx(Icon, { name: "person", size: 15 }), "Owner"] }), _jsx("dd", { children: editable
|
|
239
|
+
? (_jsx(AssigneePicker, { people: people, value: shown.assignee, onChange: (key) => set({ assignee: key }), trigger: (props) => (_jsxs("button", { type: "button", className: "card-prop", "data-empty": !owner || undefined, ...props, children: [_jsx(Face, { someone: owner, size: 22 }), _jsx("span", { children: owner?.name ?? "Nobody yet" })] })) }))
|
|
240
|
+
: (_jsxs("span", { className: "card-prop", children: [_jsx(Face, { someone: owner, size: 22 }), _jsx("span", { children: owner?.name ?? "Nobody yet" })] })) }), _jsxs("dt", { children: [_jsx(Glyph, { name: "label", size: 15 }), "Labels"] }), _jsx("dd", { children: _jsxs("span", { className: "card-prop-labels", children: [shown.labels.map((label) => (_jsxs("span", { className: "board-label", "data-hue": hueOf(label), children: [_jsx("span", { children: label }), editable
|
|
241
|
+
? (_jsx("button", { type: "button", className: "card-label-x", "aria-label": `Take off “${label}”`, onClick: () => set({
|
|
242
|
+
labels: shown.labels.filter((l) => l !== label).length
|
|
243
|
+
? shown.labels.filter((l) => l !== label)
|
|
244
|
+
: making
|
|
245
|
+
? []
|
|
246
|
+
: null,
|
|
247
|
+
}), children: _jsx(Icon, { name: "close", size: 11 }) }))
|
|
248
|
+
: null] }, label))), editable
|
|
249
|
+
? (_jsx(LabelPicker, { known: labels, value: shown.labels, onChange: (next) => set({ labels: next.length ? next : making ? [] : null }), trigger: (props) => (_jsxs("button", { type: "button", className: "card-prop", "data-empty": !shown.labels.length || undefined, "aria-label": shown.labels.length ? "Change labels" : "Add labels", ...props, children: [_jsx(Icon, { name: "plus", size: 14 }), shown.labels.length ? null : _jsx("span", { children: "Add labels" })] })) }))
|
|
250
|
+
: shown.labels.length
|
|
251
|
+
? null
|
|
252
|
+
: _jsx("span", { className: "card-due-said", children: "None" })] }) }), _jsxs("dt", { children: [_jsx(Glyph, { name: "calendar", size: 15 }), "Due"] }), _jsxs("dd", { className: "card-due", children: [editable
|
|
253
|
+
? (_jsx(Input, { type: "date", size: "sm", "aria-label": "Due date", value: shown.due ?? "", onChange: (event) => set({ due: event.target.value || (making ? undefined : null) }), end: shown.due
|
|
254
|
+
? (_jsx(IconButton, { icon: "close", label: "Clear the due date", size: "sm", onClick: () => set({ due: making ? undefined : null }) }))
|
|
255
|
+
: undefined }))
|
|
256
|
+
: _jsx("span", { children: shown.due ? dayOf(shown.due, today) : "None" }), due ? _jsx("span", { className: "card-due-said", "data-tone": due.tone, children: due.title }) : null] })] }), _jsxs("section", { className: "card-desc", "aria-labelledby": "card-desc-title", children: [_jsxs("div", { className: "card-desc-head", children: [_jsx("h3", { id: "card-desc-title", children: "Description" }), writing
|
|
257
|
+
? (_jsx(Tabs, { label: "Write or preview", value: tab, onChange: setTab, tabs: [{ value: "write", label: "Write" }, {
|
|
258
|
+
value: "preview",
|
|
259
|
+
label: "Preview",
|
|
260
|
+
}] }))
|
|
261
|
+
: null] }), writing || (making && editable)
|
|
262
|
+
? (_jsxs(_Fragment, { children: [tab === "write" || !writing
|
|
263
|
+
? (_jsx(Textarea, { autoGrow: true, maxHeight: 420, rows: making ? 3 : 6, maxLength: 20000, "aria-label": "The card's description", placeholder: "What's the outcome? How will we know it's done? What blocks it? (Markdown)", value: draft.description, autoFocus: !making, onFocus: () => making && setWriting(true), onChange: (event) => {
|
|
264
|
+
const description = event.target.value;
|
|
265
|
+
setDraft((d) => ({ ...d, description }));
|
|
266
|
+
}, onKeyDown: (event) => {
|
|
267
|
+
if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
|
|
268
|
+
event.preventDefault();
|
|
269
|
+
if (making)
|
|
270
|
+
void create();
|
|
271
|
+
else
|
|
272
|
+
void saveDescription();
|
|
273
|
+
}
|
|
274
|
+
if (event.key === "Escape" && !making) {
|
|
275
|
+
event.preventDefault();
|
|
276
|
+
event.stopPropagation();
|
|
277
|
+
setDraft((d) => ({ ...d, description: card?.description ?? "" }));
|
|
278
|
+
setWriting(false);
|
|
279
|
+
}
|
|
280
|
+
} }))
|
|
281
|
+
: (_jsx("div", { className: "card-desc-preview", children: draft.description.trim()
|
|
282
|
+
? _jsx(Markdown, { text: draft.description })
|
|
283
|
+
: _jsx("p", { className: "card-due-said", children: "Nothing to preview yet." }) })), !making
|
|
284
|
+
? (_jsxs("div", { className: "card-desc-end", children: [_jsxs("span", { className: "board-quick-hint", children: [_jsx(Kbd, { children: MOD }), _jsx(Kbd, { children: "Enter" }), " saves \u00B7 Markdown works"] }), _jsx(Button, { size: "sm", variant: "ghost", onClick: () => {
|
|
285
|
+
setDraft((d) => ({ ...d, description: card?.description ?? "" }));
|
|
286
|
+
setWriting(false);
|
|
287
|
+
}, children: "Cancel" }), _jsx(Button, { size: "sm", variant: "primary", loading: busy, onClick: () => void saveDescription(), children: "Save" })] }))
|
|
288
|
+
: null] }))
|
|
289
|
+
: (_jsx("button", { type: "button", className: "card-desc-view", "data-empty": !shown.description.trim() || undefined, disabled: !editable, onClick: () => {
|
|
290
|
+
setDraft((d) => ({ ...d, description: card?.description ?? "" }));
|
|
291
|
+
setTab("write");
|
|
292
|
+
setWriting(true);
|
|
293
|
+
}, children: shown.description.trim()
|
|
294
|
+
? _jsx(Markdown, { text: shown.description })
|
|
295
|
+
: editable
|
|
296
|
+
? "Add a description: the outcome, how we'll know it's done, any blocker…"
|
|
297
|
+
: "No description." }))] }), error ? _jsx("p", { role: "alert", className: "card-sheet-error", children: error }) : null] }), _jsx("footer", { className: "card-sheet-foot", children: making
|
|
298
|
+
? (_jsxs(_Fragment, { children: [_jsx("span", { className: "card-sheet-meta", children: _jsxs("span", { className: "board-quick-hint", children: [_jsx(Kbd, { children: MOD }), _jsx(Kbd, { children: "Enter" }), " creates it"] }) }), _jsxs("span", { className: "card-sheet-end", children: [_jsx(Button, { variant: "ghost", onClick: onClose, children: "Cancel" }), _jsx(Button, { variant: "primary", loading: busy, disabled: !draft.title.trim(), onClick: () => void create(), children: "Create card" })] })] }))
|
|
299
|
+
: deleting
|
|
300
|
+
? (_jsxs(_Fragment, { children: [_jsxs("span", { className: "card-sheet-meta", children: ["Delete \u201C", card.title, "\u201D? It can't be brought back."] }), _jsxs("span", { className: "card-sheet-end", children: [_jsx(Button, { size: "sm", variant: "ghost", onClick: () => setDeleting(false), children: "Keep it" }), _jsx(Button, { size: "sm", variant: "destructive", icon: "trash", loading: busy, onClick: () => void remove(), children: "Delete" })] })] }))
|
|
301
|
+
: (_jsxs(_Fragment, { children: [_jsxs("span", { className: "card-sheet-meta", children: [_jsxs("span", { children: ["Made by ", who(card.by, team, me, names), " ", _jsx(Time, { at: card.at })] }), card.updated && card.updatedBy
|
|
302
|
+
? (_jsxs("span", { children: ["changed by ", who(card.updatedBy, team, me, names), " ", _jsx(Time, { at: card.updated })] }))
|
|
303
|
+
: null] }), can
|
|
304
|
+
? (_jsx("span", { className: "card-sheet-end", children: _jsx(Button, { size: "sm", variant: "ghost", icon: "trash", onClick: () => setDeleting(true), children: "Delete" }) }))
|
|
305
|
+
: null] })) })] }));
|
|
306
|
+
}
|
|
307
|
+
/** Who did something, as a sentence says it: "you", "North", "bob". */
|
|
308
|
+
function who(key, team, me, names) {
|
|
309
|
+
if (!key || key === "system")
|
|
310
|
+
return "the app";
|
|
311
|
+
if (key === `person:${me}`)
|
|
312
|
+
return "you";
|
|
313
|
+
return someoneOf(key, team, undefined, names).name;
|
|
314
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A card on a board: its labels, its title, when it's due (an overdue one
|
|
3
|
+
* says so, unless it's done), a mark when it has a description, and who
|
|
4
|
+
* owns it (a person's initial, an agent's emoji). It opens its details; it
|
|
5
|
+
* drags by pointer (a mouse at once, a finger after a short press); with the
|
|
6
|
+
* keyboard, Space picks it up and the arrows move it. Its menu: open it,
|
|
7
|
+
* move it (to a column, the top, the bottom), take it, delete it.
|
|
8
|
+
*/
|
|
9
|
+
import type { KeyboardEvent, PointerEvent, ReactNode } from "react";
|
|
10
|
+
import { type MenuItem } from "copilotz/web";
|
|
11
|
+
import type { Card } from "../../contract.js";
|
|
12
|
+
import { type Someone } from "./shown.js";
|
|
13
|
+
export declare function CardTile({ card, done, today, owner, lifted, held, busy, menu, describedBy, onOpen, onPress, onKeys, }: {
|
|
14
|
+
card: Card;
|
|
15
|
+
/** In a column of finished work: a past due date isn't overdue there. */
|
|
16
|
+
done: boolean;
|
|
17
|
+
today: string;
|
|
18
|
+
owner?: Someone;
|
|
19
|
+
/** Being dragged: the slot shows where it goes, so it hides here. */
|
|
20
|
+
lifted?: boolean;
|
|
21
|
+
/** Picked up with the keyboard. */
|
|
22
|
+
held?: boolean;
|
|
23
|
+
busy?: boolean;
|
|
24
|
+
menu?: (MenuItem | "separator")[];
|
|
25
|
+
describedBy?: string;
|
|
26
|
+
onOpen(): void;
|
|
27
|
+
onPress?(event: PointerEvent<HTMLElement>): void;
|
|
28
|
+
onKeys?(event: KeyboardEvent<HTMLElement>): void;
|
|
29
|
+
}): ReactNode;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar, Menu, Tooltip } from "copilotz/web";
|
|
3
|
+
import { Glyph } from "./glyphs.js";
|
|
4
|
+
import { dueShown, hueOf, says } from "./shown.js";
|
|
5
|
+
export function CardTile({ card, done, today, owner, lifted, held, busy, menu, describedBy, onOpen, onPress, onKeys, }) {
|
|
6
|
+
const due = card.due ? dueShown(card.due, today, done) : undefined;
|
|
7
|
+
return (_jsxs("li", { className: "board-card", "data-card": card._id, "data-lifted": lifted || undefined, "data-held": held || undefined, "data-busy": busy || undefined, onPointerDown: onPress, children: [_jsxs("button", { type: "button", className: "board-card-open", id: `card-${card._id}`, "aria-describedby": describedBy, "aria-pressed": held ? true : undefined, onClick: onOpen, onKeyDown: onKeys, children: [card.labels?.length
|
|
8
|
+
? (_jsx("span", { className: "board-card-labels", children: card.labels.map((label) => (_jsx("span", { className: "board-label", "data-hue": hueOf(label), children: _jsx("span", { children: label }) }, label))) }))
|
|
9
|
+
: null, _jsx("span", { className: "board-card-title", children: card.title }), due || says(card) || owner
|
|
10
|
+
? (_jsxs("span", { className: "board-card-meta", children: [due
|
|
11
|
+
? (_jsxs("span", { className: "board-due", "data-tone": due.tone, title: due.title, children: [_jsx(Glyph, { name: "calendar", size: 12 }), due.text, _jsxs("span", { className: "board-sr", children: [", ", due.title] })] }))
|
|
12
|
+
: null, says(card)
|
|
13
|
+
? (_jsxs("span", { className: "board-card-mark", title: "Has a description", children: [_jsx(Glyph, { name: "lines", size: 14 }), _jsx("span", { className: "board-sr", children: "Has a description." })] }))
|
|
14
|
+
: null, owner
|
|
15
|
+
? (_jsxs("span", { className: "board-card-who", children: [_jsx(Tooltip, { text: owner.name, describe: false, children: _jsx(Avatar, { name: owner.name, kind: owner.kind, icon: owner.icon, size: 22, title: owner.name }) }), _jsxs("span", { className: "board-sr", children: ["Owned by ", owner.name, "."] })] }))
|
|
16
|
+
: null] }))
|
|
17
|
+
: null] }), menu
|
|
18
|
+
? (_jsx("span", { className: "board-card-menu", "data-no-drag": true, children: _jsx(Menu, { label: `${card.title}: more`, align: "end", size: "sm", items: menu }) }))
|
|
19
|
+
: null] }));
|
|
20
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A board's column: its stage mark, its name (renamed in place by editors),
|
|
3
|
+
* how many cards it has (and how many show, when filtered), its menu (add a
|
|
4
|
+
* card, rename, move it left or right, remove it: at once when it's empty,
|
|
5
|
+
* or saying where its cards go), its cards, and a quick add at its foot. In
|
|
6
|
+
* a side panel it folds. And the board's last column: one to add.
|
|
7
|
+
*/
|
|
8
|
+
import { type ReactNode } from "react";
|
|
9
|
+
import type { Column } from "../../contract.js";
|
|
10
|
+
export declare function ColumnView({ column, index, columns, total, shown, can, compact, over, folded, onFold, adding, onAdding, onAdd, onChange, onRemove, children, }: {
|
|
11
|
+
column: Column;
|
|
12
|
+
index: number;
|
|
13
|
+
columns: Column[];
|
|
14
|
+
/** Its cards, and how many of them the filters show. */
|
|
15
|
+
total: number;
|
|
16
|
+
shown: number;
|
|
17
|
+
can: boolean;
|
|
18
|
+
compact: boolean;
|
|
19
|
+
/** A dragged card would land here. */
|
|
20
|
+
over: boolean;
|
|
21
|
+
folded: boolean;
|
|
22
|
+
onFold(): void;
|
|
23
|
+
/** The quick add at its foot is open. */
|
|
24
|
+
adding: boolean;
|
|
25
|
+
onAdding(open: boolean): void;
|
|
26
|
+
onAdd(title: string): Promise<void>;
|
|
27
|
+
/** The board's columns, changed: renamed or moved. */
|
|
28
|
+
onChange(columns: Column[]): Promise<unknown>;
|
|
29
|
+
/** Removes it, its cards going `into` another column. */
|
|
30
|
+
onRemove(into?: string): Promise<unknown>;
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
}): ReactNode;
|
|
33
|
+
/** The board's last column: a new one, named and added. */
|
|
34
|
+
export declare function NewColumn({ open, onOpen, onAdd }: {
|
|
35
|
+
open: boolean;
|
|
36
|
+
onOpen(open: boolean): void;
|
|
37
|
+
onAdd(name: string): Promise<unknown>;
|
|
38
|
+
}): ReactNode;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A board's column: its stage mark, its name (renamed in place by editors),
|
|
4
|
+
* how many cards it has (and how many show, when filtered), its menu (add a
|
|
5
|
+
* card, rename, move it left or right, remove it: at once when it's empty,
|
|
6
|
+
* or saying where its cards go), its cards, and a quick add at its foot. In
|
|
7
|
+
* a side panel it folds. And the board's last column: one to add.
|
|
8
|
+
*/
|
|
9
|
+
import { useEffect, useRef, useState } from "react";
|
|
10
|
+
import { Button, Icon, IconButton, InlineEdit, Input, Kbd, Menu, message, Select, Textarea, } from "copilotz/web";
|
|
11
|
+
import { stageOf } from "../../shared/columns.js";
|
|
12
|
+
import { Sheet } from "./card-sheet.js";
|
|
13
|
+
import { StageMark } from "./glyphs.js";
|
|
14
|
+
export function ColumnView({ column, index, columns, total, shown, can, compact, over, folded, onFold, adding, onAdding, onAdd, onChange, onRemove, children, }) {
|
|
15
|
+
const [renaming, setRenaming] = useState(false);
|
|
16
|
+
const [removing, setRemoving] = useState(false);
|
|
17
|
+
const [error, setError] = useState();
|
|
18
|
+
const counted = shown === total ? `${total}` : `${shown} of ${total}`;
|
|
19
|
+
const swap = (by) => {
|
|
20
|
+
const next = [...columns];
|
|
21
|
+
const [moved] = next.splice(index, 1);
|
|
22
|
+
next.splice(index + by, 0, moved);
|
|
23
|
+
void onChange(next).catch((e) => setError(message(e)));
|
|
24
|
+
};
|
|
25
|
+
const items = [
|
|
26
|
+
{ label: "Add a card", icon: "plus", onSelect: () => onAdding(true) },
|
|
27
|
+
{ label: "Rename", icon: "pencil", onSelect: () => setRenaming(true) },
|
|
28
|
+
...(index > 0
|
|
29
|
+
? [{
|
|
30
|
+
label: compact ? "Move up" : "Move left",
|
|
31
|
+
icon: "chevron-left",
|
|
32
|
+
onSelect: () => swap(-1),
|
|
33
|
+
}]
|
|
34
|
+
: []),
|
|
35
|
+
...(index < columns.length - 1
|
|
36
|
+
? [{
|
|
37
|
+
label: compact ? "Move down" : "Move right",
|
|
38
|
+
icon: "chevron",
|
|
39
|
+
onSelect: () => swap(1),
|
|
40
|
+
}]
|
|
41
|
+
: []),
|
|
42
|
+
...(columns.length > 1
|
|
43
|
+
? [
|
|
44
|
+
"separator",
|
|
45
|
+
{
|
|
46
|
+
label: total ? "Remove column…" : "Remove column",
|
|
47
|
+
icon: "trash",
|
|
48
|
+
tone: "destructive",
|
|
49
|
+
onSelect: () => total ? setRemoving(true) : void onRemove().catch((e) => setError(message(e))),
|
|
50
|
+
},
|
|
51
|
+
]
|
|
52
|
+
: []),
|
|
53
|
+
];
|
|
54
|
+
return (_jsxs("section", { className: "board-column", "data-column": column.id, "data-over": over || undefined, "aria-label": `${column.name}, ${counted} card${total === 1 ? "" : "s"}`, children: [_jsxs("header", { className: "board-column-head", children: [compact
|
|
55
|
+
? (_jsx("button", { type: "button", className: "board-fold", "aria-expanded": !folded, "aria-label": folded ? `Show ${column.name}` : `Fold ${column.name}`, onClick: onFold, children: _jsx(Icon, { name: "chevron-down", size: 15 }) }))
|
|
56
|
+
: null, _jsx(StageMark, { stage: stageOf(column) }), renaming
|
|
57
|
+
? (_jsx(InlineEdit, { className: "board-column-rename", label: "The column's name", value: column.name, maxLength: 40, size: "sm", save: (name) => onChange(columns.map((c) => c.id === column.id ? { ...c, name } : c)), done: () => setRenaming(false) }))
|
|
58
|
+
: can
|
|
59
|
+
? (_jsx("button", { type: "button", className: "board-column-name", title: "Rename", onClick: () => setRenaming(true), children: column.name }))
|
|
60
|
+
: _jsx("h3", { className: "board-column-name", children: column.name }), renaming ? null : _jsx("span", { className: "board-column-count", children: counted }), can && !renaming
|
|
61
|
+
? (_jsxs("span", { className: "board-column-tools", children: [_jsx(IconButton, { icon: "plus", label: `Add a card to ${column.name}`, size: "sm", onClick: () => onAdding(true) }), _jsx(Menu, { label: `${column.name}: more`, align: "end", size: "sm", items: items })] }))
|
|
62
|
+
: null] }), error ? _jsx("p", { role: "alert", className: "board-error board-column-error", children: error }) : null, children, can && !folded
|
|
63
|
+
? (_jsx("div", { className: "board-column-foot", children: adding
|
|
64
|
+
? _jsx(QuickAdd, { column: column, onAdd: onAdd, onClose: () => onAdding(false) })
|
|
65
|
+
: (_jsxs("button", { type: "button", className: "board-add", onClick: () => onAdding(true), children: [_jsx(Icon, { name: "plus", size: 15 }), "Add a card"] })) }))
|
|
66
|
+
: null, removing
|
|
67
|
+
? (_jsx(RemoveColumn, { column: column, columns: columns, total: total, onClose: () => setRemoving(false), onRemove: onRemove }))
|
|
68
|
+
: null] }));
|
|
69
|
+
}
|
|
70
|
+
/** A card's title typed at a column's foot: Enter adds it and keeps the field for the next. */
|
|
71
|
+
function QuickAdd({ column, onAdd, onClose }) {
|
|
72
|
+
const [title, setTitle] = useState("");
|
|
73
|
+
const [busy, setBusy] = useState(false);
|
|
74
|
+
const [error, setError] = useState();
|
|
75
|
+
const field = useRef(null);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
field.current?.focus();
|
|
78
|
+
field.current?.scrollIntoView({ block: "nearest" });
|
|
79
|
+
}, []);
|
|
80
|
+
const add = async () => {
|
|
81
|
+
const text = title.trim();
|
|
82
|
+
if (!text || busy)
|
|
83
|
+
return;
|
|
84
|
+
setBusy(true);
|
|
85
|
+
setError(undefined);
|
|
86
|
+
try {
|
|
87
|
+
await onAdd(text);
|
|
88
|
+
setTitle("");
|
|
89
|
+
requestAnimationFrame(() => field.current?.scrollIntoView({ block: "nearest" }));
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
setError(message(e));
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
setBusy(false);
|
|
96
|
+
field.current?.focus();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
return (_jsxs("div", { className: "board-quick", children: [_jsx(Textarea, { ref: field, bare: true, autoGrow: true, rows: 2, maxLength: 300, "aria-label": `A new card in ${column.name}`, placeholder: "What's the outcome?", value: title, onChange: (event) => setTitle(event.target.value.replace(/\n/g, " ")), onKeyDown: (event) => {
|
|
100
|
+
if (event.key === "Enter") {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
void add();
|
|
103
|
+
}
|
|
104
|
+
else if (event.key === "Escape") {
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
event.stopPropagation();
|
|
107
|
+
onClose();
|
|
108
|
+
}
|
|
109
|
+
}, onBlur: (event) => {
|
|
110
|
+
// Leaving it empty, for somewhere else on the page, closes it.
|
|
111
|
+
const to = event.relatedTarget;
|
|
112
|
+
if (!title.trim() && !event.currentTarget.closest(".board-quick")?.contains(to)) {
|
|
113
|
+
onClose();
|
|
114
|
+
}
|
|
115
|
+
} }), error ? _jsx("p", { role: "alert", className: "board-error", children: error }) : null, _jsxs("div", { className: "board-quick-end", children: [_jsxs("span", { className: "board-quick-hint", children: [_jsx(Kbd, { children: "Enter" }), " adds \u00B7 ", _jsx(Kbd, { children: "Esc" }), " closes"] }), _jsxs("span", { className: "board-quick-buttons", children: [_jsx(IconButton, { icon: "close", label: "Close", size: "sm", onClick: onClose }), _jsx(Button, { size: "sm", variant: "primary", loading: busy, disabled: !title.trim(), onClick: () => void add(), children: "Add" })] })] })] }));
|
|
116
|
+
}
|
|
117
|
+
/** Removing a column that has cards: where they go first. */
|
|
118
|
+
function RemoveColumn({ column, columns, total, onClose, onRemove }) {
|
|
119
|
+
const others = columns.filter((c) => c.id !== column.id);
|
|
120
|
+
const [into, setInto] = useState(others[0]?.id ?? "");
|
|
121
|
+
const [busy, setBusy] = useState(false);
|
|
122
|
+
const [error, setError] = useState();
|
|
123
|
+
return (_jsx(Sheet, { open: true, onClose: onClose, label: `Remove ${column.name}`, children: _jsxs("form", { className: "card-sheet", onSubmit: async (event) => {
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
setBusy(true);
|
|
126
|
+
setError(undefined);
|
|
127
|
+
try {
|
|
128
|
+
await onRemove(into);
|
|
129
|
+
onClose();
|
|
130
|
+
}
|
|
131
|
+
catch (e) {
|
|
132
|
+
setError(message(e));
|
|
133
|
+
setBusy(false);
|
|
134
|
+
}
|
|
135
|
+
}, children: [_jsxs("header", { className: "card-sheet-head", children: [_jsxs("span", { className: "card-sheet-where", children: [_jsx(StageMark, { stage: stageOf(column) }), "Remove \u201C", column.name, "\u201D"] }), _jsx("span", { className: "card-sheet-head-end", children: _jsx(IconButton, { icon: "close", label: "Close", size: "sm", onClick: onClose }) })] }), _jsxs("div", { className: "card-sheet-body", children: [_jsxs("p", { className: "card-sheet-say", children: ["It has ", total, " card", total === 1 ? "" : "s", ". Move ", total === 1 ? "it" : "them", " to:"] }), _jsx(Select, { value: into, onChange: (event) => setInto(event.target.value), "aria-label": "Where its cards go", children: others.map((c) => _jsx("option", { value: c.id, children: c.name }, c.id)) }), error ? _jsx("p", { role: "alert", className: "card-sheet-error", children: error }) : null] }), _jsxs("footer", { className: "card-sheet-foot", children: [_jsxs("span", { className: "card-sheet-meta", children: [total === 1 ? "It goes" : "They go", " to the bottom, in the order they're in."] }), _jsxs("span", { className: "card-sheet-end", children: [_jsx(Button, { variant: "ghost", onClick: onClose, children: "Cancel" }), _jsx(Button, { type: "submit", variant: "destructive", loading: busy, children: "Move and remove" })] })] })] }) }));
|
|
136
|
+
}
|
|
137
|
+
/** The board's last column: a new one, named and added. */
|
|
138
|
+
export function NewColumn({ open, onOpen, onAdd }) {
|
|
139
|
+
const [name, setName] = useState("");
|
|
140
|
+
const [busy, setBusy] = useState(false);
|
|
141
|
+
const [error, setError] = useState();
|
|
142
|
+
const box = useRef(null);
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
if (open)
|
|
145
|
+
box.current?.scrollIntoView({ inline: "end", block: "nearest", behavior: "smooth" });
|
|
146
|
+
}, [open]);
|
|
147
|
+
return (_jsx("div", { className: "board-new-column", ref: box, children: open
|
|
148
|
+
? (_jsxs("form", { onSubmit: async (event) => {
|
|
149
|
+
event.preventDefault();
|
|
150
|
+
if (!name.trim() || busy)
|
|
151
|
+
return;
|
|
152
|
+
setBusy(true);
|
|
153
|
+
setError(undefined);
|
|
154
|
+
try {
|
|
155
|
+
await onAdd(name.trim());
|
|
156
|
+
setName("");
|
|
157
|
+
}
|
|
158
|
+
catch (e) {
|
|
159
|
+
setError(message(e));
|
|
160
|
+
}
|
|
161
|
+
finally {
|
|
162
|
+
setBusy(false);
|
|
163
|
+
}
|
|
164
|
+
}, children: [_jsx(Input, { size: "sm", autoFocus: true, maxLength: 40, placeholder: "The column's name", "aria-label": "The new column's name", value: name, onChange: (event) => setName(event.target.value), onKeyDown: (event) => {
|
|
165
|
+
if (event.key === "Escape") {
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
onOpen(false);
|
|
168
|
+
}
|
|
169
|
+
} }), error ? _jsx("p", { role: "alert", className: "board-error", children: error }) : null, _jsxs("div", { className: "board-new-column-end", children: [_jsx(Button, { size: "sm", variant: "ghost", onClick: () => onOpen(false), children: "Cancel" }), _jsx(Button, { size: "sm", variant: "primary", type: "submit", loading: busy, disabled: !name.trim(), children: "Add column" })] })] }))
|
|
170
|
+
: (_jsxs("button", { type: "button", onClick: () => onOpen(true), children: [_jsx(Icon, { name: "plus", size: 16 }), "Add a column"] })) }));
|
|
171
|
+
}
|