@ai-matrx/records-ui 0.42.0 → 0.43.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,40 @@
1
1
  # Changelog — @ai-matrx/records-ui
2
2
 
3
+ ## 0.43.0
4
+
5
+ **Five headings carrying the store's real counts, over five empty columns.**
6
+
7
+ Measured in the real app (lane SCREENS-2, 2026-09-20) on a dental practice's
8
+ treatment plans, immediately after 0.42.0 made the board reachable at all: it
9
+ drew *Proposed 4*, *Insurance review 3*, *Scheduled 2 / 2* — and every column was
10
+ empty. That is the worst thing a screen can do. A heading that says four over a
11
+ column that shows none, with nothing anywhere saying the two disagree.
12
+
13
+ **A real disagreement about what a cell holds.** `PipelineStage.key` is documented
14
+ as "what a cell holds" and `custom.pipeline_board` keys its columns that way
15
+ (`stage_key: "proposed"`). `custom.read_records` answers the LABEL in the cell and
16
+ puts the key BESIDE it:
17
+
18
+ ```json
19
+ {"stage": "Proposed", "_choices": {"stage": {"key": "proposed", "label": "Proposed"}}}
20
+ ```
21
+
22
+ so `cardsByStage.get(stage.key)` matched nothing, for every row, on every pipeline.
23
+
24
+ `stageOfCard` is the one seam that decides it and it asks the ROW's own resolved
25
+ choice first, never the wording. Two fallbacks follow, because a cell may
26
+ legitimately hold the key (an agent wrote it) or only the label (an import did),
27
+ and neither is a reason to lose a card.
28
+
29
+ **And a card with nowhere to go is now SAID.** A retired stage, or a value an
30
+ import wrote that is not one of the board's choices, used to vanish — a board
31
+ quietly one card short is the same lie as the heading that disagreed with its
32
+ column. The board names them and says how to move one.
33
+
34
+ `src/pipeline-cards.test.tsx` — five clauses, all red on 0.42.0's bytes.
35
+
36
+ **Consumer action:** none.
37
+
3
38
  ## 0.42.0
4
39
 
5
40
  **A pipeline table opened as "pick a column", and the board it already had was
package/dist/index.cjs CHANGED
@@ -5029,6 +5029,27 @@ var import_react38 = require("react");
5029
5029
  var import_react39 = require("@ai-matrx/records/react");
5030
5030
  var import_design_system18 = require("@ai-matrx/design-system");
5031
5031
  var import_jsx_runtime20 = require("react/jsx-runtime");
5032
+ var UNPLACED = "\0unplaced";
5033
+ function stageOfCard(row, stageKey, stages) {
5034
+ const document2 = row.document ?? {};
5035
+ const choices = document2["_choices"];
5036
+ if (choices && typeof choices === "object") {
5037
+ const chosen = choices[stageKey];
5038
+ if (chosen && typeof chosen === "object") {
5039
+ const key = chosen["key"];
5040
+ if (typeof key === "string" && key !== "") {
5041
+ return stages.some((s) => s.key === key) ? key : null;
5042
+ }
5043
+ }
5044
+ }
5045
+ const raw = document2[stageKey];
5046
+ if (raw === null || raw === void 0 || raw === "") return null;
5047
+ const said = String(raw).trim();
5048
+ const byKey = stages.find((s) => s.key === said);
5049
+ if (byKey) return byKey.key;
5050
+ const byLabel = stages.find((s) => s.label.toLowerCase() === said.toLowerCase());
5051
+ return byLabel ? byLabel.key : null;
5052
+ }
5032
5053
  function PipelineBoard({
5033
5054
  tableId,
5034
5055
  rows,
@@ -5078,12 +5099,12 @@ function PipelineBoard({
5078
5099
  const map = /* @__PURE__ */ new Map();
5079
5100
  if (!stageKey) return map;
5080
5101
  for (const row of rows) {
5081
- const raw = (row.document ?? {})[stageKey];
5082
- const key = raw === null || raw === void 0 || raw === "" ? "" : String(raw);
5083
- map.set(key, [...map.get(key) ?? [], row]);
5102
+ const key = stageOfCard(row, stageKey, definition?.stages ?? []);
5103
+ map.set(key ?? UNPLACED, [...map.get(key ?? UNPLACED) ?? [], row]);
5084
5104
  }
5085
5105
  return map;
5086
- }, [rows, stageKey]);
5106
+ }, [rows, stageKey, definition?.stages]);
5107
+ const unplaced = cardsByStage.get(UNPLACED) ?? [];
5087
5108
  const all = fields.data ?? [];
5088
5109
  const titleField = (0, import_react38.useMemo)(
5089
5110
  () => all.find((f) => f.key !== stageKey) ?? all[0],
@@ -5230,7 +5251,14 @@ function PipelineBoard({
5230
5251
  },
5231
5252
  stage.key
5232
5253
  );
5233
- }) })
5254
+ }) }),
5255
+ unplaced.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("p", { className: "text-xs text-muted-foreground", "data-testid": "pipeline-unplaced", children: [
5256
+ unplaced.length === 1 ? "One record is" : `${unplaced.length} records are`,
5257
+ " not in any of these columns \u2014 ",
5258
+ unplaced.slice(0, 3).map((r) => rowName(r, titleField?.key ?? null, "Untitled")).join(", "),
5259
+ unplaced.length > 3 ? ` and ${unplaced.length - 3} more` : "",
5260
+ ". Their stage is not one this pipeline offers, so nothing here can draw them; open one from the grid to move it."
5261
+ ] }) : null
5234
5262
  ] });
5235
5263
  }
5236
5264
  function formatTotal(total) {