@soffits/dsh-card-board 0.16.1 → 0.17.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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.17.0
4
+
5
+ A `detail` can carry `actions`: buttons shown only when its card or row is opened, below the detail, and pressed like any other (the server finds them by id on that card or row). They let a row stay short on the board, a chip and a snooze, while its answers sit under the note that asks the question. View-only viewers get none of them, as with the row's own buttons. Why: `docs/decisions/detail-actions.md`.
6
+
3
7
  ## 0.16.1
4
8
 
5
9
  Someone who may see a board but isn't an actor no longer gets its declared chat buttons. Those are the board owner's buttons, often a prompt in the owner's own words ("My answer to …:"), so a view-only viewer could still speak for the owner through a conversation. Now only plain `link` buttons survive the filter, plus the page's own "Chat about this" and "Ask", which ask about what the viewer sees in their own new conversation. A row whose chat button is taken away gets the built-in "Ask" back.
package/README.md CHANGED
@@ -285,11 +285,12 @@ Tapping a card (anywhere that isn't one of its buttons, links or rows that open
285
285
  "text": "Three books, due at the branch on Elm Street.",
286
286
  "facts": [{ "label": "Renewals left", "value": 1 }, { "label": "Fine per day", "value": "0.25 EUR" }],
287
287
  "chart": { "type": "bar", "data": { "bars": [{ "x": "2026-02", "value": 4 }, { "x": "2026-03", "value": 3 }] } },
288
- "history": [{ "at": "2026-02-20T15:10:00+01:00", "text": "Borrowed" }]
288
+ "history": [{ "at": "2026-02-20T15:10:00+01:00", "text": "Borrowed" }],
289
+ "actions": [{ "kind": "done", "id": "library-books:returned-elm", "label": "Returned at Elm Street" }]
289
290
  }
290
291
  ```
291
292
 
292
- Every part is optional: `text`, `facts` (label and value, up to 24), `chart` (a `line` or `bar` card's `data`) and `history` (newest first, up to 100). A row needs a `key` to carry a `detail`.
293
+ Every part is optional: `text`, `facts` (label and value, up to 24), `chart` (a `line` or `bar` card's `data`), `history` (newest first, up to 100) and `actions`, buttons shown only in the opened view, below the detail ([Actions](#actions); their ids must differ from the card's or row's own buttons, since a press names its button by id). Buttons that only make sense with the detail in view go there, so the row on the board stays short: a question's answers under the note that asks it, with only a chip and a snooze on the row. A row needs a `key` to carry a `detail`.
293
294
 
294
295
  On a chart, hovering or tapping shows the value and date of the point under the pointer. Cards and rows answer a hover and a press; a row's buttons show on hover with a mouse and are always there on touch. A card that changes settles into place, numbers ease to their new value and rows that a list opens fade in; nothing moves with reduced motion. Buttons, tags, axes and other chrome aren't selectable; titles, notes and numbers are.
295
296
 
package/client.js CHANGED
@@ -1,4 +1,4 @@
1
- /* @soffits/dsh-card-board 0.16.1: built by scripts/build.mjs from src/client/. Do not edit. */
1
+ /* @soffits/dsh-card-board 0.17.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) => {
@@ -1540,6 +1540,16 @@ function Card({ entry, live, boardId, assistant, tracks, active, locale, t, pres
1540
1540
  about: about(),
1541
1541
  onPress: onPress({})
1542
1542
  }));
1543
+ const opened = sheet && actions && card.detail?.actions?.length > 0 && [
1544
+ card.detail.actions.some((action) => action.kind === "step") && (0, import_react10.createElement)(kit.Suggested, { key: "steps", actions: card.detail.actions, about: about(), states: statesOf(entry.presses, void 0), onPress: onPress({}) }),
1545
+ (0, import_react10.createElement)("footer", { key: "buttons", className: "cb-cardActions" }, (0, import_react10.createElement)(actions.ActionBar, {
1546
+ actions: named(card.detail.actions.filter((action) => action.kind !== "step")),
1547
+ part: "buttons",
1548
+ states: statesOf(entry.presses, void 0),
1549
+ about: about(),
1550
+ onPress: onPress({})
1551
+ }))
1552
+ ];
1543
1553
  const openable = !sheet && onOpen && card.type !== "summary";
1544
1554
  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(" ");
1545
1555
  const openOnTap = openable ? { onClick: (event) => {
@@ -1550,6 +1560,7 @@ function Card({ entry, live, boardId, assistant, tracks, active, locale, t, pres
1550
1560
  const index = card.data.rows?.findIndex((r) => r.key === openRow) ?? -1;
1551
1561
  const target = index >= 0 ? card.data.rows[index] : null;
1552
1562
  if (!target) return (0, import_react10.createElement)("p", { className: "cb-muted" }, t("rowGone"));
1563
+ const opened2 = target.detail?.actions ?? [];
1553
1564
  return (0, import_react10.createElement)(
1554
1565
  "div",
1555
1566
  { className: "cb-rowSheet" },
@@ -1563,7 +1574,13 @@ function Card({ entry, live, boardId, assistant, tracks, active, locale, t, pres
1563
1574
  all: true,
1564
1575
  rowControls: { ...rowControls, kept: [], press: (_, action) => rowControls.press(index, action), state: (_, id) => rowControls.state(index, id), latest: (_, id) => rowControls.latest(index, id) }
1565
1576
  }),
1566
- (0, import_react10.createElement)(DetailParts, { detail: target.detail, locale, t })
1577
+ (0, import_react10.createElement)(DetailParts, { detail: target.detail, locale, t }),
1578
+ rowActions && opened2.length > 0 && (0, import_react10.createElement)(
1579
+ "footer",
1580
+ { className: "cb-cardActions" },
1581
+ opened2.some((action) => action.kind === "step") && rowActions(index, opened2, "steps"),
1582
+ rowActions(index, opened2, "buttons")
1583
+ )
1567
1584
  );
1568
1585
  }
1569
1586
  if (card.type === "summary") {
@@ -1601,6 +1618,7 @@ function Card({ entry, live, boardId, assistant, tracks, active, locale, t, pres
1601
1618
  ),
1602
1619
  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)],
1603
1620
  sheet && (0, import_react10.createElement)(DetailParts, { detail: card.detail, locale, t }),
1621
+ opened,
1604
1622
  steps,
1605
1623
  footer,
1606
1624
  sheet && chat && (0, import_react10.createElement)("div", { className: "cb-sheetChat" }, chat)
@@ -87,6 +87,19 @@
87
87
  "at": "2026-02-20T15:10:00+01:00",
88
88
  "text": "Borrowed"
89
89
  }
90
+ ],
91
+ "actions": [
92
+ {
93
+ "kind": "done",
94
+ "id": "library-books:returned-elm",
95
+ "label": {
96
+ "en": "Returned at Elm Street",
97
+ "zh": "在榆树街还了"
98
+ },
99
+ "payload": {
100
+ "branch": "elm"
101
+ }
102
+ }
90
103
  ]
91
104
  }
92
105
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soffits/dsh-card-board",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
4
4
  "description": "A data-driven card board for DeepSeek Harness: scripts write small JSON cards, the Web UI shows each person the boards they may see.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/access.js CHANGED
@@ -122,6 +122,7 @@ export function withoutActions(card) {
122
122
  const trimmed = holder => {
123
123
  const { actions, ...rest } = holder
124
124
  const kept = (actions ?? []).filter(action => action.kind === 'link')
125
+ if (Array.isArray(rest.detail?.actions)) rest.detail = trimmed(rest.detail)
125
126
  return kept.length > 0 ? { ...rest, actions: kept } : rest
126
127
  }
127
128
  const rows = card.data?.rows
package/src/schema.js CHANGED
@@ -245,11 +245,13 @@ function actions(c, list, path) {
245
245
 
246
246
  /**
247
247
  * The more a card or a row shows when it is opened: some text, facts (label and value), a chart (a line or bar card's
248
- * data) and a history, newest first. Every part is optional; the opened view also shows the whole body and all actions.
249
- * Exported so other row shapes can check theirs the same way.
248
+ * data), a history, newest first, and buttons that only make sense with all of that in view. Every part is optional;
249
+ * the opened view also shows the whole body and all actions. `own` is the holder's own actions: an opened button's
250
+ * id must differ from them, since a press names its button by id. Exported so other row shapes can check theirs the
251
+ * same way.
250
252
  */
251
- export function checkDetail(c, detail, path) {
252
- if (!c.object(detail, path, [], ['text', 'facts', 'chart', 'history'])) return
253
+ export function checkDetail(c, detail, path, own = []) {
254
+ if (!c.object(detail, path, [], ['text', 'facts', 'chart', 'history', 'actions'])) return
253
255
  c.optional(detail, 'text', v => c.label(v, join(path, 'text'), { max: 2000 }))
254
256
  c.optional(detail, 'facts', facts => {
255
257
  if (!c.array(facts, join(path, 'facts'), { max: 24 })) return
@@ -266,6 +268,12 @@ export function checkDetail(c, detail, path) {
266
268
  if (!c.oneOf(chart.type, join(cp, 'type'), ['line', 'bar'])) return
267
269
  DATA[chart.type](c, chart.data, join(cp, 'data'))
268
270
  })
271
+ c.optional(detail, 'actions', list => {
272
+ const ap = join(path, 'actions')
273
+ actions(c, list, ap)
274
+ const taken = new Set((Array.isArray(own) ? own : []).map(action => action?.id))
275
+ if (Array.isArray(list)) list.forEach((action, i) => { if (taken.has(action?.id)) c.fail(join(join(ap, i), 'id'), 'repeats one of the buttons it opens from') })
276
+ })
269
277
  c.optional(detail, 'history', history => {
270
278
  if (!c.array(history, join(path, 'history'), { max: 100 })) return
271
279
  history.forEach((entry, i) => {
@@ -281,7 +289,7 @@ export function checkDetail(c, detail, path) {
281
289
  function rowOpen(c, row, path) {
282
290
  c.optional(row, 'link', v => isSafeLink(v) || c.fail(join(path, 'link'), 'must be an http(s) URL or a path starting with /'))
283
291
  c.optional(row, 'detail', v => {
284
- checkDetail(c, v, join(path, 'detail'))
292
+ checkDetail(c, v, join(path, 'detail'), row.actions)
285
293
  if (row.key === undefined) c.fail(join(path, 'key'), 'is required on a row with a detail: it is how the row is opened')
286
294
  })
287
295
  }
@@ -578,7 +586,7 @@ export function checkCard(card) {
578
586
  if (!c.object(card, '', ['type', 'title', 'updatedAt', 'data'], ['staleAfter', 'link', 'stat', 'actions', 'icon', 'tone', 'detail', 'raise', 'ask'])) return c.problems
579
587
  c.optional(card, 'ask', v => c.boolean(v, 'ask'))
580
588
  c.optional(card, 'raise', v => raiseWindow(c, v, 'raise'))
581
- c.optional(card, 'detail', v => checkDetail(c, v, 'detail'))
589
+ c.optional(card, 'detail', v => checkDetail(c, v, 'detail', card.actions))
582
590
  if (!c.oneOf(card.type, 'type', CARD_TYPES)) return c.problems
583
591
  c.label(card.title, 'title', { max: 120 })
584
592
  c.dateTime(card.updatedAt, 'updatedAt')
@@ -597,12 +605,14 @@ export function checkCard(card) {
597
605
 
598
606
  /**
599
607
  * The action a press names, looked up in the card as written: on the card
600
- * itself, or on row `row` of a list or status card. Undefined when there is
601
- * no such action, so a browser can only press what the data offers.
608
+ * itself, or on row `row` of a list or status card, among its own buttons and
609
+ * those its detail shows when opened. Undefined when there is no such action,
610
+ * so a browser can only press what the data offers.
602
611
  */
603
612
  export function findAction(card, actionId, row) {
604
- const list = row === undefined ? card?.actions : card?.data?.rows?.[row]?.actions
605
- return Array.isArray(list) ? list.find(action => action?.id === actionId) : undefined
613
+ const holder = row === undefined ? card : card?.data?.rows?.[row]
614
+ const list = [holder?.actions, holder?.detail?.actions].flatMap(value => (Array.isArray(value) ? value : []))
615
+ return list.find(action => action?.id === actionId)
606
616
  }
607
617
 
608
618
  /** Problems with a board.json's parsed content. */