@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.cjs CHANGED
@@ -881,6 +881,21 @@ var toBar = ({ chip, ...bar }) => ({
881
881
  });
882
882
  var STEP_TICK = (n) => `step ${Math.round(n)}`;
883
883
  var STEPS = (n) => Math.round(n) === 1 ? "1 step" : `${Math.round(n)} steps`;
884
+ var lastEnd = (spec) => {
885
+ const end = (b) => (b.startMs ?? 0) + (b.durationMs ?? 0);
886
+ const ends = (tasks) => tasks.flatMap((t) => [
887
+ ...t.startMs != null ? [end(t)] : [],
888
+ ...(t.attempts ?? []).map(end),
889
+ ...(t.segments ?? []).map(end),
890
+ ...ends(t.subtasks ?? [])
891
+ ]);
892
+ return Math.max(spec.nowMs ?? 0, ...ends(spec.tasks), ...(spec.seams ?? []).map(end));
893
+ };
894
+ var stepTicks = (span) => {
895
+ if (span <= 8) return span;
896
+ for (let n = 8; n > 1; n--) if (span % n === 0) return n;
897
+ return 1;
898
+ };
884
899
  var toRow = ({ open: _open, subtasks, segments, ...task }) => ({
885
900
  ...task,
886
901
  bars: segments?.map(toBar),
@@ -907,6 +922,10 @@ function GanttBlock({ spec, onAction }) {
907
922
  }
908
923
  }
909
924
  const rows = React18__namespace.useMemo(() => spec.tasks.map(toRow), [spec.tasks]);
925
+ const seq = spec.scale === "seq";
926
+ const steps = seq ? spec.spanMs ?? Math.max(Math.ceil(lastEnd(spec)), 1) : void 0;
927
+ const span = steps ?? spec.spanMs;
928
+ const ticks = spec.ticks ?? (steps != null ? stepTicks(steps) : void 0);
910
929
  const pick = (key) => {
911
930
  setSelected(key);
912
931
  onAction?.("select", key);
@@ -915,12 +934,12 @@ function GanttBlock({ spec, onAction }) {
915
934
  ui.Gantt,
916
935
  {
917
936
  rows,
918
- spanMs: spec.spanMs,
937
+ spanMs: span,
919
938
  nowMs: spec.nowMs,
920
939
  openEnded: spec.openEnded,
921
- ticks: spec.ticks,
922
- formatTick: spec.scale === "seq" ? STEP_TICK : void 0,
923
- formatDuration: spec.scale === "seq" ? STEPS : void 0,
940
+ ticks,
941
+ formatTick: seq ? STEP_TICK : void 0,
942
+ formatDuration: seq ? STEPS : void 0,
924
943
  labelWidth: spec.labelWidth,
925
944
  durationWidth: spec.durationWidth,
926
945
  palette: spec.palette,
@@ -1353,7 +1372,6 @@ function ProposalBlock({ spec, onAction }) {
1353
1372
  ui.ProposalCard,
1354
1373
  {
1355
1374
  flush: true,
1356
- seamless: true,
1357
1375
  title: spec.heading,
1358
1376
  done: spec.done?.label,
1359
1377
  consequence: spec.consequence,
@@ -1602,7 +1620,7 @@ function CellText({ cell }) {
1602
1620
  }
1603
1621
  );
1604
1622
  }
1605
- function TableBlock({ spec, onAction }) {
1623
+ function TableBlock({ spec, onAction, seamless }) {
1606
1624
  const truncated = spec.total != null && spec.total > spec.rows.length;
1607
1625
  const highlighted = new Set(spec.highlight?.map((i) => spec.rows[i]));
1608
1626
  const data = spec.totals ? [...spec.rows, spec.totals] : spec.rows;
@@ -1625,7 +1643,8 @@ function TableBlock({ spec, onAction }) {
1625
1643
  columns,
1626
1644
  data,
1627
1645
  density: "compact",
1628
- seamless: true,
1646
+ bordered: false,
1647
+ seamless,
1629
1648
  enableSorting: false,
1630
1649
  enableColumnVisibility: false,
1631
1650
  minWidth: spec.columns.length > FITS ? spec.columns.length * COLUMN_MIN : void 0,