@soffits/dsh-card-board 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +16 -3
- package/client.js +509 -122
- package/examples/boards/home/cards/countdown.json +9 -0
- package/index.js +2 -0
- package/locale/en.json +16 -1
- package/locale/fr.json +16 -1
- package/locale/zh.json +16 -1
- package/package.json +1 -1
- package/src/arrange-store.js +54 -0
- package/src/arrange.js +119 -0
- package/src/person-store.js +54 -0
- package/src/routes.js +31 -3
- package/src/schema.js +16 -1
- package/src/seen.js +7 -37
package/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @soffits/dsh-card-board 0.
|
|
1
|
+
/* @soffits/dsh-card-board 0.11.0: built by scripts/build.mjs from src/client/. Do not edit. */
|
|
2
2
|
window.__ModuleLoader__.load({
|
|
3
3
|
id: "@soffits/dsh-card-board",
|
|
4
4
|
factory: (require) => {
|
|
@@ -29,7 +29,7 @@ __export(index_exports, {
|
|
|
29
29
|
inject: () => inject
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(index_exports);
|
|
32
|
-
var
|
|
32
|
+
var import_react16 = require("react");
|
|
33
33
|
|
|
34
34
|
// src/client/look.js
|
|
35
35
|
var STYLE_ID = "dsh-card-board-style";
|
|
@@ -223,6 +223,25 @@ button.cb-cardOpen{border:0;background:transparent;padding:0;font:inherit;cursor
|
|
|
223
223
|
.cb-chips,.cb-summaryLine,.cb-summaryAside,.cb-cardHead,.cb-tabs,.cb-heading .cb-sub,.cb-rowMeta,.cb-rowActions,.cb-statLabel,.cb-strip,.cb-chart svg,.cb-legend,.cb-track b,.cb-more,.cb-doneBox,.cb-delta,.cb-when,.cb-progress small,.cb-bubble,.cb-page .uk-chip,.cb-page .uk-tile,.cb-page .uk-icon,.cb-page .uk-newDot,.cb-page .uk-justNow,.cb-page .uk-ringText small{-webkit-user-select:none;user-select:none}
|
|
224
224
|
.cb-cardHead h3{-webkit-user-select:text;user-select:text}
|
|
225
225
|
.cb-card svg,.cb-card img{-webkit-user-drag:none}
|
|
226
|
+
/* Arranging: a card's own place (drag, pin, move), and the cue on a card a producer has raised for now */
|
|
227
|
+
.cb-card{position:relative}
|
|
228
|
+
.cb-cardRaised{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dsw-alias-state-business-primary) 38%,transparent)}
|
|
229
|
+
.cb-raisedCue{flex:0 1 auto;min-width:0;display:inline-flex}
|
|
230
|
+
button.cb-cardMore{border:0;background:transparent;padding:0;font:inherit;cursor:pointer}
|
|
231
|
+
.cb-pinMark{flex:none;display:inline-flex;color:var(--dsw-alias-state-business-primary)}
|
|
232
|
+
.cb-cardMore.cb-open{background:var(--dsw-alias-interactive-bg-active,var(--dsw-alias-interactive-bg-hover));color:var(--dsw-alias-label-primary)}
|
|
233
|
+
.cb-cardMore:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
|
|
234
|
+
@media (hover:hover) and (pointer:fine){.cb-cardMore{cursor:grab;opacity:0;transition:opacity var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease)}.cb-cardMore:active{cursor:grabbing}.cb-card:hover .cb-cardMore,.cb-card:focus-within .cb-cardMore,.cb-cardMore.cb-open{opacity:1}}
|
|
235
|
+
@media (hover:none),(pointer:coarse){.cb-cardHead,.cb-cardHead h3{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}}
|
|
236
|
+
.cb-cardDragging{z-index:6;pointer-events:none;opacity:.94;cursor:grabbing;box-shadow:0 14px 36px color-mix(in srgb,var(--dsw-alias-label-primary) 22%,transparent),inset 0 0 0 .5px var(--dsw-alias-border-l3)}
|
|
237
|
+
.cb-card[data-drop]::after{content:"";position:absolute;z-index:5;pointer-events:none;border-radius:3px;background:var(--dsw-alias-state-business-primary);animation:cb-in var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease) both}
|
|
238
|
+
.cb-card[data-axis=x][data-drop=before]::after{left:-9px;top:6px;bottom:6px;width:3px}
|
|
239
|
+
.cb-card[data-axis=x][data-drop=after]::after{right:-9px;top:6px;bottom:6px;width:3px}
|
|
240
|
+
.cb-card[data-axis=y][data-drop=before]::after{top:-9px;left:6px;right:6px;height:3px}
|
|
241
|
+
.cb-card[data-axis=y][data-drop=after]::after{bottom:-9px;left:6px;right:6px;height:3px}
|
|
242
|
+
.cb-heading .cb-sub{display:flex;flex-wrap:wrap;align-items:center;gap:4px 10px}
|
|
243
|
+
.cb-reset{margin:-4px 0}
|
|
244
|
+
.cb-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
|
|
226
245
|
/* The point under the pointer on a chart */
|
|
227
246
|
.cb-chart{position:relative}
|
|
228
247
|
.cb-plot{touch-action:pan-y}
|
|
@@ -249,16 +268,92 @@ button.cb-cardOpen{border:0;background:transparent;padding:0;font:inherit;cursor
|
|
|
249
268
|
.cb-doneBox{min-width:40px;min-height:40px;margin:-6px -6px -6px -10px}
|
|
250
269
|
.cb-doneBox label{display:inline-flex;align-items:center;justify-content:center;min-width:40px;min-height:40px}
|
|
251
270
|
.cb-cardChat{margin:-9px -10px -9px 0}
|
|
271
|
+
.cb-reset{min-height:40px}
|
|
252
272
|
}
|
|
253
273
|
`;
|
|
254
274
|
|
|
255
275
|
// src/client/page.js
|
|
256
|
-
var
|
|
257
|
-
var
|
|
276
|
+
var import_react15 = require("react");
|
|
277
|
+
var import_dsh_client_ui_primitives5 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
278
|
+
|
|
279
|
+
// src/schema.js
|
|
280
|
+
var SIZES = Object.freeze(["small", "medium", "large", "wide"]);
|
|
281
|
+
var CARD_TYPES = Object.freeze(["summary", "countdown", "stat", "line", "bar", "donut", "list", "timeline", "status"]);
|
|
282
|
+
var TONES = Object.freeze(["ok", "warn", "bad", "muted", "accent", "violet"]);
|
|
283
|
+
var ACTION_KINDS = Object.freeze(["chat", "step", "done", "snooze", "event", "link"]);
|
|
284
|
+
var PRESS_KINDS = Object.freeze(["step", "done", "snooze", "event"]);
|
|
285
|
+
var INVERSE_KINDS = Object.freeze(["done", "snooze", "event"]);
|
|
286
|
+
var DIRECTIONS = Object.freeze(["up", "down", "flat"]);
|
|
287
|
+
var TIMELINE_KINDS = Object.freeze(["travel", "due", "event", "health", "home", "money"]);
|
|
288
|
+
var MAX_CARD_BYTES = 256 * 1024;
|
|
289
|
+
|
|
290
|
+
// src/arrange.js
|
|
291
|
+
function arranged(ids, arrangement) {
|
|
292
|
+
if (arrangement === void 0) return { pinned: [], order: [...ids] };
|
|
293
|
+
const present = new Set(ids);
|
|
294
|
+
const pinned = arrangement.pinned.filter((id) => present.has(id));
|
|
295
|
+
const taken = new Set(pinned);
|
|
296
|
+
const order = arrangement.order.filter((id) => present.has(id) && !taken.has(id));
|
|
297
|
+
const placed = new Set(order);
|
|
298
|
+
ids.forEach((id, i) => {
|
|
299
|
+
if (taken.has(id) || placed.has(id)) return;
|
|
300
|
+
let after = -1;
|
|
301
|
+
for (let before = i - 1; before >= 0 && after < 0; before--) after = order.indexOf(ids[before]);
|
|
302
|
+
order.splice(after + 1, 0, id);
|
|
303
|
+
});
|
|
304
|
+
return { pinned, order };
|
|
305
|
+
}
|
|
306
|
+
var sequenceOf = ({ pinned, order }) => [...pinned, ...order];
|
|
307
|
+
function visibleOrder(state, raised) {
|
|
308
|
+
const all = sequenceOf(state);
|
|
309
|
+
return [...all.filter((id) => raised.has(id)), ...all.filter((id) => !raised.has(id))];
|
|
310
|
+
}
|
|
311
|
+
function pinCard({ pinned, order }, id) {
|
|
312
|
+
return { pinned: [...pinned.filter((p) => p !== id), id], order: order.filter((o) => o !== id) };
|
|
313
|
+
}
|
|
314
|
+
function unpinCard({ pinned, order }, id) {
|
|
315
|
+
return { pinned: pinned.filter((p) => p !== id), order: [id, ...order.filter((o) => o !== id)] };
|
|
316
|
+
}
|
|
317
|
+
function shiftCard({ pinned, order }, id, delta) {
|
|
318
|
+
const shift = (list) => {
|
|
319
|
+
const from = list.indexOf(id);
|
|
320
|
+
const to = from + delta;
|
|
321
|
+
if (from < 0 || to < 0 || to >= list.length) return list;
|
|
322
|
+
const next = [...list];
|
|
323
|
+
next.splice(from, 1);
|
|
324
|
+
next.splice(to, 0, id);
|
|
325
|
+
return next;
|
|
326
|
+
};
|
|
327
|
+
return { pinned: shift(pinned), order: shift(order) };
|
|
328
|
+
}
|
|
329
|
+
function canShift({ pinned, order }, id, delta) {
|
|
330
|
+
const list = pinned.includes(id) ? pinned : order;
|
|
331
|
+
const to = list.indexOf(id) + delta;
|
|
332
|
+
return list.includes(id) && to >= 0 && to < list.length;
|
|
333
|
+
}
|
|
334
|
+
function dropCard(state, id, target, after) {
|
|
335
|
+
if (id === target) return state;
|
|
336
|
+
const wasPinned = state.pinned.includes(id);
|
|
337
|
+
const rest = sequenceOf(state).filter((card) => card !== id);
|
|
338
|
+
const pinsLeft = state.pinned.filter((card) => card !== id).length;
|
|
339
|
+
const at2 = rest.indexOf(target) + (after ? 1 : 0);
|
|
340
|
+
if (at2 < 0 || rest.indexOf(target) < 0) return state;
|
|
341
|
+
const next = [...rest.slice(0, at2), id, ...rest.slice(at2)];
|
|
342
|
+
const pinCount = at2 < pinsLeft ? pinsLeft + 1 : at2 > pinsLeft ? pinsLeft : pinsLeft + (wasPinned ? 1 : 0);
|
|
343
|
+
return { pinned: next.slice(0, pinCount), order: next.slice(pinCount) };
|
|
344
|
+
}
|
|
345
|
+
var at = (time, fallback) => time === void 0 ? fallback : Date.parse(time);
|
|
346
|
+
function isRaised(raise, now) {
|
|
347
|
+
return raise !== void 0 && at(raise.from, -Infinity) <= now && now < at(raise.until, Infinity);
|
|
348
|
+
}
|
|
349
|
+
function nextRaiseChange(raises, now) {
|
|
350
|
+
const times = raises.flatMap((raise) => [at(raise?.from, NaN), at(raise?.until, NaN)]).filter((time) => time > now);
|
|
351
|
+
return times.length > 0 ? Math.min(...times) : void 0;
|
|
352
|
+
}
|
|
258
353
|
|
|
259
354
|
// src/client/card.js
|
|
260
|
-
var
|
|
261
|
-
var
|
|
355
|
+
var import_react10 = require("react");
|
|
356
|
+
var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
262
357
|
|
|
263
358
|
// src/client/charts.js
|
|
264
359
|
var import_react4 = require("react");
|
|
@@ -373,12 +468,12 @@ var useButtons = () => (0, import_react3.useSyncExternalStore)(buttonsStore.subs
|
|
|
373
468
|
var PALETTE = ["accent", "ok", "warn", "violet", "bad", "muted"];
|
|
374
469
|
var toneColor = (tone, index = 0) => kitStore.get().toneColor(tone ?? PALETTE[index % PALETTE.length]);
|
|
375
470
|
function usePointer(pick) {
|
|
376
|
-
const [
|
|
471
|
+
const [at2, setAt] = (0, import_react4.useState)(null);
|
|
377
472
|
const fromEvent = (event) => {
|
|
378
473
|
const box = event.currentTarget.getBoundingClientRect();
|
|
379
474
|
return pick(event.clientX - box.left);
|
|
380
475
|
};
|
|
381
|
-
return [
|
|
476
|
+
return [at2, {
|
|
382
477
|
onPointerMove: (event) => setAt(fromEvent(event)),
|
|
383
478
|
onPointerDown: (event) => setAt(fromEvent(event)),
|
|
384
479
|
onPointerLeave: (event) => {
|
|
@@ -794,8 +889,8 @@ function onControl(event) {
|
|
|
794
889
|
}
|
|
795
890
|
|
|
796
891
|
// src/client/steps.js
|
|
797
|
-
function ownOffset(
|
|
798
|
-
const m = /(?:([+-])(\d{2}):?(\d{2})|Z)$/.exec(String(
|
|
892
|
+
function ownOffset(at2) {
|
|
893
|
+
const m = /(?:([+-])(\d{2}):?(\d{2})|Z)$/.exec(String(at2));
|
|
799
894
|
if (!m) return null;
|
|
800
895
|
return m[1] ? (m[1] === "-" ? -1 : 1) * (Number(m[2]) * 60 + Number(m[3])) : 0;
|
|
801
896
|
}
|
|
@@ -844,6 +939,11 @@ function shownRows(rows, open, limit, live) {
|
|
|
844
939
|
if (open || rows.length <= limit + 1) return rows;
|
|
845
940
|
return rows.filter((row, i) => i < limit || row.key !== void 0 && (live?.freshRows?.has(row.key) || live?.rows?.[row.key] > 0));
|
|
846
941
|
}
|
|
942
|
+
function dropAfter(rect, x, y, single) {
|
|
943
|
+
const across = (x - (rect.left + rect.width / 2)) / Math.max(1, rect.width);
|
|
944
|
+
const down = (y - (rect.top + rect.height / 2)) / Math.max(1, rect.height);
|
|
945
|
+
return single || Math.abs(down) > Math.abs(across) ? down > 0 : across > 0;
|
|
946
|
+
}
|
|
847
947
|
|
|
848
948
|
// src/client/ticks.js
|
|
849
949
|
var doneOf = (row) => row?.actions?.find((action) => action.kind === "done");
|
|
@@ -1256,12 +1356,53 @@ function DetailParts({ detail, locale, t }) {
|
|
|
1256
1356
|
);
|
|
1257
1357
|
}
|
|
1258
1358
|
|
|
1359
|
+
// src/client/arrange-ui.js
|
|
1360
|
+
var import_react9 = require("react");
|
|
1361
|
+
var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
1362
|
+
function ArrangeControls({ t, arrange }) {
|
|
1363
|
+
const [open, setOpen] = (0, import_react9.useState)(false);
|
|
1364
|
+
const items = [
|
|
1365
|
+
{ id: "pin", label: t(arrange.pinned ? "arrange.unpin" : "arrange.pin"), icon: (0, import_react9.createElement)(import_dsh_client_ui_primitives2.IconPinOutlineRegular, { size: 14 }) },
|
|
1366
|
+
{ id: "up", label: t("arrange.up"), icon: (0, import_react9.createElement)(import_dsh_client_ui_primitives2.IconChevronUpOutlineRegular, { size: 14 }), disabled: !arrange.canUp },
|
|
1367
|
+
{ id: "down", label: t("arrange.down"), icon: (0, import_react9.createElement)(import_dsh_client_ui_primitives2.IconChevronDownOutlineRegular, { size: 14 }), disabled: !arrange.canDown }
|
|
1368
|
+
];
|
|
1369
|
+
const choose = (id) => {
|
|
1370
|
+
setOpen(false);
|
|
1371
|
+
if (id === "pin") arrange.onPin();
|
|
1372
|
+
else arrange.onMove(id === "up" ? -1 : 1);
|
|
1373
|
+
};
|
|
1374
|
+
const onKeyDown = (event) => {
|
|
1375
|
+
if (!event.altKey || event.key !== "ArrowUp" && event.key !== "ArrowDown") return;
|
|
1376
|
+
event.preventDefault();
|
|
1377
|
+
const delta = event.key === "ArrowUp" ? -1 : 1;
|
|
1378
|
+
if (delta < 0 ? arrange.canUp : arrange.canDown) arrange.onMove(delta);
|
|
1379
|
+
};
|
|
1380
|
+
const onPointerDown = (event) => {
|
|
1381
|
+
if (event.pointerType === "mouse") arrange.onGrip(event);
|
|
1382
|
+
};
|
|
1383
|
+
return [
|
|
1384
|
+
arrange.pinned && (0, import_react9.createElement)("span", { key: "pin", className: "cb-pinMark", role: "img", title: t("arrange.pinned"), "aria-label": t("arrange.pinned") }, (0, import_react9.createElement)(import_dsh_client_ui_primitives2.IconPinFillRegular, { size: 14 })),
|
|
1385
|
+
(0, import_react9.createElement)(import_dsh_client_ui_primitives2.Menu, {
|
|
1386
|
+
key: "menu",
|
|
1387
|
+
open,
|
|
1388
|
+
onClose: () => setOpen(false),
|
|
1389
|
+
onSelect: choose,
|
|
1390
|
+
items,
|
|
1391
|
+
align: "end",
|
|
1392
|
+
portal: true,
|
|
1393
|
+
compact: true,
|
|
1394
|
+
className: "cb-cardMenu",
|
|
1395
|
+
anchor: (0, import_react9.createElement)("button", { type: "button", className: `cb-cardLink cb-cardMore${open ? " cb-open" : ""}`, title: t("arrange.menu"), "aria-label": t("arrange.menu"), "aria-haspopup": "menu", "aria-expanded": open, onPointerDown, onClick: () => setOpen((value) => !value), onKeyDown }, (0, import_react9.createElement)(import_dsh_client_ui_primitives2.IconDragHandleOutlineRegular, { size: 14 }))
|
|
1396
|
+
})
|
|
1397
|
+
];
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1259
1400
|
// src/client/card.js
|
|
1260
1401
|
var CHART_HEIGHT = 150;
|
|
1261
1402
|
function useRowSpan() {
|
|
1262
|
-
const ref = (0,
|
|
1263
|
-
const [rows, setRows] = (0,
|
|
1264
|
-
(0,
|
|
1403
|
+
const ref = (0, import_react10.useRef)(null);
|
|
1404
|
+
const [rows, setRows] = (0, import_react10.useState)(0);
|
|
1405
|
+
(0, import_react10.useLayoutEffect)(() => {
|
|
1265
1406
|
const el = ref.current;
|
|
1266
1407
|
if (!el || typeof ResizeObserver === "undefined") return void 0;
|
|
1267
1408
|
const measure = () => setRows(Math.ceil((el.getBoundingClientRect().height + GAP) / ROW));
|
|
@@ -1285,34 +1426,39 @@ function Body({ card, live, wash, locale, t, rowActions, all, onOpenRow, rowCont
|
|
|
1285
1426
|
const data = card.data;
|
|
1286
1427
|
switch (card.type) {
|
|
1287
1428
|
case "stat":
|
|
1288
|
-
return (0,
|
|
1429
|
+
return (0, import_react10.createElement)(StatBlock, { data, locale, wash });
|
|
1289
1430
|
case "list":
|
|
1290
|
-
return (0,
|
|
1431
|
+
return (0, import_react10.createElement)(ListCard, { data, live, locale, t, rowActions, all, onOpenRow, rowControls });
|
|
1291
1432
|
case "status":
|
|
1292
|
-
return (0,
|
|
1433
|
+
return (0, import_react10.createElement)(StatusCard, { data, live, locale, rowActions, onOpenRow });
|
|
1293
1434
|
case "countdown":
|
|
1294
|
-
return (0,
|
|
1435
|
+
return (0, import_react10.createElement)(CountdownBody, { card, locale });
|
|
1295
1436
|
default: {
|
|
1296
1437
|
const Chart = CHARTS2[card.type];
|
|
1297
1438
|
if (Chart === void 0) return null;
|
|
1298
|
-
return (0,
|
|
1439
|
+
return (0, import_react10.createElement)(Chart, { data, locale, height: all ? card.type === "donut" ? 200 : 240 : card.type === "bar" ? 130 : card.type === "donut" ? 160 : CHART_HEIGHT });
|
|
1299
1440
|
}
|
|
1300
1441
|
}
|
|
1301
1442
|
}
|
|
1302
|
-
function Card({ entry, live, boardId, assistant, tracks, active, locale, t, press, undo, kept, onOpen, sheet = false, row: openRow }) {
|
|
1443
|
+
function Card({ entry, live, boardId, assistant, tracks, active, locale, t, press, undo, kept, onOpen, sheet = false, row: openRow, arrange, raised = false, dragging = null, drop }) {
|
|
1303
1444
|
const kit = useKit();
|
|
1304
1445
|
const actions = useButtons();
|
|
1305
1446
|
const now = kit.useNow();
|
|
1306
1447
|
const wash = kit.useWash(live.wash, entry.id);
|
|
1307
1448
|
const [ref, rows] = useRowSpan();
|
|
1308
|
-
const style = sheet ? void 0 : {
|
|
1449
|
+
const style = sheet ? void 0 : {
|
|
1450
|
+
gridColumn: `span ${spanOf(entry.card?.type, entry.size, tracks)}`,
|
|
1451
|
+
gridRowEnd: rows > 0 ? `span ${rows}` : void 0,
|
|
1452
|
+
...dragging ? { transform: `translate(${dragging.dx}px, ${dragging.dy}px) scale(1.015)`, transition: "box-shadow var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease)" } : {}
|
|
1453
|
+
};
|
|
1454
|
+
const placing = { "data-card": sheet ? void 0 : entry.id, "data-drop": drop, "data-axis": tracks === 1 ? "y" : "x" };
|
|
1309
1455
|
if (!entry.card) {
|
|
1310
|
-
return (0,
|
|
1456
|
+
return (0, import_react10.createElement)(
|
|
1311
1457
|
"section",
|
|
1312
|
-
{ ref, className:
|
|
1313
|
-
(0,
|
|
1314
|
-
(0,
|
|
1315
|
-
(0,
|
|
1458
|
+
{ ref, className: `cb-card cb-cardError${dragging ? " cb-cardDragging" : ""}`, style, ...placing },
|
|
1459
|
+
(0, import_react10.createElement)("header", { className: "cb-cardHead" }, (0, import_react10.createElement)("h3", { title: entry.id }, entry.id)),
|
|
1460
|
+
(0, import_react10.createElement)("p", { className: "cb-errorText" }, t("cardError")),
|
|
1461
|
+
(0, import_react10.createElement)("ul", { className: "cb-problems" }, (entry.problems ?? []).map((p, i) => (0, import_react10.createElement)("li", { key: i }, p)))
|
|
1316
1462
|
);
|
|
1317
1463
|
}
|
|
1318
1464
|
const card = pickCard(entry.card, active);
|
|
@@ -1331,7 +1477,7 @@ function Card({ entry, live, boardId, assistant, tracks, active, locale, t, pres
|
|
|
1331
1477
|
const askName = assistant ? t("action.chatNamed", { name: assistant }) : void 0;
|
|
1332
1478
|
const named = (list) => assistant ? list?.map((action) => action.kind === "chat" && action.label === void 0 ? { ...action, label: askName } : action) : list;
|
|
1333
1479
|
const onPress = (target) => (action, extra) => press(action, extra, { card: entry.id, ...target }, target.row === void 0 ? void 0 : card.data.rows?.[target.row]);
|
|
1334
|
-
const rowActions = actions && ((row, list, part2) => (0,
|
|
1480
|
+
const rowActions = actions && ((row, list, part2) => (0, import_react10.createElement)(actions.ActionBar, {
|
|
1335
1481
|
actions: named(list),
|
|
1336
1482
|
part: part2,
|
|
1337
1483
|
states: statesOf(entry.presses, row),
|
|
@@ -1346,10 +1492,10 @@ function Card({ entry, live, boardId, assistant, tracks, active, locale, t, pres
|
|
|
1346
1492
|
kept,
|
|
1347
1493
|
undo: (pressId) => undo(pressId, entry.id)
|
|
1348
1494
|
};
|
|
1349
|
-
const chat = actions && (0,
|
|
1495
|
+
const chat = actions && (0, import_react10.createElement)("span", { className: "cb-cardChat" }, (0, import_react10.createElement)(actions.ActionButton, { action: { kind: "chat", id: "_chat", label: askName }, compact: true, about: about() }));
|
|
1350
1496
|
const others = card.actions?.filter((action) => action.kind !== "step") ?? [];
|
|
1351
|
-
const steps = card.actions?.some((action) => action.kind === "step") && (0,
|
|
1352
|
-
const footer = actions && others.length > 0 && (0,
|
|
1497
|
+
const steps = card.actions?.some((action) => action.kind === "step") && (0, import_react10.createElement)(kit.Suggested, { actions: card.actions, about: about(), states: statesOf(entry.presses, void 0), onPress: onPress({}) });
|
|
1498
|
+
const footer = actions && others.length > 0 && (0, import_react10.createElement)("footer", { className: "cb-cardActions" }, (0, import_react10.createElement)(actions.ActionBar, {
|
|
1353
1499
|
actions: named(others),
|
|
1354
1500
|
part: "buttons",
|
|
1355
1501
|
states: statesOf(entry.presses, void 0),
|
|
@@ -1357,7 +1503,7 @@ function Card({ entry, live, boardId, assistant, tracks, active, locale, t, pres
|
|
|
1357
1503
|
onPress: onPress({})
|
|
1358
1504
|
}));
|
|
1359
1505
|
const openable = !sheet && onOpen && card.type !== "summary";
|
|
1360
|
-
const className = ["cb-card", `cb-card-${card.type}`, stale && "cb-cardStale", openable && "cb-cardOpenable", sheet && "cb-cardInSheet", wash].filter(Boolean).join(" ");
|
|
1506
|
+
const className = ["cb-card", `cb-card-${card.type}`, stale && "cb-cardStale", openable && "cb-cardOpenable", sheet && "cb-cardInSheet", raised && "cb-cardRaised", dragging && "cb-cardDragging", wash].filter(Boolean).join(" ");
|
|
1361
1507
|
const openOnTap = openable ? { onClick: (event) => {
|
|
1362
1508
|
if (!onControl(event) && !event.target.closest?.("[data-opens]") && !window.getSelection?.()?.toString()) onOpen();
|
|
1363
1509
|
} } : {};
|
|
@@ -1365,11 +1511,11 @@ function Card({ entry, live, boardId, assistant, tracks, active, locale, t, pres
|
|
|
1365
1511
|
if (sheet && openRow !== void 0) {
|
|
1366
1512
|
const index = card.data.rows?.findIndex((r) => r.key === openRow) ?? -1;
|
|
1367
1513
|
const target = index >= 0 ? card.data.rows[index] : null;
|
|
1368
|
-
if (!target) return (0,
|
|
1369
|
-
return (0,
|
|
1514
|
+
if (!target) return (0, import_react10.createElement)("p", { className: "cb-muted" }, t("rowGone"));
|
|
1515
|
+
return (0, import_react10.createElement)(
|
|
1370
1516
|
"div",
|
|
1371
1517
|
{ className: "cb-rowSheet" },
|
|
1372
|
-
(0,
|
|
1518
|
+
(0, import_react10.createElement)(Body, {
|
|
1373
1519
|
card: { ...card, data: { ...card.data, rows: [target], progress: void 0 } },
|
|
1374
1520
|
live,
|
|
1375
1521
|
wash: false,
|
|
@@ -1379,46 +1525,214 @@ function Card({ entry, live, boardId, assistant, tracks, active, locale, t, pres
|
|
|
1379
1525
|
all: true,
|
|
1380
1526
|
rowControls: { ...rowControls, kept: [], press: (_, action) => rowControls.press(index, action), state: (_, id) => rowControls.state(index, id), latest: (_, id) => rowControls.latest(index, id) }
|
|
1381
1527
|
}),
|
|
1382
|
-
(0,
|
|
1528
|
+
(0, import_react10.createElement)(DetailParts, { detail: target.detail, locale, t })
|
|
1383
1529
|
);
|
|
1384
1530
|
}
|
|
1385
1531
|
if (card.type === "summary") {
|
|
1386
|
-
return (0,
|
|
1532
|
+
return (0, import_react10.createElement)(
|
|
1387
1533
|
"section",
|
|
1388
|
-
{ ref, className, style, "data-type": card.type },
|
|
1389
|
-
(0,
|
|
1390
|
-
(0,
|
|
1534
|
+
{ ref, className, style, "data-type": card.type, ...placing },
|
|
1535
|
+
(0, import_react10.createElement)("div", { className: "cb-summaryMain" }, (0, import_react10.createElement)(SummaryBody, { card, locale, t, wash: wash !== "" }), steps, footer),
|
|
1536
|
+
(0, import_react10.createElement)("div", { className: "cb-summaryAside" }, live.fresh && (0, import_react10.createElement)(kit.NewDot), chat)
|
|
1391
1537
|
);
|
|
1392
1538
|
}
|
|
1393
|
-
const statBlock = card.stat && (0,
|
|
1394
|
-
const body = (0,
|
|
1395
|
-
return (0,
|
|
1539
|
+
const statBlock = card.stat && (0, import_react10.createElement)(StatBlock, { data: card.stat, locale, compact: true, wash: wash !== "" });
|
|
1540
|
+
const body = (0, import_react10.createElement)(Body, { card, live, wash: wash !== "", locale, t, rowActions, all: sheet, onOpenRow, rowControls });
|
|
1541
|
+
return (0, import_react10.createElement)(
|
|
1396
1542
|
"section",
|
|
1397
|
-
{ ref, className, style, "data-type": card.type, ...openOnTap },
|
|
1398
|
-
!sheet && (0,
|
|
1543
|
+
{ ref, className, style, "data-type": card.type, ...placing, ...openOnTap },
|
|
1544
|
+
!sheet && (0, import_react10.createElement)(
|
|
1399
1545
|
"header",
|
|
1400
|
-
{ className: "cb-cardHead"
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1546
|
+
{ className: "cb-cardHead", ...arrange ? { onPointerDown: (event) => {
|
|
1547
|
+
if (event.pointerType !== "mouse" && !onControl(event)) arrange.onHold(event);
|
|
1548
|
+
} } : {} },
|
|
1549
|
+
card.icon && (0, import_react10.createElement)(kit.Tile, { icon: card.icon, tone: card.tone ?? "muted", size: 30 }),
|
|
1550
|
+
(0, import_react10.createElement)(Trunc, { as: "h3", text: card.title }),
|
|
1551
|
+
live.fresh && (0, import_react10.createElement)(kit.NewDot),
|
|
1552
|
+
raised && (0, import_react10.createElement)("span", { className: "cb-raisedCue", title: t("arrange.raisedWhy") }, (0, import_react10.createElement)(import_dsh_client_ui_primitives3.Tag, { tone: "info" }, card.raise?.label ?? t("arrange.raised"))),
|
|
1553
|
+
wash !== "" && card.type !== "stat" && !card.stat && (0, import_react10.createElement)(kit.JustNow),
|
|
1554
|
+
stale && (0, import_react10.createElement)(
|
|
1406
1555
|
"span",
|
|
1407
1556
|
{ className: "cb-stale", title: new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short" }).format(updated) },
|
|
1408
|
-
(0,
|
|
1557
|
+
(0, import_react10.createElement)(import_dsh_client_ui_primitives3.Tag, { tone: "warning" }, t("stale", { age: formatAge(age, locale) }))
|
|
1409
1558
|
),
|
|
1410
|
-
|
|
1411
|
-
|
|
1559
|
+
arrange && (0, import_react10.createElement)(ArrangeControls, { t, arrange }),
|
|
1560
|
+
card.link && (0, import_react10.createElement)("a", { className: "cb-cardLink", href: card.link, title: t("open"), "aria-label": t("open"), ...external ? { target: "_blank", rel: "noopener noreferrer" } : {} }, (0, import_react10.createElement)(import_dsh_client_ui_primitives3.IconRightUpOutlineRegular, { size: 14 })),
|
|
1561
|
+
openable && (0, import_react10.createElement)("button", { type: "button", className: "cb-cardLink cb-cardOpen", title: t("details"), "aria-label": t("details"), onClick: () => onOpen() }, (0, import_react10.createElement)(import_dsh_client_ui_primitives3.IconFullscreenOutlineRegular, { size: 14 })),
|
|
1412
1562
|
chat
|
|
1413
1563
|
),
|
|
1414
|
-
statBlock && ["line", "bar", "donut"].includes(card.type) ? (0,
|
|
1415
|
-
sheet && (0,
|
|
1564
|
+
statBlock && ["line", "bar", "donut"].includes(card.type) ? (0, import_react10.createElement)("div", { className: "cb-split" }, statBlock, (0, import_react10.createElement)("div", { className: "cb-cardBody" }, body)) : [statBlock && (0, import_react10.createElement)("div", { key: "stat" }, statBlock), (0, import_react10.createElement)("div", { key: "body", className: "cb-cardBody" }, body)],
|
|
1565
|
+
sheet && (0, import_react10.createElement)(DetailParts, { detail: card.detail, locale, t }),
|
|
1416
1566
|
steps,
|
|
1417
1567
|
footer,
|
|
1418
|
-
sheet && chat && (0,
|
|
1568
|
+
sheet && chat && (0, import_react10.createElement)("div", { className: "cb-sheetChat" }, chat)
|
|
1419
1569
|
);
|
|
1420
1570
|
}
|
|
1421
1571
|
|
|
1572
|
+
// src/client/drag.js
|
|
1573
|
+
var import_react11 = require("react");
|
|
1574
|
+
var HOLD_MS = 380;
|
|
1575
|
+
var SLOP = 8;
|
|
1576
|
+
var PULL = 4;
|
|
1577
|
+
var EDGE = 72;
|
|
1578
|
+
function useCardDrag(onDrop) {
|
|
1579
|
+
const [drag, setDrag] = (0, import_react11.useState)(null);
|
|
1580
|
+
const dropRef = (0, import_react11.useRef)(onDrop);
|
|
1581
|
+
dropRef.current = onDrop;
|
|
1582
|
+
const stop = (0, import_react11.useRef)(() => {
|
|
1583
|
+
});
|
|
1584
|
+
(0, import_react11.useEffect)(() => () => stop.current(), []);
|
|
1585
|
+
const begin = (0, import_react11.useCallback)((event, id, hold) => {
|
|
1586
|
+
if (event.pointerType === "mouse" && event.button !== 0) return;
|
|
1587
|
+
stop.current();
|
|
1588
|
+
const el = event.currentTarget.closest("[data-card]");
|
|
1589
|
+
const scroller = el?.closest(".cb-page");
|
|
1590
|
+
if (!el || !scroller) return;
|
|
1591
|
+
const grid = el.parentElement;
|
|
1592
|
+
const origin = { x: event.clientX, y: event.clientY, scroll: scroller.scrollTop };
|
|
1593
|
+
const point = { x: origin.x, y: origin.y };
|
|
1594
|
+
let active = false;
|
|
1595
|
+
let hint = null;
|
|
1596
|
+
let timer = 0;
|
|
1597
|
+
let frame = 0;
|
|
1598
|
+
const single = () => getComputedStyle(grid).gridTemplateColumns.split(" ").length === 1;
|
|
1599
|
+
const update = () => {
|
|
1600
|
+
const under = document.elementsFromPoint(point.x, point.y).map((node) => node.closest?.("[data-card]")).find((card) => card && card.dataset.card !== id);
|
|
1601
|
+
if (under) hint = { target: under.dataset.card, after: dropAfter(under.getBoundingClientRect(), point.x, point.y, single()) };
|
|
1602
|
+
setDrag({ id, dx: point.x - origin.x, dy: point.y - origin.y + (scroller.scrollTop - origin.scroll), hint });
|
|
1603
|
+
};
|
|
1604
|
+
const scroll = () => {
|
|
1605
|
+
if (!active) return;
|
|
1606
|
+
const box = scroller.getBoundingClientRect();
|
|
1607
|
+
const near = point.y < box.top + EDGE ? (point.y - box.top - EDGE) / EDGE : point.y > box.bottom - EDGE ? (point.y - box.bottom + EDGE) / EDGE : 0;
|
|
1608
|
+
if (near !== 0) {
|
|
1609
|
+
const before = scroller.scrollTop;
|
|
1610
|
+
scroller.scrollTop += Math.round(Math.max(-1, Math.min(1, near)) * 16);
|
|
1611
|
+
if (scroller.scrollTop !== before) update();
|
|
1612
|
+
}
|
|
1613
|
+
frame = requestAnimationFrame(scroll);
|
|
1614
|
+
};
|
|
1615
|
+
const lift = () => {
|
|
1616
|
+
timer = 0;
|
|
1617
|
+
active = true;
|
|
1618
|
+
navigator.vibrate?.(10);
|
|
1619
|
+
document.body.style.cursor = "grabbing";
|
|
1620
|
+
update();
|
|
1621
|
+
scroll();
|
|
1622
|
+
};
|
|
1623
|
+
const onMove = (move) => {
|
|
1624
|
+
point.x = move.clientX;
|
|
1625
|
+
point.y = move.clientY;
|
|
1626
|
+
if (active) return update();
|
|
1627
|
+
const travel = Math.hypot(point.x - origin.x, point.y - origin.y);
|
|
1628
|
+
if (hold && travel > SLOP) finish(false);
|
|
1629
|
+
else if (!hold && travel > PULL) lift();
|
|
1630
|
+
};
|
|
1631
|
+
const onTouchMove = (move) => {
|
|
1632
|
+
if (active && move.cancelable) move.preventDefault();
|
|
1633
|
+
};
|
|
1634
|
+
const onKey = (key) => {
|
|
1635
|
+
if (key.key === "Escape") finish(false);
|
|
1636
|
+
};
|
|
1637
|
+
const onMenu = (menu) => {
|
|
1638
|
+
if (hold) menu.preventDefault();
|
|
1639
|
+
};
|
|
1640
|
+
function finish(drop) {
|
|
1641
|
+
clearTimeout(timer);
|
|
1642
|
+
cancelAnimationFrame(frame);
|
|
1643
|
+
window.removeEventListener("pointermove", onMove);
|
|
1644
|
+
window.removeEventListener("pointerup", onUp);
|
|
1645
|
+
window.removeEventListener("pointercancel", onCancel);
|
|
1646
|
+
window.removeEventListener("touchmove", onTouchMove);
|
|
1647
|
+
window.removeEventListener("keydown", onKey);
|
|
1648
|
+
window.removeEventListener("contextmenu", onMenu);
|
|
1649
|
+
document.body.style.cursor = "";
|
|
1650
|
+
stop.current = () => {
|
|
1651
|
+
};
|
|
1652
|
+
if (active) {
|
|
1653
|
+
const swallow = (click) => {
|
|
1654
|
+
click.stopPropagation();
|
|
1655
|
+
click.preventDefault();
|
|
1656
|
+
};
|
|
1657
|
+
window.addEventListener("click", swallow, { capture: true, once: true });
|
|
1658
|
+
setTimeout(() => window.removeEventListener("click", swallow, true), 60);
|
|
1659
|
+
if (drop && hint) dropRef.current(id, hint.target, hint.after);
|
|
1660
|
+
}
|
|
1661
|
+
active = false;
|
|
1662
|
+
setDrag(null);
|
|
1663
|
+
}
|
|
1664
|
+
const onUp = () => finish(true);
|
|
1665
|
+
const onCancel = () => finish(false);
|
|
1666
|
+
window.addEventListener("pointermove", onMove);
|
|
1667
|
+
window.addEventListener("pointerup", onUp);
|
|
1668
|
+
window.addEventListener("pointercancel", onCancel);
|
|
1669
|
+
window.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
1670
|
+
window.addEventListener("keydown", onKey);
|
|
1671
|
+
window.addEventListener("contextmenu", onMenu);
|
|
1672
|
+
if (hold) timer = setTimeout(lift, HOLD_MS);
|
|
1673
|
+
stop.current = () => finish(false);
|
|
1674
|
+
}, []);
|
|
1675
|
+
return { drag, begin };
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
// src/client/flip.js
|
|
1679
|
+
var import_react12 = require("react");
|
|
1680
|
+
var MS = 240;
|
|
1681
|
+
function useGlide(gridRef, orderKey) {
|
|
1682
|
+
const spots = (0, import_react12.useRef)(/* @__PURE__ */ new Map());
|
|
1683
|
+
const lastKey = (0, import_react12.useRef)(orderKey);
|
|
1684
|
+
(0, import_react12.useLayoutEffect)(() => {
|
|
1685
|
+
const grid = gridRef.current;
|
|
1686
|
+
if (!grid) return;
|
|
1687
|
+
const next = /* @__PURE__ */ new Map();
|
|
1688
|
+
const animate = lastKey.current !== orderKey && typeof matchMedia === "function" && !matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1689
|
+
for (const el of grid.children) {
|
|
1690
|
+
const id = el.dataset?.card;
|
|
1691
|
+
if (id === void 0) continue;
|
|
1692
|
+
const spot = { x: el.offsetLeft, y: el.offsetTop };
|
|
1693
|
+
const was = spots.current.get(id);
|
|
1694
|
+
if (animate && was && typeof el.animate === "function" && (Math.abs(was.x - spot.x) > 1 || Math.abs(was.y - spot.y) > 1)) {
|
|
1695
|
+
el.animate([{ transform: `translate(${was.x - spot.x}px, ${was.y - spot.y}px)` }, { transform: "none" }], { duration: MS, easing: "cubic-bezier(.2,.7,.2,1)" });
|
|
1696
|
+
}
|
|
1697
|
+
next.set(id, spot);
|
|
1698
|
+
}
|
|
1699
|
+
spots.current = next;
|
|
1700
|
+
lastKey.current = orderKey;
|
|
1701
|
+
});
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
// src/client/raise.js
|
|
1705
|
+
var import_react13 = require("react");
|
|
1706
|
+
var MAX_WAIT_MS = 2 ** 31 - 1;
|
|
1707
|
+
var SLACK_MS = 25;
|
|
1708
|
+
function useRaised(entries) {
|
|
1709
|
+
const [now, setNow] = (0, import_react13.useState)(() => Date.now());
|
|
1710
|
+
const raises = entries.filter((entry) => entry.card?.raise).map((entry) => [entry.id, entry.card.raise]);
|
|
1711
|
+
const key = JSON.stringify(raises);
|
|
1712
|
+
(0, import_react13.useEffect)(() => {
|
|
1713
|
+
let timer;
|
|
1714
|
+
const arm = () => {
|
|
1715
|
+
clearTimeout(timer);
|
|
1716
|
+
const current = Date.now();
|
|
1717
|
+
setNow(current);
|
|
1718
|
+
const next = nextRaiseChange(raises.map(([, raise]) => raise), current);
|
|
1719
|
+
if (next !== void 0) timer = setTimeout(arm, Math.min(next - current + SLACK_MS, MAX_WAIT_MS));
|
|
1720
|
+
};
|
|
1721
|
+
const wake = () => {
|
|
1722
|
+
if (document.visibilityState === "visible") arm();
|
|
1723
|
+
};
|
|
1724
|
+
arm();
|
|
1725
|
+
document.addEventListener("visibilitychange", wake);
|
|
1726
|
+
window.addEventListener("focus", wake);
|
|
1727
|
+
return () => {
|
|
1728
|
+
clearTimeout(timer);
|
|
1729
|
+
document.removeEventListener("visibilitychange", wake);
|
|
1730
|
+
window.removeEventListener("focus", wake);
|
|
1731
|
+
};
|
|
1732
|
+
}, [key]);
|
|
1733
|
+
return (0, import_react13.useMemo)(() => new Set(raises.filter(([, raise]) => isRaised(raise, now)).map(([id]) => id)), [key, now]);
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1422
1736
|
// src/client/live-state.js
|
|
1423
1737
|
var EMPTY = Object.freeze({ wash: 0, rows: Object.freeze({}), fresh: false, freshRows: /* @__PURE__ */ new Set() });
|
|
1424
1738
|
var liveOf = (live, id) => live[id] ?? EMPTY;
|
|
@@ -1471,10 +1785,10 @@ function writeNav(search, nav) {
|
|
|
1471
1785
|
var hasNav = (search) => Boolean(readNav(search).card);
|
|
1472
1786
|
|
|
1473
1787
|
// src/client/sheet.js
|
|
1474
|
-
var
|
|
1475
|
-
var
|
|
1788
|
+
var import_react14 = require("react");
|
|
1789
|
+
var import_dsh_client_ui_primitives4 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
1476
1790
|
function Sheet({ open, onClose, title, closeLabel, children }) {
|
|
1477
|
-
return (0,
|
|
1791
|
+
return (0, import_react14.createElement)(import_dsh_client_ui_primitives4.Modal, { open, onClose, title, closeLabel, className: "cb-sheetModal", contentClassName: "cb-sheet" }, children);
|
|
1478
1792
|
}
|
|
1479
1793
|
|
|
1480
1794
|
// src/client/page.js
|
|
@@ -1508,11 +1822,11 @@ var visible = () => document.visibilityState === "visible";
|
|
|
1508
1822
|
function BoardsPage() {
|
|
1509
1823
|
const kit = useKit();
|
|
1510
1824
|
const { active, intl: locale, ready, t } = useActiveLocale();
|
|
1511
|
-
const [boards, setBoards] = (0,
|
|
1512
|
-
const [listError, setListError] = (0,
|
|
1513
|
-
const [opened, setOpened] = (0,
|
|
1514
|
-
const pushed = (0,
|
|
1515
|
-
const [selected, setSelected] = (0,
|
|
1825
|
+
const [boards, setBoards] = (0, import_react15.useState)(null);
|
|
1826
|
+
const [listError, setListError] = (0, import_react15.useState)(null);
|
|
1827
|
+
const [opened, setOpened] = (0, import_react15.useState)(() => typeof location === "undefined" ? {} : readNav(location.search));
|
|
1828
|
+
const pushed = (0, import_react15.useRef)(false);
|
|
1829
|
+
const [selected, setSelected] = (0, import_react15.useState)(() => {
|
|
1516
1830
|
if (opened.board) return opened.board;
|
|
1517
1831
|
try {
|
|
1518
1832
|
return localStorage.getItem(STORE_KEY);
|
|
@@ -1520,25 +1834,36 @@ function BoardsPage() {
|
|
|
1520
1834
|
return null;
|
|
1521
1835
|
}
|
|
1522
1836
|
});
|
|
1523
|
-
const [view, setView] = (0,
|
|
1524
|
-
const [boardError, setBoardError] = (0,
|
|
1525
|
-
const [pollSeconds, setPollSeconds] = (0,
|
|
1526
|
-
const etag = (0,
|
|
1527
|
-
const
|
|
1528
|
-
const
|
|
1529
|
-
const translateRef = (0, import_react11.useRef)(t);
|
|
1837
|
+
const [view, setView] = (0, import_react15.useState)({ board: null, live: {} });
|
|
1838
|
+
const [boardError, setBoardError] = (0, import_react15.useState)(null);
|
|
1839
|
+
const [pollSeconds, setPollSeconds] = (0, import_react15.useState)(30);
|
|
1840
|
+
const etag = (0, import_react15.useRef)(null);
|
|
1841
|
+
const currentRef = (0, import_react15.useRef)(null);
|
|
1842
|
+
const translateRef = (0, import_react15.useRef)(t);
|
|
1530
1843
|
translateRef.current = t;
|
|
1531
|
-
const [kept, setKept] = (0,
|
|
1532
|
-
const [toast, setToast] = (0,
|
|
1533
|
-
const toasts = (0,
|
|
1844
|
+
const [kept, setKept] = (0, import_react15.useState)({});
|
|
1845
|
+
const [toast, setToast] = (0, import_react15.useState)(null);
|
|
1846
|
+
const toasts = (0, import_react15.useRef)(0);
|
|
1534
1847
|
const board = view.board;
|
|
1535
|
-
const boardRef = (0,
|
|
1848
|
+
const boardRef = (0, import_react15.useRef)(null);
|
|
1536
1849
|
boardRef.current = board;
|
|
1537
|
-
const
|
|
1850
|
+
const ids = (0, import_react15.useMemo)(() => board ? board.cards.map((entry) => entry.id) : [], [board]);
|
|
1851
|
+
const mine = (0, import_react15.useMemo)(() => arranged(ids, board?.arrangement), [ids, board?.arrangement]);
|
|
1852
|
+
const raised = useRaised(board?.cards ?? []);
|
|
1853
|
+
const order = (0, import_react15.useMemo)(() => visibleOrder(mine, raised), [mine, raised]);
|
|
1854
|
+
const shown = (0, import_react15.useMemo)(() => {
|
|
1855
|
+
const byId = new Map((board?.cards ?? []).map((entry) => [entry.id, entry]));
|
|
1856
|
+
return order.map((id) => byId.get(id)).filter(Boolean);
|
|
1857
|
+
}, [board, order]);
|
|
1858
|
+
const gridRef = (0, import_react15.useRef)(null);
|
|
1859
|
+
const [contentRef, tracks] = useTracks();
|
|
1860
|
+
useGlide(gridRef, order.join("\n"));
|
|
1861
|
+
const [said, setSaid] = (0, import_react15.useState)("");
|
|
1862
|
+
const show = (0, import_react15.useCallback)((next) => setView((prev) => ({
|
|
1538
1863
|
board: next,
|
|
1539
1864
|
live: next === null ? {} : nextLive(prev.board?.id === next.id ? prev.board : null, next, prev.board?.id === next.id ? prev.live : {})
|
|
1540
1865
|
})), []);
|
|
1541
|
-
const loadList = (0,
|
|
1866
|
+
const loadList = (0, import_react15.useCallback)(async () => {
|
|
1542
1867
|
try {
|
|
1543
1868
|
const { body } = await getJson("boards");
|
|
1544
1869
|
setBoards(body.boards);
|
|
@@ -1549,7 +1874,7 @@ function BoardsPage() {
|
|
|
1549
1874
|
}
|
|
1550
1875
|
}, []);
|
|
1551
1876
|
const current = boards?.some((b) => b.id === selected) ? selected : boards?.[0]?.id ?? null;
|
|
1552
|
-
const loadBoard = (0,
|
|
1877
|
+
const loadBoard = (0, import_react15.useCallback)(async (id, fresh) => {
|
|
1553
1878
|
if (!id) return;
|
|
1554
1879
|
try {
|
|
1555
1880
|
const result = await getJson(`board?id=${encodeURIComponent(id)}`, fresh ? null : etag.current);
|
|
@@ -1565,7 +1890,7 @@ function BoardsPage() {
|
|
|
1565
1890
|
}
|
|
1566
1891
|
}
|
|
1567
1892
|
}, [loadList, show]);
|
|
1568
|
-
const loadCard = (0,
|
|
1893
|
+
const loadCard = (0, import_react15.useCallback)(async (boardId, id) => {
|
|
1569
1894
|
try {
|
|
1570
1895
|
if (boardRef.current?.id !== boardId || !boardRef.current.cards.some((card) => card.id === id)) return loadBoard(boardId, false);
|
|
1571
1896
|
const { body } = await getJson(`card?board=${encodeURIComponent(boardId)}&id=${encodeURIComponent(id)}`);
|
|
@@ -1579,11 +1904,11 @@ function BoardsPage() {
|
|
|
1579
1904
|
else loadBoard(boardId, false);
|
|
1580
1905
|
}
|
|
1581
1906
|
}, [loadBoard]);
|
|
1582
|
-
const onEvent = (0,
|
|
1907
|
+
const onEvent = (0, import_react15.useCallback)((message) => {
|
|
1583
1908
|
const id = currentRef.current;
|
|
1584
1909
|
if (!id) return;
|
|
1585
1910
|
if (message.type === "card") loadCard(id, message.id);
|
|
1586
|
-
else if (message.type === "board" || message.type === "hello") loadBoard(id, false);
|
|
1911
|
+
else if (message.type === "board" || message.type === "hello" || message.type === "arrange") loadBoard(id, false);
|
|
1587
1912
|
else if (message.type === "gone") {
|
|
1588
1913
|
show(null);
|
|
1589
1914
|
setBoardError(requestError(403));
|
|
@@ -1591,7 +1916,7 @@ function BoardsPage() {
|
|
|
1591
1916
|
}
|
|
1592
1917
|
}, [loadBoard, loadCard, loadList, show]);
|
|
1593
1918
|
const status = kit.useEventStream(current ? `api/card-board/events?board=${encodeURIComponent(current)}` : null, onEvent);
|
|
1594
|
-
const post = (0,
|
|
1919
|
+
const post = (0, import_react15.useCallback)(async (body) => {
|
|
1595
1920
|
const response = await fetch(api("action"), {
|
|
1596
1921
|
method: "POST",
|
|
1597
1922
|
credentials: "same-origin",
|
|
@@ -1603,8 +1928,23 @@ function BoardsPage() {
|
|
|
1603
1928
|
loadBoard(currentRef.current, false);
|
|
1604
1929
|
return answer;
|
|
1605
1930
|
}, [loadBoard]);
|
|
1606
|
-
const showToast = (0,
|
|
1607
|
-
const
|
|
1931
|
+
const showToast = (0, import_react15.useCallback)((next) => setToast({ seq: ++toasts.current, ...next }), []);
|
|
1932
|
+
const keepArrangement = (0, import_react15.useCallback)(async (next, board2) => {
|
|
1933
|
+
setView((prev) => prev.board?.id === board2 ? { ...prev, board: { ...prev.board, arrangement: next ?? void 0 } } : prev);
|
|
1934
|
+
try {
|
|
1935
|
+
const response = await fetch(api("arrange"), {
|
|
1936
|
+
method: "POST",
|
|
1937
|
+
credentials: "same-origin",
|
|
1938
|
+
headers: { "content-type": "application/json" },
|
|
1939
|
+
body: JSON.stringify(next === null ? { board: board2, reset: true } : { board: board2, ...next })
|
|
1940
|
+
});
|
|
1941
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
1942
|
+
} catch {
|
|
1943
|
+
showToast({ text: "arrange.failed" });
|
|
1944
|
+
loadBoard(board2, true);
|
|
1945
|
+
}
|
|
1946
|
+
}, [loadBoard, showToast]);
|
|
1947
|
+
const undo = (0, import_react15.useCallback)(async (pressId, card) => {
|
|
1608
1948
|
try {
|
|
1609
1949
|
await post({ card, undo: pressId });
|
|
1610
1950
|
showToast({ text: "toast.undone" });
|
|
@@ -1612,7 +1952,7 @@ function BoardsPage() {
|
|
|
1612
1952
|
showToast({ text: "toast.undoFailed" });
|
|
1613
1953
|
}
|
|
1614
1954
|
}, [post, showToast]);
|
|
1615
|
-
const press = (0,
|
|
1955
|
+
const press = (0, import_react15.useCallback)(async (action, extra, target, row) => {
|
|
1616
1956
|
const answer = await post({ ...target, id: action.id, ...extra });
|
|
1617
1957
|
if (answer?.undoable) {
|
|
1618
1958
|
showToast({ text: TOAST_KEYS[action.kind] ?? "toast.event", undo: () => undo(answer.press, target.card) });
|
|
@@ -1621,10 +1961,10 @@ function BoardsPage() {
|
|
|
1621
1961
|
}
|
|
1622
1962
|
return answer;
|
|
1623
1963
|
}, [post, showToast, undo]);
|
|
1624
|
-
(0,
|
|
1964
|
+
(0, import_react15.useEffect)(() => {
|
|
1625
1965
|
loadList();
|
|
1626
1966
|
}, [loadList]);
|
|
1627
|
-
(0,
|
|
1967
|
+
(0, import_react15.useEffect)(() => {
|
|
1628
1968
|
currentRef.current = current;
|
|
1629
1969
|
if (!current) return;
|
|
1630
1970
|
etag.current = null;
|
|
@@ -1634,7 +1974,7 @@ function BoardsPage() {
|
|
|
1634
1974
|
loadBoard(current, true);
|
|
1635
1975
|
}, [current, loadBoard]);
|
|
1636
1976
|
const waiting = board?.cards.some((entry) => entry.presses?.some((p) => p.state === "pending")) === true;
|
|
1637
|
-
(0,
|
|
1977
|
+
(0, import_react15.useEffect)(() => {
|
|
1638
1978
|
if (!current || status === "live" && !waiting) return void 0;
|
|
1639
1979
|
let ticks = 0;
|
|
1640
1980
|
const timer = setInterval(() => {
|
|
@@ -1654,8 +1994,8 @@ function BoardsPage() {
|
|
|
1654
1994
|
document.removeEventListener("visibilitychange", onVisible);
|
|
1655
1995
|
};
|
|
1656
1996
|
}, [current, status, waiting, pollSeconds, loadBoard, loadList]);
|
|
1657
|
-
const reported = (0,
|
|
1658
|
-
(0,
|
|
1997
|
+
const reported = (0, import_react15.useRef)("");
|
|
1998
|
+
(0, import_react15.useEffect)(() => {
|
|
1659
1999
|
if (!board) return void 0;
|
|
1660
2000
|
const report = seenReport(board);
|
|
1661
2001
|
const text = JSON.stringify(report);
|
|
@@ -1669,7 +2009,7 @@ function BoardsPage() {
|
|
|
1669
2009
|
}, SEEN_AFTER_MS);
|
|
1670
2010
|
return () => clearTimeout(timer);
|
|
1671
2011
|
}, [board]);
|
|
1672
|
-
(0,
|
|
2012
|
+
(0, import_react15.useEffect)(() => {
|
|
1673
2013
|
const onPop = () => {
|
|
1674
2014
|
pushed.current = false;
|
|
1675
2015
|
setOpened(readNav(location.search));
|
|
@@ -1677,19 +2017,39 @@ function BoardsPage() {
|
|
|
1677
2017
|
window.addEventListener("popstate", onPop);
|
|
1678
2018
|
return () => window.removeEventListener("popstate", onPop);
|
|
1679
2019
|
}, []);
|
|
1680
|
-
const openCard = (0,
|
|
2020
|
+
const openCard = (0, import_react15.useCallback)((boardId, card, row) => {
|
|
1681
2021
|
const nav = { board: boardId, card, ...row === void 0 ? {} : { row } };
|
|
1682
2022
|
window.history[pushed.current ? "replaceState" : "pushState"](window.history.state, "", `${location.pathname}${writeNav(location.search, nav)}${location.hash}`);
|
|
1683
2023
|
pushed.current = true;
|
|
1684
2024
|
setOpened(nav);
|
|
1685
2025
|
}, []);
|
|
1686
|
-
const closeCard = (0,
|
|
2026
|
+
const closeCard = (0, import_react15.useCallback)(() => {
|
|
1687
2027
|
setOpened({});
|
|
1688
2028
|
if (pushed.current) {
|
|
1689
2029
|
pushed.current = false;
|
|
1690
2030
|
window.history.back();
|
|
1691
2031
|
} else window.history.replaceState(window.history.state, "", `${location.pathname}${writeNav(location.search, {})}${location.hash}`);
|
|
1692
2032
|
}, []);
|
|
2033
|
+
const rearrange = (next, id, saying) => {
|
|
2034
|
+
if (board === null) return;
|
|
2035
|
+
keepArrangement(next, board.id);
|
|
2036
|
+
const title = pickText(boardRef.current?.cards.find((entry) => entry.id === id)?.card?.title, active) ?? id;
|
|
2037
|
+
const place = [...visibleOrder(next, raised)].indexOf(id) + 1;
|
|
2038
|
+
setSaid(t(saying, { title, n: place, total: ids.length }));
|
|
2039
|
+
};
|
|
2040
|
+
const { drag, begin } = useCardDrag((id, target, after) => rearrange(dropCard(mine, id, target, after), id, "arrange.moved"));
|
|
2041
|
+
const arrangeOf = (id) => ({
|
|
2042
|
+
pinned: mine.pinned.includes(id),
|
|
2043
|
+
canUp: canShift(mine, id, -1),
|
|
2044
|
+
canDown: canShift(mine, id, 1),
|
|
2045
|
+
onPin: () => mine.pinned.includes(id) ? rearrange(unpinCard(mine, id), id, "arrange.unpinnedDone") : rearrange(pinCard(mine, id), id, "arrange.pinnedDone"),
|
|
2046
|
+
onMove: (delta) => rearrange(shiftCard(mine, id, delta), id, "arrange.moved"),
|
|
2047
|
+
onGrip: (event) => {
|
|
2048
|
+
event.preventDefault();
|
|
2049
|
+
begin(event, id, false);
|
|
2050
|
+
},
|
|
2051
|
+
onHold: (event) => begin(event, id, true)
|
|
2052
|
+
});
|
|
1693
2053
|
const choose = (id) => {
|
|
1694
2054
|
setSelected(id);
|
|
1695
2055
|
try {
|
|
@@ -1702,54 +2062,81 @@ function BoardsPage() {
|
|
|
1702
2062
|
return Number.isFinite(time) && time > max ? time : max;
|
|
1703
2063
|
}, 0);
|
|
1704
2064
|
const titleOf = (entry) => pickText(entry.title, active);
|
|
1705
|
-
if (!ready) return (0,
|
|
2065
|
+
if (!ready) return (0, import_react15.createElement)("div", { className: "cb-page" });
|
|
1706
2066
|
let content;
|
|
1707
|
-
if (listError) content = (0,
|
|
1708
|
-
else if (boards === null) content = (0,
|
|
1709
|
-
else if (boards.length === 0) content = (0,
|
|
1710
|
-
else if (boardError) content = (0,
|
|
1711
|
-
else if (!board) content = (0,
|
|
1712
|
-
else content = (0,
|
|
1713
|
-
|
|
2067
|
+
if (listError) content = (0, import_react15.createElement)("p", { className: "cb-notice" }, errorText(listError, t));
|
|
2068
|
+
else if (boards === null) content = (0, import_react15.createElement)("p", { className: "cb-muted" }, t("loading"));
|
|
2069
|
+
else if (boards.length === 0) content = (0, import_react15.createElement)("div", { className: "cb-empty" }, (0, import_react15.createElement)("p", { className: "cb-emptyTitle" }, t("emptyTitle")), (0, import_react15.createElement)("p", { className: "cb-muted" }, t("emptyHint")));
|
|
2070
|
+
else if (boardError) content = (0, import_react15.createElement)("p", { className: "cb-notice" }, errorText(boardError, t));
|
|
2071
|
+
else if (!board) content = (0, import_react15.createElement)("p", { className: "cb-muted" }, t("loading"));
|
|
2072
|
+
else content = (0, import_react15.createElement)(
|
|
2073
|
+
import_react15.Fragment,
|
|
1714
2074
|
null,
|
|
1715
|
-
board.problems?.length > 0 && (0,
|
|
1716
|
-
board.cards.length === 0 && (0,
|
|
1717
|
-
(0,
|
|
2075
|
+
board.problems?.length > 0 && (0, import_react15.createElement)("div", { className: "cb-notice" }, t("boardProblems"), (0, import_react15.createElement)("ul", { className: "cb-problems" }, board.problems.map((p, i) => (0, import_react15.createElement)("li", { key: i }, p)))),
|
|
2076
|
+
board.cards.length === 0 && (0, import_react15.createElement)("p", { className: "cb-muted" }, t("noCards")),
|
|
2077
|
+
(0, import_react15.createElement)(
|
|
1718
2078
|
"div",
|
|
1719
|
-
{ className: "cb-grid", style: { gridTemplateColumns: `repeat(${tracks}, minmax(0, 1fr))`, gridAutoRows: `${ROW}px`, columnGap: GAP } },
|
|
1720
|
-
|
|
2079
|
+
{ className: "cb-grid", ref: gridRef, style: { gridTemplateColumns: `repeat(${tracks}, minmax(0, 1fr))`, gridAutoRows: `${ROW}px`, columnGap: GAP } },
|
|
2080
|
+
shown.map((entry) => (0, import_react15.createElement)(Card, {
|
|
2081
|
+
key: entry.id,
|
|
2082
|
+
entry,
|
|
2083
|
+
live: liveOf(view.live, entry.id),
|
|
2084
|
+
boardId: board.id,
|
|
2085
|
+
assistant: board.assistant,
|
|
2086
|
+
tracks,
|
|
2087
|
+
active,
|
|
2088
|
+
locale,
|
|
2089
|
+
t,
|
|
2090
|
+
press,
|
|
2091
|
+
undo,
|
|
2092
|
+
kept: kept[entry.id],
|
|
2093
|
+
onOpen: (row) => openCard(board.id, entry.id, row),
|
|
2094
|
+
raised: raised.has(entry.id),
|
|
2095
|
+
dragging: drag?.id === entry.id ? drag : null,
|
|
2096
|
+
drop: drag?.hint?.target === entry.id ? drag.hint.after ? "after" : "before" : void 0,
|
|
2097
|
+
arrange: entry.card && arrangeOf(entry.id)
|
|
2098
|
+
}))
|
|
1721
2099
|
)
|
|
1722
2100
|
);
|
|
1723
2101
|
const openEntry = opened.card && board && (!opened.board || opened.board === board.id) ? board.cards.find((entry) => entry.id === opened.card && entry.card) : void 0;
|
|
1724
2102
|
const openCardData = openEntry && pickCard(openEntry.card, active);
|
|
1725
2103
|
const openRow = openCardData && opened.row !== void 0 ? openCardData.data.rows?.find((r) => r.key === opened.row) : void 0;
|
|
1726
|
-
const sheet = (0,
|
|
2104
|
+
const sheet = (0, import_react15.createElement)(Sheet, {
|
|
1727
2105
|
open: Boolean(openEntry),
|
|
1728
2106
|
onClose: closeCard,
|
|
1729
2107
|
title: openRow ? openRow.title ?? openRow.label : openCardData?.title,
|
|
1730
2108
|
closeLabel: t("close")
|
|
1731
|
-
}, openEntry && (0,
|
|
1732
|
-
return (0,
|
|
2109
|
+
}, openEntry && (0, import_react15.createElement)(Card, { entry: openEntry, live: liveOf(view.live, openEntry.id), boardId: board.id, assistant: board.assistant, tracks: 1, active, locale, t, press, undo, kept: kept[openEntry.id], sheet: true, row: opened.row }));
|
|
2110
|
+
return (0, import_react15.createElement)(
|
|
1733
2111
|
"div",
|
|
1734
2112
|
{ className: "cb-page" },
|
|
1735
|
-
(0,
|
|
2113
|
+
(0, import_react15.createElement)(
|
|
1736
2114
|
"div",
|
|
1737
|
-
{ className: "cb-content", ref:
|
|
1738
|
-
(0,
|
|
2115
|
+
{ className: "cb-content", ref: contentRef },
|
|
2116
|
+
(0, import_react15.createElement)(
|
|
1739
2117
|
"div",
|
|
1740
2118
|
{ className: "cb-heading" },
|
|
1741
|
-
(0,
|
|
1742
|
-
board && (0,
|
|
2119
|
+
(0, import_react15.createElement)("h1", null, boards?.length === 1 ? titleOf(boards[0]) : t("title")),
|
|
2120
|
+
board && (0, import_react15.createElement)(
|
|
2121
|
+
"div",
|
|
2122
|
+
{ className: "cb-sub" },
|
|
2123
|
+
(0, import_react15.createElement)(kit.LiveStatus, { status, updatedAt: newest || void 0 }),
|
|
2124
|
+
board.arrangement && (0, import_react15.createElement)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", className: "cb-reset", title: t("arrange.resetHint"), onClick: () => {
|
|
2125
|
+
keepArrangement(null, board.id);
|
|
2126
|
+
setSaid(t("arrange.resetDone"));
|
|
2127
|
+
} }, t("arrange.reset"))
|
|
2128
|
+
)
|
|
1743
2129
|
),
|
|
1744
|
-
boards && boards.length > 1 && (0,
|
|
2130
|
+
boards && boards.length > 1 && (0, import_react15.createElement)("div", { className: "cb-tabs", role: "tablist" }, boards.map((b) => (0, import_react15.createElement)(import_dsh_client_ui_primitives5.Pill, { key: b.id, active: b.id === current, role: "tab", "aria-selected": b.id === current, title: titleOf(b), onClick: () => choose(b.id) }, titleOf(b)))),
|
|
1745
2131
|
content
|
|
1746
2132
|
),
|
|
1747
2133
|
board && sheet,
|
|
1748
|
-
|
|
2134
|
+
(0, import_react15.createElement)("div", { className: "cb-sr", role: "status", "aria-live": "polite" }, said),
|
|
2135
|
+
toast && (0, import_react15.createElement)(import_dsh_client_ui_primitives5.Toast, {
|
|
1749
2136
|
key: toast.seq,
|
|
1750
2137
|
text: t(toast.text),
|
|
1751
2138
|
tone: "success",
|
|
1752
|
-
...toast.undo ? { holdMs: UNDO_HOLD_MS, actions: [{ label: (0,
|
|
2139
|
+
...toast.undo ? { holdMs: UNDO_HOLD_MS, actions: [{ label: (0, import_react15.createElement)("span", { className: "cb-toastUndo" }, t("undo")), onClick: () => {
|
|
1753
2140
|
setToast(null);
|
|
1754
2141
|
toast.undo();
|
|
1755
2142
|
} }] } : {},
|
|
@@ -1763,17 +2150,17 @@ var NS = "dsh-card-board";
|
|
|
1763
2150
|
var PANEL = "dsh-card-board";
|
|
1764
2151
|
function SidebarIcon({ size }) {
|
|
1765
2152
|
const stroke = { stroke: "currentColor", strokeWidth: 1.2, strokeLinecap: "round", strokeLinejoin: "round", fill: "none" };
|
|
1766
|
-
return (0,
|
|
2153
|
+
return (0, import_react16.createElement)(
|
|
1767
2154
|
"svg",
|
|
1768
2155
|
{ width: size, height: size, viewBox: "0 0 16 16", "aria-hidden": true, focusable: "false" },
|
|
1769
|
-
(0,
|
|
1770
|
-
(0,
|
|
1771
|
-
(0,
|
|
1772
|
-
(0,
|
|
2156
|
+
(0, import_react16.createElement)("rect", { x: 1.75, y: 1.75, width: 5.5, height: 5.5, rx: 1.4, ...stroke }),
|
|
2157
|
+
(0, import_react16.createElement)("rect", { x: 8.75, y: 1.75, width: 5.5, height: 5.5, rx: 1.4, ...stroke }),
|
|
2158
|
+
(0, import_react16.createElement)("rect", { x: 1.75, y: 8.75, width: 5.5, height: 5.5, rx: 1.4, ...stroke }),
|
|
2159
|
+
(0, import_react16.createElement)("path", { d: "M9 13.5l1.6-2 1.4 1 2-2.8", ...stroke })
|
|
1773
2160
|
);
|
|
1774
2161
|
}
|
|
1775
2162
|
function Page() {
|
|
1776
|
-
return useKit() === null ? (0,
|
|
2163
|
+
return useKit() === null ? (0, import_react16.createElement)("div", { className: "cb-page" }) : (0, import_react16.createElement)(BoardsPage);
|
|
1777
2164
|
}
|
|
1778
2165
|
var inject = ["slots", "locale"];
|
|
1779
2166
|
function apply(ctx) {
|