strata-react 1.3.4 → 1.3.5

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
@@ -183,7 +183,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
183
183
  | Marking text | `MarkableText`, `Mark`, `MarkSummary`; `rangeBetween` | Select words by drag, Shift+click and Shift+arrows (ids in document order, so it holds across virtualised rows), apply the app's marks from a bar or single-key chords, marks drawn by role, pattern and text, summarised and announced |
184
184
  | Maps | `strata-react/map`: `RouteMap`; `geo`, `LatLng` (main entry) | Routes and a position that moves along them, on Leaflet (no react-leaflet), behind its own entry. Tiles are the app's (`tiles.light`, `tiles.dark`, each with its attribution); the dark scheme uses the dark set or a filter over the light one. Route colours are roles resolved at draw time; `values` with `colourScale` colour a route by value in runs of one step, with a key that names the steps; a single route gets direction chevrons and start/finish marks (a loop is one mark). The position is one marker moved with `setLatLng`: no route is redrawn for it (keep `routes` stable). As picture content (a route inset over footage): `zoom` sets any zoom (animate it per frame), `follow="centre"` holds the view exactly on a position with no animation (a frame is deterministic), and `positions` draws several, each tied to a route, in its colour and named in the text alternative; routes are not redrawn for any of it. Leaflet's keyboard pan and zoom stay; the map is named by `label` and described by a generated text alternative (routes, lengths, position along). Overlay slots `topEnd` and `bottomStart` avoid Leaflet's own controls and attribution. Leaflet's stylesheet is injected once, so an app imports nothing. `geo` (distance, bearing, bounds, `pointAlong`, `arrows`, `ends`) and `format.distance` need no map library |
185
185
  | Timeline | `Timeline`, `useTimelineZoom`, `TimelineZoomControls`, `noOverlap` | Items with a start and a length in lanes on a zoomable time axis, for media edits, bookings, rotas and plans. The timeline draws and the app decides: every move, trim, lane change, selection and current-time change is reported (`onItemChange`, `onSelect`, `onPositionChange`) and the app applies it; `validate` refuses a change with a reason shown in words while it is made. One tab stop for the items; arrows move between them, Ctrl+arrows nudge and change lane, Alt+arrows trim, the current time is its own slider, `+` `-` `0` zoom, and each change is announced ("run-02.mp4 moved to 0:13"). The ruler picks steps people write on a scale so labels never collide. Lanes take drops from outside (`dropTypes`, `onDrop` with the lane and snapped time, `validateDrop`, and React Aria's keyboard drag landing at the current time), `laneRows` makes them taller, `kindColours` fixes each kind's stripe, and the header column fits its content. Only items near the view are rendered |
186
- | Answering by tap | `ChoiceGrid`, `ChoiceGridSkeleton`, `ChoiceState`; the `type-picture` step | One question, large picture tiles, one right answer, for someone who may not read yet (a child's learning game). Each tile is `open`, `wrong` (greyed, never red), `right` or `answer` (shown after the tries ran out), always with its word; the app owns the answer key. Answered tiles cannot be pressed again and the grid closes once the answer shows. React Aria's `GridList`: arrows across and down, Enter answers. Tiles at least 120px (`md`) or 160px (`lg`) |
186
+ | Answering by tap | `ChoiceGrid`, `ChoiceGridSkeleton`, `ChoiceState`; the `type-picture` step | One question, large picture tiles, one right answer, for someone who may not read yet (a child's learning game). Each tile is `open`, `wrong` (greyed, never red), `right` or `answer` (shown after the tries ran out), always with its word; a choice with no answer key ("Which one next?", a rating) uses `picked` (primary border, neutral word, `marks={{ picked }}`), which closes the grid so a slow request cannot be tapped twice; the app owns the answer key. Answered tiles cannot be pressed again and the grid closes once the answer shows. React Aria's `GridList`: arrows across and down, Enter answers. Tiles at least 120px (`md`) or 160px (`lg`) |
187
187
  | Answering by placing | `PlaceBoard`, `PlaceState` | An answer that is an arrangement (give a number, put in order, match pairs, sort), for someone who may not read yet. Two taps: pick a piece up (`aria-pressed`, "Picked up"), put it in a place ("Put apple in the basket"); tap it again to put it down, "Put … back" returns a placed one. Same presses by touch, mouse, keyboard and screen reader; places are disabled until a piece is held, so Tab walks the pieces, then the places; focus follows a moved piece. The app owns `placement`, applies `onMove` and checks; `placeState` marks a place `right` or `wrong` (neutral, never red) with its word, `locked` ends the round. Pieces 96px or more in the pile, 72px once placed |
188
188
  | Sortable list | `SortableList` | Reorder a list and move items between lists, by pointer and by keyboard. React Aria's `GridList` with `useDragAndDrop` (no `@dnd-kit`): a grip per row is the drag handle, so clicking a row selects it and its own actions still work; Enter on the grip picks up, arrows and Tab choose a position or list, Enter drops, Escape cancels, with React Aria's screen-reader announcements. Items carry a kind (`getKind`); a list takes the kinds in `accepts` and says why it refuses another (`refuses`, shown with an icon while that kind is dragged over it). The list never changes the data: `onReorder` and `onInsert` report the move and the app applies it, undoably |
189
189
  | Drag source | `DragSource` | A row that is dragged onto a drop target elsewhere (a `Timeline` lane), by pointer or from the keyboard. React Aria's `useDrag` with a drag button: a grip named "Drag <label>" picks it up with Enter, Tab moves between targets that take its types, Enter drops, Escape cancels, with React Aria's announcements; the pointer can pick up the whole row and the row's own buttons still work. `items` returns the drag's data (`DragData`, a type to a value), read by the target |
package/UPGRADING.md CHANGED
@@ -12,6 +12,7 @@ time. While the version is 0.x, any release may break.
12
12
  Every PR that changes what an app sees adds a line here (see `CLAUDE.md`, "Changelog").
13
13
 
14
14
  ## 2026-11-23
15
+ - `ChoiceGrid`'s `marks` type is `ChoiceMarks` (a quiz's three words, or `{ picked }` alone); `createTypedApi`'s POST/PUT/PATCH on an operation with `requestBody?: never` no longer ask for `json`, so a `json: undefined` workaround can be deleted. The request argument is now required when the operation has a required path or query value (a call that left it out compiled and threw at run time); pass `{ path: … }`.
15
16
  - `installLayoutShims()` now also installs an in-memory `localStorage` and `sessionStorage` where the runtime's are unusable (Node 25+ under jsdom), emptied after each test. Apps that carried their own shim can delete it; one that tests "no storage" must replace it afterwards.
16
17
  - `strata-api-types` reports why openapi-typescript failed to load instead of always asking for an install; a TypeScript 7 app needs the `typescript`/`typescript7` split in the README (new section text, no code change).
17
18
  - `NativeSelect`, `ChoiceGroup` and `ToggleGroup` are now unions that also take `param` (URL-held choice); `ChoiceGroup` and `ToggleGroup` are function components with the same props, so nothing changes for existing callers. `fetchJson`'s init type is `FetchJsonInit` (`RequestInit` plus `json`).
@@ -1,6 +1,15 @@
1
1
  import * as React from "react";
2
2
  /** Where a tile stands in the round: not yet tried, tried and wrong, tried and right, or shown as the answer after the tries ran out. */
3
- export type ChoiceState = "open" | "wrong" | "right" | "answer";
3
+ export type ChoiceState = "open" | "wrong" | "right" | "answer" | "picked";
4
+ /** The word under each closed tile. A quiz gives `wrong`, `right` and `answer` (and `picked` if it ever uses it); a choice with no answer key gives only `picked`. A state with no word draws no word, so name every state the grid can reach. */
5
+ export type ChoiceMarks = (Record<"wrong" | "right" | "answer", string> & {
6
+ picked?: string;
7
+ }) | {
8
+ picked: string;
9
+ wrong?: never;
10
+ right?: never;
11
+ answer?: never;
12
+ };
4
13
  /** Smallest tile side: `md` 120px, `lg` 160px. Tiles grow to fill the row. */
5
14
  export type ChoiceSize = "md" | "lg";
6
15
  /** Props of `ChoiceGrid`. */
@@ -15,15 +24,15 @@ export type ChoiceGridProps<T> = {
15
24
  renderPicture: (item: T) => React.ReactNode;
16
25
  /** Each tile's state in the round. The app owns the answer; the grid only draws it. */
17
26
  state: (item: T) => ChoiceState;
18
- /** The word under a closed tile, for each closed state: `{ wrong: "Not this one", right: "Right", answer: "This one" }`. */
19
- marks: Record<Exclude<ChoiceState, "open">, string>;
27
+ /** The word under a closed tile, for each closed state: `{ wrong: "Not this one", right: "Right", answer: "This one" }`, or `{ picked: "Picked" }` where there is no answer key. */
28
+ marks: ChoiceMarks;
20
29
  /** An open tile was pressed (pointer, touch, Enter or Space). */
21
30
  onChoose: (item: T) => void;
22
31
  /** Default `md`. */
23
32
  size?: ChoiceSize;
24
33
  className?: string;
25
34
  };
26
- /** A grid of large picture tiles for answering one question with a tap: each tile open, wrong, right or shown as the answer, with its word; answered tiles cannot be pressed again, and the grid closes once the answer shows. */
35
+ /** A grid of large picture tiles for answering one question with a tap: each tile open, wrong, right, shown as the answer or (no answer key) picked, with its word; answered tiles cannot be pressed again, and the grid closes once the answer shows. */
27
36
  export declare function ChoiceGrid<T>({ label, items, itemKey, itemLabel, renderPicture, state, marks, onChoose, size, className }: ChoiceGridProps<T>): React.JSX.Element;
28
37
  /** The loading shape of a `ChoiceGrid`: `count` tiles at the same size, for a `DataView` skeleton. */
29
38
  export declare function ChoiceGridSkeleton({ count, size, className }: {
package/dist/index.d.ts CHANGED
@@ -58,7 +58,7 @@ export { BulkBar, useSelection, useChoices, type InitialSelection, type Choices,
58
58
  export type { Implies } from './lib/choice';
59
59
  export { SelectableGrid, type SelectableGridProps, type TileAspect, type TileSize, } from './components/selectable-grid';
60
60
  export { ViewOptions, useViewOptions, sortRows, type ViewOptionsProps, type ViewOptionsConfig, type ViewOptionsState, type ViewSort, type ViewGroup, type ViewGroupRows } from './components/view-options';
61
- export { ChoiceGrid, ChoiceGridSkeleton, type ChoiceGridProps, type ChoiceState, type ChoiceSize } from './components/choice-grid';
61
+ export { ChoiceGrid, ChoiceGridSkeleton, type ChoiceGridProps, type ChoiceState, type ChoiceMarks, type ChoiceSize } from './components/choice-grid';
62
62
  export { PlaceBoard, type PlaceBoardProps, type PlaceState } from './components/place-board';
63
63
  export { TileGrid, TileGridSkeleton, SelectableGridSkeleton, type TileGridProps } from './components/tile-grid';
64
64
  export { VirtualList } from './components/virtual-list';
package/dist/index.js CHANGED
@@ -9280,9 +9280,9 @@ var minSide = {
9280
9280
  md: 120,
9281
9281
  lg: 160
9282
9282
  };
9283
- var closed = (s) => s === "right" || s === "answer";
9283
+ var closed = (s) => s === "right" || s === "answer" || s === "picked";
9284
9284
  var columns = (size) => ({ gridTemplateColumns: `repeat(auto-fill, minmax(min(${minSide[size]}px, 100%), 1fr))` });
9285
- /** A grid of large picture tiles for answering one question with a tap: each tile open, wrong, right or shown as the answer, with its word; answered tiles cannot be pressed again, and the grid closes once the answer shows. */
9285
+ /** A grid of large picture tiles for answering one question with a tap: each tile open, wrong, right, shown as the answer or (no answer key) picked, with its word; answered tiles cannot be pressed again, and the grid closes once the answer shows. */
9286
9286
  function ChoiceGrid({ label, items, itemKey, itemLabel, renderPicture, state, marks, onChoose, size = "md", className }) {
9287
9287
  const byKey = new Map(items.map((item) => [itemKey(item), item]));
9288
9288
  const over = items.some((item) => closed(state(item)));
@@ -9301,19 +9301,19 @@ function ChoiceGrid({ label, items, itemKey, itemLabel, renderPicture, state, ma
9301
9301
  children: items.map((item) => {
9302
9302
  const key = itemKey(item);
9303
9303
  const s = state(item);
9304
- const mark = s === "open" ? null : marks[s];
9304
+ const mark = s === "open" ? null : marks[s] ?? null;
9305
9305
  return /* @__PURE__ */ jsxs(GridListItem, {
9306
9306
  id: key,
9307
9307
  textValue: itemLabel(item),
9308
9308
  "aria-label": mark ? `${itemLabel(item)}, ${mark.toLowerCase()}` : itemLabel(item),
9309
9309
  "data-choice": s,
9310
- className: cn("flex aspect-square min-w-0 cursor-pointer flex-col items-center justify-center gap-1 rounded-overlay border-2 border-border bg-card p-2 text-card-foreground select-none outline-offset-2 transition-state press", "hover:border-primary disabled:cursor-default disabled:hover:border-border", closed(s) && "border-4 border-success bg-success-subtle disabled:hover:border-success"),
9310
+ className: cn("flex aspect-square min-w-0 cursor-pointer flex-col items-center justify-center gap-1 rounded-overlay border-2 border-border bg-card p-2 text-card-foreground select-none outline-offset-2 transition-state press", "hover:border-primary disabled:cursor-default disabled:hover:border-border", (s === "right" || s === "answer") && "border-4 border-success bg-success-subtle disabled:hover:border-success", s === "picked" && "border-4 border-primary bg-surface-sunken disabled:hover:border-primary"),
9311
9311
  children: [/* @__PURE__ */ jsx("span", {
9312
9312
  "aria-hidden": true,
9313
9313
  className: cn("type-picture transition-state", s === "wrong" && "opacity-40"),
9314
9314
  children: renderPicture(item)
9315
9315
  }), mark && /* @__PURE__ */ jsx(Status, {
9316
- tone: s === "wrong" ? "neutral" : "success",
9316
+ tone: s === "wrong" || s === "picked" ? "neutral" : "success",
9317
9317
  className: "max-w-full truncate",
9318
9318
  children: mark
9319
9319
  })]