strata-react 1.3.1 → 1.3.2

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
@@ -184,7 +184,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
184
184
  | 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 |
185
185
  | 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 |
186
186
  | 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 |
187
- | File intake | `FileButton`, `FileDropZone`, `FileOutcomes`, `MissingFile`, `useFileIntake` | Pick or drop local files, then one outcome per file. `FileButton` is React Aria's `FileTrigger` behind a real named button (the keyboard and phone route); `FileDropZone` is its `DropZone` and says what it takes while a drag is over it. `useFileIntake({ accept, acceptLabel, process })` judges each file after the drop, so a wrong one is named with its reason (type, `maxBytes`, your `check`), runs your own `process` per file (a throw becomes `Failed` with its message and a retry), and never blocks the rest. `FileOutcomes` draws the rows and announces one summary per batch. `MissingFile` is a status word and a "Relink" that opens the picker for that item; the name wraps in a narrow pane and a `thumbnail` can lead it. Nothing assumes a server |
187
+ | File intake | `FileButton`, `FileDropZone`, `FileOutcomes`, `MissingFile`, `useFileIntake` | Pick or drop local files, then one outcome per file. `FileButton` is React Aria's `FileTrigger` behind a real named button (the keyboard and phone route); `FileDropZone` is its `DropZone` and says what it takes while a drag is over it; it ignores the app's own drags (every `DragSource`'s, and any type named in `refuseTypes`), so a keyboard drag to a timeline lane does not stop on it. `useFileIntake({ accept, acceptLabel, process })` judges each file after the drop, so a wrong one is named with its reason (type, `maxBytes`, your `check`), runs your own `process` per file (a throw becomes `Failed` with its message and a retry), and never blocks the rest. `FileOutcomes` draws the rows and announces one summary per batch. `MissingFile` is a status word and a "Relink" that opens the picker for that item; the name wraps in a narrow pane and a `thumbnail` can lead it. Nothing assumes a server |
188
188
  | Inspector | `Inspector`, `InspectorSection`, `PropertyRow`, `PropertyList` | Properties of the selected thing. `Inspector` is a labelled region with the selection's name as its heading and the empty state (`empty`, required) when `title` is `null`; `selectionKey` gives a new selection fresh controls and keeps focus in the panel. `InspectorSection` is React Aria's `Disclosure` with the body mounted only while open; open and closed are remembered under `storageKey` (storage that throws just means defaults). `PropertyRow` is a `Field` with a "Reset <label>" that shows only while `modified`. `PropertyList` is a `dl`: missing values print an en dash heard as "Not known", units follow a non-breaking space, long values truncate with the whole value in a tooltip |
189
189
  | Feedback | `UndoBar`, `useUndoable`, `Done` | Undo before confirm; the hook owns which rows are out of view (`isRemoved`), a failed commit brings the row back with Try again in the same bar, and `flush()` commits before a dependent action; `Done` is the one celebration, and it must say what happens next |
190
190
  | Helpers | `cn`, `format`, `createFormat`, `NBSP` | `cn` knows `type-*`; all numbers and dates through `Intl`; `format.integer(n)`, `.decimal(n)`, `.percent(n)` are callable and keep Intl's methods; `format.bytes(n, unit?)` writes sizes in decimal units (`byteUnit` shares one unit across figures); `format.date(at)` ("8 Nov 2026") and `format.dateTime(at)` ("8 Nov 2026, 06:05"), like `clock`, `day` and `shortDay`, take a Date, ISO string or epoch ms; `format.ago(at, now?)` ("3 weeks ago"), `format.compact(n)` ("1.2k", and `count(n, one, many, { compact: true })`), `format.runningTime(seconds)` ("1:02:09") and `format.share(n)` ("<1%" for a part that rounds to 0); every number and date formatter prints the placeholder (`format.missing`, an en dash) for `null` or `undefined`; `createFormat(locale, { timeZone, missing })` fixes the zone and the placeholder; units and counts join with a non-breaking space |
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
+ - `FileDropZone` no longer takes a `DragSource` drag (or one of its new `refuseTypes`): a keyboard drag skips it and it does not offer "Drop to add". A test that Tabbed past the zone during a keyboard drag can drop that Tab.
15
16
  - `strata-visual` gives a route's page, when taller than the window, a window as tall as itself before its shot, so lazy pictures (`Thumbnail`) below the fold are drawn in the baseline: re-record baselines that showed their grey loading boxes (`scrollThrough: false` in the config keeps the old behaviour). An app that passed `eager` to `Thumbnail` only for its screenshots can drop it.
16
17
  - `MediaPlayer` with `controls="native"` (or `"auto"` on a touch device) and `spans` now draws a thin strip of the spans under the picture.
17
18
 
@@ -1,4 +1,11 @@
1
1
  import * as React from "react";
2
+ /**
3
+ * The type every `DragSource` drag carries beside the app's own, so a drop target that takes only files (`FileDropZone`) can tell
4
+ * an in-app drag from a drag of files without the app declaring anything (issue #291). A drag started by `useDrag` carries only
5
+ * the types it is given, and React Aria's `DragTypes` cannot tell an app's `text/plain` from a dragged `.txt` file, so a type of
6
+ * our own is the one that can be recognised for certain.
7
+ */
8
+ export declare const STRATA_DRAG_TYPE = "application/x-strata-drag";
2
9
  /** One dragged item: each drag type it offers, with its value (`{ "application/x-clip": "clip-9", "text/plain": "run.mp4" }`). React Aria's `DragItem`. */
3
10
  export type DragData = Record<string, string>;
4
11
  /** Props for `DragSource`. */
@@ -12,14 +12,20 @@ export declare function FileButton({ accept, multiple, onFiles, icon: Icon, chil
12
12
  icon?: IconComponent;
13
13
  children: string;
14
14
  }): React.JSX.Element;
15
+ /** Whether a drag is the app's own, not files: it carries one of `refuse`, and the browser has not left its types unknown. */
16
+ export declare function refusesDrag(types: {
17
+ has: (type: string) => boolean;
18
+ }, refuse: readonly string[]): boolean;
15
19
  /** A region that takes dropped files and offers the picker as its keyboard alternative. */
16
- export declare function FileDropZone({ onFiles, acceptLabel, title, disabled, children, className, }: {
20
+ export declare function FileDropZone({ onFiles, acceptLabel, title, disabled, refuseTypes, children, className, }: {
17
21
  onFiles: (files: File[]) => void;
18
22
  /** What it takes, in words ("a video, an audio file or a GPX track"). Shown while a drag is over it. */
19
23
  acceptLabel: string;
20
24
  /** The resting prompt ("Drag files here"). */
21
25
  title: string;
22
26
  disabled?: boolean;
27
+ /** Drag types of the app's own drags to ignore, besides every `DragSource`'s (which are always ignored): the zone does not light up for them and a keyboard drag does not stop on it. A dragged file never carries these, so a file is never refused. */
28
+ refuseTypes?: readonly string[];
23
29
  /** The `FileButton` (required in practice: it is how a keyboard or phone gets files in). */
24
30
  children?: React.ReactNode;
25
31
  className?: string;
package/dist/index.d.ts CHANGED
@@ -49,7 +49,7 @@ export { Transport, TimeReadout, SeekBar, SpanStrip, VolumeControl, RateChoice,
49
49
  export { Timeline, TimelineZoomControls, useTimelineZoom, noOverlap, type TimelineProps, type TimelineItem, type TimelineLane, type TimelineMarker, type TimelineChange, type TimelineDrop } from './components/timeline';
50
50
  export { tickStep, ticksBetween, tickLabel } from './lib/timeline';
51
51
  export { SortableList, type SortableListProps, type DropTarget } from './components/sortable-list';
52
- export { DragSource, type DragSourceProps, type DragData } from './components/drag-source';
52
+ export { DragSource, STRATA_DRAG_TYPE, type DragSourceProps, type DragData } from './components/drag-source';
53
53
  export { FileButton, FileDropZone, FileOutcomes, MissingFile } from './components/file-intake';
54
54
  export { useFileIntake, matchesAccept, type FileIntake, type FileIntakeOptions, type FileOutcome } from './lib/file-intake';
55
55
  export { Inspector, InspectorSection, PropertyRow, PropertyList, type InspectorProps, type InspectorSectionProps, type PropertyRowProps, type Property, type PropertyListProps } from './components/inspector';
package/dist/index.js CHANGED
@@ -6796,10 +6796,20 @@ function SortableList({ label, items, getKey, getLabel, children, renderActions,
6796
6796
  });
6797
6797
  }
6798
6798
  // src/components/drag-source.tsx
6799
+ /**
6800
+ * The type every `DragSource` drag carries beside the app's own, so a drop target that takes only files (`FileDropZone`) can tell
6801
+ * an in-app drag from a drag of files without the app declaring anything (issue #291). A drag started by `useDrag` carries only
6802
+ * the types it is given, and React Aria's `DragTypes` cannot tell an app's `text/plain` from a dragged `.txt` file, so a type of
6803
+ * our own is the one that can be recognised for certain.
6804
+ */
6805
+ var STRATA_DRAG_TYPE = "application/x-strata-drag";
6799
6806
  /** A row that can be dragged onto a drop target, such as a `Timeline` lane, by pointer or from the keyboard with its named grip. */
6800
6807
  function DragSource({ label, items, onDragStart, onDragEnd, disabled, children, className }) {
6801
6808
  const { dragProps, dragButtonProps, isDragging } = useDrag({
6802
- getItems: items,
6809
+ getItems: () => items().map((item) => ({
6810
+ ...item,
6811
+ [STRATA_DRAG_TYPE]: ""
6812
+ })),
6803
6813
  hasDragButton: true,
6804
6814
  isDisabled: disabled,
6805
6815
  onDragStart: () => onDragStart?.(),
@@ -6840,8 +6850,13 @@ function FileButton({ accept, multiple = false, onFiles, icon: Icon, children, .
6840
6850
  })
6841
6851
  });
6842
6852
  }
6853
+ var NEVER_CARRIED = "application/x-strata-never";
6854
+ /** Whether a drag is the app's own, not files: it carries one of `refuse`, and the browser has not left its types unknown. */
6855
+ function refusesDrag(types, refuse) {
6856
+ return !types.has(NEVER_CARRIED) && refuse.some((type) => types.has(type));
6857
+ }
6843
6858
  /** A region that takes dropped files and offers the picker as its keyboard alternative. */
6844
- function FileDropZone({ onFiles, acceptLabel, title, disabled, children, className }) {
6859
+ function FileDropZone({ onFiles, acceptLabel, title, disabled, refuseTypes, children, className }) {
6845
6860
  const onDrop = async (e) => {
6846
6861
  const items = e.items.filter((i) => i.kind === "file");
6847
6862
  const files = await Promise.all(items.map((i) => i.getFile()));
@@ -6850,6 +6865,7 @@ function FileDropZone({ onFiles, acceptLabel, title, disabled, children, classNa
6850
6865
  return /* @__PURE__ */ jsx(DropZone, {
6851
6866
  "aria-label": title,
6852
6867
  isDisabled: disabled,
6868
+ getDropOperation: (types) => refusesDrag(types, ["application/x-strata-drag", ...refuseTypes ?? []]) ? "cancel" : "copy",
6853
6869
  onDrop,
6854
6870
  className: ({ isDropTarget, isFocusVisible }) => cn("grid min-w-0 justify-items-center gap-2 rounded-surface border border-dashed border-input px-4 py-6 text-center", isDropTarget && "border-solid border-primary bg-muted", isFocusVisible && "outline-2 outline-offset-2 outline-ring", className),
6855
6871
  children: ({ isDropTarget }) => /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -16767,6 +16783,6 @@ function FolderPicker({ label, useFolders: useListing, value, onChange, onChoose
16767
16783
  ]
16768
16784
  });
16769
16785
  }
16770
- export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, ContextMenu, Conversation, CursorScope, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, DragSource, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FolderPicker, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, PairJudge, PairVote, Pane, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, SaveStatus, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, SideNav, Skeleton, Slider, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, Workspace, actualPixelsScale, ancestorsOf, apiPage, boxViewport, buttonVariants, canFullscreen, clampToRoom, clampViewport, cn, colorSchemeScript, commandShortcut, countMarks, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, describeRegion, detectPlatform, diffWords, differences, drawRect, ease, errorPayload, fetchJson, fieldErrorsOf, findPage, fitRect, format, formatChord, gainToVolume, geo, gridPoints, gutterOf, isDoubtful, isReservedChord, isTaskRunning, isTypingTarget, jobProgressText, joinMediaGroup, joinRects, labelOf, lerpRect, logScale, loudnessOf, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveGutter, moveRect, noOverlap, normaliseAngle, pageName, parentOf, parseChord, parseInline, parseRichText, parseSort, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, resample, resamplePeaks, resizeRect, safeHref, sayPosition, serialiseSort, settleCut, snapToGrid, sortRows, splitRect, staleOf, stepId, stepOnGrid, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, usePlayerWarnings, useSelection, useSharedCursor, useSystemColorScheme, useTimelineZoom, useUndoable, useViewOptions, useViewport, useWorkspaceState, valueAt, viewOf, viewsOf, wordAt, wordId, zoomAt, zoomToBox };
16786
+ export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, ContextMenu, Conversation, CursorScope, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, DragSource, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FolderPicker, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, PairJudge, PairVote, Pane, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, SideNav, Skeleton, Slider, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, Workspace, actualPixelsScale, ancestorsOf, apiPage, boxViewport, buttonVariants, canFullscreen, clampToRoom, clampViewport, cn, colorSchemeScript, commandShortcut, countMarks, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, describeRegion, detectPlatform, diffWords, differences, drawRect, ease, errorPayload, fetchJson, fieldErrorsOf, findPage, fitRect, format, formatChord, gainToVolume, geo, gridPoints, gutterOf, isDoubtful, isReservedChord, isTaskRunning, isTypingTarget, jobProgressText, joinMediaGroup, joinRects, labelOf, lerpRect, logScale, loudnessOf, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveGutter, moveRect, noOverlap, normaliseAngle, pageName, parentOf, parseChord, parseInline, parseRichText, parseSort, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, resample, resamplePeaks, resizeRect, safeHref, sayPosition, serialiseSort, settleCut, snapToGrid, sortRows, splitRect, staleOf, stepId, stepOnGrid, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, usePlayerWarnings, useSelection, useSharedCursor, useSystemColorScheme, useTimelineZoom, useUndoable, useViewOptions, useViewport, useWorkspaceState, valueAt, viewOf, viewsOf, wordAt, wordId, zoomAt, zoomToBox };
16771
16787
 
16772
16788
  //# sourceMappingURL=index.js.map