@arbidocs/react 0.4.65 → 0.4.67

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 (42) 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/{chunk-DIZC2XVB.js → chunk-47CCGUWR.js} +13 -35
  6. package/dist/chunk-47CCGUWR.js.map +1 -0
  7. package/dist/{chunk-6YKVIERB.cjs → chunk-BWVIAATD.cjs} +21 -22
  8. package/dist/chunk-BWVIAATD.cjs.map +1 -0
  9. package/dist/{chunk-NDABXDML.js → chunk-ECOSGMTW.js} +4 -3
  10. package/dist/chunk-ECOSGMTW.js.map +1 -0
  11. package/dist/{chunk-D3CSLSGD.cjs → chunk-F7KQVVD2.cjs} +10 -9
  12. package/dist/chunk-F7KQVVD2.cjs.map +1 -0
  13. package/dist/{chunk-LCMCZS5Y.cjs → chunk-HJDR5HEO.cjs} +15 -38
  14. package/dist/chunk-HJDR5HEO.cjs.map +1 -0
  15. package/dist/chunk-HUZB36QU.cjs +63 -0
  16. package/dist/chunk-HUZB36QU.cjs.map +1 -0
  17. package/dist/{chunk-GXQO3IJC.cjs → chunk-LQ5YHB7W.cjs} +4 -4
  18. package/dist/{chunk-GXQO3IJC.cjs.map → chunk-LQ5YHB7W.cjs.map} +1 -1
  19. package/dist/{chunk-F5WHYJRB.js → chunk-TQ6FRVAH.js} +4 -5
  20. package/dist/chunk-TQ6FRVAH.js.map +1 -0
  21. package/dist/chunk-W4H6XAIU.js +39 -0
  22. package/dist/chunk-W4H6XAIU.js.map +1 -0
  23. package/dist/{chunk-2VW47ADK.js → chunk-WS6DF5X4.js} +3 -3
  24. package/dist/{chunk-2VW47ADK.js.map → chunk-WS6DF5X4.js.map} +1 -1
  25. package/dist/index.cjs +262 -262
  26. package/dist/index.js +10 -9
  27. package/dist/index.js.map +1 -1
  28. package/dist/shell/index.cjs +8 -8
  29. package/dist/shell/index.js +3 -3
  30. package/dist/ui/index.cjs +152 -152
  31. package/dist/ui/index.js +4 -4
  32. package/package.json +3 -3
  33. package/dist/chunk-4PRCRCQ5.cjs +0 -41
  34. package/dist/chunk-4PRCRCQ5.cjs.map +0 -1
  35. package/dist/chunk-6YKVIERB.cjs.map +0 -1
  36. package/dist/chunk-D3CSLSGD.cjs.map +0 -1
  37. package/dist/chunk-DIZC2XVB.js.map +0 -1
  38. package/dist/chunk-F5WHYJRB.js.map +0 -1
  39. package/dist/chunk-LCMCZS5Y.cjs.map +0 -1
  40. package/dist/chunk-NDABXDML.js.map +0 -1
  41. package/dist/chunk-QICALPFQ.js +0 -18
  42. package/dist/chunk-QICALPFQ.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkGXQO3IJC_cjs = require('../chunk-GXQO3IJC.cjs');
4
- require('../chunk-4PRCRCQ5.cjs');
3
+ var chunkLQ5YHB7W_cjs = require('../chunk-LQ5YHB7W.cjs');
4
+ var chunkHJDR5HEO_cjs = require('../chunk-HJDR5HEO.cjs');
5
5
  var chunkS6A6FSG7_cjs = require('../chunk-S6A6FSG7.cjs');
6
6
  var chunkSSOPIPEX_cjs = require('../chunk-SSOPIPEX.cjs');
7
7
  var react = require('react');
@@ -665,6 +665,7 @@ function selectionToPageMarks(pages) {
665
665
  return out;
666
666
  }
667
667
  var PAGE_ATTRIBUTE = "data-annotation-page";
668
+ var ownerDocument = (node) => node.ownerDocument ?? document;
668
669
  var toPixelRect = (r) => ({
669
670
  x: r.left,
670
671
  y: r.top,
@@ -673,7 +674,7 @@ var toPixelRect = (r) => ({
673
674
  });
674
675
  function clipRange(range, container) {
675
676
  if (!range.intersectsNode(container)) return null;
676
- const bounds = document.createRange();
677
+ const bounds = ownerDocument(container).createRange();
677
678
  bounds.selectNodeContents(container);
678
679
  const clipped = range.cloneRange();
679
680
  if (clipped.compareBoundaryPoints(Range.START_TO_START, bounds) < 0) {
@@ -685,11 +686,12 @@ function clipRange(range, container) {
685
686
  return clipped;
686
687
  }
687
688
  function textClientRects(range, container) {
688
- const walker = document.createTreeWalker(container, NodeFilter.SHOW_TEXT);
689
+ const doc = ownerDocument(container);
690
+ const walker = doc.createTreeWalker(container, NodeFilter.SHOW_TEXT);
689
691
  const rects = [];
690
692
  for (let node = walker.nextNode(); node; node = walker.nextNode()) {
691
693
  if (!node.textContent?.trim() || !range.intersectsNode(node)) continue;
692
- const part = document.createRange();
694
+ const part = doc.createRange();
693
695
  part.selectNodeContents(node);
694
696
  if (node === range.startContainer) part.setStart(node, range.startOffset);
695
697
  if (node === range.endContainer) part.setEnd(node, range.endOffset);
@@ -697,6 +699,47 @@ function textClientRects(range, container) {
697
699
  }
698
700
  return rects;
699
701
  }
702
+ function firstTextAt(container, offset) {
703
+ if (container.nodeType === Node.TEXT_NODE) return { node: container, offset };
704
+ const child = container.childNodes[offset];
705
+ if (!child) return null;
706
+ if (child.nodeType === Node.TEXT_NODE) return { node: child, offset: 0 };
707
+ const first = ownerDocument(child).createTreeWalker(child, NodeFilter.SHOW_TEXT).nextNode();
708
+ return first ? { node: first, offset: 0 } : null;
709
+ }
710
+ function extendFocusToPointer(selection, point) {
711
+ if (selection.rangeCount === 0 || selection.isCollapsed) return;
712
+ const range = selection.getRangeAt(0);
713
+ if (selection.focusNode !== range.endContainer || selection.focusOffset !== range.endOffset)
714
+ return;
715
+ const start = firstTextAt(range.endContainer, range.endOffset);
716
+ if (!start) return;
717
+ const doc = ownerDocument(start.node);
718
+ const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_TEXT);
719
+ walker.currentNode = start.node;
720
+ const glyph = doc.createRange();
721
+ let end = null;
722
+ let node = start.node;
723
+ let offset = start.offset;
724
+ let passed = false;
725
+ while (node && !passed) {
726
+ const text = node.textContent ?? "";
727
+ for (let i = offset; i < text.length && !passed; i++) {
728
+ glyph.setStart(node, i);
729
+ glyph.setEnd(node, i + 1);
730
+ const r = glyph.getBoundingClientRect();
731
+ if (r.height === 0) continue;
732
+ const mid = r.top + r.height / 2;
733
+ if (mid > point.y + r.height / 2) passed = true;
734
+ else if (Math.abs(mid - point.y) > r.height / 2) continue;
735
+ else if (r.right > point.x + 0.5) passed = true;
736
+ else end = { node, offset: i + 1 };
737
+ }
738
+ node = walker.nextNode();
739
+ offset = 0;
740
+ }
741
+ if (end) selection.extend(end.node, end.offset);
742
+ }
700
743
  function readSelection(selection, root = document) {
701
744
  if (selection.rangeCount === 0 || selection.isCollapsed) return [];
702
745
  const range = selection.getRangeAt(0);
@@ -726,6 +769,7 @@ var MAX_SETTLE_ROUNDS = 12;
726
769
  function useTextSelectionMarks(controller) {
727
770
  const latest = react.useRef(controller);
728
771
  latest.current = controller;
772
+ const pagesDoc = chunkHJDR5HEO_cjs.usePortalContainer()?.ownerDocument ?? document;
729
773
  react.useEffect(() => {
730
774
  let startedOnPage = false;
731
775
  let touchSelecting = false;
@@ -733,9 +777,9 @@ function useTextSelectionMarks(controller) {
733
777
  const settleTimers = /* @__PURE__ */ new Set();
734
778
  const markSelection = () => {
735
779
  const c = latest.current;
736
- const selection = window.getSelection();
780
+ const selection = pagesDoc.getSelection();
737
781
  if (!selection || !TEXT_TOOLS.includes(c.tool)) return false;
738
- const pages = selectionToPageMarks(readSelection(selection));
782
+ const pages = selectionToPageMarks(readSelection(selection, pagesDoc));
739
783
  if (pages.length === 0) return false;
740
784
  const marks = pages.map(
741
785
  (p) => c.tool === "highlight" ? {
@@ -761,14 +805,18 @@ function useTextSelectionMarks(controller) {
761
805
  startedOnPage = e.target instanceof Element && e.target.closest(PAGE_SELECTOR) !== null;
762
806
  touchSelecting = startedOnPage && e.pointerType === "touch";
763
807
  };
764
- const onUp = () => {
808
+ const onUp = (e) => {
765
809
  if (!startedOnPage || !TEXT_TOOLS.includes(latest.current.tool)) return;
766
810
  startedOnPage = false;
767
- let last = window.getSelection()?.toString() ?? "";
811
+ const selection = pagesDoc.getSelection();
812
+ if (selection && e.pointerType === "mouse") {
813
+ extendFocusToPointer(selection, { x: e.clientX, y: e.clientY });
814
+ }
815
+ let last = selection?.toString() ?? "";
768
816
  let stable = 0;
769
817
  let rounds = 0;
770
818
  const check = () => {
771
- const now = window.getSelection()?.toString() ?? "";
819
+ const now = pagesDoc.getSelection()?.toString() ?? "";
772
820
  if (now === last) stable++;
773
821
  else {
774
822
  last = now;
@@ -789,17 +837,17 @@ function useTextSelectionMarks(controller) {
789
837
  if (markSelection()) touchSelecting = false;
790
838
  }, TOUCH_SETTLE_MS);
791
839
  };
792
- document.addEventListener("pointerdown", onDown, true);
793
- document.addEventListener("pointerup", onUp, true);
794
- document.addEventListener("selectionchange", onSelectionChange);
840
+ pagesDoc.addEventListener("pointerdown", onDown, true);
841
+ pagesDoc.addEventListener("pointerup", onUp, true);
842
+ pagesDoc.addEventListener("selectionchange", onSelectionChange);
795
843
  return () => {
796
844
  clearTimeout(settleTimer);
797
845
  settleTimers.forEach(clearTimeout);
798
- document.removeEventListener("pointerdown", onDown, true);
799
- document.removeEventListener("pointerup", onUp, true);
800
- document.removeEventListener("selectionchange", onSelectionChange);
846
+ pagesDoc.removeEventListener("pointerdown", onDown, true);
847
+ pagesDoc.removeEventListener("pointerup", onUp, true);
848
+ pagesDoc.removeEventListener("selectionchange", onSelectionChange);
801
849
  };
802
- }, []);
850
+ }, [pagesDoc]);
803
851
  }
804
852
 
805
853
  // src/annotations/overlay-geometry.ts
@@ -1093,11 +1141,13 @@ function AnnotationPageOverlay({
1093
1141
  {
1094
1142
  annotation: selected,
1095
1143
  controller,
1144
+ pageHeight: size.height,
1096
1145
  onClose: () => {
1097
1146
  setOpenComment(null);
1098
1147
  controller.select(null);
1099
1148
  }
1100
- }
1149
+ },
1150
+ selected.id
1101
1151
  )
1102
1152
  ]
1103
1153
  }
@@ -1203,6 +1253,7 @@ function MarkView(props) {
1203
1253
  {
1204
1254
  type: "button",
1205
1255
  ...base(`Comment: ${a.body || "empty"}`),
1256
+ onMouseDown: (e) => e.preventDefault(),
1206
1257
  className: chunkS6A6FSG7_cjs.cn(
1207
1258
  "absolute flex items-center justify-center rounded-md border border-amber-700/60 bg-amber-300 text-amber-900 shadow-sm",
1208
1259
  a.resolved && "opacity-50",
@@ -1240,10 +1291,11 @@ function RedactionView({
1240
1291
  const rects = rectOverride ? [rectOverride] : a.rects;
1241
1292
  const approved = a.status === "approved";
1242
1293
  const rejected = a.status === "rejected";
1294
+ const label = `Redaction (${a.status}): ${a.reason}`;
1243
1295
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: rects.map((r, i) => /* @__PURE__ */ jsxRuntime.jsx(
1244
1296
  "div",
1245
1297
  {
1246
- ...i === 0 ? base(`Redaction (${a.status}): ${a.reason}`) : {},
1298
+ ...i === 0 ? { ...base(label), title: label } : {},
1247
1299
  "data-status": i === 0 ? a.status : void 0,
1248
1300
  className: chunkS6A6FSG7_cjs.cn(
1249
1301
  "absolute flex items-center justify-center overflow-hidden text-[10px] leading-none",
@@ -1337,6 +1389,15 @@ function ActionBar({
1337
1389
  },
1338
1390
  onPointerDown: (e) => e.stopPropagation(),
1339
1391
  children: [
1392
+ a.kind === "redaction" && /* @__PURE__ */ jsxRuntime.jsx(
1393
+ "span",
1394
+ {
1395
+ className: "max-w-44 truncate self-center px-1.5 text-xs text-muted-foreground",
1396
+ title: a.reason,
1397
+ "data-testid": "annotation-action-reason",
1398
+ children: a.reason
1399
+ }
1400
+ ),
1340
1401
  a.kind === "redaction" && a.status !== "approved" && /* @__PURE__ */ jsxRuntime.jsx(
1341
1402
  "button",
1342
1403
  {
@@ -1392,16 +1453,39 @@ function ActionBar({
1392
1453
  function CommentPopover({
1393
1454
  annotation: a,
1394
1455
  controller,
1456
+ pageHeight,
1395
1457
  onClose
1396
1458
  }) {
1397
1459
  const [body, setBody] = react.useState(a.body);
1398
1460
  const [reply, setReply] = react.useState("");
1461
+ const [lift, setLift] = react.useState(0);
1462
+ const popRef = react.useRef(null);
1463
+ const unsaved = react.useRef(null);
1399
1464
  const readOnly = controller.readOnly;
1400
1465
  const mine = a.author === controller.author && !readOnly;
1401
1466
  react.useEffect(() => setBody(a.body), [a.body]);
1467
+ react.useLayoutEffect(() => {
1468
+ const el = popRef.current;
1469
+ if (!el) return;
1470
+ const top2 = a.rect.y * pageHeight;
1471
+ const fit = () => setLift(Math.min(top2, Math.max(0, top2 + el.offsetHeight - pageHeight)));
1472
+ fit();
1473
+ const observer = new ResizeObserver(fit);
1474
+ observer.observe(el);
1475
+ return () => observer.disconnect();
1476
+ }, [a.rect.y, pageHeight]);
1402
1477
  const commitBody = () => {
1403
1478
  if (mine && body !== a.body) controller.update(a.id, { body });
1479
+ unsaved.current = null;
1404
1480
  };
1481
+ react.useEffect(
1482
+ () => () => {
1483
+ if (unsaved.current !== null) controller.update(a.id, { body: unsaved.current });
1484
+ unsaved.current = null;
1485
+ },
1486
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- runs once, when this comment's box unmounts
1487
+ [a.id]
1488
+ );
1405
1489
  const close = () => {
1406
1490
  commitBody();
1407
1491
  if (!readOnly && body.trim() === "" && a.replies.length === 0) controller.remove(a.id);
@@ -1418,10 +1502,12 @@ function CommentPopover({
1418
1502
  return /* @__PURE__ */ jsxRuntime.jsxs(
1419
1503
  "div",
1420
1504
  {
1505
+ ref: popRef,
1421
1506
  "data-testid": "annotation-comment-popover",
1422
1507
  className: "pointer-events-auto absolute z-30 w-64 rounded-lg border border-border bg-background p-3 text-sm shadow-lg",
1423
1508
  style: {
1424
1509
  top: pct(a.rect.y),
1510
+ marginTop: -lift,
1425
1511
  ...onRight ? { right: `calc(${pct(1 - a.rect.x)} + 8px)` } : { left: `calc(${pct(a.rect.x)} + ${COMMENT_ICON_PX + 8}px)` }
1426
1512
  },
1427
1513
  onPointerDown: (e) => e.stopPropagation(),
@@ -1449,11 +1535,14 @@ function CommentPopover({
1449
1535
  {
1450
1536
  autoFocus: a.body === "",
1451
1537
  "data-testid": "annotation-comment-body",
1452
- className: "min-h-16 w-full resize-y rounded-md border border-input bg-background p-2 text-sm",
1538
+ 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",
1453
1539
  placeholder: "Add a comment",
1454
1540
  value: body,
1455
1541
  readOnly: !mine,
1456
- onChange: (e) => setBody(e.target.value),
1542
+ onChange: (e) => {
1543
+ setBody(e.target.value);
1544
+ unsaved.current = e.target.value;
1545
+ },
1457
1546
  onBlur: commitBody,
1458
1547
  onKeyDown: (e) => {
1459
1548
  if (e.key === "Escape") close();
@@ -1591,6 +1680,44 @@ function Swatches({
1591
1680
  c
1592
1681
  )) });
1593
1682
  }
1683
+ function PresetField({
1684
+ label,
1685
+ testId,
1686
+ value,
1687
+ presets,
1688
+ maxLength,
1689
+ className,
1690
+ onChange
1691
+ }) {
1692
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
1693
+ /* @__PURE__ */ jsxRuntime.jsx(
1694
+ "input",
1695
+ {
1696
+ "aria-label": label,
1697
+ "data-testid": testId,
1698
+ className: chunkS6A6FSG7_cjs.cn("h-8 rounded-l-md border border-input bg-background px-2 text-sm", className),
1699
+ value,
1700
+ maxLength,
1701
+ onFocus: (e) => e.currentTarget.select(),
1702
+ onChange: (e) => onChange(e.target.value)
1703
+ }
1704
+ ),
1705
+ /* @__PURE__ */ jsxRuntime.jsxs(chunkHJDR5HEO_cjs.DropdownMenu, { children: [
1706
+ /* @__PURE__ */ jsxRuntime.jsx(chunkHJDR5HEO_cjs.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
1707
+ "button",
1708
+ {
1709
+ type: "button",
1710
+ "aria-label": `Choose ${label.toLowerCase()}`,
1711
+ title: `Choose ${label.toLowerCase()}`,
1712
+ "data-testid": `${testId}-presets`,
1713
+ 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",
1714
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { size: 14 })
1715
+ }
1716
+ ) }),
1717
+ /* @__PURE__ */ jsxRuntime.jsx(chunkHJDR5HEO_cjs.DropdownMenuContent, { align: "end", children: presets.map((p) => /* @__PURE__ */ jsxRuntime.jsx(chunkHJDR5HEO_cjs.DropdownMenuItem, { onSelect: () => onChange(p), children: p }, p)) })
1718
+ ] })
1719
+ ] });
1720
+ }
1594
1721
  function AnnotationToolbar({
1595
1722
  controller,
1596
1723
  onFreeze,
@@ -1603,8 +1730,61 @@ function AnnotationToolbar({
1603
1730
  const pending = pendingRedactions(controller.layer);
1604
1731
  const redactionCount = controller.layer.annotations.filter((a) => a.kind === "redaction").length;
1605
1732
  const colored = tool === "highlight" || tool === "box" || tool === "stamp";
1733
+ const redacting = tool === "redact-text" || tool === "redact-area";
1606
1734
  const status = layerStatusText(controller);
1607
1735
  const editable = !controller.readOnly;
1736
+ const redactionControls = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1737
+ editable && redacting && /* @__PURE__ */ jsxRuntime.jsx(
1738
+ PresetField,
1739
+ {
1740
+ label: "Redaction reason",
1741
+ testId: "annotation-redaction-reason",
1742
+ className: "w-44",
1743
+ value: settings.redactionReason,
1744
+ presets: REDACTION_REASONS,
1745
+ maxLength: 80,
1746
+ onChange: (redactionReason) => controller.setSettings({ redactionReason })
1747
+ }
1748
+ ),
1749
+ redactionCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-sm", "data-testid": "annotation-review", children: [
1750
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "rounded-md bg-muted px-2 py-1", "data-testid": "annotation-pending-count", children: [
1751
+ pending.length,
1752
+ " pending"
1753
+ ] }),
1754
+ editable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1755
+ /* @__PURE__ */ jsxRuntime.jsx(
1756
+ chunkLQ5YHB7W_cjs.Button,
1757
+ {
1758
+ type: "button",
1759
+ size: "sm",
1760
+ variant: "outline",
1761
+ disabled: pending.length === 0,
1762
+ "data-testid": "annotation-approve-all",
1763
+ onClick: () => controller.setRedactionStatus(
1764
+ pending.map((a) => a.id),
1765
+ "approved"
1766
+ ),
1767
+ children: "Approve all"
1768
+ }
1769
+ ),
1770
+ /* @__PURE__ */ jsxRuntime.jsx(
1771
+ chunkLQ5YHB7W_cjs.Button,
1772
+ {
1773
+ type: "button",
1774
+ size: "sm",
1775
+ variant: "outline",
1776
+ disabled: pending.length === 0,
1777
+ "data-testid": "annotation-reject-all",
1778
+ onClick: () => controller.setRedactionStatus(
1779
+ pending.map((a) => a.id),
1780
+ "rejected"
1781
+ ),
1782
+ children: "Reject all"
1783
+ }
1784
+ )
1785
+ ] })
1786
+ ] })
1787
+ ] });
1608
1788
  return /* @__PURE__ */ jsxRuntime.jsxs(
1609
1789
  "div",
1610
1790
  {
@@ -1616,8 +1796,46 @@ function AnnotationToolbar({
1616
1796
  className
1617
1797
  ),
1618
1798
  children: [
1799
+ editable && /* @__PURE__ */ jsxRuntime.jsxs(
1800
+ "div",
1801
+ {
1802
+ className: "flex items-center gap-1 border-r border-border pr-3",
1803
+ role: "group",
1804
+ "aria-label": "History",
1805
+ children: [
1806
+ /* @__PURE__ */ jsxRuntime.jsx(
1807
+ chunkLQ5YHB7W_cjs.Button,
1808
+ {
1809
+ type: "button",
1810
+ size: "icon",
1811
+ variant: "ghost",
1812
+ title: "Undo",
1813
+ "aria-label": "Undo",
1814
+ "data-testid": "annotation-undo",
1815
+ disabled: !controller.canUndo,
1816
+ onClick: controller.undo,
1817
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Undo2, { size: 16 })
1818
+ }
1819
+ ),
1820
+ /* @__PURE__ */ jsxRuntime.jsx(
1821
+ chunkLQ5YHB7W_cjs.Button,
1822
+ {
1823
+ type: "button",
1824
+ size: "icon",
1825
+ variant: "ghost",
1826
+ title: "Redo",
1827
+ "aria-label": "Redo",
1828
+ "data-testid": "annotation-redo",
1829
+ disabled: !controller.canRedo,
1830
+ onClick: controller.redo,
1831
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Redo2, { size: 16 })
1832
+ }
1833
+ )
1834
+ ]
1835
+ }
1836
+ ),
1619
1837
  editable && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-1", role: "group", "aria-label": "Tool", children: TOOLS.map(({ tool: t, label, icon }) => /* @__PURE__ */ jsxRuntime.jsx(
1620
- chunkGXQO3IJC_cjs.Button,
1838
+ chunkLQ5YHB7W_cjs.Button,
1621
1839
  {
1622
1840
  type: "button",
1623
1841
  size: "icon",
@@ -1631,36 +1849,6 @@ function AnnotationToolbar({
1631
1849
  },
1632
1850
  t
1633
1851
  )) }),
1634
- editable && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", role: "group", "aria-label": "History", children: [
1635
- /* @__PURE__ */ jsxRuntime.jsx(
1636
- chunkGXQO3IJC_cjs.Button,
1637
- {
1638
- type: "button",
1639
- size: "icon",
1640
- variant: "ghost",
1641
- title: "Undo",
1642
- "aria-label": "Undo",
1643
- "data-testid": "annotation-undo",
1644
- disabled: !controller.canUndo,
1645
- onClick: controller.undo,
1646
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Undo2, { size: 16 })
1647
- }
1648
- ),
1649
- /* @__PURE__ */ jsxRuntime.jsx(
1650
- chunkGXQO3IJC_cjs.Button,
1651
- {
1652
- type: "button",
1653
- size: "icon",
1654
- variant: "ghost",
1655
- title: "Redo",
1656
- "aria-label": "Redo",
1657
- "data-testid": "annotation-redo",
1658
- disabled: !controller.canRedo,
1659
- onClick: controller.redo,
1660
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Redo2, { size: 16 })
1661
- }
1662
- )
1663
- ] }),
1664
1852
  editable && colored && /* @__PURE__ */ jsxRuntime.jsx(
1665
1853
  Swatches,
1666
1854
  {
@@ -1670,75 +1858,27 @@ function AnnotationToolbar({
1670
1858
  onChange: (c) => controller.setSettings({ colors: { ...settings.colors, [tool]: c } })
1671
1859
  }
1672
1860
  ),
1673
- editable && tool === "stamp" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1674
- /* @__PURE__ */ jsxRuntime.jsx(
1675
- "input",
1676
- {
1677
- list: "annotation-stamp-presets",
1678
- "aria-label": "Stamp text",
1679
- "data-testid": "annotation-stamp-label",
1680
- className: "h-8 w-40 rounded-md border border-input bg-background px-2 text-sm",
1681
- value: settings.stampLabel,
1682
- maxLength: 40,
1683
- onChange: (e) => controller.setSettings({ stampLabel: e.target.value })
1684
- }
1685
- ),
1686
- /* @__PURE__ */ jsxRuntime.jsx("datalist", { id: "annotation-stamp-presets", children: STAMP_PRESETS.map((s) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: s }, s)) })
1687
- ] }),
1688
- editable && (tool === "redact-text" || tool === "redact-area") && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1689
- /* @__PURE__ */ jsxRuntime.jsx(
1690
- "input",
1691
- {
1692
- list: "annotation-redaction-reasons",
1693
- "aria-label": "Redaction reason",
1694
- "data-testid": "annotation-redaction-reason",
1695
- className: "h-8 w-44 rounded-md border border-input bg-background px-2 text-sm",
1696
- value: settings.redactionReason,
1697
- maxLength: 80,
1698
- onChange: (e) => controller.setSettings({ redactionReason: e.target.value })
1699
- }
1700
- ),
1701
- /* @__PURE__ */ jsxRuntime.jsx("datalist", { id: "annotation-redaction-reasons", children: REDACTION_REASONS.map((r) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: r }, r)) })
1702
- ] }),
1703
- redactionCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-sm", "data-testid": "annotation-review", children: [
1704
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "rounded-md bg-muted px-2 py-1", "data-testid": "annotation-pending-count", children: [
1705
- pending.length,
1706
- " pending"
1707
- ] }),
1708
- editable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1709
- /* @__PURE__ */ jsxRuntime.jsx(
1710
- chunkGXQO3IJC_cjs.Button,
1711
- {
1712
- type: "button",
1713
- size: "sm",
1714
- variant: "outline",
1715
- disabled: pending.length === 0,
1716
- "data-testid": "annotation-approve-all",
1717
- onClick: () => controller.setRedactionStatus(
1718
- pending.map((a) => a.id),
1719
- "approved"
1720
- ),
1721
- children: "Approve all"
1722
- }
1723
- ),
1724
- /* @__PURE__ */ jsxRuntime.jsx(
1725
- chunkGXQO3IJC_cjs.Button,
1726
- {
1727
- type: "button",
1728
- size: "sm",
1729
- variant: "outline",
1730
- disabled: pending.length === 0,
1731
- "data-testid": "annotation-reject-all",
1732
- onClick: () => controller.setRedactionStatus(
1733
- pending.map((a) => a.id),
1734
- "rejected"
1735
- ),
1736
- children: "Reject all"
1737
- }
1738
- )
1739
- ] })
1740
- ] }),
1741
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-auto flex items-center gap-3 text-xs text-muted-foreground", children: [
1861
+ editable && tool === "stamp" && /* @__PURE__ */ jsxRuntime.jsx(
1862
+ PresetField,
1863
+ {
1864
+ label: "Stamp text",
1865
+ testId: "annotation-stamp-label",
1866
+ className: "w-40",
1867
+ value: settings.stampLabel,
1868
+ presets: STAMP_PRESETS,
1869
+ maxLength: 40,
1870
+ onChange: (stampLabel) => controller.setSettings({ stampLabel })
1871
+ }
1872
+ ),
1873
+ (redacting || redactionCount > 0) && /* @__PURE__ */ jsxRuntime.jsx(
1874
+ "div",
1875
+ {
1876
+ className: "flex w-full flex-wrap items-center gap-x-3 gap-y-2",
1877
+ "data-testid": "annotation-redaction-row",
1878
+ children: redactionControls
1879
+ }
1880
+ ),
1881
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center justify-end gap-3 text-xs text-muted-foreground", children: [
1742
1882
  /* @__PURE__ */ jsxRuntime.jsx(
1743
1883
  "span",
1744
1884
  {
@@ -1751,7 +1891,7 @@ function AnnotationToolbar({
1751
1891
  }
1752
1892
  ),
1753
1893
  actions,
1754
- onFreeze && /* @__PURE__ */ jsxRuntime.jsxs(chunkGXQO3IJC_cjs.Button, { type: "button", size: "sm", "data-testid": "annotation-freeze", onClick: onFreeze, children: [
1894
+ onFreeze && /* @__PURE__ */ jsxRuntime.jsxs(chunkLQ5YHB7W_cjs.Button, { type: "button", size: "sm", "data-testid": "annotation-freeze", onClick: onFreeze, children: [
1755
1895
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Snowflake, { size: 14 }),
1756
1896
  "Freeze copy"
1757
1897
  ] })
@@ -1793,10 +1933,10 @@ function FreezeDialog({
1793
1933
  marks.filter((a) => a.kind === k && (k !== "redaction" || chunkSSOPIPEX_cjs.isEffectiveRedaction(a))).length
1794
1934
  ]
1795
1935
  ).filter(([, n]) => n > 0);
1796
- return /* @__PURE__ */ jsxRuntime.jsx(chunkGXQO3IJC_cjs.Dialog, { open, onOpenChange: (next) => !busy && onOpenChange(next), children: /* @__PURE__ */ jsxRuntime.jsxs(chunkGXQO3IJC_cjs.DialogContent, { "data-testid": "freeze-dialog", children: [
1797
- /* @__PURE__ */ jsxRuntime.jsxs(chunkGXQO3IJC_cjs.DialogHeader, { children: [
1798
- /* @__PURE__ */ jsxRuntime.jsx(chunkGXQO3IJC_cjs.DialogTitle, { children: "Freeze a copy" }),
1799
- /* @__PURE__ */ jsxRuntime.jsx(chunkGXQO3IJC_cjs.DialogDescription, { children: "Saves a separate document with your annotations built in, next to the original. The original stays as it is." })
1936
+ return /* @__PURE__ */ jsxRuntime.jsx(chunkLQ5YHB7W_cjs.Dialog, { open, onOpenChange: (next) => !busy && onOpenChange(next), children: /* @__PURE__ */ jsxRuntime.jsxs(chunkLQ5YHB7W_cjs.DialogContent, { "data-testid": "freeze-dialog", children: [
1937
+ /* @__PURE__ */ jsxRuntime.jsxs(chunkLQ5YHB7W_cjs.DialogHeader, { children: [
1938
+ /* @__PURE__ */ jsxRuntime.jsx(chunkLQ5YHB7W_cjs.DialogTitle, { children: "Freeze a copy" }),
1939
+ /* @__PURE__ */ jsxRuntime.jsx(chunkLQ5YHB7W_cjs.DialogDescription, { children: "Saves a separate document with your annotations built in, next to the original. The original stays as it is." })
1800
1940
  ] }),
1801
1941
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", "data-testid": "freeze-summary", children: counts.length === 0 ? "No annotations yet." : counts.map(([k, n]) => `${n} ${KIND_LABELS[k]}`).join(", ") }),
1802
1942
  /* @__PURE__ */ jsxRuntime.jsxs("fieldset", { className: "space-y-2 text-sm", disabled: busy, children: [
@@ -1905,9 +2045,9 @@ function FreezeDialog({
1905
2045
  "\u2026"
1906
2046
  ] }),
1907
2047
  error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", role: "alert", "data-testid": "freeze-error", children: error }),
1908
- /* @__PURE__ */ jsxRuntime.jsxs(chunkGXQO3IJC_cjs.DialogFooter, { children: [
2048
+ /* @__PURE__ */ jsxRuntime.jsxs(chunkLQ5YHB7W_cjs.DialogFooter, { children: [
1909
2049
  /* @__PURE__ */ jsxRuntime.jsx(
1910
- chunkGXQO3IJC_cjs.Button,
2050
+ chunkLQ5YHB7W_cjs.Button,
1911
2051
  {
1912
2052
  type: "button",
1913
2053
  variant: "outline",
@@ -1917,7 +2057,7 @@ function FreezeDialog({
1917
2057
  }
1918
2058
  ),
1919
2059
  /* @__PURE__ */ jsxRuntime.jsx(
1920
- chunkGXQO3IJC_cjs.Button,
2060
+ chunkLQ5YHB7W_cjs.Button,
1921
2061
  {
1922
2062
  type: "button",
1923
2063
  "data-testid": "freeze-confirm",
@@ -1992,10 +2132,10 @@ function ProductionDialog({
1992
2132
  setDragFrom(null);
1993
2133
  };
1994
2134
  const valid = Number.isInteger(start) && start >= 0 && Number.isInteger(digits) && digits >= 1 && digits <= 12;
1995
- return /* @__PURE__ */ jsxRuntime.jsx(chunkGXQO3IJC_cjs.Dialog, { open, onOpenChange: (next) => !busy && onOpenChange(next), children: /* @__PURE__ */ jsxRuntime.jsxs(chunkGXQO3IJC_cjs.DialogContent, { "data-testid": "production-dialog", className: "max-h-[90dvh] overflow-y-auto", children: [
1996
- /* @__PURE__ */ jsxRuntime.jsxs(chunkGXQO3IJC_cjs.DialogHeader, { children: [
1997
- /* @__PURE__ */ jsxRuntime.jsx(chunkGXQO3IJC_cjs.DialogTitle, { children: "Production set" }),
1998
- /* @__PURE__ */ jsxRuntime.jsx(chunkGXQO3IJC_cjs.DialogDescription, { children: "Numbers every page with a Bates label, in the order shown. The originals are never changed; the result is downloaded and, if you choose, saved to the workspace." })
2135
+ return /* @__PURE__ */ jsxRuntime.jsx(chunkLQ5YHB7W_cjs.Dialog, { open, onOpenChange: (next) => !busy && onOpenChange(next), children: /* @__PURE__ */ jsxRuntime.jsxs(chunkLQ5YHB7W_cjs.DialogContent, { "data-testid": "production-dialog", className: "max-h-[90dvh] overflow-y-auto", children: [
2136
+ /* @__PURE__ */ jsxRuntime.jsxs(chunkLQ5YHB7W_cjs.DialogHeader, { children: [
2137
+ /* @__PURE__ */ jsxRuntime.jsx(chunkLQ5YHB7W_cjs.DialogTitle, { children: "Production set" }),
2138
+ /* @__PURE__ */ jsxRuntime.jsx(chunkLQ5YHB7W_cjs.DialogDescription, { children: "Numbers every page with a Bates label, in the order shown. The originals are never changed; the result is downloaded and, if you choose, saved to the workspace." })
1999
2139
  ] }),
2000
2140
  /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-muted-foreground", "data-testid": "production-summary", children: [
2001
2141
  documents.length,
@@ -2036,7 +2176,7 @@ function ProductionDialog({
2036
2176
  ] }),
2037
2177
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", title: doc.name, children: doc.name }),
2038
2178
  /* @__PURE__ */ jsxRuntime.jsx(
2039
- chunkGXQO3IJC_cjs.Button,
2179
+ chunkLQ5YHB7W_cjs.Button,
2040
2180
  {
2041
2181
  type: "button",
2042
2182
  variant: "ghost",
@@ -2050,7 +2190,7 @@ function ProductionDialog({
2050
2190
  }
2051
2191
  ),
2052
2192
  /* @__PURE__ */ jsxRuntime.jsx(
2053
- chunkGXQO3IJC_cjs.Button,
2193
+ chunkLQ5YHB7W_cjs.Button,
2054
2194
  {
2055
2195
  type: "button",
2056
2196
  variant: "ghost",
@@ -2235,9 +2375,9 @@ function ProductionDialog({
2235
2375
  "\u2026"
2236
2376
  ] }),
2237
2377
  error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", role: "alert", "data-testid": "production-error", children: error }),
2238
- /* @__PURE__ */ jsxRuntime.jsxs(chunkGXQO3IJC_cjs.DialogFooter, { children: [
2378
+ /* @__PURE__ */ jsxRuntime.jsxs(chunkLQ5YHB7W_cjs.DialogFooter, { children: [
2239
2379
  /* @__PURE__ */ jsxRuntime.jsx(
2240
- chunkGXQO3IJC_cjs.Button,
2380
+ chunkLQ5YHB7W_cjs.Button,
2241
2381
  {
2242
2382
  type: "button",
2243
2383
  variant: "outline",
@@ -2247,7 +2387,7 @@ function ProductionDialog({
2247
2387
  }
2248
2388
  ),
2249
2389
  /* @__PURE__ */ jsxRuntime.jsx(
2250
- chunkGXQO3IJC_cjs.Button,
2390
+ chunkLQ5YHB7W_cjs.Button,
2251
2391
  {
2252
2392
  type: "button",
2253
2393
  "data-testid": "production-confirm",