@soffits/dsh-card-board 0.8.0 → 0.9.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 +10 -0
- package/README.md +22 -4
- package/client.js +547 -225
- package/examples/boards/home/cards/chores.json +46 -3
- package/examples/boards/home/cards/weather.json +2 -1
- package/locale/en.json +6 -2
- package/locale/fr.json +6 -2
- package/locale/zh.json +6 -2
- package/package.json +1 -1
- package/src/presses.js +3 -1
- package/src/schema.js +51 -4
package/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @soffits/dsh-card-board 0.
|
|
1
|
+
/* @soffits/dsh-card-board 0.9.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_react12 = require("react");
|
|
33
33
|
|
|
34
34
|
// src/client/look.js
|
|
35
35
|
var STYLE_ID = "dsh-card-board-style";
|
|
@@ -127,8 +127,8 @@ h3.cb-truncOpen{overflow:visible}
|
|
|
127
127
|
.cb-when{flex:none;color:var(--dsw-alias-label-tertiary);font-size:12px;font-variant-numeric:tabular-nums}
|
|
128
128
|
.cb-rowActions{display:inline-flex;flex-wrap:wrap;justify-content:flex-end;min-width:0}
|
|
129
129
|
.cb-rowSteps{flex-basis:100%;min-width:0;padding-left:41px}
|
|
130
|
-
.cb-
|
|
131
|
-
.cb-
|
|
130
|
+
.cb-doneBox{flex:none;display:inline-flex;align-items:center;min-width:28px;min-height:28px;justify-content:center}
|
|
131
|
+
.cb-visuallyHidden{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
|
|
132
132
|
.cb-dotSlot{flex:none;display:inline-grid;place-items:center;width:28px}
|
|
133
133
|
.cb-statusSpark{flex:0 1 90px;min-width:48px}
|
|
134
134
|
.cb-statusValue{flex:none;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}
|
|
@@ -175,7 +175,7 @@ h3.cb-truncOpen{overflow:visible}
|
|
|
175
175
|
.cb-row>.cb-statusValue{grid-column:3;grid-row:1}
|
|
176
176
|
.cb-statusRow>.cb-rowActions{grid-row:2}
|
|
177
177
|
.cb-row>.cb-rowSteps{grid-column:2/-1;padding-left:0}
|
|
178
|
-
.cb-row>.cb-
|
|
178
|
+
.cb-row>.cb-doneBox+.uk-tile{display:none}
|
|
179
179
|
}
|
|
180
180
|
@container (width<520px){
|
|
181
181
|
.cb-track{grid-auto-flow:row;grid-auto-columns:auto;gap:10px}
|
|
@@ -193,6 +193,56 @@ h3.cb-truncOpen{overflow:visible}
|
|
|
193
193
|
.cb-summaryText{font-size:16px;line-height:24px}
|
|
194
194
|
.cb-statValue{font-size:24px;line-height:30px}
|
|
195
195
|
}
|
|
196
|
+
/* Touch and pointer: cards and rows answer a hover and a press, in DSH's own interactive colours and motion. */
|
|
197
|
+
.cb-card{transition:box-shadow var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease),transform var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease)}
|
|
198
|
+
.cb-cardOpenable{cursor:pointer}
|
|
199
|
+
button.cb-cardOpen{border:0;background:transparent;padding:0;font:inherit;cursor:pointer}
|
|
200
|
+
@media (hover:hover) and (pointer:fine){.cb-cardOpen{opacity:0;transition:opacity var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease)}.cb-card:hover .cb-cardOpen,.cb-cardOpen:focus-visible{opacity:1}}
|
|
201
|
+
.cb-cardOpenable:active{transform:scale(.995)}
|
|
202
|
+
.cb-rowOpens{cursor:pointer}
|
|
203
|
+
.cb-row{transition:background-color var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease)}
|
|
204
|
+
.cb-rowOpens:active{background:var(--dsw-alias-interactive-bg-active,var(--dsw-alias-interactive-bg-hover))}
|
|
205
|
+
.cb-rowOpens:focus-visible,.cb-cardOpen:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
|
|
206
|
+
.cb-statLink{color:inherit;text-decoration:none;border-radius:10px;margin:-4px -6px;padding:4px 6px;transition:background-color var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease)}
|
|
207
|
+
.cb-statLink:active{background:var(--dsw-alias-interactive-bg-active,var(--dsw-alias-interactive-bg-hover))}
|
|
208
|
+
@media (hover:hover) and (pointer:fine){
|
|
209
|
+
.cb-cardOpenable:hover{box-shadow:inset 0 0 0 .5px var(--dsw-alias-border-l3),0 2px 10px color-mix(in srgb,var(--dsw-alias-label-primary) 6%,transparent)}
|
|
210
|
+
.cb-row:hover,.cb-statLink:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
211
|
+
/* a row's buttons show on hover or focus; on touch they are always there */
|
|
212
|
+
.cb-row .cb-rowActions{opacity:0;transition:opacity var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease)}
|
|
213
|
+
.cb-row:hover .cb-rowActions,.cb-row:focus-within .cb-rowActions{opacity:1}
|
|
214
|
+
}
|
|
215
|
+
/* Motion: a changed card settles, rows that open in a list fade in, numbers ease (motion.js). */
|
|
216
|
+
@keyframes cb-settle{from{transform:translateY(3px);opacity:.55}to{transform:none;opacity:1}}
|
|
217
|
+
@keyframes cb-in{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}
|
|
218
|
+
.cb-card.uk-wash .cb-cardBody,.cb-card.uk-wash .cb-stats{animation:cb-settle var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease) both}
|
|
219
|
+
.cb-rowLate{animation:cb-in var(--ds-transition-duration,.2s) var(--ds-ease-in-out,ease) both}
|
|
220
|
+
@media (prefers-reduced-motion:reduce){.cb-card,.cb-row,.cb-statLink{transition:none}.cb-card.uk-wash .cb-cardBody,.cb-card.uk-wash .cb-stats,.cb-rowLate{animation:none}.cb-cardOpenable:active{transform:none}}
|
|
221
|
+
/* What is chrome is not selectable (heads, tags, axes, legends, strips, buttons, times); titles, notes and numbers are. */
|
|
222
|
+
.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{-webkit-user-select:none;user-select:none}
|
|
223
|
+
.cb-cardHead h3{-webkit-user-select:text;user-select:text}
|
|
224
|
+
.cb-card svg,.cb-card img{-webkit-user-drag:none}
|
|
225
|
+
/* The point under the pointer on a chart */
|
|
226
|
+
.cb-chart{position:relative}
|
|
227
|
+
.cb-plot{touch-action:pan-y}
|
|
228
|
+
.cb-hoverRule{stroke:var(--dsw-alias-border-l3);stroke-width:1}
|
|
229
|
+
.cb-bubble{position:absolute;top:4px;z-index:1;pointer-events:none;padding:5px 8px;border-radius:8px;background:var(--dsw-alias-bg-base);box-shadow:0 2px 10px color-mix(in srgb,var(--dsw-alias-label-primary) 14%,transparent),inset 0 0 0 .5px var(--dsw-alias-border-l2);color:var(--dsw-alias-label-primary);font-size:12px;line-height:17px;white-space:nowrap;font-variant-numeric:tabular-nums}
|
|
230
|
+
.cb-bubbleHead{color:var(--dsw-alias-label-tertiary)}
|
|
231
|
+
/* The opened card */
|
|
232
|
+
.cb-sheetModal.cb-sheetModal{width:min(720px,calc(100vw - 32px));max-width:none}
|
|
233
|
+
.cb-sheet{min-width:0}
|
|
234
|
+
.cb-cardInSheet{padding:0;box-shadow:none;background:transparent;border-radius:0}
|
|
235
|
+
.cb-detail{display:flex;flex-direction:column;gap:14px;margin-top:4px}
|
|
236
|
+
.cb-detailText{margin:0;color:var(--dsw-alias-label-secondary);font-size:14px;line-height:21px;white-space:pre-wrap}
|
|
237
|
+
.cb-facts{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 18px;margin:0;font-size:13px;line-height:19px}
|
|
238
|
+
.cb-facts dt{color:var(--dsw-alias-label-tertiary);-webkit-user-select:none;user-select:none}
|
|
239
|
+
.cb-facts dd{margin:0;color:var(--dsw-alias-label-primary);overflow-wrap:anywhere}
|
|
240
|
+
.cb-detailHistory h4{margin:0 0 6px;font-size:12px;font-weight:500;color:var(--dsw-alias-label-tertiary);-webkit-user-select:none;user-select:none}
|
|
241
|
+
.cb-sheetChat{display:flex;justify-content:flex-end}
|
|
242
|
+
.cb-rowSheet{display:flex;flex-direction:column;gap:12px}
|
|
243
|
+
/* the opened view shows every word: nothing is cut to a line or two */
|
|
244
|
+
.cb-sheet .cb-trunc{white-space:normal;display:block;-webkit-line-clamp:unset;overflow:visible;text-overflow:clip}
|
|
245
|
+
@media (width<=640px){.cb-sheetModal.cb-sheetModal{width:calc(100vw - 16px)}}
|
|
196
246
|
@media (width<=768px),(pointer:coarse){
|
|
197
247
|
.cb-cardLink{width:40px;height:40px;margin:-9px 0}
|
|
198
248
|
.cb-cardChat{margin:-9px -10px -9px 0}
|
|
@@ -200,19 +250,18 @@ h3.cb-truncOpen{overflow:visible}
|
|
|
200
250
|
`;
|
|
201
251
|
|
|
202
252
|
// src/client/page.js
|
|
203
|
-
var
|
|
253
|
+
var import_react11 = require("react");
|
|
204
254
|
var import_dsh_client_ui_primitives4 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
205
255
|
|
|
206
256
|
// src/client/card.js
|
|
207
|
-
var
|
|
208
|
-
var
|
|
257
|
+
var import_react9 = require("react");
|
|
258
|
+
var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
209
259
|
|
|
210
260
|
// src/client/charts.js
|
|
211
261
|
var import_react4 = require("react");
|
|
212
262
|
|
|
213
263
|
// src/client/pieces.js
|
|
214
264
|
var import_react = require("react");
|
|
215
|
-
var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
216
265
|
function Trunc({ text, as = "div", className = "", lines = 1 }) {
|
|
217
266
|
const [open, setOpen] = (0, import_react.useState)(false);
|
|
218
267
|
return (0, import_react.createElement)(as, {
|
|
@@ -221,13 +270,6 @@ function Trunc({ text, as = "div", className = "", lines = 1 }) {
|
|
|
221
270
|
onClick: () => setOpen((value) => !value)
|
|
222
271
|
}, text);
|
|
223
272
|
}
|
|
224
|
-
function CheckBox({ checked, label }) {
|
|
225
|
-
return (0, import_react.createElement)(
|
|
226
|
-
"span",
|
|
227
|
-
{ className: "cb-check", "data-checked": checked ? "true" : "false", role: "img", "aria-label": label },
|
|
228
|
-
checked && (0, import_react.createElement)(import_dsh_client_ui_primitives.IconCheckOutlineMedium, { size: 12 })
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
273
|
|
|
232
274
|
// src/client/format.js
|
|
233
275
|
var import_react2 = require("react");
|
|
@@ -327,6 +369,28 @@ var useButtons = () => (0, import_react3.useSyncExternalStore)(buttonsStore.subs
|
|
|
327
369
|
// src/client/charts.js
|
|
328
370
|
var PALETTE = ["accent", "ok", "warn", "violet", "bad", "muted"];
|
|
329
371
|
var toneColor = (tone, index = 0) => kitStore.get().toneColor(tone ?? PALETTE[index % PALETTE.length]);
|
|
372
|
+
function usePointer(pick) {
|
|
373
|
+
const [at, setAt] = (0, import_react4.useState)(null);
|
|
374
|
+
const fromEvent = (event) => {
|
|
375
|
+
const box = event.currentTarget.getBoundingClientRect();
|
|
376
|
+
return pick(event.clientX - box.left);
|
|
377
|
+
};
|
|
378
|
+
return [at, {
|
|
379
|
+
onPointerMove: (event) => setAt(fromEvent(event)),
|
|
380
|
+
onPointerDown: (event) => setAt(fromEvent(event)),
|
|
381
|
+
onPointerLeave: (event) => {
|
|
382
|
+
if (event.pointerType === "mouse") setAt(null);
|
|
383
|
+
}
|
|
384
|
+
}, () => setAt(null)];
|
|
385
|
+
}
|
|
386
|
+
function Bubble({ x, width, lines }) {
|
|
387
|
+
const flip = x > width * 0.6;
|
|
388
|
+
return (0, import_react4.createElement)(
|
|
389
|
+
"div",
|
|
390
|
+
{ className: "cb-bubble", role: "status", style: flip ? { right: Math.max(0, width - x + 10) } : { left: x + 10 } },
|
|
391
|
+
lines.map((line, i) => (0, import_react4.createElement)("div", { key: i, className: i === 0 ? "cb-bubbleHead" : void 0 }, line))
|
|
392
|
+
);
|
|
393
|
+
}
|
|
330
394
|
function Legend({ items, locale }) {
|
|
331
395
|
return (0, import_react4.createElement)("ul", { className: "cb-legend" }, items.map((item, i) => (0, import_react4.createElement)(
|
|
332
396
|
"li",
|
|
@@ -402,9 +466,20 @@ function LineChart({ data, locale, height }) {
|
|
|
402
466
|
return d;
|
|
403
467
|
};
|
|
404
468
|
const gradientId = (0, import_react4.useMemo)(() => `cb-g-${Math.random().toString(36).slice(2, 9)}`, []);
|
|
405
|
-
|
|
469
|
+
const xsAll = (0, import_react4.useMemo)(() => [...new Set(data.series.flatMap((s) => s.points.filter((p) => typeof p.y === "number").map((p) => p.x)))], [data]);
|
|
470
|
+
const [hover, pointer] = usePointer((px) => {
|
|
471
|
+
let best = null;
|
|
472
|
+
for (const x of xsAll) if (best === null || Math.abs(sx(x) - px) < Math.abs(sx(best) - px)) best = x;
|
|
473
|
+
return best;
|
|
474
|
+
});
|
|
475
|
+
const hoverX = hover === null ? null : sx(hover);
|
|
476
|
+
const hoverLines = hover === null ? [] : [model.timeAxis ? formatDay(toTime(hover), locale, 0) : xLabel(hover), ...data.series.flatMap((s) => {
|
|
477
|
+
const p = s.points.find((q) => q.x === hover && typeof q.y === "number");
|
|
478
|
+
return p ? [`${s.name ? `${s.name}: ` : ""}${formatNumber(p.y, locale)}${data.unit ? ` ${data.unit}` : ""}`] : [];
|
|
479
|
+
})];
|
|
480
|
+
return (0, import_react4.createElement)("div", { ref, className: "cb-chart", style: { height } }, width > 0 && hover !== null && (0, import_react4.createElement)(Bubble, { x: hoverX, width, lines: hoverLines }), width > 0 && (0, import_react4.createElement)(
|
|
406
481
|
"svg",
|
|
407
|
-
{ width, height, role: "img" },
|
|
482
|
+
{ width, height, role: "img", className: "cb-plot", ...pointer },
|
|
408
483
|
(0, import_react4.createElement)("defs", null, data.series.map((s, i) => (0, import_react4.createElement)(
|
|
409
484
|
"linearGradient",
|
|
410
485
|
{ key: i, id: `${gradientId}-${i}`, x1: 0, y1: 0, x2: 0, y2: 1 },
|
|
@@ -449,7 +524,16 @@ function LineChart({ data, locale, height }) {
|
|
|
449
524
|
)),
|
|
450
525
|
valid.length > 16 && last && (0, import_react4.createElement)("circle", { cx: sx(last.x), cy: sy(last.y), r: 3, fill: color })
|
|
451
526
|
);
|
|
452
|
-
})
|
|
527
|
+
}),
|
|
528
|
+
hover !== null && (0, import_react4.createElement)(
|
|
529
|
+
"g",
|
|
530
|
+
{ className: "cb-hover" },
|
|
531
|
+
(0, import_react4.createElement)("line", { x1: hoverX, x2: hoverX, y1: top, y2: top + plotH, className: "cb-hoverRule" }),
|
|
532
|
+
data.series.map((s, i) => {
|
|
533
|
+
const p = s.points.find((q) => q.x === hover && typeof q.y === "number");
|
|
534
|
+
return p && (0, import_react4.createElement)("circle", { key: i, cx: hoverX, cy: sy(p.y), r: 4, fill: toneColor(s.tone, i), stroke: "var(--dsw-alias-bg-base)", strokeWidth: 2 });
|
|
535
|
+
})
|
|
536
|
+
)
|
|
453
537
|
));
|
|
454
538
|
}
|
|
455
539
|
function BarChart({ data, locale, height }) {
|
|
@@ -476,51 +560,58 @@ function BarChart({ data, locale, height }) {
|
|
|
476
560
|
const time = toTime(x);
|
|
477
561
|
return Number.isFinite(time) ? formatDay(time, locale, 0) : String(x);
|
|
478
562
|
};
|
|
563
|
+
const [hover, pointer] = usePointer((px) => Math.max(0, Math.min(data.bars.length - 1, Math.floor(px / slot))));
|
|
564
|
+
const tipOf = (bar) => multi ? [label(bar.x), ...keys.filter((k) => bar.values?.[k] !== void 0).map((k) => `${k}: ${formatNumber(bar.values[k], locale)}${data.unit ? ` ${data.unit}` : ""}`)] : [label(bar.x), `${formatNumber(bar.value, locale)}${data.unit ? ` ${data.unit}` : ""}`];
|
|
479
565
|
return (0, import_react4.createElement)(
|
|
480
566
|
"div",
|
|
481
567
|
null,
|
|
482
|
-
(0, import_react4.createElement)(
|
|
483
|
-
"
|
|
484
|
-
{
|
|
485
|
-
(0, import_react4.createElement)(
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
parts
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
base
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
568
|
+
(0, import_react4.createElement)(
|
|
569
|
+
"div",
|
|
570
|
+
{ ref, className: "cb-chart", style: { height } },
|
|
571
|
+
width > 0 && hover !== null && data.bars[hover] && (0, import_react4.createElement)(Bubble, { x: slot * hover + slot / 2, width, lines: tipOf(data.bars[hover]) }),
|
|
572
|
+
width > 0 && (0, import_react4.createElement)(
|
|
573
|
+
"svg",
|
|
574
|
+
{ width, height, role: "img", className: "cb-plot", ...pointer },
|
|
575
|
+
(0, import_react4.createElement)("line", { x1: 0, x2: width, y1: top + plotH + 0.5, y2: top + plotH + 0.5, className: "cb-rule" }),
|
|
576
|
+
data.goal && (0, import_react4.createElement)("line", { x1: 0, x2: width, y1: sy(data.goal.y), y2: sy(data.goal.y), className: "cb-goal" }),
|
|
577
|
+
data.goal?.label && (0, import_react4.createElement)("text", { x: width, y: sy(data.goal.y) - 4, className: "cb-goalLabel", textAnchor: "end" }, (0, import_react4.createElement)("title", null, data.goal.label), fit(data.goal.label, width)),
|
|
578
|
+
data.bars.map((bar, i) => {
|
|
579
|
+
const cx = slot * i + slot / 2;
|
|
580
|
+
const tip = multi ? `${label(bar.x)}: ${keys.filter((k) => bar.values?.[k] !== void 0).map((k) => `${k} ${formatNumber(bar.values[k], locale)}`).join(", ")}` : `${label(bar.x)}: ${formatNumber(bar.value, locale)}${data.unit ? ` ${data.unit}` : ""}`;
|
|
581
|
+
let parts;
|
|
582
|
+
if (!multi) parts = [{ y0: 0, y1: Math.max(0, bar.value), color: toneColor(void 0, 1), x: cx - barW / 2, w: barW }];
|
|
583
|
+
else if (stacked) {
|
|
584
|
+
let base = 0;
|
|
585
|
+
parts = keys.map((key, k) => {
|
|
586
|
+
const v = Math.max(0, bar.values?.[key] ?? 0);
|
|
587
|
+
const part2 = { y0: base, y1: base + v, color: toneColor(void 0, k), x: cx - barW / 2, w: barW };
|
|
588
|
+
base += v;
|
|
589
|
+
return part2;
|
|
590
|
+
});
|
|
591
|
+
} else {
|
|
592
|
+
const each = barW / keys.length;
|
|
593
|
+
parts = keys.map((key, k) => ({ y0: 0, y1: Math.max(0, bar.values?.[key] ?? 0), color: toneColor(void 0, k), x: cx - barW / 2 + k * each, w: Math.max(1, each - 1) }));
|
|
594
|
+
}
|
|
595
|
+
return (0, import_react4.createElement)(
|
|
596
|
+
"g",
|
|
597
|
+
{ key: i },
|
|
598
|
+
(0, import_react4.createElement)("title", null, tip),
|
|
599
|
+
parts.filter((p) => p.y1 > p.y0).map((p, k) => (0, import_react4.createElement)("rect", {
|
|
600
|
+
key: k,
|
|
601
|
+
x: p.x,
|
|
602
|
+
width: p.w,
|
|
603
|
+
y: sy(p.y1),
|
|
604
|
+
height: Math.max(0.5, sy(p.y0) - sy(p.y1)),
|
|
605
|
+
rx: Math.min(4, p.w / 3),
|
|
606
|
+
fill: p.color,
|
|
607
|
+
fillOpacity: hover === i ? 1 : multi ? 0.85 : 0.55
|
|
608
|
+
})),
|
|
609
|
+
showValues && (0, import_react4.createElement)("text", { x: cx, y: sy(peaks[i]) - 4, className: "cb-barValue", textAnchor: "middle" }, formatNumber(multi && !stacked ? peaks[i] : totals[i], locale, 1)),
|
|
610
|
+
i % labelEvery === 0 && (0, import_react4.createElement)("text", { x: Math.min(Math.max(cx, textWidth(label(bar.x)) / 2), width - textWidth(label(bar.x)) / 2), y: height - 4, className: "cb-axis", textAnchor: "middle" }, label(bar.x))
|
|
611
|
+
);
|
|
612
|
+
})
|
|
613
|
+
)
|
|
614
|
+
),
|
|
524
615
|
multi && (0, import_react4.createElement)(Legend, { items: keys.map((key, k) => ({ label: key, color: toneColor(void 0, k) })), locale })
|
|
525
616
|
);
|
|
526
617
|
}
|
|
@@ -654,8 +745,50 @@ function Timeline({ data, locale }) {
|
|
|
654
745
|
}
|
|
655
746
|
|
|
656
747
|
// src/client/cards.js
|
|
748
|
+
var import_react6 = require("react");
|
|
749
|
+
var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
750
|
+
|
|
751
|
+
// src/client/motion.js
|
|
657
752
|
var import_react5 = require("react");
|
|
658
|
-
var
|
|
753
|
+
var reduced = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
754
|
+
function useEased(value, ms = 500) {
|
|
755
|
+
const [shown, setShown] = (0, import_react5.useState)(value);
|
|
756
|
+
const from = (0, import_react5.useRef)(value);
|
|
757
|
+
(0, import_react5.useEffect)(() => {
|
|
758
|
+
const start = from.current;
|
|
759
|
+
from.current = value;
|
|
760
|
+
if (typeof value !== "number" || typeof start !== "number" || start === value || reduced() || typeof requestAnimationFrame !== "function") {
|
|
761
|
+
setShown(value);
|
|
762
|
+
return void 0;
|
|
763
|
+
}
|
|
764
|
+
const begin = performance.now();
|
|
765
|
+
let frame = 0;
|
|
766
|
+
const step = (now) => {
|
|
767
|
+
const k = Math.min(1, (now - begin) / ms);
|
|
768
|
+
const eased = 1 - (1 - k) ** 3;
|
|
769
|
+
setShown(k >= 1 ? value : start + (value - start) * eased);
|
|
770
|
+
if (k < 1) frame = requestAnimationFrame(step);
|
|
771
|
+
};
|
|
772
|
+
frame = requestAnimationFrame(step);
|
|
773
|
+
return () => cancelAnimationFrame(frame);
|
|
774
|
+
}, [value, ms]);
|
|
775
|
+
return shown;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
// src/client/links.js
|
|
779
|
+
function openLink(link) {
|
|
780
|
+
if (/^https?:/i.test(link)) {
|
|
781
|
+
window.open(link, "_blank", "noopener,noreferrer");
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
const url = new URL(link, window.location.origin);
|
|
785
|
+
if (url.origin !== window.location.origin) return;
|
|
786
|
+
window.history.pushState(null, "", url.pathname + url.search + url.hash);
|
|
787
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
788
|
+
}
|
|
789
|
+
function onControl(event) {
|
|
790
|
+
return Boolean(event.target?.closest?.("button,a,input,select,textarea,label,[role=button],[role=checkbox],[role=menuitem]"));
|
|
791
|
+
}
|
|
659
792
|
|
|
660
793
|
// src/client/steps.js
|
|
661
794
|
function ownOffset(at) {
|
|
@@ -712,139 +845,195 @@ function shownRows(rows, open, limit, live) {
|
|
|
712
845
|
// src/client/cards.js
|
|
713
846
|
var STATE_OF_TONE = { ok: "done", warn: "warning", bad: "error" };
|
|
714
847
|
var DIRECTION_ICON = { up: "trending-up", down: "trending-down" };
|
|
848
|
+
function EasedNumber({ value, locale }) {
|
|
849
|
+
const shown = useEased(value);
|
|
850
|
+
if (typeof value !== "number") return formatNumber(value, locale);
|
|
851
|
+
const decimals = Math.min(3, (String(value).split(".")[1] ?? "").length);
|
|
852
|
+
return formatNumber(shown === value ? value : Number(shown.toFixed(decimals)), locale);
|
|
853
|
+
}
|
|
715
854
|
function StatBlock({ data, locale, compact, wash }) {
|
|
716
855
|
const kit = useKit();
|
|
717
|
-
return (0,
|
|
718
|
-
"div",
|
|
719
|
-
{ key: i, className: `cb-stat${item.strip ? " cb-statWide" : ""}
|
|
720
|
-
(0,
|
|
721
|
-
(0,
|
|
856
|
+
return (0, import_react6.createElement)("div", { className: `cb-stats${compact ? " cb-statsCompact" : ""}` }, data.items.map((item, i) => (0, import_react6.createElement)(
|
|
857
|
+
item.link ? "a" : "div",
|
|
858
|
+
{ key: i, className: `cb-stat${item.strip ? " cb-statWide" : ""}${item.link ? " cb-statLink" : ""}`, ...item.link ? linkProps(item.link) : {} },
|
|
859
|
+
(0, import_react6.createElement)("div", { className: "cb-statLabel" }, (0, import_react6.createElement)(Trunc, { as: "span", text: item.label }), i === 0 && wash && (0, import_react6.createElement)(kit.JustNow)),
|
|
860
|
+
(0, import_react6.createElement)(
|
|
722
861
|
"div",
|
|
723
862
|
{ className: "cb-statValue", style: item.tone ? { color: kit.toneColor(item.tone) } : void 0 },
|
|
724
|
-
(0,
|
|
725
|
-
item.unit && (0,
|
|
863
|
+
(0, import_react6.createElement)("span", null, (0, import_react6.createElement)(EasedNumber, { value: item.value, locale })),
|
|
864
|
+
item.unit && (0, import_react6.createElement)("small", null, item.unit)
|
|
726
865
|
),
|
|
727
|
-
item.delta && (0,
|
|
866
|
+
item.delta && (0, import_react6.createElement)(
|
|
728
867
|
"div",
|
|
729
868
|
{ className: "cb-delta", style: { color: kit.toneColor(item.delta.tone ?? "muted") } },
|
|
730
|
-
DIRECTION_ICON[item.delta.dir] && (0,
|
|
731
|
-
(0,
|
|
869
|
+
DIRECTION_ICON[item.delta.dir] && (0, import_react6.createElement)(kit.Icon, { name: DIRECTION_ICON[item.delta.dir], size: 13 }),
|
|
870
|
+
(0, import_react6.createElement)("span", null, item.delta.text)
|
|
732
871
|
),
|
|
733
|
-
item.progress && (0,
|
|
872
|
+
item.progress && (0, import_react6.createElement)(
|
|
734
873
|
"div",
|
|
735
874
|
{ className: "cb-statProgress" },
|
|
736
|
-
(0,
|
|
737
|
-
item.progress.text && (0,
|
|
875
|
+
(0, import_react6.createElement)(kit.Progress, { value: item.progress.value, max: item.progress.max, tone: item.tone ?? (item.progress.value > item.progress.max ? "warn" : "ok") }),
|
|
876
|
+
item.progress.text && (0, import_react6.createElement)("div", { className: "cb-statSub" }, item.progress.text)
|
|
738
877
|
),
|
|
739
|
-
item.spark && (0,
|
|
740
|
-
item.sub && (0,
|
|
741
|
-
item.strip && (0,
|
|
878
|
+
item.spark && (0, import_react6.createElement)(kit.Spark, { values: item.spark, tone: item.tone ?? "accent", height: 28, area: true }),
|
|
879
|
+
item.sub && (0, import_react6.createElement)(Trunc, { className: "cb-statSub", lines: 2, text: item.sub }),
|
|
880
|
+
item.strip && (0, import_react6.createElement)("ol", { className: "cb-strip" }, item.strip.map((cell, j) => (0, import_react6.createElement)(
|
|
742
881
|
"li",
|
|
743
882
|
{ key: j, "data-on": cell.on ? "true" : void 0 },
|
|
744
|
-
(0,
|
|
745
|
-
cell.icon && (0,
|
|
746
|
-
(0,
|
|
883
|
+
(0, import_react6.createElement)("b", null, formatNumber(cell.value, locale, 1)),
|
|
884
|
+
cell.icon && (0, import_react6.createElement)(kit.Icon, { name: cell.icon, size: 14 }),
|
|
885
|
+
(0, import_react6.createElement)("span", null, cell.label)
|
|
747
886
|
)))
|
|
748
887
|
)));
|
|
749
888
|
}
|
|
889
|
+
function linkProps(link) {
|
|
890
|
+
const external = /^https?:/i.test(link);
|
|
891
|
+
return { href: link, ...external ? { target: "_blank", rel: "noopener noreferrer" } : { onClick: (event) => {
|
|
892
|
+
event.preventDefault();
|
|
893
|
+
openLink(link);
|
|
894
|
+
} } };
|
|
895
|
+
}
|
|
750
896
|
function RowWhen({ row, locale, t }) {
|
|
751
897
|
const kit = useKit();
|
|
752
898
|
const now = kit.useNow();
|
|
753
899
|
if (row.active) {
|
|
754
|
-
if (isActive(row.active, now)) return (0,
|
|
900
|
+
if (isActive(row.active, now)) return (0, import_react6.createElement)(import_dsh_client_ui_primitives.Tag, { tone: "info" }, t("now"));
|
|
755
901
|
const from = Date.parse(row.active.from);
|
|
756
|
-
if (from > now && new Date(from).toDateString() === new Date(now).toDateString()) return (0,
|
|
902
|
+
if (from > now && new Date(from).toDateString() === new Date(now).toDateString()) return (0, import_react6.createElement)("span", { className: "cb-when" }, t("fromTime", { time: formatClock(from, locale) }));
|
|
757
903
|
}
|
|
758
|
-
return row.date ? (0,
|
|
904
|
+
return row.date ? (0, import_react6.createElement)("span", { className: "cb-when" }, (0, import_react6.createElement)(kit.RelativeDay, { date: row.date })) : null;
|
|
759
905
|
}
|
|
760
|
-
function Row({ lead, title, sub, meta, value, spark, row, index, washCount, fresh, rowActions, className }) {
|
|
906
|
+
function Row({ lead, title, sub, meta, value, spark, row, index, washCount, fresh, rowActions, className, onOpenRow }) {
|
|
761
907
|
const kit = useKit();
|
|
762
908
|
const now = kit.useNow();
|
|
763
909
|
const wash = kit.useWash(washCount, row.key);
|
|
764
|
-
|
|
910
|
+
const go = row.link ? () => openLink(row.link) : row.detail && row.key !== void 0 && onOpenRow ? () => onOpenRow(row.key) : null;
|
|
911
|
+
const opens = go && {
|
|
912
|
+
"data-opens": "true",
|
|
913
|
+
role: row.link ? "link" : "button",
|
|
914
|
+
tabIndex: 0,
|
|
915
|
+
onClick: (event) => {
|
|
916
|
+
if (!onControl(event)) {
|
|
917
|
+
event.stopPropagation();
|
|
918
|
+
go();
|
|
919
|
+
}
|
|
920
|
+
},
|
|
921
|
+
onKeyDown: (event) => {
|
|
922
|
+
if ((event.key === "Enter" || event.key === " ") && event.target === event.currentTarget) {
|
|
923
|
+
event.preventDefault();
|
|
924
|
+
go();
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
return (0, import_react6.createElement)(
|
|
765
929
|
"li",
|
|
766
|
-
{ className: ["cb-row", className, row.checked && "cb-done", isActive(row.active, now) && "cb-rowNow", wash].filter(Boolean).join(" ") },
|
|
930
|
+
{ className: ["cb-row", className, row.checked && "cb-done", isActive(row.active, now) && "cb-rowNow", go && "cb-rowOpens", wash].filter(Boolean).join(" "), ...opens },
|
|
767
931
|
lead,
|
|
768
|
-
(0,
|
|
932
|
+
(0, import_react6.createElement)(
|
|
769
933
|
"div",
|
|
770
934
|
{ className: "cb-rowText" },
|
|
771
|
-
(0,
|
|
772
|
-
sub && (0,
|
|
935
|
+
(0, import_react6.createElement)("div", { className: "cb-rowTitle" }, fresh && (0, import_react6.createElement)(kit.NewDot), (0, import_react6.createElement)(Trunc, { as: "span", lines: 2, text: title })),
|
|
936
|
+
sub && (0, import_react6.createElement)(Trunc, { className: "cb-rowSub", lines: 2, text: sub })
|
|
773
937
|
),
|
|
774
938
|
spark,
|
|
775
939
|
meta,
|
|
776
940
|
value,
|
|
777
|
-
|
|
778
|
-
row.actions
|
|
941
|
+
// The row's own buttons on the right: its steps first (a step starts the work on one tap), then the others.
|
|
942
|
+
row.actions && rowActions && (0, import_react6.createElement)(
|
|
943
|
+
"span",
|
|
944
|
+
{ className: "cb-rowActions" },
|
|
945
|
+
row.actions.some((action) => action.kind === "step") && rowActions(index, row.actions, "steps"),
|
|
946
|
+
rowActions(index, row.actions, "buttons")
|
|
947
|
+
)
|
|
948
|
+
);
|
|
949
|
+
}
|
|
950
|
+
function DoneBox({ row, index, done, rowControls, t }) {
|
|
951
|
+
const state = rowControls.state(index, done.id);
|
|
952
|
+
const checked = row.checked === true || state === "done" || state === "pending";
|
|
953
|
+
return (0, import_react6.createElement)(
|
|
954
|
+
"span",
|
|
955
|
+
{ className: "cb-doneBox", onClick: (event) => event.stopPropagation() },
|
|
956
|
+
(0, import_react6.createElement)(import_dsh_client_ui_primitives.Checkbox, {
|
|
957
|
+
checked,
|
|
958
|
+
disabled: checked,
|
|
959
|
+
title: t(checked ? "checked" : "markDone"),
|
|
960
|
+
label: (0, import_react6.createElement)("span", { className: "cb-visuallyHidden" }, t(checked ? "checked" : "markDone")),
|
|
961
|
+
onChange: (value) => {
|
|
962
|
+
if (value) rowControls.press(index, done);
|
|
963
|
+
}
|
|
964
|
+
})
|
|
779
965
|
);
|
|
780
966
|
}
|
|
781
967
|
var rowLive = (live, row) => ({ washCount: live.rows?.[row.key] ?? 0, fresh: row.key !== void 0 && live.freshRows.has(row.key) });
|
|
782
|
-
function ListCard({ data, live, locale, t, rowActions }) {
|
|
968
|
+
function ListCard({ data, live, locale, t, rowActions, all = false, onOpenRow, rowControls }) {
|
|
783
969
|
const kit = useKit();
|
|
784
|
-
const [open, setOpen] = (0,
|
|
785
|
-
const rows = shownRows(data.rows, open, LIST_ROWS, live);
|
|
970
|
+
const [open, setOpen] = (0, import_react6.useState)(false);
|
|
971
|
+
const rows = shownRows(data.rows, open || all, LIST_ROWS, live);
|
|
786
972
|
const hidden = data.rows.length - rows.length;
|
|
787
|
-
const
|
|
973
|
+
const doneOf = (row) => row.actions?.find((action) => action.kind === "done");
|
|
788
974
|
const progress = data.progress;
|
|
789
|
-
return (0,
|
|
975
|
+
return (0, import_react6.createElement)(
|
|
790
976
|
"div",
|
|
791
977
|
{ className: "cb-list" },
|
|
792
|
-
progress && (0,
|
|
978
|
+
progress && (0, import_react6.createElement)(
|
|
793
979
|
"div",
|
|
794
980
|
{ className: "cb-progress" },
|
|
795
|
-
(0,
|
|
981
|
+
(0, import_react6.createElement)(
|
|
796
982
|
kit.Ring,
|
|
797
983
|
{ value: progress.done, max: progress.total, size: 54, tone: progress.done >= progress.total ? "ok" : "accent", label: `${progress.done}/${progress.total}` },
|
|
798
|
-
(0,
|
|
799
|
-
(0,
|
|
984
|
+
(0, import_react6.createElement)("span", null, String(progress.done)),
|
|
985
|
+
(0, import_react6.createElement)("small", null, t("ofTotal", { total: progress.total }))
|
|
800
986
|
),
|
|
801
|
-
(0,
|
|
987
|
+
(0, import_react6.createElement)(
|
|
802
988
|
"div",
|
|
803
989
|
{ className: "cb-progressText" },
|
|
804
|
-
progress.label && (0,
|
|
805
|
-
progress.sub && (0,
|
|
990
|
+
progress.label && (0, import_react6.createElement)("div", { className: "cb-progressLabel" }, progress.label),
|
|
991
|
+
progress.sub && (0, import_react6.createElement)("div", { className: "cb-rowSub" }, progress.sub)
|
|
806
992
|
)
|
|
807
993
|
),
|
|
808
|
-
data.rows.length === 0 ? (0,
|
|
994
|
+
data.rows.length === 0 ? (0, import_react6.createElement)("p", { className: "cb-muted" }, data.empty ?? t("listEmpty")) : (0, import_react6.createElement)("ul", { className: "cb-rows" }, rows.map((row, i) => (0, import_react6.createElement)(Row, {
|
|
809
995
|
key: row.key ?? i,
|
|
810
|
-
index:
|
|
811
|
-
row,
|
|
996
|
+
index: data.rows.indexOf(row),
|
|
997
|
+
row: doneOf(row) && rowControls ? { ...row, actions: row.actions.filter((a) => a.kind !== "done") } : row,
|
|
812
998
|
rowActions,
|
|
999
|
+
onOpenRow,
|
|
1000
|
+
className: i >= LIST_ROWS ? "cb-rowLate" : void 0,
|
|
813
1001
|
...rowLive(live, row),
|
|
814
1002
|
lead: [
|
|
815
|
-
|
|
816
|
-
row.icon && (0,
|
|
1003
|
+
doneOf(row) && rowControls && (0, import_react6.createElement)(DoneBox, { key: "check", row, index: data.rows.indexOf(row), done: doneOf(row), rowControls, t }),
|
|
1004
|
+
row.icon && (0, import_react6.createElement)(kit.Tile, { key: "tile", icon: row.icon, tone: row.tone ?? "muted", size: 30 })
|
|
817
1005
|
],
|
|
818
1006
|
title: row.title,
|
|
819
1007
|
sub: row.sub,
|
|
820
|
-
meta: (0,
|
|
1008
|
+
meta: (0, import_react6.createElement)(
|
|
821
1009
|
"span",
|
|
822
1010
|
{ className: "cb-rowMeta" },
|
|
823
|
-
row.chip && (0,
|
|
824
|
-
(0,
|
|
1011
|
+
row.chip && (0, import_react6.createElement)(import_dsh_client_ui_primitives.Tag, { tone: kit.tagTone(row.chip.tone ?? "muted") }, row.chip.text),
|
|
1012
|
+
(0, import_react6.createElement)(RowWhen, { row, locale, t })
|
|
825
1013
|
)
|
|
826
1014
|
}))),
|
|
827
|
-
(hidden > 0 || open) && data.rows.length > LIST_ROWS + 1 && (0,
|
|
828
|
-
|
|
1015
|
+
!all && (hidden > 0 || open) && data.rows.length > LIST_ROWS + 1 && (0, import_react6.createElement)(
|
|
1016
|
+
import_dsh_client_ui_primitives.Button,
|
|
829
1017
|
{ variant: "ghost", size: "sm", className: "cb-more", onClick: () => setOpen((value) => !value) },
|
|
830
1018
|
open ? t("showFewer") : t("showMore", { n: hidden })
|
|
831
1019
|
)
|
|
832
1020
|
);
|
|
833
1021
|
}
|
|
834
|
-
function StatusCard({ data, live, locale, rowActions }) {
|
|
1022
|
+
function StatusCard({ data, live, locale, rowActions, onOpenRow }) {
|
|
835
1023
|
const kit = useKit();
|
|
836
|
-
return (0,
|
|
1024
|
+
return (0, import_react6.createElement)("ul", { className: "cb-rows" }, data.rows.map((row, i) => (0, import_react6.createElement)(Row, {
|
|
837
1025
|
key: row.key ?? i,
|
|
838
1026
|
index: i,
|
|
839
1027
|
row,
|
|
840
1028
|
rowActions,
|
|
1029
|
+
onOpenRow,
|
|
841
1030
|
...rowLive(live, row),
|
|
842
1031
|
className: "cb-statusRow",
|
|
843
|
-
lead: row.icon ? (0,
|
|
1032
|
+
lead: row.icon ? (0, import_react6.createElement)(kit.Tile, { icon: row.icon, tone: row.tone, size: 28 }) : (0, import_react6.createElement)("span", { className: "cb-dotSlot" }, (0, import_react6.createElement)(import_dsh_client_ui_primitives.StateDot, { state: STATE_OF_TONE[row.tone] ?? "idle" })),
|
|
844
1033
|
title: row.label,
|
|
845
1034
|
sub: row.sub,
|
|
846
|
-
spark: row.spark && (0,
|
|
847
|
-
value: (0,
|
|
1035
|
+
spark: row.spark && (0, import_react6.createElement)("span", { className: "cb-statusSpark" }, (0, import_react6.createElement)(kit.Spark, { values: row.spark, tone: row.tone === "ok" ? "ok" : row.tone, height: 22 })),
|
|
1036
|
+
value: (0, import_react6.createElement)("span", { className: "cb-statusValue", style: row.tone === "bad" || row.tone === "warn" ? { color: kit.toneColor(row.tone) } : void 0 }, formatNumber(row.value, locale))
|
|
848
1037
|
})));
|
|
849
1038
|
}
|
|
850
1039
|
var PARTS = [[5, "dayPart.morning"], [12, "dayPart.afternoon"], [18, "dayPart.evening"], [22, "dayPart.night"]];
|
|
@@ -857,12 +1046,12 @@ function SummaryBody({ card, locale, t, wash }) {
|
|
|
857
1046
|
const kit = useKit();
|
|
858
1047
|
const now = kit.useNow();
|
|
859
1048
|
const day = dayLine(now, locale, t);
|
|
860
|
-
return (0,
|
|
1049
|
+
return (0, import_react6.createElement)(
|
|
861
1050
|
"div",
|
|
862
1051
|
{ className: "cb-summary" },
|
|
863
|
-
(0,
|
|
864
|
-
(0,
|
|
865
|
-
card.data.chips?.length > 0 && (0,
|
|
1052
|
+
(0, import_react6.createElement)("div", { className: "cb-summaryLine" }, (0, import_react6.createElement)(kit.Icon, { name: day.dark ? "moon" : "sun-medium", size: 14 }), (0, import_react6.createElement)("span", null, `${day.text} \xB7 ${card.title}`), wash && (0, import_react6.createElement)(kit.JustNow)),
|
|
1053
|
+
(0, import_react6.createElement)("p", { className: "cb-summaryText" }, card.data.text),
|
|
1054
|
+
card.data.chips?.length > 0 && (0, import_react6.createElement)("div", { className: "cb-chips" }, card.data.chips.map((chip, i) => (0, import_react6.createElement)(kit.Chip, { key: i, icon: chip.icon, tone: chip.tone ?? "muted", to: chip.to }, chip.text)))
|
|
866
1055
|
);
|
|
867
1056
|
}
|
|
868
1057
|
function CountdownBody({ card, locale }) {
|
|
@@ -871,26 +1060,26 @@ function CountdownBody({ card, locale }) {
|
|
|
871
1060
|
const data = card.data;
|
|
872
1061
|
const times = data.steps ? stepTimes(data.steps, locale) : [];
|
|
873
1062
|
const next = times.findIndex((step) => step.time > now);
|
|
874
|
-
return (0,
|
|
1063
|
+
return (0, import_react6.createElement)(
|
|
875
1064
|
"div",
|
|
876
1065
|
{ className: "cb-countdown" },
|
|
877
|
-
(0,
|
|
1066
|
+
(0, import_react6.createElement)(
|
|
878
1067
|
"div",
|
|
879
1068
|
{ className: "cb-countdownHead" },
|
|
880
|
-
(0,
|
|
881
|
-
(0,
|
|
1069
|
+
(0, import_react6.createElement)(kit.Countdown, { to: data.to }),
|
|
1070
|
+
(0, import_react6.createElement)(
|
|
882
1071
|
"div",
|
|
883
1072
|
{ className: "cb-countdownText" },
|
|
884
|
-
(0,
|
|
885
|
-
data.sub && (0,
|
|
1073
|
+
(0, import_react6.createElement)("div", null, data.label),
|
|
1074
|
+
data.sub && (0, import_react6.createElement)("div", { className: "cb-rowSub" }, data.sub)
|
|
886
1075
|
)
|
|
887
1076
|
),
|
|
888
|
-
times.length > 0 && (0,
|
|
1077
|
+
times.length > 0 && (0, import_react6.createElement)("ol", { className: "cb-track" }, data.steps.map((step, i) => (0, import_react6.createElement)(
|
|
889
1078
|
"li",
|
|
890
1079
|
{ key: i, "data-state": i === next ? "next" : times[i].time <= now ? "past" : "later" },
|
|
891
|
-
(0,
|
|
892
|
-
(0,
|
|
893
|
-
(0,
|
|
1080
|
+
(0, import_react6.createElement)("i", { "aria-hidden": true }),
|
|
1081
|
+
(0, import_react6.createElement)("b", null, times[i].text),
|
|
1082
|
+
(0, import_react6.createElement)("span", null, step.sub ? `${step.label} \xB7 ${step.sub}` : step.label)
|
|
894
1083
|
)))
|
|
895
1084
|
);
|
|
896
1085
|
}
|
|
@@ -944,7 +1133,7 @@ function summaryLines(card, locale, t) {
|
|
|
944
1133
|
}
|
|
945
1134
|
|
|
946
1135
|
// src/client/words.js
|
|
947
|
-
var
|
|
1136
|
+
var import_react7 = require("react");
|
|
948
1137
|
var messageRequests = /* @__PURE__ */ new Map();
|
|
949
1138
|
function fetchMessages(tag) {
|
|
950
1139
|
if (!messageRequests.has(tag)) {
|
|
@@ -990,11 +1179,11 @@ var setClientContext = (ctx) => {
|
|
|
990
1179
|
clientCtx = ctx;
|
|
991
1180
|
};
|
|
992
1181
|
function useActiveLocale() {
|
|
993
|
-
const subscribe = (0,
|
|
994
|
-
const active = (0,
|
|
995
|
-
const [loaded, setLoaded] = (0,
|
|
996
|
-
const [attempt, setAttempt] = (0,
|
|
997
|
-
(0,
|
|
1182
|
+
const subscribe = (0, import_react7.useCallback)((listener) => clientCtx.locale.subscribe(listener), []);
|
|
1183
|
+
const active = (0, import_react7.useSyncExternalStore)(subscribe, () => clientCtx.locale.getSnapshot().active);
|
|
1184
|
+
const [loaded, setLoaded] = (0, import_react7.useState)(null);
|
|
1185
|
+
const [attempt, setAttempt] = (0, import_react7.useState)(0);
|
|
1186
|
+
(0, import_react7.useEffect)(() => {
|
|
998
1187
|
let live = true;
|
|
999
1188
|
let timer;
|
|
1000
1189
|
fetchMessages(active).then(
|
|
@@ -1010,15 +1199,40 @@ function useActiveLocale() {
|
|
|
1010
1199
|
clearTimeout(timer);
|
|
1011
1200
|
};
|
|
1012
1201
|
}, [active, attempt]);
|
|
1013
|
-
return (0,
|
|
1202
|
+
return (0, import_react7.useMemo)(() => ({ active: loaded?.active ?? active, ready: loaded !== null, intl: intlTag(loaded?.active ?? active), t: translator(loaded?.messages ?? {}) }), [loaded, active]);
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
// src/client/detail.js
|
|
1206
|
+
var import_react8 = require("react");
|
|
1207
|
+
var CHARTS = { line: LineChart, bar: BarChart };
|
|
1208
|
+
function DetailParts({ detail, locale, t }) {
|
|
1209
|
+
const kit = useKit();
|
|
1210
|
+
if (!detail) return null;
|
|
1211
|
+
const Chart = detail.chart && CHARTS[detail.chart.type];
|
|
1212
|
+
return (0, import_react8.createElement)(
|
|
1213
|
+
"div",
|
|
1214
|
+
{ className: "cb-detail" },
|
|
1215
|
+
detail.text && (0, import_react8.createElement)("p", { className: "cb-detailText" }, detail.text),
|
|
1216
|
+
detail.facts?.length > 0 && (0, import_react8.createElement)("dl", { className: "cb-facts" }, detail.facts.map((fact, i) => [
|
|
1217
|
+
(0, import_react8.createElement)("dt", { key: `t${i}` }, fact.label),
|
|
1218
|
+
(0, import_react8.createElement)("dd", { key: `d${i}` }, typeof fact.value === "number" ? formatNumber(fact.value, locale) : fact.value)
|
|
1219
|
+
])),
|
|
1220
|
+
Chart && (0, import_react8.createElement)("div", { className: "cb-detailChart" }, (0, import_react8.createElement)(Chart, { data: detail.chart.data, locale, height: 240 })),
|
|
1221
|
+
detail.history?.length > 0 && (0, import_react8.createElement)(
|
|
1222
|
+
"section",
|
|
1223
|
+
{ className: "cb-detailHistory" },
|
|
1224
|
+
(0, import_react8.createElement)("h4", null, t("history")),
|
|
1225
|
+
(0, import_react8.createElement)(kit.History, { items: detail.history, max: 8, moreLabel: t("showMore", { n: "{n}" }) })
|
|
1226
|
+
)
|
|
1227
|
+
);
|
|
1014
1228
|
}
|
|
1015
1229
|
|
|
1016
1230
|
// src/client/card.js
|
|
1017
1231
|
var CHART_HEIGHT = 150;
|
|
1018
1232
|
function useRowSpan() {
|
|
1019
|
-
const ref = (0,
|
|
1020
|
-
const [rows, setRows] = (0,
|
|
1021
|
-
(0,
|
|
1233
|
+
const ref = (0, import_react9.useRef)(null);
|
|
1234
|
+
const [rows, setRows] = (0, import_react9.useState)(0);
|
|
1235
|
+
(0, import_react9.useLayoutEffect)(() => {
|
|
1022
1236
|
const el = ref.current;
|
|
1023
1237
|
if (!el || typeof ResizeObserver === "undefined") return void 0;
|
|
1024
1238
|
const measure = () => setRows(Math.ceil((el.getBoundingClientRect().height + GAP) / ROW));
|
|
@@ -1029,44 +1243,44 @@ function useRowSpan() {
|
|
|
1029
1243
|
}, []);
|
|
1030
1244
|
return [ref, rows];
|
|
1031
1245
|
}
|
|
1032
|
-
var
|
|
1246
|
+
var CHARTS2 = { line: LineChart, bar: BarChart, donut: Donut, timeline: Timeline };
|
|
1033
1247
|
function statesOf(presses, row) {
|
|
1034
1248
|
const states = {};
|
|
1035
1249
|
for (const press of presses ?? []) if (press.row === row) states[press.id] = press.state;
|
|
1036
1250
|
return states;
|
|
1037
1251
|
}
|
|
1038
|
-
function Body({ card, live, wash, locale, t, rowActions }) {
|
|
1252
|
+
function Body({ card, live, wash, locale, t, rowActions, all, onOpenRow, rowControls }) {
|
|
1039
1253
|
const data = card.data;
|
|
1040
1254
|
switch (card.type) {
|
|
1041
1255
|
case "stat":
|
|
1042
|
-
return (0,
|
|
1256
|
+
return (0, import_react9.createElement)(StatBlock, { data, locale, wash });
|
|
1043
1257
|
case "list":
|
|
1044
|
-
return (0,
|
|
1258
|
+
return (0, import_react9.createElement)(ListCard, { data, live, locale, t, rowActions, all, onOpenRow, rowControls });
|
|
1045
1259
|
case "status":
|
|
1046
|
-
return (0,
|
|
1260
|
+
return (0, import_react9.createElement)(StatusCard, { data, live, locale, rowActions, onOpenRow });
|
|
1047
1261
|
case "countdown":
|
|
1048
|
-
return (0,
|
|
1262
|
+
return (0, import_react9.createElement)(CountdownBody, { card, locale });
|
|
1049
1263
|
default: {
|
|
1050
|
-
const Chart =
|
|
1264
|
+
const Chart = CHARTS2[card.type];
|
|
1051
1265
|
if (Chart === void 0) return null;
|
|
1052
|
-
return (0,
|
|
1266
|
+
return (0, import_react9.createElement)(Chart, { data, locale, height: all ? card.type === "donut" ? 200 : 240 : card.type === "bar" ? 130 : card.type === "donut" ? 160 : CHART_HEIGHT });
|
|
1053
1267
|
}
|
|
1054
1268
|
}
|
|
1055
1269
|
}
|
|
1056
|
-
function Card({ entry, live, boardId, assistant, tracks, active, locale, t, press }) {
|
|
1270
|
+
function Card({ entry, live, boardId, assistant, tracks, active, locale, t, press, onOpen, sheet = false, row: openRow }) {
|
|
1057
1271
|
const kit = useKit();
|
|
1058
1272
|
const actions = useButtons();
|
|
1059
1273
|
const now = kit.useNow();
|
|
1060
1274
|
const wash = kit.useWash(live.wash, entry.id);
|
|
1061
1275
|
const [ref, rows] = useRowSpan();
|
|
1062
|
-
const style = { gridColumn: `span ${spanOf(entry.card?.type, entry.size, tracks)}`, gridRowEnd: rows > 0 ? `span ${rows}` : void 0 };
|
|
1276
|
+
const style = sheet ? void 0 : { gridColumn: `span ${spanOf(entry.card?.type, entry.size, tracks)}`, gridRowEnd: rows > 0 ? `span ${rows}` : void 0 };
|
|
1063
1277
|
if (!entry.card) {
|
|
1064
|
-
return (0,
|
|
1278
|
+
return (0, import_react9.createElement)(
|
|
1065
1279
|
"section",
|
|
1066
1280
|
{ ref, className: "cb-card cb-cardError", style },
|
|
1067
|
-
(0,
|
|
1068
|
-
(0,
|
|
1069
|
-
(0,
|
|
1281
|
+
(0, import_react9.createElement)("header", { className: "cb-cardHead" }, (0, import_react9.createElement)("h3", { title: entry.id }, entry.id)),
|
|
1282
|
+
(0, import_react9.createElement)("p", { className: "cb-errorText" }, t("cardError")),
|
|
1283
|
+
(0, import_react9.createElement)("ul", { className: "cb-problems" }, (entry.problems ?? []).map((p, i) => (0, import_react9.createElement)("li", { key: i }, p)))
|
|
1070
1284
|
);
|
|
1071
1285
|
}
|
|
1072
1286
|
const card = pickCard(entry.card, active);
|
|
@@ -1085,7 +1299,7 @@ function Card({ entry, live, boardId, assistant, tracks, active, locale, t, pres
|
|
|
1085
1299
|
const askName = assistant ? t("action.chatNamed", { name: assistant }) : void 0;
|
|
1086
1300
|
const named = (list) => assistant ? list?.map((action) => action.kind === "chat" && action.label === void 0 ? { ...action, label: askName } : action) : list;
|
|
1087
1301
|
const onPress = (target) => (action, extra) => press(action, extra, { card: entry.id, ...target });
|
|
1088
|
-
const rowActions = actions && ((row, list, part2) => (0,
|
|
1302
|
+
const rowActions = actions && ((row, list, part2) => (0, import_react9.createElement)(actions.ActionBar, {
|
|
1089
1303
|
actions: named(list),
|
|
1090
1304
|
part: part2,
|
|
1091
1305
|
states: statesOf(entry.presses, row),
|
|
@@ -1093,48 +1307,80 @@ function Card({ entry, live, boardId, assistant, tracks, active, locale, t, pres
|
|
|
1093
1307
|
about: about(row, rowLine(row)),
|
|
1094
1308
|
onPress: onPress({ row })
|
|
1095
1309
|
}));
|
|
1096
|
-
const
|
|
1310
|
+
const rowControls = {
|
|
1311
|
+
press: (row, action) => onPress({ row })(action),
|
|
1312
|
+
state: (row, id) => statesOf(entry.presses, row)[id]
|
|
1313
|
+
};
|
|
1314
|
+
const chat = actions && (0, import_react9.createElement)("span", { className: "cb-cardChat" }, (0, import_react9.createElement)(actions.ActionButton, { action: { kind: "chat", id: "_chat", label: askName }, compact: true, about: about() }));
|
|
1097
1315
|
const others = card.actions?.filter((action) => action.kind !== "step") ?? [];
|
|
1098
|
-
const steps = card.actions?.some((action) => action.kind === "step") && (0,
|
|
1099
|
-
const footer = actions && others.length > 0 && (0,
|
|
1316
|
+
const steps = card.actions?.some((action) => action.kind === "step") && (0, import_react9.createElement)(kit.Suggested, { actions: card.actions, about: about(), states: statesOf(entry.presses, void 0), onPress: onPress({}) });
|
|
1317
|
+
const footer = actions && others.length > 0 && (0, import_react9.createElement)("footer", { className: "cb-cardActions" }, (0, import_react9.createElement)(actions.ActionBar, {
|
|
1100
1318
|
actions: named(others),
|
|
1101
1319
|
part: "buttons",
|
|
1102
1320
|
states: statesOf(entry.presses, void 0),
|
|
1103
1321
|
about: about(),
|
|
1104
1322
|
onPress: onPress({})
|
|
1105
1323
|
}));
|
|
1106
|
-
const
|
|
1324
|
+
const openable = !sheet && onOpen && card.type !== "summary";
|
|
1325
|
+
const className = ["cb-card", `cb-card-${card.type}`, stale && "cb-cardStale", openable && "cb-cardOpenable", sheet && "cb-cardInSheet", wash].filter(Boolean).join(" ");
|
|
1326
|
+
const openOnTap = openable ? { onClick: (event) => {
|
|
1327
|
+
if (!onControl(event) && !event.target.closest?.("[data-opens]") && !window.getSelection?.()?.toString()) onOpen();
|
|
1328
|
+
} } : {};
|
|
1329
|
+
const onOpenRow = onOpen && ((key) => onOpen(key));
|
|
1330
|
+
if (sheet && openRow !== void 0) {
|
|
1331
|
+
const index = card.data.rows?.findIndex((r) => r.key === openRow) ?? -1;
|
|
1332
|
+
const target = index >= 0 ? card.data.rows[index] : null;
|
|
1333
|
+
if (!target) return (0, import_react9.createElement)("p", { className: "cb-muted" }, t("rowGone"));
|
|
1334
|
+
return (0, import_react9.createElement)(
|
|
1335
|
+
"div",
|
|
1336
|
+
{ className: "cb-rowSheet" },
|
|
1337
|
+
(0, import_react9.createElement)(Body, {
|
|
1338
|
+
card: { ...card, data: { ...card.data, rows: [target], progress: void 0 } },
|
|
1339
|
+
live,
|
|
1340
|
+
wash: false,
|
|
1341
|
+
locale,
|
|
1342
|
+
t,
|
|
1343
|
+
rowActions: rowActions && ((_, list, part2) => rowActions(index, list, part2)),
|
|
1344
|
+
all: true,
|
|
1345
|
+
rowControls: { press: (_, action) => rowControls.press(index, action), state: (_, id) => rowControls.state(index, id) }
|
|
1346
|
+
}),
|
|
1347
|
+
(0, import_react9.createElement)(DetailParts, { detail: target.detail, locale, t })
|
|
1348
|
+
);
|
|
1349
|
+
}
|
|
1107
1350
|
if (card.type === "summary") {
|
|
1108
|
-
return (0,
|
|
1351
|
+
return (0, import_react9.createElement)(
|
|
1109
1352
|
"section",
|
|
1110
1353
|
{ ref, className, style, "data-type": card.type },
|
|
1111
|
-
(0,
|
|
1112
|
-
(0,
|
|
1354
|
+
(0, import_react9.createElement)("div", { className: "cb-summaryMain" }, (0, import_react9.createElement)(SummaryBody, { card, locale, t, wash: wash !== "" }), steps, footer),
|
|
1355
|
+
(0, import_react9.createElement)("div", { className: "cb-summaryAside" }, live.fresh && (0, import_react9.createElement)(kit.NewDot), chat)
|
|
1113
1356
|
);
|
|
1114
1357
|
}
|
|
1115
|
-
const statBlock = card.stat && (0,
|
|
1116
|
-
const body = (0,
|
|
1117
|
-
return (0,
|
|
1358
|
+
const statBlock = card.stat && (0, import_react9.createElement)(StatBlock, { data: card.stat, locale, compact: true, wash: wash !== "" });
|
|
1359
|
+
const body = (0, import_react9.createElement)(Body, { card, live, wash: wash !== "", locale, t, rowActions, all: sheet, onOpenRow, rowControls });
|
|
1360
|
+
return (0, import_react9.createElement)(
|
|
1118
1361
|
"section",
|
|
1119
|
-
{ ref, className, style, "data-type": card.type },
|
|
1120
|
-
(0,
|
|
1362
|
+
{ ref, className, style, "data-type": card.type, ...openOnTap },
|
|
1363
|
+
!sheet && (0, import_react9.createElement)(
|
|
1121
1364
|
"header",
|
|
1122
1365
|
{ className: "cb-cardHead" },
|
|
1123
|
-
card.icon && (0,
|
|
1124
|
-
(0,
|
|
1125
|
-
live.fresh && (0,
|
|
1126
|
-
wash !== "" && card.type !== "stat" && !card.stat && (0,
|
|
1127
|
-
stale && (0,
|
|
1366
|
+
card.icon && (0, import_react9.createElement)(kit.Tile, { icon: card.icon, tone: card.tone ?? "muted", size: 30 }),
|
|
1367
|
+
(0, import_react9.createElement)(Trunc, { as: "h3", text: card.title }),
|
|
1368
|
+
live.fresh && (0, import_react9.createElement)(kit.NewDot),
|
|
1369
|
+
wash !== "" && card.type !== "stat" && !card.stat && (0, import_react9.createElement)(kit.JustNow),
|
|
1370
|
+
stale && (0, import_react9.createElement)(
|
|
1128
1371
|
"span",
|
|
1129
1372
|
{ className: "cb-stale", title: new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short" }).format(updated) },
|
|
1130
|
-
(0,
|
|
1373
|
+
(0, import_react9.createElement)(import_dsh_client_ui_primitives2.Tag, { tone: "warning" }, t("stale", { age: formatAge(age, locale) }))
|
|
1131
1374
|
),
|
|
1132
|
-
card.link && (0,
|
|
1375
|
+
card.link && (0, import_react9.createElement)("a", { className: "cb-cardLink", href: card.link, title: t("open"), "aria-label": t("open"), ...external ? { target: "_blank", rel: "noopener noreferrer" } : {} }, (0, import_react9.createElement)(import_dsh_client_ui_primitives2.IconRightUpOutlineRegular, { size: 14 })),
|
|
1376
|
+
openable && (0, import_react9.createElement)("button", { type: "button", className: "cb-cardLink cb-cardOpen", title: t("details"), "aria-label": t("details"), onClick: () => onOpen() }, (0, import_react9.createElement)(import_dsh_client_ui_primitives2.IconFullscreenOutlineRegular, { size: 14 })),
|
|
1133
1377
|
chat
|
|
1134
1378
|
),
|
|
1135
|
-
statBlock && ["line", "bar", "donut"].includes(card.type) ? (0,
|
|
1379
|
+
statBlock && ["line", "bar", "donut"].includes(card.type) ? (0, import_react9.createElement)("div", { className: "cb-split" }, statBlock, (0, import_react9.createElement)("div", { className: "cb-cardBody" }, body)) : [statBlock && (0, import_react9.createElement)("div", { key: "stat" }, statBlock), (0, import_react9.createElement)("div", { key: "body", className: "cb-cardBody" }, body)],
|
|
1380
|
+
sheet && (0, import_react9.createElement)(DetailParts, { detail: card.detail, locale, t }),
|
|
1136
1381
|
steps,
|
|
1137
|
-
footer
|
|
1382
|
+
footer,
|
|
1383
|
+
sheet && chat && (0, import_react9.createElement)("div", { className: "cb-sheetChat" }, chat)
|
|
1138
1384
|
);
|
|
1139
1385
|
}
|
|
1140
1386
|
|
|
@@ -1169,6 +1415,33 @@ function seenReport(board) {
|
|
|
1169
1415
|
return { board: board.id, cards };
|
|
1170
1416
|
}
|
|
1171
1417
|
|
|
1418
|
+
// src/client/nav.js
|
|
1419
|
+
var NAMES = ["board", "card", "row"];
|
|
1420
|
+
function readNav(search) {
|
|
1421
|
+
const params = new URLSearchParams(search);
|
|
1422
|
+
const nav = {};
|
|
1423
|
+
for (const name of NAMES) {
|
|
1424
|
+
const value = params.get(name);
|
|
1425
|
+
if (value) nav[name] = value;
|
|
1426
|
+
}
|
|
1427
|
+
return nav;
|
|
1428
|
+
}
|
|
1429
|
+
function writeNav(search, nav) {
|
|
1430
|
+
const params = new URLSearchParams(search);
|
|
1431
|
+
for (const name of NAMES) params.delete(name);
|
|
1432
|
+
for (const name of NAMES) if (nav?.[name]) params.set(name, nav[name]);
|
|
1433
|
+
const query = params.toString();
|
|
1434
|
+
return query ? `?${query}` : "";
|
|
1435
|
+
}
|
|
1436
|
+
var hasNav = (search) => Boolean(readNav(search).card);
|
|
1437
|
+
|
|
1438
|
+
// src/client/sheet.js
|
|
1439
|
+
var import_react10 = require("react");
|
|
1440
|
+
var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
1441
|
+
function Sheet({ open, onClose, title, closeLabel, children }) {
|
|
1442
|
+
return (0, import_react10.createElement)(import_dsh_client_ui_primitives3.Modal, { open, onClose, title, closeLabel, className: "cb-sheetModal", contentClassName: "cb-sheet" }, children);
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1172
1445
|
// src/client/page.js
|
|
1173
1446
|
var STORE_KEY = "dsh-card-board:board";
|
|
1174
1447
|
var SEEN_AFTER_MS = 2500;
|
|
@@ -1198,31 +1471,34 @@ var visible = () => document.visibilityState === "visible";
|
|
|
1198
1471
|
function BoardsPage() {
|
|
1199
1472
|
const kit = useKit();
|
|
1200
1473
|
const { active, intl: locale, ready, t } = useActiveLocale();
|
|
1201
|
-
const [boards, setBoards] = (0,
|
|
1202
|
-
const [listError, setListError] = (0,
|
|
1203
|
-
const [
|
|
1474
|
+
const [boards, setBoards] = (0, import_react11.useState)(null);
|
|
1475
|
+
const [listError, setListError] = (0, import_react11.useState)(null);
|
|
1476
|
+
const [opened, setOpened] = (0, import_react11.useState)(() => typeof location === "undefined" ? {} : readNav(location.search));
|
|
1477
|
+
const pushed = (0, import_react11.useRef)(false);
|
|
1478
|
+
const [selected, setSelected] = (0, import_react11.useState)(() => {
|
|
1479
|
+
if (opened.board) return opened.board;
|
|
1204
1480
|
try {
|
|
1205
1481
|
return localStorage.getItem(STORE_KEY);
|
|
1206
1482
|
} catch {
|
|
1207
1483
|
return null;
|
|
1208
1484
|
}
|
|
1209
1485
|
});
|
|
1210
|
-
const [view, setView] = (0,
|
|
1211
|
-
const [boardError, setBoardError] = (0,
|
|
1212
|
-
const [pollSeconds, setPollSeconds] = (0,
|
|
1213
|
-
const etag = (0,
|
|
1486
|
+
const [view, setView] = (0, import_react11.useState)({ board: null, live: {} });
|
|
1487
|
+
const [boardError, setBoardError] = (0, import_react11.useState)(null);
|
|
1488
|
+
const [pollSeconds, setPollSeconds] = (0, import_react11.useState)(30);
|
|
1489
|
+
const etag = (0, import_react11.useRef)(null);
|
|
1214
1490
|
const [gridRef, tracks] = useTracks();
|
|
1215
|
-
const currentRef = (0,
|
|
1216
|
-
const translateRef = (0,
|
|
1491
|
+
const currentRef = (0, import_react11.useRef)(null);
|
|
1492
|
+
const translateRef = (0, import_react11.useRef)(t);
|
|
1217
1493
|
translateRef.current = t;
|
|
1218
1494
|
const board = view.board;
|
|
1219
|
-
const boardRef = (0,
|
|
1495
|
+
const boardRef = (0, import_react11.useRef)(null);
|
|
1220
1496
|
boardRef.current = board;
|
|
1221
|
-
const show = (0,
|
|
1497
|
+
const show = (0, import_react11.useCallback)((next) => setView((prev) => ({
|
|
1222
1498
|
board: next,
|
|
1223
1499
|
live: next === null ? {} : nextLive(prev.board?.id === next.id ? prev.board : null, next, prev.board?.id === next.id ? prev.live : {})
|
|
1224
1500
|
})), []);
|
|
1225
|
-
const loadList = (0,
|
|
1501
|
+
const loadList = (0, import_react11.useCallback)(async () => {
|
|
1226
1502
|
try {
|
|
1227
1503
|
const { body } = await getJson("boards");
|
|
1228
1504
|
setBoards(body.boards);
|
|
@@ -1233,7 +1509,7 @@ function BoardsPage() {
|
|
|
1233
1509
|
}
|
|
1234
1510
|
}, []);
|
|
1235
1511
|
const current = boards?.some((b) => b.id === selected) ? selected : boards?.[0]?.id ?? null;
|
|
1236
|
-
const loadBoard = (0,
|
|
1512
|
+
const loadBoard = (0, import_react11.useCallback)(async (id, fresh) => {
|
|
1237
1513
|
if (!id) return;
|
|
1238
1514
|
try {
|
|
1239
1515
|
const result = await getJson(`board?id=${encodeURIComponent(id)}`, fresh ? null : etag.current);
|
|
@@ -1249,7 +1525,7 @@ function BoardsPage() {
|
|
|
1249
1525
|
}
|
|
1250
1526
|
}
|
|
1251
1527
|
}, [loadList, show]);
|
|
1252
|
-
const loadCard = (0,
|
|
1528
|
+
const loadCard = (0, import_react11.useCallback)(async (boardId, id) => {
|
|
1253
1529
|
try {
|
|
1254
1530
|
if (boardRef.current?.id !== boardId || !boardRef.current.cards.some((card) => card.id === id)) return loadBoard(boardId, false);
|
|
1255
1531
|
const { body } = await getJson(`card?board=${encodeURIComponent(boardId)}&id=${encodeURIComponent(id)}`);
|
|
@@ -1263,7 +1539,7 @@ function BoardsPage() {
|
|
|
1263
1539
|
else loadBoard(boardId, false);
|
|
1264
1540
|
}
|
|
1265
1541
|
}, [loadBoard]);
|
|
1266
|
-
const onEvent = (0,
|
|
1542
|
+
const onEvent = (0, import_react11.useCallback)((message) => {
|
|
1267
1543
|
const id = currentRef.current;
|
|
1268
1544
|
if (!id) return;
|
|
1269
1545
|
if (message.type === "card") loadCard(id, message.id);
|
|
@@ -1275,7 +1551,7 @@ function BoardsPage() {
|
|
|
1275
1551
|
}
|
|
1276
1552
|
}, [loadBoard, loadCard, loadList, show]);
|
|
1277
1553
|
const status = kit.useEventStream(current ? `api/card-board/events?board=${encodeURIComponent(current)}` : null, onEvent);
|
|
1278
|
-
const press = (0,
|
|
1554
|
+
const press = (0, import_react11.useCallback)(async (action, extra, target) => {
|
|
1279
1555
|
const response = await fetch(api("action"), {
|
|
1280
1556
|
method: "POST",
|
|
1281
1557
|
credentials: "same-origin",
|
|
@@ -1287,10 +1563,10 @@ function BoardsPage() {
|
|
|
1287
1563
|
loadBoard(currentRef.current, false);
|
|
1288
1564
|
return body;
|
|
1289
1565
|
}, [loadBoard]);
|
|
1290
|
-
(0,
|
|
1566
|
+
(0, import_react11.useEffect)(() => {
|
|
1291
1567
|
loadList();
|
|
1292
1568
|
}, [loadList]);
|
|
1293
|
-
(0,
|
|
1569
|
+
(0, import_react11.useEffect)(() => {
|
|
1294
1570
|
currentRef.current = current;
|
|
1295
1571
|
if (!current) return;
|
|
1296
1572
|
etag.current = null;
|
|
@@ -1298,7 +1574,7 @@ function BoardsPage() {
|
|
|
1298
1574
|
loadBoard(current, true);
|
|
1299
1575
|
}, [current, loadBoard]);
|
|
1300
1576
|
const waiting = board?.cards.some((entry) => entry.presses?.some((p) => p.state === "pending")) === true;
|
|
1301
|
-
(0,
|
|
1577
|
+
(0, import_react11.useEffect)(() => {
|
|
1302
1578
|
if (!current || status === "live" && !waiting) return void 0;
|
|
1303
1579
|
let ticks = 0;
|
|
1304
1580
|
const timer = setInterval(() => {
|
|
@@ -1318,8 +1594,8 @@ function BoardsPage() {
|
|
|
1318
1594
|
document.removeEventListener("visibilitychange", onVisible);
|
|
1319
1595
|
};
|
|
1320
1596
|
}, [current, status, waiting, pollSeconds, loadBoard, loadList]);
|
|
1321
|
-
const reported = (0,
|
|
1322
|
-
(0,
|
|
1597
|
+
const reported = (0, import_react11.useRef)("");
|
|
1598
|
+
(0, import_react11.useEffect)(() => {
|
|
1323
1599
|
if (!board) return void 0;
|
|
1324
1600
|
const report = seenReport(board);
|
|
1325
1601
|
const text = JSON.stringify(report);
|
|
@@ -1333,6 +1609,27 @@ function BoardsPage() {
|
|
|
1333
1609
|
}, SEEN_AFTER_MS);
|
|
1334
1610
|
return () => clearTimeout(timer);
|
|
1335
1611
|
}, [board]);
|
|
1612
|
+
(0, import_react11.useEffect)(() => {
|
|
1613
|
+
const onPop = () => {
|
|
1614
|
+
pushed.current = false;
|
|
1615
|
+
setOpened(readNav(location.search));
|
|
1616
|
+
};
|
|
1617
|
+
window.addEventListener("popstate", onPop);
|
|
1618
|
+
return () => window.removeEventListener("popstate", onPop);
|
|
1619
|
+
}, []);
|
|
1620
|
+
const openCard = (0, import_react11.useCallback)((boardId, card, row) => {
|
|
1621
|
+
const nav = { board: boardId, card, ...row === void 0 ? {} : { row } };
|
|
1622
|
+
window.history[pushed.current ? "replaceState" : "pushState"](window.history.state, "", `${location.pathname}${writeNav(location.search, nav)}${location.hash}`);
|
|
1623
|
+
pushed.current = true;
|
|
1624
|
+
setOpened(nav);
|
|
1625
|
+
}, []);
|
|
1626
|
+
const closeCard = (0, import_react11.useCallback)(() => {
|
|
1627
|
+
setOpened({});
|
|
1628
|
+
if (pushed.current) {
|
|
1629
|
+
pushed.current = false;
|
|
1630
|
+
window.history.back();
|
|
1631
|
+
} else window.history.replaceState(window.history.state, "", `${location.pathname}${writeNav(location.search, {})}${location.hash}`);
|
|
1632
|
+
}, []);
|
|
1336
1633
|
const choose = (id) => {
|
|
1337
1634
|
setSelected(id);
|
|
1338
1635
|
try {
|
|
@@ -1345,39 +1642,49 @@ function BoardsPage() {
|
|
|
1345
1642
|
return Number.isFinite(time) && time > max ? time : max;
|
|
1346
1643
|
}, 0);
|
|
1347
1644
|
const titleOf = (entry) => pickText(entry.title, active);
|
|
1348
|
-
if (!ready) return (0,
|
|
1645
|
+
if (!ready) return (0, import_react11.createElement)("div", { className: "cb-page" });
|
|
1349
1646
|
let content;
|
|
1350
|
-
if (listError) content = (0,
|
|
1351
|
-
else if (boards === null) content = (0,
|
|
1352
|
-
else if (boards.length === 0) content = (0,
|
|
1353
|
-
else if (boardError) content = (0,
|
|
1354
|
-
else if (!board) content = (0,
|
|
1355
|
-
else content = (0,
|
|
1356
|
-
|
|
1647
|
+
if (listError) content = (0, import_react11.createElement)("p", { className: "cb-notice" }, errorText(listError, t));
|
|
1648
|
+
else if (boards === null) content = (0, import_react11.createElement)("p", { className: "cb-muted" }, t("loading"));
|
|
1649
|
+
else if (boards.length === 0) content = (0, import_react11.createElement)("div", { className: "cb-empty" }, (0, import_react11.createElement)("p", { className: "cb-emptyTitle" }, t("emptyTitle")), (0, import_react11.createElement)("p", { className: "cb-muted" }, t("emptyHint")));
|
|
1650
|
+
else if (boardError) content = (0, import_react11.createElement)("p", { className: "cb-notice" }, errorText(boardError, t));
|
|
1651
|
+
else if (!board) content = (0, import_react11.createElement)("p", { className: "cb-muted" }, t("loading"));
|
|
1652
|
+
else content = (0, import_react11.createElement)(
|
|
1653
|
+
import_react11.Fragment,
|
|
1357
1654
|
null,
|
|
1358
|
-
board.problems?.length > 0 && (0,
|
|
1359
|
-
board.cards.length === 0 && (0,
|
|
1360
|
-
(0,
|
|
1655
|
+
board.problems?.length > 0 && (0, import_react11.createElement)("div", { className: "cb-notice" }, t("boardProblems"), (0, import_react11.createElement)("ul", { className: "cb-problems" }, board.problems.map((p, i) => (0, import_react11.createElement)("li", { key: i }, p)))),
|
|
1656
|
+
board.cards.length === 0 && (0, import_react11.createElement)("p", { className: "cb-muted" }, t("noCards")),
|
|
1657
|
+
(0, import_react11.createElement)(
|
|
1361
1658
|
"div",
|
|
1362
1659
|
{ className: "cb-grid", style: { gridTemplateColumns: `repeat(${tracks}, minmax(0, 1fr))`, gridAutoRows: `${ROW}px`, columnGap: GAP } },
|
|
1363
|
-
board.cards.map((entry) => (0,
|
|
1660
|
+
board.cards.map((entry) => (0, import_react11.createElement)(Card, { key: entry.id, entry, live: liveOf(view.live, entry.id), boardId: board.id, assistant: board.assistant, tracks, active, locale, t, press, onOpen: (row) => openCard(board.id, entry.id, row) }))
|
|
1364
1661
|
)
|
|
1365
1662
|
);
|
|
1366
|
-
|
|
1663
|
+
const openEntry = opened.card && board && (!opened.board || opened.board === board.id) ? board.cards.find((entry) => entry.id === opened.card && entry.card) : void 0;
|
|
1664
|
+
const openCardData = openEntry && pickCard(openEntry.card, active);
|
|
1665
|
+
const openRow = openCardData && opened.row !== void 0 ? openCardData.data.rows?.find((r) => r.key === opened.row) : void 0;
|
|
1666
|
+
const sheet = (0, import_react11.createElement)(Sheet, {
|
|
1667
|
+
open: Boolean(openEntry),
|
|
1668
|
+
onClose: closeCard,
|
|
1669
|
+
title: openRow ? openRow.title ?? openRow.label : openCardData?.title,
|
|
1670
|
+
closeLabel: t("close")
|
|
1671
|
+
}, openEntry && (0, import_react11.createElement)(Card, { entry: openEntry, live: liveOf(view.live, openEntry.id), boardId: board.id, assistant: board.assistant, tracks: 1, active, locale, t, press, sheet: true, row: opened.row }));
|
|
1672
|
+
return (0, import_react11.createElement)(
|
|
1367
1673
|
"div",
|
|
1368
1674
|
{ className: "cb-page" },
|
|
1369
|
-
(0,
|
|
1675
|
+
(0, import_react11.createElement)(
|
|
1370
1676
|
"div",
|
|
1371
1677
|
{ className: "cb-content", ref: gridRef },
|
|
1372
|
-
(0,
|
|
1678
|
+
(0, import_react11.createElement)(
|
|
1373
1679
|
"div",
|
|
1374
1680
|
{ className: "cb-heading" },
|
|
1375
|
-
(0,
|
|
1376
|
-
board && (0,
|
|
1681
|
+
(0, import_react11.createElement)("h1", null, boards?.length === 1 ? titleOf(boards[0]) : t("title")),
|
|
1682
|
+
board && (0, import_react11.createElement)("div", { className: "cb-sub" }, (0, import_react11.createElement)(kit.LiveStatus, { status, updatedAt: newest || void 0 }))
|
|
1377
1683
|
),
|
|
1378
|
-
boards && boards.length > 1 && (0,
|
|
1684
|
+
boards && boards.length > 1 && (0, import_react11.createElement)("div", { className: "cb-tabs", role: "tablist" }, boards.map((b) => (0, import_react11.createElement)(import_dsh_client_ui_primitives4.Pill, { key: b.id, active: b.id === current, role: "tab", "aria-selected": b.id === current, title: titleOf(b), onClick: () => choose(b.id) }, titleOf(b)))),
|
|
1379
1685
|
content
|
|
1380
|
-
)
|
|
1686
|
+
),
|
|
1687
|
+
board && sheet
|
|
1381
1688
|
);
|
|
1382
1689
|
}
|
|
1383
1690
|
|
|
@@ -1386,17 +1693,17 @@ var NS = "dsh-card-board";
|
|
|
1386
1693
|
var PANEL = "dsh-card-board";
|
|
1387
1694
|
function SidebarIcon({ size }) {
|
|
1388
1695
|
const stroke = { stroke: "currentColor", strokeWidth: 1.2, strokeLinecap: "round", strokeLinejoin: "round", fill: "none" };
|
|
1389
|
-
return (0,
|
|
1696
|
+
return (0, import_react12.createElement)(
|
|
1390
1697
|
"svg",
|
|
1391
1698
|
{ width: size, height: size, viewBox: "0 0 16 16", "aria-hidden": true, focusable: "false" },
|
|
1392
|
-
(0,
|
|
1393
|
-
(0,
|
|
1394
|
-
(0,
|
|
1395
|
-
(0,
|
|
1699
|
+
(0, import_react12.createElement)("rect", { x: 1.75, y: 1.75, width: 5.5, height: 5.5, rx: 1.4, ...stroke }),
|
|
1700
|
+
(0, import_react12.createElement)("rect", { x: 8.75, y: 1.75, width: 5.5, height: 5.5, rx: 1.4, ...stroke }),
|
|
1701
|
+
(0, import_react12.createElement)("rect", { x: 1.75, y: 8.75, width: 5.5, height: 5.5, rx: 1.4, ...stroke }),
|
|
1702
|
+
(0, import_react12.createElement)("path", { d: "M9 13.5l1.6-2 1.4 1 2-2.8", ...stroke })
|
|
1396
1703
|
);
|
|
1397
1704
|
}
|
|
1398
1705
|
function Page() {
|
|
1399
|
-
return useKit() === null ? (0,
|
|
1706
|
+
return useKit() === null ? (0, import_react12.createElement)("div", { className: "cb-page" }) : (0, import_react12.createElement)(BoardsPage);
|
|
1400
1707
|
}
|
|
1401
1708
|
var inject = ["slots", "locale"];
|
|
1402
1709
|
function apply(ctx) {
|
|
@@ -1460,6 +1767,21 @@ function apply(ctx) {
|
|
|
1460
1767
|
document.head.appendChild(tag);
|
|
1461
1768
|
return () => tag.remove();
|
|
1462
1769
|
}, "card-board: styles");
|
|
1770
|
+
ctx.effect(() => {
|
|
1771
|
+
if (typeof location === "undefined" || !hasNav(location.search)) return () => {
|
|
1772
|
+
};
|
|
1773
|
+
let tries = 0;
|
|
1774
|
+
const timer = setInterval(() => {
|
|
1775
|
+
const layout = ctx.get("layout");
|
|
1776
|
+
try {
|
|
1777
|
+
layout?.selectPanel(PANEL);
|
|
1778
|
+
if (layout) clearInterval(timer);
|
|
1779
|
+
} catch {
|
|
1780
|
+
}
|
|
1781
|
+
if (++tries > 50) clearInterval(timer);
|
|
1782
|
+
}, 100);
|
|
1783
|
+
return () => clearInterval(timer);
|
|
1784
|
+
}, "card-board: card link");
|
|
1463
1785
|
ctx.slots.inject("main", () => ctx.slots.register({ name: "main", key: PANEL, locale: NS }, Page));
|
|
1464
1786
|
ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
|
|
1465
1787
|
name: "sidebar.panellist",
|