@arbidocs/react 0.4.66 → 0.4.68

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.
Files changed (52) hide show
  1. package/dist/annotations/index.cjs +278 -138
  2. package/dist/annotations/index.cjs.map +1 -1
  3. package/dist/annotations/index.js +260 -120
  4. package/dist/annotations/index.js.map +1 -1
  5. package/dist/artifacts/index.cjs +17 -17
  6. package/dist/artifacts/index.js +3 -3
  7. package/dist/{chunk-DIZC2XVB.js → chunk-47CCGUWR.js} +13 -35
  8. package/dist/chunk-47CCGUWR.js.map +1 -0
  9. package/dist/{chunk-RM5DPY5G.cjs → chunk-BWVIAATD.cjs} +21 -22
  10. package/dist/chunk-BWVIAATD.cjs.map +1 -0
  11. package/dist/{chunk-NDABXDML.js → chunk-ECOSGMTW.js} +4 -3
  12. package/dist/chunk-ECOSGMTW.js.map +1 -0
  13. package/dist/{chunk-D3CSLSGD.cjs → chunk-F7KQVVD2.cjs} +10 -9
  14. package/dist/chunk-F7KQVVD2.cjs.map +1 -0
  15. package/dist/{chunk-LCMCZS5Y.cjs → chunk-HJDR5HEO.cjs} +15 -38
  16. package/dist/chunk-HJDR5HEO.cjs.map +1 -0
  17. package/dist/chunk-HUZB36QU.cjs +63 -0
  18. package/dist/chunk-HUZB36QU.cjs.map +1 -0
  19. package/dist/{chunk-GXQO3IJC.cjs → chunk-LQ5YHB7W.cjs} +4 -4
  20. package/dist/{chunk-GXQO3IJC.cjs.map → chunk-LQ5YHB7W.cjs.map} +1 -1
  21. package/dist/{chunk-OTNB2IZL.js → chunk-PFKLOVGQ.js} +4 -4
  22. package/dist/chunk-PFKLOVGQ.js.map +1 -0
  23. package/dist/{chunk-IS23MR2A.js → chunk-TQ6FRVAH.js} +4 -5
  24. package/dist/chunk-TQ6FRVAH.js.map +1 -0
  25. package/dist/chunk-W4H6XAIU.js +39 -0
  26. package/dist/chunk-W4H6XAIU.js.map +1 -0
  27. package/dist/{chunk-2VW47ADK.js → chunk-WS6DF5X4.js} +3 -3
  28. package/dist/{chunk-2VW47ADK.js.map → chunk-WS6DF5X4.js.map} +1 -1
  29. package/dist/{chunk-NCUBNIO4.cjs → chunk-Z3RRZ3KV.cjs} +4 -4
  30. package/dist/chunk-Z3RRZ3KV.cjs.map +1 -0
  31. package/dist/index.cjs +392 -392
  32. package/dist/index.d.cts +6 -2
  33. package/dist/index.d.ts +6 -2
  34. package/dist/index.js +15 -14
  35. package/dist/index.js.map +1 -1
  36. package/dist/shell/index.cjs +8 -8
  37. package/dist/shell/index.js +3 -3
  38. package/dist/ui/index.cjs +176 -176
  39. package/dist/ui/index.js +4 -4
  40. package/package.json +3 -3
  41. package/dist/chunk-4PRCRCQ5.cjs +0 -41
  42. package/dist/chunk-4PRCRCQ5.cjs.map +0 -1
  43. package/dist/chunk-D3CSLSGD.cjs.map +0 -1
  44. package/dist/chunk-DIZC2XVB.js.map +0 -1
  45. package/dist/chunk-IS23MR2A.js.map +0 -1
  46. package/dist/chunk-LCMCZS5Y.cjs.map +0 -1
  47. package/dist/chunk-NCUBNIO4.cjs.map +0 -1
  48. package/dist/chunk-NDABXDML.js.map +0 -1
  49. package/dist/chunk-OTNB2IZL.js.map +0 -1
  50. package/dist/chunk-QICALPFQ.js +0 -18
  51. package/dist/chunk-QICALPFQ.js.map +0 -1
  52. package/dist/chunk-RM5DPY5G.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
- import { Button, Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter } from '../chunk-2VW47ADK.js';
2
- import '../chunk-QICALPFQ.js';
1
+ import { Button, Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter } from '../chunk-WS6DF5X4.js';
2
+ import { usePortalContainer, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '../chunk-47CCGUWR.js';
3
3
  import { cn } from '../chunk-SN5YV6FF.js';
4
4
  import { parseAnnotation, parseLayer, emptyLayer, clampRect, isEffectiveRedaction } from '../chunk-COWZGCL5.js';
5
5
  export { AnnotationLayerError, LAYER_SCHEMA_VERSION, annotationRects, clampRect, emptyLayer, isEffectiveRedaction, parseAnnotation, parseLayer } from '../chunk-COWZGCL5.js';
@@ -664,6 +664,7 @@ function selectionToPageMarks(pages) {
664
664
  return out;
665
665
  }
666
666
  var PAGE_ATTRIBUTE = "data-annotation-page";
667
+ var ownerDocument = (node) => node.ownerDocument ?? document;
667
668
  var toPixelRect = (r) => ({
668
669
  x: r.left,
669
670
  y: r.top,
@@ -672,7 +673,7 @@ var toPixelRect = (r) => ({
672
673
  });
673
674
  function clipRange(range, container) {
674
675
  if (!range.intersectsNode(container)) return null;
675
- const bounds = document.createRange();
676
+ const bounds = ownerDocument(container).createRange();
676
677
  bounds.selectNodeContents(container);
677
678
  const clipped = range.cloneRange();
678
679
  if (clipped.compareBoundaryPoints(Range.START_TO_START, bounds) < 0) {
@@ -684,11 +685,12 @@ function clipRange(range, container) {
684
685
  return clipped;
685
686
  }
686
687
  function textClientRects(range, container) {
687
- const walker = document.createTreeWalker(container, NodeFilter.SHOW_TEXT);
688
+ const doc = ownerDocument(container);
689
+ const walker = doc.createTreeWalker(container, NodeFilter.SHOW_TEXT);
688
690
  const rects = [];
689
691
  for (let node = walker.nextNode(); node; node = walker.nextNode()) {
690
692
  if (!node.textContent?.trim() || !range.intersectsNode(node)) continue;
691
- const part = document.createRange();
693
+ const part = doc.createRange();
692
694
  part.selectNodeContents(node);
693
695
  if (node === range.startContainer) part.setStart(node, range.startOffset);
694
696
  if (node === range.endContainer) part.setEnd(node, range.endOffset);
@@ -696,6 +698,47 @@ function textClientRects(range, container) {
696
698
  }
697
699
  return rects;
698
700
  }
701
+ function firstTextAt(container, offset) {
702
+ if (container.nodeType === Node.TEXT_NODE) return { node: container, offset };
703
+ const child = container.childNodes[offset];
704
+ if (!child) return null;
705
+ if (child.nodeType === Node.TEXT_NODE) return { node: child, offset: 0 };
706
+ const first = ownerDocument(child).createTreeWalker(child, NodeFilter.SHOW_TEXT).nextNode();
707
+ return first ? { node: first, offset: 0 } : null;
708
+ }
709
+ function extendFocusToPointer(selection, point) {
710
+ if (selection.rangeCount === 0 || selection.isCollapsed) return;
711
+ const range = selection.getRangeAt(0);
712
+ if (selection.focusNode !== range.endContainer || selection.focusOffset !== range.endOffset)
713
+ return;
714
+ const start = firstTextAt(range.endContainer, range.endOffset);
715
+ if (!start) return;
716
+ const doc = ownerDocument(start.node);
717
+ const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_TEXT);
718
+ walker.currentNode = start.node;
719
+ const glyph = doc.createRange();
720
+ let end = null;
721
+ let node = start.node;
722
+ let offset = start.offset;
723
+ let passed = false;
724
+ while (node && !passed) {
725
+ const text = node.textContent ?? "";
726
+ for (let i = offset; i < text.length && !passed; i++) {
727
+ glyph.setStart(node, i);
728
+ glyph.setEnd(node, i + 1);
729
+ const r = glyph.getBoundingClientRect();
730
+ if (r.height === 0) continue;
731
+ const mid = r.top + r.height / 2;
732
+ if (mid > point.y + r.height / 2) passed = true;
733
+ else if (Math.abs(mid - point.y) > r.height / 2) continue;
734
+ else if (r.right > point.x + 0.5) passed = true;
735
+ else end = { node, offset: i + 1 };
736
+ }
737
+ node = walker.nextNode();
738
+ offset = 0;
739
+ }
740
+ if (end) selection.extend(end.node, end.offset);
741
+ }
699
742
  function readSelection(selection, root = document) {
700
743
  if (selection.rangeCount === 0 || selection.isCollapsed) return [];
701
744
  const range = selection.getRangeAt(0);
@@ -725,6 +768,7 @@ var MAX_SETTLE_ROUNDS = 12;
725
768
  function useTextSelectionMarks(controller) {
726
769
  const latest = useRef(controller);
727
770
  latest.current = controller;
771
+ const pagesDoc = usePortalContainer()?.ownerDocument ?? document;
728
772
  useEffect(() => {
729
773
  let startedOnPage = false;
730
774
  let touchSelecting = false;
@@ -732,9 +776,9 @@ function useTextSelectionMarks(controller) {
732
776
  const settleTimers = /* @__PURE__ */ new Set();
733
777
  const markSelection = () => {
734
778
  const c = latest.current;
735
- const selection = window.getSelection();
779
+ const selection = pagesDoc.getSelection();
736
780
  if (!selection || !TEXT_TOOLS.includes(c.tool)) return false;
737
- const pages = selectionToPageMarks(readSelection(selection));
781
+ const pages = selectionToPageMarks(readSelection(selection, pagesDoc));
738
782
  if (pages.length === 0) return false;
739
783
  const marks = pages.map(
740
784
  (p) => c.tool === "highlight" ? {
@@ -760,14 +804,18 @@ function useTextSelectionMarks(controller) {
760
804
  startedOnPage = e.target instanceof Element && e.target.closest(PAGE_SELECTOR) !== null;
761
805
  touchSelecting = startedOnPage && e.pointerType === "touch";
762
806
  };
763
- const onUp = () => {
807
+ const onUp = (e) => {
764
808
  if (!startedOnPage || !TEXT_TOOLS.includes(latest.current.tool)) return;
765
809
  startedOnPage = false;
766
- let last = window.getSelection()?.toString() ?? "";
810
+ const selection = pagesDoc.getSelection();
811
+ if (selection && e.pointerType === "mouse") {
812
+ extendFocusToPointer(selection, { x: e.clientX, y: e.clientY });
813
+ }
814
+ let last = selection?.toString() ?? "";
767
815
  let stable = 0;
768
816
  let rounds = 0;
769
817
  const check = () => {
770
- const now = window.getSelection()?.toString() ?? "";
818
+ const now = pagesDoc.getSelection()?.toString() ?? "";
771
819
  if (now === last) stable++;
772
820
  else {
773
821
  last = now;
@@ -788,17 +836,17 @@ function useTextSelectionMarks(controller) {
788
836
  if (markSelection()) touchSelecting = false;
789
837
  }, TOUCH_SETTLE_MS);
790
838
  };
791
- document.addEventListener("pointerdown", onDown, true);
792
- document.addEventListener("pointerup", onUp, true);
793
- document.addEventListener("selectionchange", onSelectionChange);
839
+ pagesDoc.addEventListener("pointerdown", onDown, true);
840
+ pagesDoc.addEventListener("pointerup", onUp, true);
841
+ pagesDoc.addEventListener("selectionchange", onSelectionChange);
794
842
  return () => {
795
843
  clearTimeout(settleTimer);
796
844
  settleTimers.forEach(clearTimeout);
797
- document.removeEventListener("pointerdown", onDown, true);
798
- document.removeEventListener("pointerup", onUp, true);
799
- document.removeEventListener("selectionchange", onSelectionChange);
845
+ pagesDoc.removeEventListener("pointerdown", onDown, true);
846
+ pagesDoc.removeEventListener("pointerup", onUp, true);
847
+ pagesDoc.removeEventListener("selectionchange", onSelectionChange);
800
848
  };
801
- }, []);
849
+ }, [pagesDoc]);
802
850
  }
803
851
 
804
852
  // src/annotations/overlay-geometry.ts
@@ -1092,11 +1140,13 @@ function AnnotationPageOverlay({
1092
1140
  {
1093
1141
  annotation: selected,
1094
1142
  controller,
1143
+ pageHeight: size.height,
1095
1144
  onClose: () => {
1096
1145
  setOpenComment(null);
1097
1146
  controller.select(null);
1098
1147
  }
1099
- }
1148
+ },
1149
+ selected.id
1100
1150
  )
1101
1151
  ]
1102
1152
  }
@@ -1202,6 +1252,7 @@ function MarkView(props) {
1202
1252
  {
1203
1253
  type: "button",
1204
1254
  ...base(`Comment: ${a.body || "empty"}`),
1255
+ onMouseDown: (e) => e.preventDefault(),
1205
1256
  className: cn(
1206
1257
  "absolute flex items-center justify-center rounded-md border border-amber-700/60 bg-amber-300 text-amber-900 shadow-sm",
1207
1258
  a.resolved && "opacity-50",
@@ -1239,10 +1290,11 @@ function RedactionView({
1239
1290
  const rects = rectOverride ? [rectOverride] : a.rects;
1240
1291
  const approved = a.status === "approved";
1241
1292
  const rejected = a.status === "rejected";
1293
+ const label = `Redaction (${a.status}): ${a.reason}`;
1242
1294
  return /* @__PURE__ */ jsx(Fragment, { children: rects.map((r, i) => /* @__PURE__ */ jsx(
1243
1295
  "div",
1244
1296
  {
1245
- ...i === 0 ? base(`Redaction (${a.status}): ${a.reason}`) : {},
1297
+ ...i === 0 ? { ...base(label), title: label } : {},
1246
1298
  "data-status": i === 0 ? a.status : void 0,
1247
1299
  className: cn(
1248
1300
  "absolute flex items-center justify-center overflow-hidden text-[10px] leading-none",
@@ -1336,6 +1388,15 @@ function ActionBar({
1336
1388
  },
1337
1389
  onPointerDown: (e) => e.stopPropagation(),
1338
1390
  children: [
1391
+ a.kind === "redaction" && /* @__PURE__ */ jsx(
1392
+ "span",
1393
+ {
1394
+ className: "max-w-44 truncate self-center px-1.5 text-xs text-muted-foreground",
1395
+ title: a.reason,
1396
+ "data-testid": "annotation-action-reason",
1397
+ children: a.reason
1398
+ }
1399
+ ),
1339
1400
  a.kind === "redaction" && a.status !== "approved" && /* @__PURE__ */ jsx(
1340
1401
  "button",
1341
1402
  {
@@ -1391,16 +1452,39 @@ function ActionBar({
1391
1452
  function CommentPopover({
1392
1453
  annotation: a,
1393
1454
  controller,
1455
+ pageHeight,
1394
1456
  onClose
1395
1457
  }) {
1396
1458
  const [body, setBody] = useState(a.body);
1397
1459
  const [reply, setReply] = useState("");
1460
+ const [lift, setLift] = useState(0);
1461
+ const popRef = useRef(null);
1462
+ const unsaved = useRef(null);
1398
1463
  const readOnly = controller.readOnly;
1399
1464
  const mine = a.author === controller.author && !readOnly;
1400
1465
  useEffect(() => setBody(a.body), [a.body]);
1466
+ useLayoutEffect(() => {
1467
+ const el = popRef.current;
1468
+ if (!el) return;
1469
+ const top2 = a.rect.y * pageHeight;
1470
+ const fit = () => setLift(Math.min(top2, Math.max(0, top2 + el.offsetHeight - pageHeight)));
1471
+ fit();
1472
+ const observer = new ResizeObserver(fit);
1473
+ observer.observe(el);
1474
+ return () => observer.disconnect();
1475
+ }, [a.rect.y, pageHeight]);
1401
1476
  const commitBody = () => {
1402
1477
  if (mine && body !== a.body) controller.update(a.id, { body });
1478
+ unsaved.current = null;
1403
1479
  };
1480
+ useEffect(
1481
+ () => () => {
1482
+ if (unsaved.current !== null) controller.update(a.id, { body: unsaved.current });
1483
+ unsaved.current = null;
1484
+ },
1485
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- runs once, when this comment's box unmounts
1486
+ [a.id]
1487
+ );
1404
1488
  const close = () => {
1405
1489
  commitBody();
1406
1490
  if (!readOnly && body.trim() === "" && a.replies.length === 0) controller.remove(a.id);
@@ -1417,10 +1501,12 @@ function CommentPopover({
1417
1501
  return /* @__PURE__ */ jsxs(
1418
1502
  "div",
1419
1503
  {
1504
+ ref: popRef,
1420
1505
  "data-testid": "annotation-comment-popover",
1421
1506
  className: "pointer-events-auto absolute z-30 w-64 rounded-lg border border-border bg-background p-3 text-sm shadow-lg",
1422
1507
  style: {
1423
1508
  top: pct(a.rect.y),
1509
+ marginTop: -lift,
1424
1510
  ...onRight ? { right: `calc(${pct(1 - a.rect.x)} + 8px)` } : { left: `calc(${pct(a.rect.x)} + ${COMMENT_ICON_PX + 8}px)` }
1425
1511
  },
1426
1512
  onPointerDown: (e) => e.stopPropagation(),
@@ -1448,11 +1534,14 @@ function CommentPopover({
1448
1534
  {
1449
1535
  autoFocus: a.body === "",
1450
1536
  "data-testid": "annotation-comment-body",
1451
- className: "min-h-16 w-full resize-y rounded-md border border-input bg-background p-2 text-sm",
1537
+ className: "field-sizing-content max-h-60 min-h-24 w-full resize-y rounded-md border border-input bg-background p-2 text-sm",
1452
1538
  placeholder: "Add a comment",
1453
1539
  value: body,
1454
1540
  readOnly: !mine,
1455
- onChange: (e) => setBody(e.target.value),
1541
+ onChange: (e) => {
1542
+ setBody(e.target.value);
1543
+ unsaved.current = e.target.value;
1544
+ },
1456
1545
  onBlur: commitBody,
1457
1546
  onKeyDown: (e) => {
1458
1547
  if (e.key === "Escape") close();
@@ -1590,6 +1679,44 @@ function Swatches({
1590
1679
  c
1591
1680
  )) });
1592
1681
  }
1682
+ function PresetField({
1683
+ label,
1684
+ testId,
1685
+ value,
1686
+ presets,
1687
+ maxLength,
1688
+ className,
1689
+ onChange
1690
+ }) {
1691
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
1692
+ /* @__PURE__ */ jsx(
1693
+ "input",
1694
+ {
1695
+ "aria-label": label,
1696
+ "data-testid": testId,
1697
+ className: cn("h-8 rounded-l-md border border-input bg-background px-2 text-sm", className),
1698
+ value,
1699
+ maxLength,
1700
+ onFocus: (e) => e.currentTarget.select(),
1701
+ onChange: (e) => onChange(e.target.value)
1702
+ }
1703
+ ),
1704
+ /* @__PURE__ */ jsxs(DropdownMenu, { children: [
1705
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
1706
+ "button",
1707
+ {
1708
+ type: "button",
1709
+ "aria-label": `Choose ${label.toLowerCase()}`,
1710
+ title: `Choose ${label.toLowerCase()}`,
1711
+ "data-testid": `${testId}-presets`,
1712
+ className: "flex h-8 items-center rounded-r-md border border-l-0 border-input bg-background px-1.5 text-muted-foreground hover:bg-accent",
1713
+ children: /* @__PURE__ */ jsx(ChevronDown, { size: 14 })
1714
+ }
1715
+ ) }),
1716
+ /* @__PURE__ */ jsx(DropdownMenuContent, { align: "end", children: presets.map((p) => /* @__PURE__ */ jsx(DropdownMenuItem, { onSelect: () => onChange(p), children: p }, p)) })
1717
+ ] })
1718
+ ] });
1719
+ }
1593
1720
  function AnnotationToolbar({
1594
1721
  controller,
1595
1722
  onFreeze,
@@ -1602,8 +1729,61 @@ function AnnotationToolbar({
1602
1729
  const pending = pendingRedactions(controller.layer);
1603
1730
  const redactionCount = controller.layer.annotations.filter((a) => a.kind === "redaction").length;
1604
1731
  const colored = tool === "highlight" || tool === "box" || tool === "stamp";
1732
+ const redacting = tool === "redact-text" || tool === "redact-area";
1605
1733
  const status = layerStatusText(controller);
1606
1734
  const editable = !controller.readOnly;
1735
+ const redactionControls = /* @__PURE__ */ jsxs(Fragment, { children: [
1736
+ editable && redacting && /* @__PURE__ */ jsx(
1737
+ PresetField,
1738
+ {
1739
+ label: "Redaction reason",
1740
+ testId: "annotation-redaction-reason",
1741
+ className: "w-44",
1742
+ value: settings.redactionReason,
1743
+ presets: REDACTION_REASONS,
1744
+ maxLength: 80,
1745
+ onChange: (redactionReason) => controller.setSettings({ redactionReason })
1746
+ }
1747
+ ),
1748
+ redactionCount > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm", "data-testid": "annotation-review", children: [
1749
+ /* @__PURE__ */ jsxs("span", { className: "rounded-md bg-muted px-2 py-1", "data-testid": "annotation-pending-count", children: [
1750
+ pending.length,
1751
+ " pending"
1752
+ ] }),
1753
+ editable && /* @__PURE__ */ jsxs(Fragment, { children: [
1754
+ /* @__PURE__ */ jsx(
1755
+ Button,
1756
+ {
1757
+ type: "button",
1758
+ size: "sm",
1759
+ variant: "outline",
1760
+ disabled: pending.length === 0,
1761
+ "data-testid": "annotation-approve-all",
1762
+ onClick: () => controller.setRedactionStatus(
1763
+ pending.map((a) => a.id),
1764
+ "approved"
1765
+ ),
1766
+ children: "Approve all"
1767
+ }
1768
+ ),
1769
+ /* @__PURE__ */ jsx(
1770
+ Button,
1771
+ {
1772
+ type: "button",
1773
+ size: "sm",
1774
+ variant: "outline",
1775
+ disabled: pending.length === 0,
1776
+ "data-testid": "annotation-reject-all",
1777
+ onClick: () => controller.setRedactionStatus(
1778
+ pending.map((a) => a.id),
1779
+ "rejected"
1780
+ ),
1781
+ children: "Reject all"
1782
+ }
1783
+ )
1784
+ ] })
1785
+ ] })
1786
+ ] });
1607
1787
  return /* @__PURE__ */ jsxs(
1608
1788
  "div",
1609
1789
  {
@@ -1615,6 +1795,44 @@ function AnnotationToolbar({
1615
1795
  className
1616
1796
  ),
1617
1797
  children: [
1798
+ editable && /* @__PURE__ */ jsxs(
1799
+ "div",
1800
+ {
1801
+ className: "flex items-center gap-1 border-r border-border pr-3",
1802
+ role: "group",
1803
+ "aria-label": "History",
1804
+ children: [
1805
+ /* @__PURE__ */ jsx(
1806
+ Button,
1807
+ {
1808
+ type: "button",
1809
+ size: "icon",
1810
+ variant: "ghost",
1811
+ title: "Undo",
1812
+ "aria-label": "Undo",
1813
+ "data-testid": "annotation-undo",
1814
+ disabled: !controller.canUndo,
1815
+ onClick: controller.undo,
1816
+ children: /* @__PURE__ */ jsx(Undo2, { size: 16 })
1817
+ }
1818
+ ),
1819
+ /* @__PURE__ */ jsx(
1820
+ Button,
1821
+ {
1822
+ type: "button",
1823
+ size: "icon",
1824
+ variant: "ghost",
1825
+ title: "Redo",
1826
+ "aria-label": "Redo",
1827
+ "data-testid": "annotation-redo",
1828
+ disabled: !controller.canRedo,
1829
+ onClick: controller.redo,
1830
+ children: /* @__PURE__ */ jsx(Redo2, { size: 16 })
1831
+ }
1832
+ )
1833
+ ]
1834
+ }
1835
+ ),
1618
1836
  editable && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1", role: "group", "aria-label": "Tool", children: TOOLS.map(({ tool: t, label, icon }) => /* @__PURE__ */ jsx(
1619
1837
  Button,
1620
1838
  {
@@ -1630,36 +1848,6 @@ function AnnotationToolbar({
1630
1848
  },
1631
1849
  t
1632
1850
  )) }),
1633
- editable && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", role: "group", "aria-label": "History", children: [
1634
- /* @__PURE__ */ jsx(
1635
- Button,
1636
- {
1637
- type: "button",
1638
- size: "icon",
1639
- variant: "ghost",
1640
- title: "Undo",
1641
- "aria-label": "Undo",
1642
- "data-testid": "annotation-undo",
1643
- disabled: !controller.canUndo,
1644
- onClick: controller.undo,
1645
- children: /* @__PURE__ */ jsx(Undo2, { size: 16 })
1646
- }
1647
- ),
1648
- /* @__PURE__ */ jsx(
1649
- Button,
1650
- {
1651
- type: "button",
1652
- size: "icon",
1653
- variant: "ghost",
1654
- title: "Redo",
1655
- "aria-label": "Redo",
1656
- "data-testid": "annotation-redo",
1657
- disabled: !controller.canRedo,
1658
- onClick: controller.redo,
1659
- children: /* @__PURE__ */ jsx(Redo2, { size: 16 })
1660
- }
1661
- )
1662
- ] }),
1663
1851
  editable && colored && /* @__PURE__ */ jsx(
1664
1852
  Swatches,
1665
1853
  {
@@ -1669,75 +1857,27 @@ function AnnotationToolbar({
1669
1857
  onChange: (c) => controller.setSettings({ colors: { ...settings.colors, [tool]: c } })
1670
1858
  }
1671
1859
  ),
1672
- editable && tool === "stamp" && /* @__PURE__ */ jsxs(Fragment, { children: [
1673
- /* @__PURE__ */ jsx(
1674
- "input",
1675
- {
1676
- list: "annotation-stamp-presets",
1677
- "aria-label": "Stamp text",
1678
- "data-testid": "annotation-stamp-label",
1679
- className: "h-8 w-40 rounded-md border border-input bg-background px-2 text-sm",
1680
- value: settings.stampLabel,
1681
- maxLength: 40,
1682
- onChange: (e) => controller.setSettings({ stampLabel: e.target.value })
1683
- }
1684
- ),
1685
- /* @__PURE__ */ jsx("datalist", { id: "annotation-stamp-presets", children: STAMP_PRESETS.map((s) => /* @__PURE__ */ jsx("option", { value: s }, s)) })
1686
- ] }),
1687
- editable && (tool === "redact-text" || tool === "redact-area") && /* @__PURE__ */ jsxs(Fragment, { children: [
1688
- /* @__PURE__ */ jsx(
1689
- "input",
1690
- {
1691
- list: "annotation-redaction-reasons",
1692
- "aria-label": "Redaction reason",
1693
- "data-testid": "annotation-redaction-reason",
1694
- className: "h-8 w-44 rounded-md border border-input bg-background px-2 text-sm",
1695
- value: settings.redactionReason,
1696
- maxLength: 80,
1697
- onChange: (e) => controller.setSettings({ redactionReason: e.target.value })
1698
- }
1699
- ),
1700
- /* @__PURE__ */ jsx("datalist", { id: "annotation-redaction-reasons", children: REDACTION_REASONS.map((r) => /* @__PURE__ */ jsx("option", { value: r }, r)) })
1701
- ] }),
1702
- redactionCount > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm", "data-testid": "annotation-review", children: [
1703
- /* @__PURE__ */ jsxs("span", { className: "rounded-md bg-muted px-2 py-1", "data-testid": "annotation-pending-count", children: [
1704
- pending.length,
1705
- " pending"
1706
- ] }),
1707
- editable && /* @__PURE__ */ jsxs(Fragment, { children: [
1708
- /* @__PURE__ */ jsx(
1709
- Button,
1710
- {
1711
- type: "button",
1712
- size: "sm",
1713
- variant: "outline",
1714
- disabled: pending.length === 0,
1715
- "data-testid": "annotation-approve-all",
1716
- onClick: () => controller.setRedactionStatus(
1717
- pending.map((a) => a.id),
1718
- "approved"
1719
- ),
1720
- children: "Approve all"
1721
- }
1722
- ),
1723
- /* @__PURE__ */ jsx(
1724
- Button,
1725
- {
1726
- type: "button",
1727
- size: "sm",
1728
- variant: "outline",
1729
- disabled: pending.length === 0,
1730
- "data-testid": "annotation-reject-all",
1731
- onClick: () => controller.setRedactionStatus(
1732
- pending.map((a) => a.id),
1733
- "rejected"
1734
- ),
1735
- children: "Reject all"
1736
- }
1737
- )
1738
- ] })
1739
- ] }),
1740
- /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-3 text-xs text-muted-foreground", children: [
1860
+ editable && tool === "stamp" && /* @__PURE__ */ jsx(
1861
+ PresetField,
1862
+ {
1863
+ label: "Stamp text",
1864
+ testId: "annotation-stamp-label",
1865
+ className: "w-40",
1866
+ value: settings.stampLabel,
1867
+ presets: STAMP_PRESETS,
1868
+ maxLength: 40,
1869
+ onChange: (stampLabel) => controller.setSettings({ stampLabel })
1870
+ }
1871
+ ),
1872
+ (redacting || redactionCount > 0) && /* @__PURE__ */ jsx(
1873
+ "div",
1874
+ {
1875
+ className: "flex w-full flex-wrap items-center gap-x-3 gap-y-2",
1876
+ "data-testid": "annotation-redaction-row",
1877
+ children: redactionControls
1878
+ }
1879
+ ),
1880
+ /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-end gap-3 text-xs text-muted-foreground", children: [
1741
1881
  /* @__PURE__ */ jsx(
1742
1882
  "span",
1743
1883
  {