strata-react 1.3.20 → 1.3.22

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/README.md CHANGED
@@ -211,7 +211,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
211
211
  |---|---|---|
212
212
  | Actions | `Button`, `IconButton`, `RowAction`, `AsyncButton`, `useAsyncAction` | Default is `outline`; one filled button per view; `IconButton` requires `label`; `RowAction` is named for its row ("Withdraw Tom Ellery"); `AsyncButton` keeps one width through idle, pending, done and error, and announces `error` with its retry label; buttons carry `data-variant` and `AsyncButton` `data-phase` for tests; a `title` is refused (type `never`, and a development warning): a tip is a `Tooltip`, or `IconButton`'s `label` and `hint`; `useAsyncAction` returns `{ phase, run, error, thrown, fieldErrors, clearFieldError }` with a stable `run`, describes an `HttpError` in a sentence with the server's own reason for a 4xx (`describeActionError`, or the product's own `describeError`), and `validate` plus a server's 422 put messages on `fieldErrors` for each `Field` |
213
213
  | Form | `Field`, `Input`, `Textarea`, `NativeSelect`, `ChoiceGroup`, `Checkbox` | `Field` wires label, hint, error, `aria-describedby`, `aria-invalid`, and `action` puts a one-field form's button on the control's row with the hint and error under both; `Checkbox` requires `label` and is one target with it, and has a mixed state |
214
- | Status and figures | `Status`, `Metric`, `MetricStrip`, `Meter`, `crossedThreshold`, `CompositionBar`, `WorkflowSteps`, `WorkflowSummary`, `JobsTable`, `ScheduleTable`, `SystemPanel`, `useSystemInfo`, `PauseButton` | A status is always a word; figures have no icons or sparklines; `Meter` is a `meter` named for what it measures, with its reading in words ("72% used"), threshold notches, and a `Status` word once a threshold is crossed (each threshold must name its state); `CompositionBar` is a stacked bar over a table naming every part, its amount and share, and names the remainder (`total` needs `restLabel`); a part that is there reads "<1%" and keeps a sliver, never "0%"; `JobStatus` is a long-running server job (its `progress` `{ done, total, current }` reads "12 of 40 done, 28 remaining · IMG_0412"; `useJobAction` starts one: busy until the server answers, a "queued" toast with a link to the jobs page, a "finished" toast when it ends): a required word per state beside the app's sentence, a progress bar when the total is known, each failure named with its reason, announced only when the item changes or the job ends; `WorkflowSteps` draws strata-python's shared `WorkflowRun` (`/api/workflows/<pipeline>/subjects/<id>`): each stage's state as a word, when it ran and how long it took, a failed stage's error with Try again, and Approve on a waiting gate (the first is the view's filled button), saying who approved or that its policy did; `JobsTable` is the shared jobs page (`GET /api/jobs`): each job's state as a word with its progress or error, and Cancel or Run again only where they apply. Both take the app's generated `Schema<"WorkflowRun">` and `Schema<"Task">` as they come; `ScheduleTable` is a machine's scheduled jobs (systemd timers, cron), not the queue: each job's last result as a word (OK, Failed, Running, Never run), when it last ran and when it runs next, the last two dropping on a phone; `SystemPanel` is strata-python's `GET /api/system` (`useSystemInfo()` reads it): version and commit, uptime, each folder as a `Meter` on shared disk limits ("Filling up", "Nearly full") or the word Missing, each service Up or Down with the server's reason, and the app's own `facts`; `PauseButton` takes the `Poll` from `usePoll` (passed to `useLoad({ poll })`): a fixed-name "Pause updates" toggle and "Updated 12:00" |
214
+ | Status and figures | `Status`, `Metric`, `MetricStrip`, `Meter`, `crossedThreshold`, `CompositionBar`, `WorkflowSteps`, `WorkflowSummary`, `JobsTable`, `ScheduleTable`, `SystemPanel`, `useSystemInfo`, `PauseButton` | A status is always a word; figures have no icons or sparklines; `Meter` is a `meter` named for what it measures, with its reading in words ("72% used"), threshold notches, and a `Status` word once a threshold is crossed (each threshold must name its state); `CompositionBar` is a stacked bar over a table naming every part, its amount and share, and names the remainder (`total` needs `restLabel`); `other={{ label }}` folds data-driven parts past five into one "Other" part (the four largest stay in order), and a production build folds instead of throwing; a part that is there reads "<1%" and keeps a sliver, never "0%"; `JobStatus` is a long-running server job (its `progress` `{ done, total, current }` reads "12 of 40 done, 28 remaining · IMG_0412"; `useJobAction` starts one: busy until the server answers, a "queued" toast with a link to the jobs page, a "finished" toast when it ends): a required word per state beside the app's sentence, a progress bar when the total is known, each failure named with its reason, announced only when the item changes or the job ends; `WorkflowSteps` draws strata-python's shared `WorkflowRun` (`/api/workflows/<pipeline>/subjects/<id>`): each stage's state as a word, when it ran and how long it took, a failed stage's error with Try again, and Approve on a waiting gate (the first is the view's filled button), saying who approved or that its policy did; `JobsTable` is the shared jobs page (`GET /api/jobs`): each job's state as a word with its progress or error, and Cancel or Run again only where they apply. Both take the app's generated `Schema<"WorkflowRun">` and `Schema<"Task">` as they come; `ScheduleTable` is a machine's scheduled jobs (systemd timers, cron), not the queue: each job's last result as a word (OK, Failed, Running, Never run), when it last ran and when it runs next, the last two dropping on a phone; `SystemPanel` is strata-python's `GET /api/system` (`useSystemInfo()` reads it): version and commit, uptime, each folder as a `Meter` on shared disk limits ("Filling up", "Nearly full") or the word Missing, each service Up or Down with the server's reason, and the app's own `facts`; `PauseButton` takes the `Poll` from `usePoll` (passed to `useLoad({ poll })`): a fixed-name "Pause updates" toggle and "Updated 12:00" |
215
215
  | Data | `DataView`, `Load<T>`, `Stale`, `StaleNotice`, `LoadError`, `EmptyState`, `Skeleton`, `Thumbnail`, `ThumbnailSkeleton`, `DataTable`, `TableSkeleton`, `VirtualList`, `InfiniteList`, `LoadMore`, `useInView`, `LineChart` | `DataView` requires skeleton and empty, keeps data on screen under a `StaleNotice` (why, how old, Try again) when a refresh fails, and takes an `error` renderer for an app's own look of a failed read (default `LoadError`, always inside an alert); `Thumbnail` is a remote image in a box of fixed `aspect`, with a skeleton while it loads, the required `missing` words (or a `fallback` drawing, such as an avatar's initial) when it fails or `src` is null, required `alt`, `children` overlaid in its corners, and a request only once it nears the screen (`eager` for the first few); tables, lists and tile grids virtualise from 100 rows, on React Aria's Virtualizer; a `DataTable` is a React Aria table (a `grid`) over TanStack Table's data model; a `DataTable` column with `value` sorts by type with missing values last both ways and draws a placeholder (`missing`, default an en dash); `InfiniteList` loads the next page on approach, with a skeleton for it, a Try again row when it fails and a Show more button for the keyboard, and `scroll="page"` draws a grid that scrolls with the page; `LoadMore` is that next-page row for any list or grid; charts label values directly; `LineChart` can also follow an app's position (`current`), read a value at the pointer or by arrow keys (`readout`, one slider whose value text is the reading), report a picked x (`onPick`) and fill one flat area (`area`); `xLabel` names the x column of its table `Thumbnail`'s `src` may be a list tried in order, `onLoad` can reject a picture that loaded (a host's grey placeholder) and `onMissing` is told once when none worked; with `alt=""` and a `fallback` its missing state is presentational. `LoadMore` and `InfiniteList` can draw the Show more and loading rows the app's way (`more`, `loading`, and `ruled={false}` for no hairlines).; a `DataTable` column's `hideBelow="sm"` hides its header and cells together on a narrow screen (CSS only; a virtualised table drops the column by a media query), never a hand-written `matchMedia` filter |
216
216
  | Compare | `Compare`, `PairVote`, `PairJudge`, `CompareAudio`, `CompareText`, `CompareGrid`, `CompareVideoGrid`, `ViewportFrame`, `useViewport`, `FullscreenFrame`, `useDifference`, `differences` | Two pictures judged together: side by side, swipe (a divider that moves from the keyboard), fade, blink (`x` flips) and difference (a live difference blend with amplify, or pixelmatch's changed pixels with a tolerance and the share that differ; pixels are read only when that view is open, at most 2048 px on the long side, and a picture the browser will not let the page read says so in words); `maxHeight="fit"` measures the window for the pair and its surroundings instead of the `"viewport"` guess; `CompareGrid` is every candidate at once with the same zoom and full screen, and `actions` for what a tile offers; one zoom and pan for both sides (buttons, `+` `-` `0`, Ctrl-wheel or trackpad pinch, drag, arrow keys, double click, `1:1`), and full screen (the browser's Fullscreen API, a modal where there is none). `blind` is required: a blind comparison names pictures by `label` only and never writes the variant `id`, `note` or `alt`. A picture that fails shows the required `missing` words in its place; the keys come from one `Shortcut[]` shared with `KeysLegend`, and `keys={false}` leaves them to a surrounding screen. `PairVote` wraps `Compare` for a blind pairwise judgment: answer keys `a` `b` `t` `s` in Compare's one legend, a vote bar with no filled button, `pending`, a flag menu, a progress line, preload and Undo, and click to choose (a click on the picture you prefer, not a drag or double click; in swipe the side of the divider, in blink the side showing, none in fade or difference; `onPick` on `Compare` and `CompareVideo`, `pick={false}` turns it off). `CompareAudio` is one transport for two clips with an A/B switch that keeps the playhead (same time, or the same share when the lengths differ), a loop range and loudness matching (the louder clip turned down to the quieter, by RMS); `CompareText` is two texts scrolled together with a word diff and an optional reference; `PairJudge` is the answering around any of them; `CompareVideo` is two videos on one clock (play, pause, seek and speed drive both, the follower kept within a frame, both held while either waits for data) in side by side, swipe, fade and blink, with zoom and pan locked and nearest-neighbour pixels past 1:1, candidates of different sizes drawn in one box, one soundtrack (`audio`), and the same slots as the rest. `autoPlay` starts the pair once both can play (muted; not with reduced motion unless `"always"`) and `loopWhole` loops the whole clip when no range is set (also on `CompareVideoGrid`). Frame by frame (`,` `.`), a loop range the app can hold (`i` `o` `c`), speeds down to 0.1 and named `moments` are in it; `CompareVideoGrid` is every candidate's video at once on that one clock (one transport, one zoom, regions, a loop, stepping), light on the browser (metadata only until the first play, cells out of sight paused and left out of the sync, sound off unless `audio` names a cell, a cell that falls behind marked "Catching up"), with an optional `reference` drawn first, never blind and nearest-neighbour. `regions` (on `Compare`, `CompareVideo` and `CompareGrid`) names boxes in the source's coordinates to look at enlarged: chips, keys `q` `w` `e` `r` `y` `u`, nearest-neighbour drawing, the box outlined while its chip is pointed at, and Shift-drag to make another |
217
217
  | Selection | `useSelection`, `useChoices`, `BulkBar`, `SelectableGrid`, `DataTable`'s `selection` (`RowSelection<T>`) | Opt-in checkbox column with "Select all shown" that respects `isSelectable`; Shift-click or Shift+Space chooses or clears the run from the last row clicked, in the order shown; `initial` (keys or a test on the row) chooses a row the first time it appears, so it applies to data that loads later; the selection drops rows that are gone; `BulkBar` announces the count politely, and while it is up its one filled action is the view's only one (the screen's primary goes to `outline`); `SelectableGrid` is the same selection as a grid of pictures (`renderImage`), each tile one labelled target, virtualised from 100 tiles; as a photo grid it takes a pixel `tileSize` zoomed by Ctrl/Cmd+wheel, `+` and `-` and two-finger pinch (`onTileSizeChange`), `aspect="natural"` (rows of equal height, each picture at its `naturalAspect`), a marquee from between tiles, `selectionMode` and `selectionBehavior` (`replace` is the Finder's rules; `onAction` opens), `groupBy` (sticky headings with a group box and a fold), a corner `badge`, `unselectableReason`, and counts what a filter hides ("3 chosen are hidden by the filter"); `ViewOptions` with `useViewOptions` is the one toolbar for how it is looked at: sort (natural order, direction named for the key), group, size slider, aspect, grid or list and a filter with its count, kept in `localStorage` and optionally `?sort=…&group=…&size=…`, a "View" popover on a phone. A choice can imply others: `implies(key)` (on `useSelection`, and `useChoices` for a lazy tree) keeps what the person chose apart from what that brings in, follows it through, locks the implied keys (they only clear with what implied them), and gives `implied`, `because(key)`, `counts`, a `note` for the live region and `summary(noun, then)`, the line a destructive confirm can carry ("12 results will be forgotten: 8 chosen, 4 that depend on them") |
package/UPGRADING.md CHANGED
@@ -11,6 +11,12 @@ time. While the version is 0.x, any release may break.
11
11
 
12
12
  Every PR that changes what an app sees adds a line here (see `CLAUDE.md`, "Changelog").
13
13
 
14
+ ## 2026-11-25 (seek bar marks past the end)
15
+ - **`SeekBar` (and `MediaPlayer` through it) no longer draws a mark outside 0 to the duration.** A test that found a mark button past the loaded file's end will not find it; pass marks within the file.
16
+
17
+ ## 2026-11-25 (CompositionBar, #377)
18
+ - `CompositionBar` no longer crashes a production build when a sixth part has no `colour`: it folds the smallest into "Other" and logs `console.error`. Development and tests still throw. Parts that come from data should pass `other={{ label }}` to fold on purpose; a test that expected the throw under `NODE_ENV=production` now sees the folded bar.
19
+
14
20
  ## 2026-11-25 (twelve issues, #359–#370)
15
21
  - **`Pane`'s body is inset** (`p-3`, the header's own padding) so an `Inspector` or text lines up with the pane's name (#366). A pane that holds a tree, table, list or stage drawn to the edge adds `flush`; a pane whose content you inset yourself (`className="p-3"` on the child) can delete that. Visual baselines with a `Pane` move.
16
22
  - `Expanded` (from `useExpanded`) has a new member, `toggle(key)` (#364): an `Expanded` you build by hand in a test or story must supply it. `Tree`'s new `branchPress="toggle"` makes pressing a folder's row open it instead of choosing it; the default (`"select"`) is unchanged.
@@ -15,6 +15,15 @@ export type CompositionBarProps = {
15
15
  formatValue: (value: number) => string;
16
16
  /** Formats a part's share of the whole (0 to 1). Defaults to `format.share` ("<1%" for a part that rounds to 0). */
17
17
  formatShare?: (share: number) => string;
18
+ /**
19
+ * Fold the smallest parts into one last part when there are more than five. The four largest keep
20
+ * their given order; the rest are summed under this label (a function gets how many were folded:
21
+ * `(n) => `${n} other apps``). Opt in for parts that come from data and have no order of their own;
22
+ * leave it off for ordered parts (used, cached, free).
23
+ */
24
+ other?: {
25
+ label: string | ((count: number) => string);
26
+ };
18
27
  /** Header of the parts column, for screen readers and over the table. Defaults to "Part". */
19
28
  partHeader?: string;
20
29
  /** Header of the amounts column. Defaults to "Amount". */
@@ -32,4 +41,4 @@ export type CompositionBarProps = {
32
41
  restLabel?: undefined;
33
42
  });
34
43
  /** What a whole is made of: a stacked bar for proportion and a table that names every part, its amount and its share, so colour is never the only cue. */
35
- export declare function CompositionBar({ label, parts, formatValue, formatShare, partHeader, valueHeader, shareHeader, className, ...whole }: CompositionBarProps): React.JSX.Element;
44
+ export declare function CompositionBar({ label, parts, formatValue, formatShare, partHeader, valueHeader, shareHeader, other, className, ...whole }: CompositionBarProps): React.JSX.Element;
package/dist/index.js CHANGED
@@ -1492,15 +1492,40 @@ function SystemPanel({ load, thresholds = diskThresholds, facts = [], now, headi
1492
1492
  }
1493
1493
  // src/components/composition.tsx
1494
1494
  var MAX_TOKENS = 5;
1495
+ /** Keeps the four largest parts in their given order and sums the rest into one last part. */
1496
+ function foldParts(parts, label) {
1497
+ if (parts.length <= MAX_TOKENS) return parts;
1498
+ const keep = new Set(parts.map((p, i) => ({
1499
+ i,
1500
+ v: Math.max(0, p.value)
1501
+ })).sort((a, b) => b.v - a.v || a.i - b.i).slice(0, 4).map((x) => x.i));
1502
+ const rest = parts.filter((_, i) => !keep.has(i));
1503
+ const folded = {
1504
+ key: "strata-other",
1505
+ label: typeof label === "function" ? label(rest.length) : label,
1506
+ value: rest.reduce((n, p) => n + Math.max(0, p.value), 0)
1507
+ };
1508
+ return [...parts.filter((_, i) => keep.has(i)), folded];
1509
+ }
1495
1510
  /** A part's colour: its own, or the chart token for its position. Throws past the fifth token. */
1496
1511
  function colourFor(part, index) {
1497
1512
  if (part.colour) return part.colour;
1498
1513
  if (index >= MAX_TOKENS) throw new Error(`CompositionBar: part "${part.label}" is number ${index + 1}, and there are only ${MAX_TOKENS} chart colours. Combine the smallest parts into one "Other" part, or give this part a colour.`);
1499
1514
  return `var(--chart-${index + 1})`;
1500
1515
  }
1516
+ /** The parts to draw: folded when asked to, or, in production only, when a part has no colour to take. */
1517
+ function shown(label, parts, other) {
1518
+ if (other) return foldParts(parts, other.label);
1519
+ if (!isDev() && parts.some((p, i) => i >= MAX_TOKENS && !p.colour)) {
1520
+ console.error(`CompositionBar "${label}": ${parts.length} parts and only ${MAX_TOKENS} chart colours, so the smallest are shown as "Other". Pass \`other\` to fold them on purpose, or give each part a colour.`);
1521
+ return foldParts(parts, "Other");
1522
+ }
1523
+ return parts;
1524
+ }
1501
1525
  /** What a whole is made of: a stacked bar for proportion and a table that names every part, its amount and its share, so colour is never the only cue. */
1502
- function CompositionBar({ label, parts, formatValue, formatShare = format.share, partHeader = "Part", valueHeader = "Amount", shareHeader = "Share", className, ...whole }) {
1526
+ function CompositionBar({ label, parts, formatValue, formatShare = format.share, partHeader = "Part", valueHeader = "Amount", shareHeader = "Share", other, className, ...whole }) {
1503
1527
  const captionId = React.useId();
1528
+ parts = shown(label, parts, other);
1504
1529
  const sum = parts.reduce((n, p) => n + Math.max(0, p.value), 0);
1505
1530
  const total = Math.max(whole.total ?? sum, sum);
1506
1531
  const rest = whole.total !== void 0 ? total - sum : 0;
@@ -3792,7 +3817,7 @@ function SeekBar({ time, duration: known, onSeek, marks = [], spans = [], onMark
3792
3817
  className: "absolute top-1/2 h-4 w-px -translate-y-1/2 bg-foreground/60",
3793
3818
  style: { left: `${otherTime / duration * 100}%` }
3794
3819
  }),
3795
- duration > 0 && marks.map((m) => /* @__PURE__ */ jsx("button", {
3820
+ duration > 0 && marks.filter((m) => m.time >= 0 && m.time <= duration).map((m) => /* @__PURE__ */ jsx("button", {
3796
3821
  type: "button",
3797
3822
  tabIndex: -1,
3798
3823
  disabled,