strata-react 1.3.0 → 1.3.1

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,6 +183,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
183
183
  | 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`) |
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
+ | 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 |
186
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
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 |
188
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 |
@@ -0,0 +1,22 @@
1
+ import * as React from "react";
2
+ /** 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
+ export type DragData = Record<string, string>;
4
+ /** Props for `DragSource`. */
5
+ export type DragSourceProps = {
6
+ /** What is dragged, as a person would say it ("GX010412.MP4"). Names the grip "Drag GX010412.MP4". */
7
+ label: string;
8
+ /** The data the drop receives, one entry per item: each maps a type to its value. Called when the drag starts. */
9
+ items: () => DragData[];
10
+ /** The drag started (pointer or keyboard). */
11
+ onDragStart?: () => void;
12
+ /** The drag ended. `dropped` is false when it was cancelled or let go where nothing took it. */
13
+ onDragEnd?: (dropped: boolean) => void;
14
+ /** Nothing can be dragged; the grip is drawn disabled. */
15
+ disabled?: boolean;
16
+ /** The row's own content, beside the grip. Its buttons keep working. */
17
+ children: React.ReactNode;
18
+ /** Layout only. */
19
+ className?: string;
20
+ };
21
+ /** 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. */
22
+ export declare function DragSource({ label, items, onDragStart, onDragEnd, disabled, children, className }: DragSourceProps): React.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -49,6 +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
53
  export { FileButton, FileDropZone, FileOutcomes, MissingFile } from './components/file-intake';
53
54
  export { useFileIntake, matchesAccept, type FileIntake, type FileIntakeOptions, type FileOutcome } from './lib/file-intake';
54
55
  export { Inspector, InspectorSection, PropertyRow, PropertyList, type InspectorProps, type InspectorSectionProps, type PropertyRowProps, type Property, type PropertyListProps } from './components/inspector';
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronDown,
11
11
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
12
  import { Link, NavLink, useHref, useNavigate, useSearchParams } from "react-router";
13
13
  import { createSortedRowModel, flexRender, rowSortingFeature, tableFeatures, useTable } from "@tanstack/react-table";
14
- import { VisuallyHidden, mergeProps, useDrop, useFocusRing, useMove, useSlider, useSliderThumb } from "react-aria";
14
+ import { VisuallyHidden, mergeProps, useDrag, useDrop, useFocusRing, useMove, useSlider, useSliderThumb } from "react-aria";
15
15
  import { LayoutInfo, Rect, Size, useSliderState } from "react-stately";
16
16
  import { hashKey, useInfiniteQuery, useQuery, useQueryClient } from "@tanstack/react-query";
17
17
  import pixelmatch from "pixelmatch";
@@ -6795,6 +6795,35 @@ function SortableList({ label, items, getKey, getLabel, children, renderActions,
6795
6795
  })]
6796
6796
  });
6797
6797
  }
6798
+ // src/components/drag-source.tsx
6799
+ /** 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
+ function DragSource({ label, items, onDragStart, onDragEnd, disabled, children, className }) {
6801
+ const { dragProps, dragButtonProps, isDragging } = useDrag({
6802
+ getItems: items,
6803
+ hasDragButton: true,
6804
+ isDisabled: disabled,
6805
+ onDragStart: () => onDragStart?.(),
6806
+ onDragEnd: (e) => onDragEnd?.(e.dropOperation !== "cancel")
6807
+ });
6808
+ return /* @__PURE__ */ jsxs("div", {
6809
+ ...dragProps,
6810
+ "data-dragging": isDragging || void 0,
6811
+ className: cn("flex min-w-0 items-center gap-1 transition-state data-[dragging]:opacity-50", className),
6812
+ children: [/* @__PURE__ */ jsx(Button$1, {
6813
+ ...dragButtonProps,
6814
+ "aria-label": `Drag ${label}`,
6815
+ isDisabled: disabled,
6816
+ className: "grid size-(--control-h-sm) shrink-0 cursor-grab place-items-center rounded-control text-muted-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-ring",
6817
+ children: /* @__PURE__ */ jsx(GripVertical, {
6818
+ "aria-hidden": true,
6819
+ className: "size-4"
6820
+ })
6821
+ }), /* @__PURE__ */ jsx("div", {
6822
+ className: "min-w-0 flex-1",
6823
+ children
6824
+ })]
6825
+ });
6826
+ }
6798
6827
  // src/components/file-intake.tsx
6799
6828
  /** The picker as a button. `children` is its visible name ("Add files"); `accept` narrows what the dialog shows. */
6800
6829
  function FileButton({ accept, multiple = false, onFiles, icon: Icon, children, ...props }) {
@@ -16738,6 +16767,6 @@ function FolderPicker({ label, useFolders: useListing, value, onChange, onChoose
16738
16767
  ]
16739
16768
  });
16740
16769
  }
16741
- 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, 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 };
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 };
16742
16771
 
16743
16772
  //# sourceMappingURL=index.js.map