strata-react 1.0.21 → 1.0.26

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.js CHANGED
@@ -1,10 +1,9 @@
1
1
  import { _ as cn, a as useColorScheme, c as ChoiceGroup, d as NativeSelect, f as Textarea, g as KeyText, h as Tooltip, i as colorSchemeScript, l as Field, m as controlHeight, n as ColorSchemeChoice, o as useSystemColorScheme, p as useFieldControl, r as ThemeProvider, s as Density, t as COLOR_SCHEME_STORAGE_KEY, u as Input, v as typeSteps } from "./theme-BgTOESmN.js";
2
2
  import { a as format, i as createFormat, n as MISSING, o as toDate, r as NBSP, t as geo } from "./geo-C0jcFp4q.js";
3
- import { a as toLoad, c as describeActionError, d as readErrorBody, i as staleOf, l as describeHttpError, n as createQueryClient, o as useLoad, r as fetchJson, s as HttpError, t as StrataQueryProvider, u as fieldErrorsOf } from "./query-CP78goXj.js";
3
+ import { _ as IconButton, a as toLoad, c as toast, d as describeActionError, f as describeHttpError, g as Button, h as overlaySurface, i as staleOf, l as toastTimeout, m as readErrorBody, n as createQueryClient, o as useLoad, p as fieldErrorsOf, r as fetchJson, s as StrataToastRegion, t as StrataQueryProvider, u as HttpError, v as RowAction, y as buttonVariants } from "./query-DgJMyXTT.js";
4
4
  import * as React from "react";
5
- import { Autocomplete, Button as Button$1, Cell, Checkbox as Checkbox$1, Collection, Column, Dialog as Dialog$1, DialogTrigger, Disclosure as Disclosure$1, DisclosurePanel, DropIndicator, DropZone, FileTrigger, GridLayout, GridList, GridListItem, Header, Heading, I18nProvider, Input as Input$1, Keyboard, ListLayout, ListStateContext, Menu as Menu$1, MenuItem, MenuSection, MenuTrigger, Modal, ModalOverlay, NumberField as NumberField$1, Popover as Popover$1, Row, SearchField, Separator, Slider as Slider$1, SliderOutput, SliderThumb, SliderTrack, SubmenuTrigger, Switch as Switch$1, Tab, TabList, TabPanel, Table, TableBody, TableHeader, TableLayout, Tabs as Tabs$1, Text, ToggleButton, ToggleButtonGroup, Toolbar as Toolbar$1, UNSTABLE_Toast, UNSTABLE_ToastContent, UNSTABLE_ToastQueue, UNSTABLE_ToastRegion, Virtualizer, useDragAndDrop, useFilter } from "react-aria-components";
6
- import { cva } from "class-variance-authority";
7
- import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronRight, CircleAlert, CircleCheck, FileQuestion, GripVertical, History, ImageOff, Info, Loader, LoaderCircle, Maximize, Maximize2, Minimize, Minus, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, Play, Redo2, RotateCcw, Scan, Search, SkipBack, SkipForward, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
5
+ import { Autocomplete, Button as Button$1, Cell, Checkbox as Checkbox$1, Collection, Column, Dialog as Dialog$1, DialogTrigger, Disclosure as Disclosure$1, DisclosurePanel, DropIndicator, DropZone, FileTrigger, GridLayout, GridList, GridListItem, Header, Heading, I18nProvider, Input as Input$1, Keyboard, ListLayout, ListStateContext, Menu as Menu$1, MenuItem, MenuSection, MenuTrigger, Modal, ModalOverlay, NumberField as NumberField$1, Popover as Popover$1, Row, SearchField, Separator, Slider as Slider$1, SliderOutput, SliderThumb, SliderTrack, SubmenuTrigger, Switch as Switch$1, Tab, TabList, TabPanel, Table, TableBody, TableHeader, TableLayout, Tabs as Tabs$1, Text, ToggleButton, ToggleButtonGroup, Toolbar as Toolbar$1, Virtualizer, useDragAndDrop, useFilter } from "react-aria-components";
6
+ import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronRight, CircleAlert, CircleCheck, FileQuestion, Flag, GripVertical, History, ImageOff, Info, Loader, LoaderCircle, Maximize, Maximize2, Minimize, Minus, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, Play, Redo2, RotateCcw, Scan, Search, SkipBack, SkipForward, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
8
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
8
  import { Link, NavLink, useSearchParams } from "react-router";
10
9
  import { createSortedRowModel, flexRender, rowSortingFeature, tableFeatures, useTable } from "@tanstack/react-table";
@@ -51,78 +50,6 @@ function useInView({ active = true, rootMargin = "0px", once = false, unsupporte
51
50
  inView
52
51
  };
53
52
  }
54
- // src/components/button.tsx
55
- var buttonVariants = cva("inline-flex max-w-full shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-control type-label transition-state press disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", {
56
- variants: {
57
- variant: {
58
- default: "bg-primary text-primary-foreground hover:bg-primary-10",
59
- outline: "border border-input bg-background text-foreground hover:bg-muted",
60
- secondary: "bg-muted text-foreground hover:bg-neutral-4",
61
- ghost: "text-foreground hover:bg-muted",
62
- destructive: "bg-destructive text-destructive-foreground hover:bg-danger",
63
- link: "h-auto px-0 text-primary-11 underline underline-offset-4 hover:text-primary-12"
64
- },
65
- size: {
66
- default: "h-(--control-h) px-4",
67
- sm: "h-(--control-h-sm) px-3",
68
- icon: "size-(--control-h)",
69
- "icon-sm": "size-(--control-h-sm)"
70
- }
71
- },
72
- defaultVariants: {
73
- variant: "outline",
74
- size: "default"
75
- }
76
- });
77
- /**
78
- * A button with shadcn's variant names, built on React Aria's `Button` (press handling that behaves
79
- * the same for mouse, touch, pen and keyboard, focus-visible and hover state). The default variant is
80
- * `outline`; ask for the filled accent (`variant="default"`) once per view. `type` defaults to `button`.
81
- * `onClick` and `disabled` are the DOM names and keep working; `onPress` is also accepted.
82
- */
83
- function Button({ className, variant, size, type = "button", disabled, children, ...props }) {
84
- return /* @__PURE__ */ jsx(Button$1, {
85
- type,
86
- isDisabled: disabled,
87
- "data-variant": variant ?? "outline",
88
- className: cn(buttonVariants({
89
- variant,
90
- size
91
- }), className),
92
- ...props,
93
- children: typeof children === "string" ? /* @__PURE__ */ jsx("span", {
94
- className: "min-w-0 truncate",
95
- children
96
- }) : children
97
- });
98
- }
99
- /** An icon-only button. `label` is required and becomes the accessible name and the tooltip (hover and keyboard focus); `hint` adds a muted aside to it, such as a shortcut. */
100
- function IconButton({ icon: Icon, label, hint, variant = "ghost", size = "default", ...props }) {
101
- return /* @__PURE__ */ jsx(Tooltip, {
102
- label,
103
- hint,
104
- children: /* @__PURE__ */ jsx(Button, {
105
- size: size === "sm" ? "icon-sm" : "icon",
106
- variant,
107
- "aria-label": label,
108
- ...props,
109
- children: /* @__PURE__ */ jsx(Icon, { "aria-hidden": true })
110
- })
111
- });
112
- }
113
- /** A small ghost action for one table row: shows `label`, and is named "`label` `subject`" so every row's action has its own name. */
114
- function RowAction({ label, subject, icon: Icon, variant = "ghost", size = "sm", className, ...props }) {
115
- return /* @__PURE__ */ jsxs(Button, {
116
- variant,
117
- size,
118
- "aria-label": `${label} ${subject}`,
119
- className: cn("-my-1.5", className),
120
- ...props,
121
- children: [Icon && /* @__PURE__ */ jsx(Icon, { "aria-hidden": true }), label]
122
- });
123
- }
124
- // src/lib/overlay.ts
125
- var overlaySurface = "rounded-overlay border border-border bg-popover text-popover-foreground shadow-overlay enter-overlay";
126
53
  // src/lib/chords.ts
127
54
  /** The platform this page runs on, read from the browser (`mac` for macOS and iOS). Server and test default: `other`. */
128
55
  function detectPlatform() {
@@ -718,11 +645,14 @@ function ToggleGroup({ label, options, value, onChange, size = "default", classN
718
645
  // src/components/switch.tsx
719
646
  /** An on/off setting that applies at once, its label and control one target. */
720
647
  function Switch({ label, detail, on, defaultOn, onChange, disabled, className }) {
648
+ const id = React.useId();
721
649
  return /* @__PURE__ */ jsxs(Switch$1, {
722
650
  isSelected: on,
723
651
  defaultSelected: defaultOn,
724
652
  onChange,
725
653
  isDisabled: disabled,
654
+ "aria-labelledby": `${id}-label`,
655
+ "aria-describedby": detail ? `${id}-detail` : void 0,
726
656
  className: cn("group inline-flex min-h-6 cursor-pointer items-start gap-3 disabled:cursor-not-allowed disabled:opacity-50", className),
727
657
  children: [/* @__PURE__ */ jsx("span", {
728
658
  "aria-hidden": true,
@@ -734,9 +664,11 @@ function Switch({ label, detail, on, defaultOn, onChange, disabled, className })
734
664
  }), /* @__PURE__ */ jsxs("span", {
735
665
  className: "grid",
736
666
  children: [/* @__PURE__ */ jsx("span", {
667
+ id: `${id}-label`,
737
668
  className: "type-body",
738
669
  children: label
739
670
  }), detail && /* @__PURE__ */ jsx("span", {
671
+ id: `${id}-detail`,
740
672
  className: "type-body-sm text-muted-foreground",
741
673
  children: detail
742
674
  })]
@@ -943,6 +875,7 @@ function Popover({ label, trigger, children, side = "bottom", align = "start", o
943
875
  /** A checkbox and its label as one target. `label` is required; `hideLabel` keeps it as the accessible name only. */
944
876
  function Checkbox({ label, hideLabel = false, detail, checked, onCheckedChange, className, disabled, required, ...props }) {
945
877
  const shift = useShiftNote();
878
+ const id = React.useId();
946
879
  return /* @__PURE__ */ jsx("span", {
947
880
  className: "contents",
948
881
  onMouseDownCapture: shift.handlers.onMouseDown,
@@ -954,6 +887,8 @@ function Checkbox({ label, hideLabel = false, detail, checked, onCheckedChange,
954
887
  isRequired: required,
955
888
  onChange: (selected) => onCheckedChange(selected, shift.take()),
956
889
  "aria-label": hideLabel ? label : void 0,
890
+ "aria-labelledby": hideLabel ? void 0 : `${id}-label`,
891
+ "aria-describedby": !hideLabel && detail ? `${id}-detail` : void 0,
957
892
  ...props,
958
893
  className: cn("group inline-flex min-h-6 min-w-6 items-start gap-3", hideLabel && "items-center justify-center", disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer", className),
959
894
  children: ({ isSelected, isIndeterminate }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(CheckboxBox, {
@@ -963,9 +898,11 @@ function Checkbox({ label, hideLabel = false, detail, checked, onCheckedChange,
963
898
  }), !hideLabel && /* @__PURE__ */ jsxs("span", {
964
899
  className: "grid",
965
900
  children: [/* @__PURE__ */ jsx("span", {
901
+ id: `${id}-label`,
966
902
  className: "type-body",
967
903
  children: label
968
904
  }), detail && /* @__PURE__ */ jsx("span", {
905
+ id: `${id}-detail`,
969
906
  className: "type-body-sm text-muted-foreground",
970
907
  children: detail
971
908
  })]
@@ -1920,91 +1857,6 @@ function Alert({ tone, title, children, action, announce = false, className }) {
1920
1857
  ]
1921
1858
  });
1922
1859
  }
1923
- // src/components/toast.tsx
1924
- var queue = new UNSTABLE_ToastQueue({ maxVisibleToasts: 3 });
1925
- /** Milliseconds a toast stays: 5 s plus 40 ms a character, to at most 15 s, and at least 8 s with an action. */
1926
- function toastTimeout(content) {
1927
- if (content.timeout !== void 0) return content.timeout;
1928
- const chars = content.title.length + (content.description?.length ?? 0) + (content.action?.label.length ?? 0);
1929
- return Math.max(content.action ? 8e3 : 0, Math.min(15e3, 5e3 + 40 * chars));
1930
- }
1931
- /** The toast queue: `toast.show({ title })` from anywhere; `toast.close(key)`; `toast.clear()`. */
1932
- var toast = {
1933
- /** Shows a toast and returns its key. */
1934
- show(content) {
1935
- return queue.add(content, { timeout: toastTimeout(content) });
1936
- },
1937
- close(key) {
1938
- queue.close(key);
1939
- },
1940
- clear() {
1941
- queue.clear();
1942
- }
1943
- };
1944
- var marks = {
1945
- info: {
1946
- icon: Info,
1947
- color: "text-info"
1948
- },
1949
- success: {
1950
- icon: CircleCheck,
1951
- color: "text-success"
1952
- },
1953
- warning: {
1954
- icon: TriangleAlert,
1955
- color: "text-warning"
1956
- }
1957
- };
1958
- /** The one place toasts appear. Render it once at the app root. A labelled landmark (F6), polite, above panes and the undo bar. */
1959
- function StrataToastRegion({ label = "Notifications", className }) {
1960
- return /* @__PURE__ */ jsx(UNSTABLE_ToastRegion, {
1961
- queue,
1962
- "aria-label": label,
1963
- className: cn("layer-bar fixed inset-x-4 top-4 grid justify-items-end gap-2 outline-none sm:inset-x-auto sm:top-auto sm:right-4 sm:bottom-4", className),
1964
- children: ({ toast: t }) => /* @__PURE__ */ jsxs(UNSTABLE_Toast, {
1965
- toast: t,
1966
- className: cn("flex w-full max-w-sm items-start gap-3 p-3 outline-none focus-visible:outline-2 focus-visible:outline-ring", overlaySurface),
1967
- children: [
1968
- (() => {
1969
- const { icon: Icon, color } = marks[t.content.tone ?? "info"];
1970
- return /* @__PURE__ */ jsx(Icon, {
1971
- "aria-hidden": true,
1972
- className: cn("mt-0.5 size-4 shrink-0", color)
1973
- });
1974
- })(),
1975
- /* @__PURE__ */ jsxs(UNSTABLE_ToastContent, {
1976
- className: "grid min-w-0 flex-1 gap-0.5",
1977
- children: [/* @__PURE__ */ jsx(Text, {
1978
- slot: "title",
1979
- className: "type-label",
1980
- children: t.content.title
1981
- }), t.content.description && /* @__PURE__ */ jsx(Text, {
1982
- slot: "description",
1983
- className: "type-body-sm text-muted-foreground",
1984
- children: t.content.description
1985
- })]
1986
- }),
1987
- t.content.action && /* @__PURE__ */ jsx(Button, {
1988
- size: "sm",
1989
- onPress: () => {
1990
- t.content.action?.onPress();
1991
- queue.close(t.key);
1992
- },
1993
- children: t.content.action.label
1994
- }),
1995
- /* @__PURE__ */ jsx(Button$1, {
1996
- slot: "close",
1997
- "aria-label": "Dismiss",
1998
- className: "grid size-6 shrink-0 cursor-pointer place-items-center rounded-control text-muted-foreground transition-state hover:bg-muted hover:text-foreground",
1999
- children: /* @__PURE__ */ jsx(X, {
2000
- "aria-hidden": true,
2001
- className: "size-4"
2002
- })
2003
- })
2004
- ]
2005
- })
2006
- });
2007
- }
2008
1860
  // src/lib/client-work.ts
2009
1861
  /** Runs browser-side work with progress, cancel and a clear end state, ready for `JobStatus`. */
2010
1862
  function useClientWork(run) {
@@ -3351,6 +3203,48 @@ function useMediaElement(ref) {
3351
3203
  read
3352
3204
  ]);
3353
3205
  }
3206
+ var keyPlayers = (() => {
3207
+ const ids = /* @__PURE__ */ new Set();
3208
+ let active = null;
3209
+ let warned = false;
3210
+ const listeners = /* @__PURE__ */ new Set();
3211
+ let snapshot = {
3212
+ count: 0,
3213
+ active: null
3214
+ };
3215
+ const emit = () => {
3216
+ snapshot = {
3217
+ count: ids.size,
3218
+ active
3219
+ };
3220
+ listeners.forEach((l) => l());
3221
+ };
3222
+ return {
3223
+ subscribe: (l) => {
3224
+ listeners.add(l);
3225
+ return () => void listeners.delete(l);
3226
+ },
3227
+ get: () => snapshot,
3228
+ add(id) {
3229
+ ids.add(id);
3230
+ if (ids.size === 2 && !warned && typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
3231
+ warned = true;
3232
+ console.warn("strata-react: several MediaPlayers are on this page, so Space, K, J, L and M go to the one last played or focused. Pass shortcuts={false} to one you bind your own keys for.");
3233
+ }
3234
+ emit();
3235
+ },
3236
+ remove(id) {
3237
+ ids.delete(id);
3238
+ if (active === id) active = null;
3239
+ emit();
3240
+ },
3241
+ use(id) {
3242
+ if (active === id || !ids.has(id)) return;
3243
+ active = id;
3244
+ emit();
3245
+ }
3246
+ };
3247
+ })();
3354
3248
  /** Playback speeds an audiobook or lecture listener expects. */
3355
3249
  var SPEECH_RATES = [
3356
3250
  .75,
@@ -3473,7 +3367,7 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3473
3367
  React.useEffect(() => {
3474
3368
  if (onTimeChange) onTimeChange(time);
3475
3369
  }, [time]);
3476
- useHotkeys(React.useMemo(() => [
3370
+ const keys = React.useMemo(() => [
3477
3371
  {
3478
3372
  keys: [" ", "k"],
3479
3373
  label: "Play or pause",
@@ -3501,7 +3395,27 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3501
3395
  time,
3502
3396
  offsets,
3503
3397
  index
3504
- ]), { enabled: shortcuts && !native });
3398
+ ]);
3399
+ const id = React.useId();
3400
+ React.useEffect(() => {
3401
+ if (!shortcuts || native) return;
3402
+ keyPlayers.add(id);
3403
+ return () => keyPlayers.remove(id);
3404
+ }, [
3405
+ id,
3406
+ shortcuts,
3407
+ native
3408
+ ]);
3409
+ const page = React.useSyncExternalStore(keyPlayers.subscribe, keyPlayers.get, keyPlayers.get);
3410
+ React.useEffect(() => {
3411
+ if (media.playing && shortcuts && !native) keyPlayers.use(id);
3412
+ }, [
3413
+ media.playing,
3414
+ id,
3415
+ shortcuts,
3416
+ native
3417
+ ]);
3418
+ useHotkeys(keys, { enabled: shortcuts && !native && (page.count <= 1 || page.active === id) });
3505
3419
  React.useEffect(() => {
3506
3420
  if (!session || typeof navigator === "undefined" || !("mediaSession" in navigator) || typeof MediaMetadata === "undefined") return;
3507
3421
  const s = navigator.mediaSession;
@@ -3556,7 +3470,7 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3556
3470
  controls: native,
3557
3471
  autoPlay,
3558
3472
  preload: "metadata",
3559
- "aria-label": label
3473
+ "aria-label": `${label}, ${kind}`
3560
3474
  };
3561
3475
  const element = kind === "video" ? /* @__PURE__ */ jsx("video", {
3562
3476
  ...common,
@@ -3571,6 +3485,8 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3571
3485
  return /* @__PURE__ */ jsxs("div", {
3572
3486
  role: "group",
3573
3487
  "aria-label": label,
3488
+ onFocusCapture: () => keyPlayers.use(id),
3489
+ onPointerDownCapture: () => keyPlayers.use(id),
3574
3490
  className: cn("grid w-full gap-2", className),
3575
3491
  children: [
3576
3492
  element,
@@ -7050,7 +6966,7 @@ var ALL_MODES = [
7050
6966
  "difference"
7051
6967
  ];
7052
6968
  /** Two pictures to judge, side by side or laid over each other, zoomed and panned together, and full screen. */
7053
- function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_MODES, keys = true, cannotCompare = "Could not read these pictures to compare their pixels.", readPixels, defaultDifference = "brightness", className }) {
6969
+ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_MODES, keys = true, extraShortcuts = [], footer, cannotCompare = "Could not read these pictures to compare their pixels.", readPixels, defaultDifference = "brightness", className }) {
7054
6970
  const { viewport, setViewport } = useViewport();
7055
6971
  const [full, setFull] = React.useState(false);
7056
6972
  const pairKey = `${a.media.src}|${b.media.src}`;
@@ -7075,6 +6991,7 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
7075
6991
  const flip = () => setShowing((s) => s === "a" ? "b" : "a");
7076
6992
  const offered = modes.includes(mode) ? modes : [mode, ...modes];
7077
6993
  const shortcuts = [
6994
+ ...extraShortcuts,
7078
6995
  ...offered.map((m, i) => ({
7079
6996
  keys: [String(i + 1)],
7080
6997
  label: MODE_LABEL[m],
@@ -7082,7 +6999,7 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
7082
6999
  })),
7083
7000
  {
7084
7001
  keys: ["x"],
7085
- label: "Flip A and B",
7002
+ label: `Flip ${a.label} and ${b.label}`,
7086
7003
  run: flip,
7087
7004
  disabled: mode !== "blink"
7088
7005
  },
@@ -7364,11 +7281,162 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
7364
7281
  size: "sm"
7365
7282
  }) }),
7366
7283
  body,
7284
+ footer,
7367
7285
  keys && /* @__PURE__ */ jsx(KeysLegend, { shortcuts })
7368
7286
  ]
7369
7287
  })
7370
7288
  });
7371
7289
  }
7290
+ // src/components/pair-vote.tsx
7291
+ /** A blind pairwise judgment: two pictures in `Compare`, answer keys in its legend, and a vote bar that never leans on either side. */
7292
+ function PairVote({ pair, skeleton, empty, onAnswer, pending, progress, flagReasons, preload, last, words = {}, ...compare }) {
7293
+ React.useEffect(() => {
7294
+ for (const src of preload ?? []) new Image().src = src;
7295
+ }, [preload]);
7296
+ const w = {
7297
+ tie: "About the same",
7298
+ skip: "Can't tell",
7299
+ pending: "Saving your answer…",
7300
+ flag: "Flag this pair",
7301
+ prefer: (l) => `Prefer ${l}`,
7302
+ ...words
7303
+ };
7304
+ return /* @__PURE__ */ jsxs("div", {
7305
+ className: "grid gap-3",
7306
+ children: [
7307
+ progress && /* @__PURE__ */ jsx("p", {
7308
+ className: "type-body-sm text-muted-foreground",
7309
+ children: progress
7310
+ }),
7311
+ /* @__PURE__ */ jsx(DataView, {
7312
+ state: pair,
7313
+ isEmpty: (p) => p === null,
7314
+ skeleton,
7315
+ empty,
7316
+ children: (p) => p && /* @__PURE__ */ jsx(Judged, {
7317
+ pair: p,
7318
+ onAnswer,
7319
+ pending,
7320
+ flagReasons,
7321
+ words: w,
7322
+ last,
7323
+ compare
7324
+ })
7325
+ }),
7326
+ last && !(pair.status === "ready" && pair.data) && /* @__PURE__ */ jsx(LastAnswer, { last })
7327
+ ]
7328
+ });
7329
+ }
7330
+ function LastAnswer({ last }) {
7331
+ return /* @__PURE__ */ jsxs("div", {
7332
+ role: "status",
7333
+ className: "flex flex-wrap items-center gap-3 type-body-sm text-muted-foreground",
7334
+ children: [
7335
+ /* @__PURE__ */ jsx("span", { children: last.text }),
7336
+ /* @__PURE__ */ jsx(Button, {
7337
+ size: "sm",
7338
+ variant: "ghost",
7339
+ onPress: last.onUndo,
7340
+ children: "Undo"
7341
+ }),
7342
+ last.reveal
7343
+ ]
7344
+ });
7345
+ }
7346
+ function Judged({ pair, onAnswer, pending, flagReasons, words, last, compare }) {
7347
+ const { a, b } = pair;
7348
+ const answer = (x) => !pending && onAnswer(x);
7349
+ const shortcuts = [
7350
+ {
7351
+ keys: ["a"],
7352
+ label: words.prefer(a.label),
7353
+ run: () => answer({ answer: "a" }),
7354
+ disabled: pending
7355
+ },
7356
+ {
7357
+ keys: ["b"],
7358
+ label: words.prefer(b.label),
7359
+ run: () => answer({ answer: "b" }),
7360
+ disabled: pending
7361
+ },
7362
+ {
7363
+ keys: ["t"],
7364
+ label: words.tie,
7365
+ run: () => answer({ answer: "tie" }),
7366
+ disabled: pending
7367
+ },
7368
+ {
7369
+ keys: ["s"],
7370
+ label: words.skip,
7371
+ run: () => answer({ answer: "skip" }),
7372
+ disabled: pending
7373
+ }
7374
+ ];
7375
+ const footer = /* @__PURE__ */ jsxs("div", {
7376
+ className: cn("grid gap-2"),
7377
+ "aria-busy": pending || void 0,
7378
+ children: [
7379
+ /* @__PURE__ */ jsxs("div", {
7380
+ role: "group",
7381
+ "aria-label": "Your answer",
7382
+ className: "flex flex-wrap items-center gap-2",
7383
+ children: [
7384
+ /* @__PURE__ */ jsx(Button, {
7385
+ disabled: pending,
7386
+ onPress: () => answer({ answer: "a" }),
7387
+ children: words.prefer(a.label)
7388
+ }),
7389
+ /* @__PURE__ */ jsx(Button, {
7390
+ disabled: pending,
7391
+ onPress: () => answer({ answer: "tie" }),
7392
+ children: words.tie
7393
+ }),
7394
+ /* @__PURE__ */ jsx(Button, {
7395
+ disabled: pending,
7396
+ onPress: () => answer({ answer: "b" }),
7397
+ children: words.prefer(b.label)
7398
+ }),
7399
+ /* @__PURE__ */ jsx(Button, {
7400
+ variant: "ghost",
7401
+ disabled: pending,
7402
+ onPress: () => answer({ answer: "skip" }),
7403
+ children: words.skip
7404
+ }),
7405
+ flagReasons && flagReasons.length > 0 && /* @__PURE__ */ jsx(Menu, {
7406
+ label: words.flag,
7407
+ trigger: /* @__PURE__ */ jsxs(Button, {
7408
+ variant: "ghost",
7409
+ disabled: pending,
7410
+ children: [/* @__PURE__ */ jsx(Flag, { "aria-hidden": true }), words.flag]
7411
+ }),
7412
+ items: flagReasons.map((reason) => ({
7413
+ id: reason,
7414
+ label: reason,
7415
+ run: () => answer({
7416
+ answer: "flag",
7417
+ reason
7418
+ })
7419
+ }))
7420
+ })
7421
+ ]
7422
+ }),
7423
+ pending && /* @__PURE__ */ jsx("p", {
7424
+ role: "status",
7425
+ className: "type-body-sm text-muted-foreground",
7426
+ children: words.pending
7427
+ }),
7428
+ last && /* @__PURE__ */ jsx(LastAnswer, { last })
7429
+ ]
7430
+ });
7431
+ return /* @__PURE__ */ jsx(Compare, {
7432
+ ...compare,
7433
+ label: pair.label,
7434
+ a,
7435
+ b,
7436
+ extraShortcuts: shortcuts,
7437
+ footer
7438
+ });
7439
+ }
7372
7440
  // src/components/compare-grid.tsx
7373
7441
  var COLUMNS = {
7374
7442
  2: "sm:grid-cols-2",
@@ -8101,6 +8169,6 @@ function SaveStatus({ state, onRetry, className }) {
8101
8169
  ]
8102
8170
  });
8103
8171
  }
8104
- export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareGrid, CompositionBar, ContextMenu, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, LineChart, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, Pane, Popover, PropertyList, PropertyRow, RateChoice, RowAction, SPEECH_RATES, SaveStatus, SeekBar, SelectableGrid, SideNav, Skeleton, Slider, SortableList, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, Transport, UndoBar, ViewportFrame, VirtualList, VolumeControl, Workspace, actualPixelsScale, buttonVariants, canFullscreen, clampViewport, cn, colorSchemeScript, commandShortcut, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, detectPlatform, differences, fetchJson, fieldErrorsOf, format, formatChord, geo, isReservedChord, isTypingTarget, labelOf, matchesAccept, matchesChord, noOverlap, parseChord, parseSort, readErrorBody, readPixels, resample, serialiseSort, staleOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toast, toastTimeout, transportShortcuts, typeSteps, useActiveItem, useAsyncAction, useAutoSave, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useLeaveGuard, useLoad, useMediaElement, useSelection, useSystemColorScheme, useTimelineZoom, useUndoable, useViewport, useWorkspaceState, zoomAt };
8172
+ export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareGrid, CompositionBar, ContextMenu, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, LineChart, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, PairVote, Pane, Popover, PropertyList, PropertyRow, RateChoice, RowAction, SPEECH_RATES, SaveStatus, SeekBar, SelectableGrid, SideNav, Skeleton, Slider, SortableList, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, Transport, UndoBar, ViewportFrame, VirtualList, VolumeControl, Workspace, actualPixelsScale, buttonVariants, canFullscreen, clampViewport, cn, colorSchemeScript, commandShortcut, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, detectPlatform, differences, fetchJson, fieldErrorsOf, format, formatChord, geo, isReservedChord, isTypingTarget, labelOf, matchesAccept, matchesChord, noOverlap, parseChord, parseSort, readErrorBody, readPixels, resample, serialiseSort, staleOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toast, toastTimeout, transportShortcuts, typeSteps, useActiveItem, useAsyncAction, useAutoSave, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useLeaveGuard, useLoad, useMediaElement, useSelection, useSystemColorScheme, useTimelineZoom, useUndoable, useViewport, useWorkspaceState, zoomAt };
8105
8173
 
8106
8174
  //# sourceMappingURL=index.js.map