@invana/blocks 0.0.33 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1176,10 +1176,11 @@ interface GanttSpecBar {
1176
1176
  };
1177
1177
  /** The bar's own hover card. Any one of these opens it. */
1178
1178
  summary?: string;
1179
- result?: Record<string, string | number>;
1179
+ result?: Record<string, unknown>;
1180
1180
  error?: {
1181
1181
  code?: string;
1182
1182
  message?: string;
1183
+ detail?: string;
1183
1184
  };
1184
1185
  log?: string;
1185
1186
  }
@@ -1208,12 +1209,14 @@ interface GanttSpecRow {
1208
1209
  summary?: string;
1209
1210
  /** What it said last — the card's foot. */
1210
1211
  log?: string;
1212
+ /** Why it failed — `detail` is the longer account under the message. */
1211
1213
  error?: {
1212
1214
  code?: string;
1213
1215
  message?: string;
1216
+ detail?: string;
1214
1217
  };
1215
- /** What it produced, as label/value pairs on the card — `{ rows: 412 }`. */
1216
- result?: Record<string, string | number>;
1218
+ /** What it produced, as label/value pairs on the card — `{ rows: 412 }`; nested values read as JSON. */
1219
+ result?: Record<string, unknown>;
1217
1220
  /** The tasks it split into, indented under it. A task with no timing draws their stretch. */
1218
1221
  subtasks?: GanttSpecRow[];
1219
1222
  /** Drawn open. The reader can open and close it either way. */
@@ -1228,7 +1231,7 @@ interface GanttOptions {
1228
1231
  nowMs?: number;
1229
1232
  /** The run has not decided its length yet: the last tick reads `8s+`. */
1230
1233
  openEnded?: boolean;
1231
- /** Intervals on the axis. `4` by default. */
1234
+ /** Intervals on the axis. `4` by default; on `seq`, one per step (or an even divisor of a long plan). */
1232
1235
  ticks?: number;
1233
1236
  /** The key column, in px. Defaults to the longest key, up to 40%. */
1234
1237
  labelWidth?: number;
@@ -1655,6 +1658,14 @@ interface BlockProps<K extends BlockKind = BlockKind> {
1655
1658
  value?: unknown;
1656
1659
  /** Names its form and fields. Unset, one is made. */
1657
1660
  id?: string;
1661
+ /**
1662
+ * Set into running text: a table's outer cells sit flush with the words
1663
+ * around it. Only the assistant sets it; everywhere else a table keeps its
1664
+ * cell padding. Only the table block reads it — grid, scope, proposal and
1665
+ * confirm are always seamless, since unset each would draw a box inside
1666
+ * the frame that already holds it.
1667
+ */
1668
+ seamless?: boolean;
1658
1669
  }
1659
1670
 
1660
1671
  /** What draws each kind; `null` is a kind with no renderer yet, drawn as a labelled placeholder. */
@@ -1824,6 +1835,12 @@ interface BlockComponentProps {
1824
1835
  /** The value given, once answered. */
1825
1836
  value?: unknown;
1826
1837
  id?: string;
1838
+ /**
1839
+ * Set into running text: the outer cells of a table sit flush with the words
1840
+ * around it. The assistant sets it; a board panel or a page section does not,
1841
+ * so its tables keep their padding. Only the table block reads it.
1842
+ */
1843
+ seamless?: boolean;
1827
1844
  /**
1828
1845
  * Patches to `spec` as they arrive — the block draws `spec` with them
1829
1846
  * applied, and a new `spec` starts over from it. See `useBlockStream`.
@@ -2243,7 +2260,7 @@ declare function SuggestionsAsk({ spec, state, value: given, onAction }: BlockPr
2243
2260
  * total sits under the rows in bold. With a `rowKey`, picking a row sends
2244
2261
  * `select` with its key, and the `selected` row is drawn picked.
2245
2262
  */
2246
- declare function TableBlock({ spec, onAction }: BlockProps<"table">): React.JSX.Element;
2263
+ declare function TableBlock({ spec, onAction, seamless }: BlockProps<"table">): React.JSX.Element;
2247
2264
 
2248
2265
  /**
2249
2266
  * A few dated events, in order, each marked by what it did to the figure — with
package/dist/index.d.ts CHANGED
@@ -1176,10 +1176,11 @@ interface GanttSpecBar {
1176
1176
  };
1177
1177
  /** The bar's own hover card. Any one of these opens it. */
1178
1178
  summary?: string;
1179
- result?: Record<string, string | number>;
1179
+ result?: Record<string, unknown>;
1180
1180
  error?: {
1181
1181
  code?: string;
1182
1182
  message?: string;
1183
+ detail?: string;
1183
1184
  };
1184
1185
  log?: string;
1185
1186
  }
@@ -1208,12 +1209,14 @@ interface GanttSpecRow {
1208
1209
  summary?: string;
1209
1210
  /** What it said last — the card's foot. */
1210
1211
  log?: string;
1212
+ /** Why it failed — `detail` is the longer account under the message. */
1211
1213
  error?: {
1212
1214
  code?: string;
1213
1215
  message?: string;
1216
+ detail?: string;
1214
1217
  };
1215
- /** What it produced, as label/value pairs on the card — `{ rows: 412 }`. */
1216
- result?: Record<string, string | number>;
1218
+ /** What it produced, as label/value pairs on the card — `{ rows: 412 }`; nested values read as JSON. */
1219
+ result?: Record<string, unknown>;
1217
1220
  /** The tasks it split into, indented under it. A task with no timing draws their stretch. */
1218
1221
  subtasks?: GanttSpecRow[];
1219
1222
  /** Drawn open. The reader can open and close it either way. */
@@ -1228,7 +1231,7 @@ interface GanttOptions {
1228
1231
  nowMs?: number;
1229
1232
  /** The run has not decided its length yet: the last tick reads `8s+`. */
1230
1233
  openEnded?: boolean;
1231
- /** Intervals on the axis. `4` by default. */
1234
+ /** Intervals on the axis. `4` by default; on `seq`, one per step (or an even divisor of a long plan). */
1232
1235
  ticks?: number;
1233
1236
  /** The key column, in px. Defaults to the longest key, up to 40%. */
1234
1237
  labelWidth?: number;
@@ -1655,6 +1658,14 @@ interface BlockProps<K extends BlockKind = BlockKind> {
1655
1658
  value?: unknown;
1656
1659
  /** Names its form and fields. Unset, one is made. */
1657
1660
  id?: string;
1661
+ /**
1662
+ * Set into running text: a table's outer cells sit flush with the words
1663
+ * around it. Only the assistant sets it; everywhere else a table keeps its
1664
+ * cell padding. Only the table block reads it — grid, scope, proposal and
1665
+ * confirm are always seamless, since unset each would draw a box inside
1666
+ * the frame that already holds it.
1667
+ */
1668
+ seamless?: boolean;
1658
1669
  }
1659
1670
 
1660
1671
  /** What draws each kind; `null` is a kind with no renderer yet, drawn as a labelled placeholder. */
@@ -1824,6 +1835,12 @@ interface BlockComponentProps {
1824
1835
  /** The value given, once answered. */
1825
1836
  value?: unknown;
1826
1837
  id?: string;
1838
+ /**
1839
+ * Set into running text: the outer cells of a table sit flush with the words
1840
+ * around it. The assistant sets it; a board panel or a page section does not,
1841
+ * so its tables keep their padding. Only the table block reads it.
1842
+ */
1843
+ seamless?: boolean;
1827
1844
  /**
1828
1845
  * Patches to `spec` as they arrive — the block draws `spec` with them
1829
1846
  * applied, and a new `spec` starts over from it. See `useBlockStream`.
@@ -2243,7 +2260,7 @@ declare function SuggestionsAsk({ spec, state, value: given, onAction }: BlockPr
2243
2260
  * total sits under the rows in bold. With a `rowKey`, picking a row sends
2244
2261
  * `select` with its key, and the `selected` row is drawn picked.
2245
2262
  */
2246
- declare function TableBlock({ spec, onAction }: BlockProps<"table">): React.JSX.Element;
2263
+ declare function TableBlock({ spec, onAction, seamless }: BlockProps<"table">): React.JSX.Element;
2247
2264
 
2248
2265
  /**
2249
2266
  * A few dated events, in order, each marked by what it did to the figure — with
package/dist/index.js CHANGED
@@ -859,6 +859,21 @@ var toBar = ({ chip, ...bar }) => ({
859
859
  });
860
860
  var STEP_TICK = (n) => `step ${Math.round(n)}`;
861
861
  var STEPS = (n) => Math.round(n) === 1 ? "1 step" : `${Math.round(n)} steps`;
862
+ var lastEnd = (spec) => {
863
+ const end = (b) => (b.startMs ?? 0) + (b.durationMs ?? 0);
864
+ const ends = (tasks) => tasks.flatMap((t) => [
865
+ ...t.startMs != null ? [end(t)] : [],
866
+ ...(t.attempts ?? []).map(end),
867
+ ...(t.segments ?? []).map(end),
868
+ ...ends(t.subtasks ?? [])
869
+ ]);
870
+ return Math.max(spec.nowMs ?? 0, ...ends(spec.tasks), ...(spec.seams ?? []).map(end));
871
+ };
872
+ var stepTicks = (span) => {
873
+ if (span <= 8) return span;
874
+ for (let n = 8; n > 1; n--) if (span % n === 0) return n;
875
+ return 1;
876
+ };
862
877
  var toRow = ({ open: _open, subtasks, segments, ...task }) => ({
863
878
  ...task,
864
879
  bars: segments?.map(toBar),
@@ -885,6 +900,10 @@ function GanttBlock({ spec, onAction }) {
885
900
  }
886
901
  }
887
902
  const rows = React18.useMemo(() => spec.tasks.map(toRow), [spec.tasks]);
903
+ const seq = spec.scale === "seq";
904
+ const steps = seq ? spec.spanMs ?? Math.max(Math.ceil(lastEnd(spec)), 1) : void 0;
905
+ const span = steps ?? spec.spanMs;
906
+ const ticks = spec.ticks ?? (steps != null ? stepTicks(steps) : void 0);
888
907
  const pick = (key) => {
889
908
  setSelected(key);
890
909
  onAction?.("select", key);
@@ -893,12 +912,12 @@ function GanttBlock({ spec, onAction }) {
893
912
  Gantt,
894
913
  {
895
914
  rows,
896
- spanMs: spec.spanMs,
915
+ spanMs: span,
897
916
  nowMs: spec.nowMs,
898
917
  openEnded: spec.openEnded,
899
- ticks: spec.ticks,
900
- formatTick: spec.scale === "seq" ? STEP_TICK : void 0,
901
- formatDuration: spec.scale === "seq" ? STEPS : void 0,
918
+ ticks,
919
+ formatTick: seq ? STEP_TICK : void 0,
920
+ formatDuration: seq ? STEPS : void 0,
902
921
  labelWidth: spec.labelWidth,
903
922
  durationWidth: spec.durationWidth,
904
923
  palette: spec.palette,
@@ -1331,7 +1350,6 @@ function ProposalBlock({ spec, onAction }) {
1331
1350
  ProposalCard,
1332
1351
  {
1333
1352
  flush: true,
1334
- seamless: true,
1335
1353
  title: spec.heading,
1336
1354
  done: spec.done?.label,
1337
1355
  consequence: spec.consequence,
@@ -1580,7 +1598,7 @@ function CellText({ cell }) {
1580
1598
  }
1581
1599
  );
1582
1600
  }
1583
- function TableBlock({ spec, onAction }) {
1601
+ function TableBlock({ spec, onAction, seamless }) {
1584
1602
  const truncated = spec.total != null && spec.total > spec.rows.length;
1585
1603
  const highlighted = new Set(spec.highlight?.map((i) => spec.rows[i]));
1586
1604
  const data = spec.totals ? [...spec.rows, spec.totals] : spec.rows;
@@ -1603,7 +1621,8 @@ function TableBlock({ spec, onAction }) {
1603
1621
  columns,
1604
1622
  data,
1605
1623
  density: "compact",
1606
- seamless: true,
1624
+ bordered: false,
1625
+ seamless,
1607
1626
  enableSorting: false,
1608
1627
  enableColumnVisibility: false,
1609
1628
  minWidth: spec.columns.length > FITS ? spec.columns.length * COLUMN_MIN : void 0,