@discuss-ds/ui 0.31.0 → 0.33.0

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
@@ -1461,37 +1461,96 @@ function splitMarks(text, marks) {
1461
1461
  if (at < text.length) out.push({ text: text.slice(at) });
1462
1462
  return out;
1463
1463
  }
1464
- var markClasses = "rounded-xxs border-b-2 border-destructive-foreground";
1465
- function useMarkAlignment(ref, text) {
1466
- const [padding, setPadding] = React24.useState({ top: 0, bottom: 0 });
1467
- React24.useLayoutEffect(() => {
1468
- const mark = ref.current;
1469
- const button = mark?.closest("button");
1470
- if (!mark || !button) return;
1471
- const align = () => {
1472
- const m = mark.getBoundingClientRect();
1464
+ var lineClasses = (tone, hovered) => cn("pointer-events-none absolute -z-10 rounded-xxs border-b-2", tone === "warning" ? "border-warning-foreground bg-warning-background-highlight" : cn("border-destructive-foreground", hovered && "bg-destructive-soft"));
1465
+ function markLines(rects, origin, field) {
1466
+ const count = field ? Math.max(1, Math.round((field.contentBottom - field.contentTop) / field.lineHeight)) : 1;
1467
+ const boxes = rects.filter((r) => r.width > 0).map((r) => {
1468
+ if (!field) return { left: r.left - origin.left, top: r.top - origin.top, width: r.width, height: r.height };
1469
+ const index = Math.min(count - 1, Math.max(0, Math.floor((r.top + r.height / 2 - field.contentTop) / field.lineHeight)));
1470
+ const top = index === 0 ? field.top : field.contentTop + index * field.lineHeight;
1471
+ const bottom = index === count - 1 ? field.bottom : field.contentTop + (index + 1) * field.lineHeight;
1472
+ return { left: r.left - origin.left, top: top - origin.top, width: r.width, height: bottom - top };
1473
+ });
1474
+ return boxes.reduce((out, box) => {
1475
+ const same = field ? out.find((o) => Math.abs(o.top - box.top) < 0.5 && Math.abs(o.height - box.height) < 0.5) : void 0;
1476
+ if (!same) return [...out, box];
1477
+ const left = Math.min(same.left, box.left);
1478
+ const right = Math.max(same.left + same.width, box.left + box.width);
1479
+ return out.map((o) => o === same ? { ...o, left, width: right - left } : o);
1480
+ }, []);
1481
+ }
1482
+ var sameLines = (a, b) => a.length === b.length && a.every((l, i) => Object.keys(l).every((k) => Math.abs(l[k] - b[i][k]) < 0.5));
1483
+ function useMarkLines(anchorRef, markRef) {
1484
+ const [lines, setLines] = React24.useState([]);
1485
+ const measure = React24.useCallback(() => {
1486
+ const anchor = anchorRef.current;
1487
+ const mark = markRef.current;
1488
+ if (!anchor || !mark) return;
1489
+ const button = mark.closest("button");
1490
+ const a = anchor.getBoundingClientRect();
1491
+ let field;
1492
+ if (button) {
1473
1493
  const b = button.getBoundingClientRect();
1474
- const markStyle = getComputedStyle(mark);
1475
- const buttonStyle = getComputedStyle(button);
1476
- const border = parseFloat(markStyle.borderBottomWidth);
1477
- const baseTop = m.top + parseFloat(markStyle.paddingTop);
1478
- const baseBottom = m.bottom - parseFloat(markStyle.paddingBottom) - border;
1479
- const contentTop = b.top + parseFloat(buttonStyle.borderTopWidth) + parseFloat(buttonStyle.paddingTop);
1480
- const contentBottom = b.bottom - parseFloat(buttonStyle.borderBottomWidth) - parseFloat(buttonStyle.paddingBottom);
1481
- const lineHeight = parseFloat(buttonStyle.lineHeight) || contentBottom - contentTop;
1482
- const lines = Math.max(1, Math.round((contentBottom - contentTop) / lineHeight));
1483
- const lineIndex = Math.min(lines - 1, Math.max(0, Math.floor(((baseTop + baseBottom) / 2 - contentTop) / lineHeight)));
1484
- const targetTop = lineIndex === 0 ? b.top : contentTop + lineIndex * lineHeight;
1485
- const targetBottom = lineIndex === lines - 1 ? b.bottom : contentTop + (lineIndex + 1) * lineHeight;
1486
- const next = { top: Math.max(0, baseTop - targetTop), bottom: Math.max(0, targetBottom - baseBottom - border) };
1487
- setPadding((p) => Math.abs(p.top - next.top) < 0.5 && Math.abs(p.bottom - next.bottom) < 0.5 ? p : next);
1488
- };
1489
- align();
1490
- const observer = new ResizeObserver(align);
1494
+ const style = getComputedStyle(button);
1495
+ const contentTop = b.top + (parseFloat(style.borderTopWidth) || 0) + (parseFloat(style.paddingTop) || 0);
1496
+ const contentBottom = b.bottom - (parseFloat(style.borderBottomWidth) || 0) - (parseFloat(style.paddingBottom) || 0);
1497
+ field = { top: b.top, bottom: b.bottom, contentTop, contentBottom, lineHeight: parseFloat(style.lineHeight) || contentBottom - contentTop };
1498
+ }
1499
+ const next = markLines([...mark.getClientRects()], a, field);
1500
+ setLines((prev) => sameLines(prev, next) ? prev : next);
1501
+ }, [anchorRef, markRef]);
1502
+ React24.useLayoutEffect(measure);
1503
+ React24.useLayoutEffect(() => {
1504
+ const button = markRef.current?.closest("button");
1505
+ if (!button) return;
1506
+ const observer = new ResizeObserver(measure);
1491
1507
  observer.observe(button);
1492
1508
  return () => observer.disconnect();
1493
- }, [ref, text]);
1494
- return padding;
1509
+ }, [markRef, measure]);
1510
+ return lines;
1511
+ }
1512
+ function remapMarks(saved, draft, marks) {
1513
+ if (!marks?.length) return [];
1514
+ if (saved === draft) return marks;
1515
+ const max = Math.min(saved.length, draft.length);
1516
+ let before = 0;
1517
+ while (before < max && saved[before] === draft[before]) before += 1;
1518
+ let after = 0;
1519
+ while (after < max - before && saved[saved.length - 1 - after] === draft[draft.length - 1 - after]) after += 1;
1520
+ const editEnd = saved.length - after;
1521
+ const delta = draft.length - saved.length;
1522
+ return marks.flatMap((m) => m.end <= before ? [m] : m.start >= editEnd ? [{ ...m, start: m.start + delta, end: m.end + delta }] : []);
1523
+ }
1524
+ function DraftMarks({ text, marks, layer, className, scrollLeft = 0, singleLine }) {
1525
+ const rootRef = React24.useRef(null);
1526
+ const textRef = React24.useRef(null);
1527
+ const [boxes, setBoxes] = React24.useState([]);
1528
+ React24.useLayoutEffect(() => {
1529
+ if (textRef.current) textRef.current.scrollLeft = scrollLeft;
1530
+ }, [scrollLeft, text]);
1531
+ React24.useLayoutEffect(() => {
1532
+ const root = rootRef.current;
1533
+ const mirror = textRef.current;
1534
+ if (!root || !mirror) return;
1535
+ const r = root.getBoundingClientRect();
1536
+ const style = getComputedStyle(mirror);
1537
+ const contentTop = r.top + (parseFloat(style.borderTopWidth) || 0) + (parseFloat(style.paddingTop) || 0);
1538
+ const contentBottom = r.bottom - (parseFloat(style.borderBottomWidth) || 0) - (parseFloat(style.paddingBottom) || 0);
1539
+ const lineHeight = singleLine ? contentBottom - contentTop : parseFloat(style.lineHeight) || contentBottom - contentTop;
1540
+ const field = { top: r.top, bottom: r.bottom, contentTop, contentBottom, lineHeight };
1541
+ const next = [...mirror.querySelectorAll("[data-draft-mark]")].flatMap(
1542
+ (el) => markLines([...el.getClientRects()], { left: r.left, top: r.top }, field).map((box) => ({ tone: el.dataset.tone ?? "destructive", box }))
1543
+ );
1544
+ setBoxes((prev) => prev.length === next.length && prev.every((p, i) => p.tone === next[i].tone && sameLines([p.box], [next[i].box])) ? prev : next);
1545
+ });
1546
+ return /* @__PURE__ */ jsxs17("div", { ref: rootRef, "aria-hidden": true, "data-draft-marks": true, "data-layer": layer, className: "pointer-events-none absolute inset-0", children: [
1547
+ /* @__PURE__ */ jsx25("div", { ref: textRef, className: cn(className, "absolute inset-0 overflow-hidden text-transparent"), children: splitMarks(text, marks).map(
1548
+ (piece, i) => piece.mark ? /* @__PURE__ */ jsx25("span", { "data-draft-mark": true, "data-tone": piece.mark.tone ?? "destructive", children: piece.text }, i) : /* @__PURE__ */ jsx25("span", { children: piece.text }, i)
1549
+ ) }),
1550
+ /* @__PURE__ */ jsx25("div", { className: "absolute inset-0", style: { clipPath: "inset(-4px 0)" }, children: boxes.map(
1551
+ ({ tone, box }, i) => layer === "behind" ? tone === "warning" && /* @__PURE__ */ jsx25("span", { "data-draft-box": true, className: "absolute rounded-xxs bg-warning-background-highlight", style: box }, i) : /* @__PURE__ */ jsx25("span", { "data-draft-box": true, className: cn("absolute rounded-xxs border-b-2", tone === "warning" ? "border-warning-foreground" : "border-destructive-foreground"), style: box }, i)
1552
+ ) })
1553
+ ] });
1495
1554
  }
1496
1555
  var closeOpenMarkCard = null;
1497
1556
  function MarkedText({ mark, text, onApply, onDismiss }) {
@@ -1504,12 +1563,19 @@ function MarkedText({ mark, text, onApply, onDismiss }) {
1504
1563
  },
1505
1564
  [close]
1506
1565
  );
1507
- const padding = useMarkAlignment(ref, text);
1508
- const style = { paddingTop: padding.top, paddingBottom: padding.bottom };
1566
+ const anchorRef = React24.useRef(null);
1567
+ const [hovered, setHovered] = React24.useState(false);
1568
+ const lines = useMarkLines(anchorRef, ref);
1569
+ const layers = /* @__PURE__ */ jsx25("span", { ref: anchorRef, "aria-hidden": true, className: "relative isolate", children: lines.map((line, i) => /* @__PURE__ */ jsx25("span", { "data-mark-line": true, className: lineClasses(mark.tone, hovered), style: line }, i)) });
1509
1570
  if (!onApply && !onDismiss) {
1510
- return /* @__PURE__ */ jsx25("span", { ref, "data-mark": true, className: markClasses, style, children: text });
1571
+ return /* @__PURE__ */ jsxs17(Fragment4, { children: [
1572
+ layers,
1573
+ /* @__PURE__ */ jsx25("span", { ref, "data-mark": true, "data-tone": mark.tone ?? "destructive", className: "relative", children: text })
1574
+ ] });
1511
1575
  }
1512
1576
  const suggestions = (mark.suggestions ?? []).slice(0, 3);
1577
+ const warning = mark.tone === "warning";
1578
+ const struck = "text-destructive-foreground";
1513
1579
  const handleOpenChange = (next) => {
1514
1580
  if (next) {
1515
1581
  if (closeOpenMarkCard && closeOpenMarkCard !== close) closeOpenMarkCard();
@@ -1521,7 +1587,22 @@ function MarkedText({ mark, text, onApply, onDismiss }) {
1521
1587
  };
1522
1588
  const stop = (event) => event.stopPropagation();
1523
1589
  return /* @__PURE__ */ jsxs17(PopoverPrimitive2.Root, { open, onOpenChange: handleOpenChange, children: [
1524
- /* @__PURE__ */ jsx25(PopoverPrimitive2.Trigger, { asChild: true, children: /* @__PURE__ */ jsx25("span", { ref, "data-mark": true, role: "button", tabIndex: -1, onClick: stop, style, className: cn(markClasses, "cursor-pointer hover:bg-destructive-soft"), children: text }) }),
1590
+ layers,
1591
+ /* @__PURE__ */ jsx25(PopoverPrimitive2.Trigger, { asChild: true, children: /* @__PURE__ */ jsx25(
1592
+ "span",
1593
+ {
1594
+ ref,
1595
+ "data-mark": true,
1596
+ "data-tone": mark.tone ?? "destructive",
1597
+ role: "button",
1598
+ tabIndex: -1,
1599
+ onClick: stop,
1600
+ onMouseEnter: () => setHovered(true),
1601
+ onMouseLeave: () => setHovered(false),
1602
+ className: "relative cursor-pointer",
1603
+ children: text
1604
+ }
1605
+ ) }),
1525
1606
  /* @__PURE__ */ jsx25(PopoverPrimitive2.Portal, { children: /* @__PURE__ */ jsxs17(
1526
1607
  PopoverPrimitive2.Content,
1527
1608
  {
@@ -1536,18 +1617,19 @@ function MarkedText({ mark, text, onApply, onDismiss }) {
1536
1617
  suggestions.length > 1 && onApply ? (
1537
1618
  // Several possible fixes: each one is a choice, applied with a click, so there is no Apply button.
1538
1619
  /* @__PURE__ */ jsx25("div", { className: "flex flex-col gap-1", role: "group", "aria-label": "Choose a correction", children: suggestions.map((suggestion) => /* @__PURE__ */ jsxs17(Button, { type: "button", size: "sm", variant: "ghost", className: "h-auto justify-start px-2 py-1 whitespace-normal", onClick: () => onApply(mark, suggestion), children: [
1539
- /* @__PURE__ */ jsx25("s", { className: "text-destructive-foreground", children: text }),
1620
+ /* @__PURE__ */ jsx25("s", { className: struck, children: text }),
1540
1621
  " ",
1541
1622
  /* @__PURE__ */ jsx25("span", { className: "font-semibold text-accent-foreground", children: suggestion === "" ? "Remove" : suggestion })
1542
1623
  ] }, suggestion)) })
1543
1624
  ) : suggestions.length > 0 && /* @__PURE__ */ jsxs17("p", { className: "min-w-0 break-words", children: [
1544
- /* @__PURE__ */ jsx25("s", { className: "text-destructive-foreground", children: text }),
1625
+ /* @__PURE__ */ jsx25("s", { className: struck, children: text }),
1545
1626
  suggestions[0] !== "" && /* @__PURE__ */ jsxs17(Fragment4, { children: [
1546
1627
  " ",
1547
1628
  /* @__PURE__ */ jsx25("span", { className: "font-semibold text-accent-foreground", children: suggestions[0] })
1548
1629
  ] })
1549
1630
  ] }),
1550
- /* @__PURE__ */ jsxs17("div", { className: "flex items-center justify-between gap-3", children: [
1631
+ mark.message && /* @__PURE__ */ jsx25("p", { className: "min-w-0 break-words text-body-small text-surface-foreground", children: mark.message }),
1632
+ /* @__PURE__ */ jsxs17("div", { className: cn("flex items-center gap-3", warning ? "justify-end" : "justify-between"), children: [
1551
1633
  onDismiss ? /* @__PURE__ */ jsxs17(Button, { type: "button", size: "sm", variant: "ghost", onClick: () => onDismiss(mark), children: [
1552
1634
  /* @__PURE__ */ jsx25(Trash2, { size: 16, "aria-hidden": true }),
1553
1635
  " Dismiss"
@@ -1600,6 +1682,8 @@ var InlineEdit = React25.forwardRef(
1600
1682
  const [error, setError] = React25.useState(null);
1601
1683
  const errorId = React25.useId();
1602
1684
  const fieldRef = React25.useRef(null);
1685
+ const [scroll, setScroll] = React25.useState(0);
1686
+ const [draftMarks, setDraftMarks] = React25.useState([]);
1603
1687
  const readRef = React25.useRef(null);
1604
1688
  const cancelled = React25.useRef(false);
1605
1689
  const restoreFocus = React25.useRef(false);
@@ -1621,6 +1705,7 @@ var InlineEdit = React25.forwardRef(
1621
1705
  const start = () => {
1622
1706
  if (disabled) return;
1623
1707
  setDraft(value);
1708
+ setDraftMarks(marks ?? []);
1624
1709
  setError(null);
1625
1710
  cancelled.current = false;
1626
1711
  setEditing(true);
@@ -1646,6 +1731,7 @@ var InlineEdit = React25.forwardRef(
1646
1731
  };
1647
1732
  const textClasses = cn("text-ui-input-value text-surface-foreground", textClassName);
1648
1733
  const question = variant === "question";
1734
+ const draftMarksClass = cn("px-3 py-1", question ? "border-0 border-b-2 border-transparent" : "border border-transparent", multiline ? "whitespace-pre-wrap break-words" : "whitespace-pre", textClasses);
1649
1735
  const fill = multiline || question;
1650
1736
  return /* @__PURE__ */ jsx26(
1651
1737
  "div",
@@ -1654,39 +1740,68 @@ var InlineEdit = React25.forwardRef(
1654
1740
  className: cn(fill ? "flex w-full min-w-0" : "inline-flex min-w-0 max-w-full", editing && (error || showLimits) && "flex-col gap-1.5", className),
1655
1741
  ...props,
1656
1742
  children: editing ? /* @__PURE__ */ jsxs18(Fragment5, { children: [
1657
- React25.createElement(multiline ? "textarea" : "input", {
1658
- ref: fieldRef,
1659
- value: draft,
1660
- maxLength,
1661
- "aria-label": ariaLabel,
1662
- "aria-invalid": error ? true : void 0,
1663
- "aria-describedby": error || showLimits ? errorId : void 0,
1664
- ...multiline ? { rows: 1 } : { type: "text" },
1665
- className: cn(
1666
- "w-full px-3 py-1 outline-none",
1667
- multiline && "field-sizing-content resize-none",
1668
- question ? cn("rounded-none border-0 border-b-2 bg-transparent", error ? "border-destructive" : "border-accent-muted") : cn("rounded-md", !error && "focus-visible:border-input-accent", fieldSurfaceClasses(error ? "error" : "default")),
1669
- textClasses
1743
+ /* @__PURE__ */ jsxs18("div", { className: cn("relative flex w-full min-w-0", draftMarks.length > 0 && !question && "rounded-md bg-surface"), children: [
1744
+ draftMarks.length > 0 && /* @__PURE__ */ jsx26(
1745
+ DraftMarks,
1746
+ {
1747
+ layer: "behind",
1748
+ singleLine: !multiline,
1749
+ text: draft,
1750
+ marks: draftMarks,
1751
+ scrollLeft: multiline ? 0 : scroll,
1752
+ className: draftMarksClass
1753
+ }
1670
1754
  ),
1671
- onChange: (event) => {
1672
- setDraft(event.target.value);
1673
- if (error) setError(problemWith(event.target.value));
1674
- onDraftChange?.(event.target.value);
1675
- },
1676
- onKeyDown: (event) => {
1677
- if (event.key === "Escape") {
1678
- cancelled.current = true;
1679
- setError(null);
1680
- finish(false, true);
1681
- } else if (event.key === "Enter" && (!multiline || event.metaKey || event.ctrlKey || (question || submitOnEnter) && !event.shiftKey)) {
1682
- event.preventDefault();
1683
- finish(true, true);
1755
+ React25.createElement(multiline ? "textarea" : "input", {
1756
+ ref: fieldRef,
1757
+ value: draft,
1758
+ maxLength,
1759
+ "aria-label": ariaLabel,
1760
+ "aria-invalid": error ? true : void 0,
1761
+ "aria-describedby": error || showLimits ? errorId : void 0,
1762
+ ...multiline ? { rows: 1 } : { type: "text" },
1763
+ className: cn(
1764
+ "relative w-full px-3 py-1 outline-none",
1765
+ multiline && "field-sizing-content resize-none",
1766
+ question ? cn("rounded-none border-0 border-b-2 bg-transparent", error ? "border-destructive" : "border-accent-muted") : cn("rounded-md", !error && "focus-visible:border-input-accent", fieldSurfaceClasses(error ? "error" : "default")),
1767
+ textClasses,
1768
+ // Transparent over the highlight layer, so the highlight and the browser's text selection show together.
1769
+ draftMarks.length > 0 && "bg-transparent"
1770
+ ),
1771
+ onChange: (event) => {
1772
+ setDraft(event.target.value);
1773
+ setDraftMarks(remapMarks(draft, event.target.value, draftMarks));
1774
+ requestAnimationFrame(() => setScroll(fieldRef.current?.scrollLeft ?? 0));
1775
+ if (error) setError(problemWith(event.target.value));
1776
+ onDraftChange?.(event.target.value);
1777
+ },
1778
+ onKeyDown: (event) => {
1779
+ if (event.key === "Escape") {
1780
+ cancelled.current = true;
1781
+ setError(null);
1782
+ finish(false, true);
1783
+ } else if (event.key === "Enter" && (!multiline || event.metaKey || event.ctrlKey || (question || submitOnEnter) && !event.shiftKey)) {
1784
+ event.preventDefault();
1785
+ finish(true, true);
1786
+ }
1787
+ },
1788
+ onScroll: (event) => setScroll(event.currentTarget.scrollLeft),
1789
+ onBlur: () => {
1790
+ if (!cancelled.current) finish(true, false);
1684
1791
  }
1685
- },
1686
- onBlur: () => {
1687
- if (!cancelled.current) finish(true, false);
1688
- }
1689
- }),
1792
+ }),
1793
+ draftMarks.length > 0 && /* @__PURE__ */ jsx26(
1794
+ DraftMarks,
1795
+ {
1796
+ layer: "over",
1797
+ singleLine: !multiline,
1798
+ text: draft,
1799
+ marks: draftMarks,
1800
+ scrollLeft: multiline ? 0 : scroll,
1801
+ className: draftMarksClass
1802
+ }
1803
+ )
1804
+ ] }),
1690
1805
  (error || showLimits) && /* @__PURE__ */ jsxs18(
1691
1806
  "p",
1692
1807
  {
@@ -2220,7 +2335,7 @@ import * as React34 from "react";
2220
2335
  import { CheckCircle as CheckCircle2, Info, Warning, WarningCircle as WarningCircle3, X as X4 } from "@phosphor-icons/react";
2221
2336
  import { cva as cva4 } from "class-variance-authority";
2222
2337
  import { Toast as ToastPrimitive } from "radix-ui";
2223
- import { jsx as jsx35, jsxs as jsxs25 } from "react/jsx-runtime";
2338
+ import { Fragment as Fragment6, jsx as jsx35, jsxs as jsxs25 } from "react/jsx-runtime";
2224
2339
  var toastVariants = cva4("border", {
2225
2340
  variants: {
2226
2341
  variant: {
@@ -2308,19 +2423,25 @@ var Toast = React34.forwardRef(
2308
2423
  Toast.displayName = "Toast";
2309
2424
  var ToastAction = ToastPrimitive.Action;
2310
2425
  var ToastInline = React34.forwardRef(
2311
- ({ className, variant = "info", actions, onClose, closeLabel = "Close", children, ...props }, ref) => {
2426
+ ({ className, variant = "info", actions, actionsPlacement = "end", onClose, closeLabel = "Close", children, ...props }, ref) => {
2312
2427
  const v = variant ?? "info";
2428
+ const below = actionsPlacement === "bottom" && !!actions;
2313
2429
  return /* @__PURE__ */ jsxs25(
2314
2430
  "div",
2315
2431
  {
2316
2432
  ref,
2317
2433
  role: v === "destructive" ? "alert" : "status",
2318
- className: cn("flex items-center gap-2 rounded-sm px-2 py-1.5", inlineVariants({ variant: v }), className),
2434
+ className: cn("flex gap-2 rounded-sm px-2 py-1.5", below ? "items-start" : "items-center", inlineVariants({ variant: v }), className),
2319
2435
  ...props,
2320
2436
  children: [
2321
- /* @__PURE__ */ jsx35(VariantIcon, { variant: v === "neutral" ? "info" : v, size: 16 }),
2322
- /* @__PURE__ */ jsx35("p", { className: "min-w-0 flex-1 text-body-small text-secondary-muted-foreground", children }),
2323
- actions && /* @__PURE__ */ jsx35("div", { className: "flex shrink-0 items-center gap-2", children: actions }),
2437
+ /* @__PURE__ */ jsx35("span", { className: cn("inline-flex shrink-0", below && "mt-0.5"), children: /* @__PURE__ */ jsx35(VariantIcon, { variant: v === "neutral" ? "info" : v, size: 16 }) }),
2438
+ below ? /* @__PURE__ */ jsxs25("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [
2439
+ /* @__PURE__ */ jsx35("p", { className: "text-body-small text-secondary-muted-foreground", children }),
2440
+ /* @__PURE__ */ jsx35("div", { className: "flex items-center gap-2", children: actions })
2441
+ ] }) : /* @__PURE__ */ jsxs25(Fragment6, { children: [
2442
+ /* @__PURE__ */ jsx35("p", { className: "min-w-0 flex-1 text-body-small text-secondary-muted-foreground", children }),
2443
+ actions && /* @__PURE__ */ jsx35("div", { className: "flex shrink-0 items-center gap-2", children: actions })
2444
+ ] }),
2324
2445
  onClose && /* @__PURE__ */ jsx35(Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": closeLabel, onClick: onClose, children: /* @__PURE__ */ jsx35(X4, { size: 16, "aria-hidden": true }) })
2325
2446
  ]
2326
2447
  }
@@ -2332,7 +2453,7 @@ ToastInline.displayName = "ToastInline";
2332
2453
  // src/components/Overlays & Feedback/Tooltip.tsx
2333
2454
  import * as React35 from "react";
2334
2455
  import { Tooltip as TooltipPrimitive } from "radix-ui";
2335
- import { Fragment as Fragment6, jsx as jsx36, jsxs as jsxs26 } from "react/jsx-runtime";
2456
+ import { Fragment as Fragment7, jsx as jsx36, jsxs as jsxs26 } from "react/jsx-runtime";
2336
2457
  var TooltipProvider = TooltipPrimitive.Provider;
2337
2458
  var Tooltip = TooltipPrimitive.Root;
2338
2459
  var TooltipTrigger = TooltipPrimitive.Trigger;
@@ -2353,7 +2474,7 @@ var TooltipContent = React35.forwardRef(
2353
2474
  ),
2354
2475
  ...props,
2355
2476
  children: [
2356
- detailed ? /* @__PURE__ */ jsxs26(Fragment6, { children: [
2477
+ detailed ? /* @__PURE__ */ jsxs26(Fragment7, { children: [
2357
2478
  title != null && /* @__PURE__ */ jsx36("p", { className: "text-xs leading-4 font-semibold text-label", children: title }),
2358
2479
  description != null && /* @__PURE__ */ jsx36("p", { className: "text-xs leading-4.5 text-plum-200", children: description }),
2359
2480
  action != null && /* @__PURE__ */ jsx36("div", { className: "mt-1 text-ui-caption text-plum-300 underline *:underline", children: action })
@@ -2412,7 +2533,7 @@ var StatusTag = React36.forwardRef(
2412
2533
  StatusTag.displayName = "StatusTag";
2413
2534
 
2414
2535
  // src/components/Question Types/FileUpload.tsx
2415
- import { Fragment as Fragment7, jsx as jsx38, jsxs as jsxs28 } from "react/jsx-runtime";
2536
+ import { Fragment as Fragment8, jsx as jsx38, jsxs as jsxs28 } from "react/jsx-runtime";
2416
2537
  var FileUploadZone = React37.forwardRef(
2417
2538
  ({ className, title = "Upload document", hint, icon, onFiles, ...props }, ref) => {
2418
2539
  const [over, setOver] = React37.useState(false);
@@ -2479,7 +2600,7 @@ var FileUploadItem = React37.forwardRef(
2479
2600
  size,
2480
2601
  status === "complete" && /* @__PURE__ */ jsx38(Tag, { variant: "success", children: "Complete" }),
2481
2602
  status === "error" && /* @__PURE__ */ jsx38(Tag, { variant: "destructive", children: "Error" }),
2482
- uploading && timeLeft && /* @__PURE__ */ jsxs28(Fragment7, { children: [
2603
+ uploading && timeLeft && /* @__PURE__ */ jsxs28(Fragment8, { children: [
2483
2604
  /* @__PURE__ */ jsx38("span", { "aria-hidden": "true", className: "size-0.5 rounded-full bg-secondary-muted-foreground" }),
2484
2605
  timeLeft
2485
2606
  ] })
@@ -2797,13 +2918,16 @@ import { DotsSixVertical } from "@phosphor-icons/react";
2797
2918
 
2798
2919
  // src/components/Question Types/QuestionTypeIcon.tsx
2799
2920
  import "react";
2800
- import { ChatsCircle, CheckSquare, FileArrowUp, ListNumbers, RadioButton, StarHalf, VideoCamera } from "@phosphor-icons/react";
2921
+ import { ChatsCircle, CheckSquare, FileArrowUp, FileText as FileText2, Image, ListNumbers, RadioButton, StarHalf, VideoCamera } from "@phosphor-icons/react";
2801
2922
  import { jsx as jsx42 } from "react/jsx-runtime";
2802
2923
  var icons = {
2803
2924
  "select-one": RadioButton,
2804
2925
  "select-multiple": CheckSquare,
2805
2926
  ranking: ListNumbers,
2806
2927
  upload: FileArrowUp,
2928
+ "upload-video": VideoCamera,
2929
+ "upload-photo": Image,
2930
+ "upload-document": FileText2,
2807
2931
  rating: StarHalf,
2808
2932
  "open-end": ChatsCircle,
2809
2933
  "screen-recording": VideoCamera
@@ -2924,7 +3048,7 @@ var QuestionHeader = React42.forwardRef(
2924
3048
  QuestionHeader.displayName = "QuestionHeader";
2925
3049
 
2926
3050
  // src/components/Question Types/QuestionEditorCard.tsx
2927
- import { Fragment as Fragment9, jsx as jsx44, jsxs as jsxs31 } from "react/jsx-runtime";
3051
+ import { Fragment as Fragment10, jsx as jsx44, jsxs as jsxs31 } from "react/jsx-runtime";
2928
3052
  var QuestionEditorCard = React43.forwardRef(
2929
3053
  ({
2930
3054
  className,
@@ -3004,7 +3128,7 @@ var QuestionEditorCard = React43.forwardRef(
3004
3128
  onTitleMarkDismiss,
3005
3129
  meta,
3006
3130
  maxLength,
3007
- actions: actions ?? /* @__PURE__ */ jsxs31(Fragment9, { children: [
3131
+ actions: actions ?? /* @__PURE__ */ jsxs31(Fragment10, { children: [
3008
3132
  /* @__PURE__ */ jsx44(
3009
3133
  Button,
3010
3134
  {
@@ -3141,7 +3265,7 @@ QuestionNavItem.displayName = "QuestionNavItem";
3141
3265
  // src/components/Question Types/QuestionOption.tsx
3142
3266
  import * as React45 from "react";
3143
3267
  import { Check as Check4, DotsSixVertical as DotsSixVertical3, Plus as Plus4, Trash as Trash5, WarningCircle as WarningCircle4 } from "@phosphor-icons/react";
3144
- import { Fragment as Fragment10, jsx as jsx46, jsxs as jsxs33 } from "react/jsx-runtime";
3268
+ import { Fragment as Fragment11, jsx as jsx46, jsxs as jsxs33 } from "react/jsx-runtime";
3145
3269
  var optionClasses = "flex w-full max-w-150 cursor-pointer items-center gap-2 rounded-md border border-border bg-surface px-4 py-2 text-body-base text-surface-foreground transition-colors hover:bg-accent-soft hover:shadow-md has-[[data-state=checked]]:border-accent-foreground has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50";
3146
3270
  function QuestionOption(props) {
3147
3271
  const id = React45.useId();
@@ -3209,6 +3333,9 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
3209
3333
  const [focused, setFocused] = React45.useState(false);
3210
3334
  const showMarks = !!marks?.length && !focused && draft === null;
3211
3335
  const fieldRef = React45.useRef(null);
3336
+ const [editMarks, setEditMarks] = React45.useState([]);
3337
+ const [scroll, setScroll] = React45.useState(0);
3338
+ const typed = guarded ? draft ?? label : label;
3212
3339
  const skipBlur = React45.useRef(false);
3213
3340
  const problemWith = (text) => minLength !== void 0 && text.trim().length < minLength ? `Enter at least ${minLength} ${minLength === 1 ? "character" : "characters"}.` : null;
3214
3341
  const save = () => {
@@ -3243,7 +3370,7 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
3243
3370
  ) : "border-border hover:border-input-muted hover:shadow-md"
3244
3371
  ),
3245
3372
  children: /* @__PURE__ */ jsxs33("div", { className: "flex min-w-0 items-start gap-2", children: [
3246
- (kind !== void 0 || !locked) && /* @__PURE__ */ jsx46("div", { className: "flex h-7 shrink-0 items-center gap-2", children: kind === "rank" ? /* @__PURE__ */ jsxs33(Fragment10, { children: [
3373
+ (kind !== void 0 || !locked) && /* @__PURE__ */ jsx46("div", { className: "flex h-7 shrink-0 items-center gap-2", children: kind === "rank" ? /* @__PURE__ */ jsxs33(Fragment11, { children: [
3247
3374
  !locked && grip,
3248
3375
  /* @__PURE__ */ jsx46(
3249
3376
  "span",
@@ -3279,6 +3406,7 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
3279
3406
  ] }) : locked ? null : grip }),
3280
3407
  /* @__PURE__ */ jsxs33("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
3281
3408
  /* @__PURE__ */ jsxs33("div", { className: "relative min-w-0", children: [
3409
+ focused && editMarks.length > 0 && /* @__PURE__ */ jsx46(DraftMarks, { layer: "behind", singleLine: true, text: typed, marks: editMarks, scrollLeft: scroll, className: "flex items-center whitespace-pre text-body-base" }),
3282
3410
  /* @__PURE__ */ jsx46(
3283
3411
  "input",
3284
3412
  {
@@ -3291,13 +3419,17 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
3291
3419
  value: guarded ? draft ?? label : label,
3292
3420
  onFocus: () => {
3293
3421
  setFocused(true);
3422
+ setEditMarks(marks ?? []);
3294
3423
  if (guarded && draft === null) setDraft(label);
3295
3424
  },
3296
3425
  onChange: (event) => {
3426
+ requestAnimationFrame(() => setScroll(fieldRef.current?.scrollLeft ?? 0));
3427
+ setEditMarks(remapMarks(typed, event.target.value, editMarks));
3297
3428
  if (!guarded) return onLabelChange?.(event.target.value);
3298
3429
  setDraft(event.target.value);
3299
3430
  if (error) setError(problemWith(event.target.value));
3300
3431
  },
3432
+ onScroll: (event) => setScroll(event.currentTarget.scrollLeft),
3301
3433
  onKeyDown: (event) => {
3302
3434
  if (!guarded) return;
3303
3435
  if (event.key === "Escape") {
@@ -3323,13 +3455,14 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
3323
3455
  save();
3324
3456
  },
3325
3457
  className: cn(
3326
- "w-full min-w-0 bg-transparent text-body-base text-surface-foreground outline-none",
3458
+ "relative w-full min-w-0 bg-transparent text-body-base text-surface-foreground outline-none",
3327
3459
  placeholderTone === "regular" ? "placeholder:text-surface-foreground" : "placeholder:text-muted-foreground",
3328
3460
  // The marked text is drawn over the field, so the field's own letters step aside until it is edited.
3329
3461
  showMarks && "text-transparent"
3330
3462
  )
3331
3463
  }
3332
3464
  ),
3465
+ focused && editMarks.length > 0 && /* @__PURE__ */ jsx46(DraftMarks, { layer: "over", singleLine: true, text: typed, marks: editMarks, scrollLeft: scroll, className: "flex items-center whitespace-pre text-body-base" }),
3333
3466
  showMarks && /* @__PURE__ */ jsx46("div", { "aria-hidden": true, className: "pointer-events-none absolute inset-0 flex items-center overflow-hidden whitespace-pre text-body-base text-surface-foreground [&_[data-mark]]:pointer-events-auto", children: splitMarks(label, marks).map(
3334
3467
  (piece, i) => piece.mark ? /* @__PURE__ */ jsx46(MarkedText, { mark: piece.mark, text: piece.text, onApply: onMarkApply, onDismiss: onMarkDismiss }, `${piece.mark.start}:${piece.text}`) : /* @__PURE__ */ jsx46("span", { children: piece.text }, i)
3335
3468
  ) })
@@ -3376,7 +3509,7 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
3376
3509
  // src/components/Question Types/RankList.tsx
3377
3510
  import * as React46 from "react";
3378
3511
  import { DotsSixVertical as DotsSixVertical4 } from "@phosphor-icons/react";
3379
- import { Fragment as Fragment11, jsx as jsx47, jsxs as jsxs34 } from "react/jsx-runtime";
3512
+ import { Fragment as Fragment12, jsx as jsx47, jsxs as jsxs34 } from "react/jsx-runtime";
3380
3513
  function move(list, from, to) {
3381
3514
  if (from === to || to < 0 || to >= list.length) return list;
3382
3515
  const next = list.slice();
@@ -3403,7 +3536,7 @@ var RankList = React46.forwardRef(
3403
3536
  setAnnouncement(`Moved to position ${to + 1} of ${items.length}`);
3404
3537
  onItemsChange(next);
3405
3538
  };
3406
- return /* @__PURE__ */ jsxs34(Fragment11, { children: [
3539
+ return /* @__PURE__ */ jsxs34(Fragment12, { children: [
3407
3540
  /* @__PURE__ */ jsx47("ol", { ref, className: cn("flex w-full max-w-150 flex-col gap-4", className), ...props, children: items.map((item, index) => /* @__PURE__ */ jsxs34(
3408
3541
  "li",
3409
3542
  {
@@ -3769,12 +3902,13 @@ var statCardVariants = cva6("flex min-w-0 flex-col gap-2 rounded-md border p-3",
3769
3902
  defaultVariants: { variant: "default" }
3770
3903
  });
3771
3904
  var StatCard = React51.forwardRef(
3772
- ({ className, variant, label, value, icon, ...props }, ref) => /* @__PURE__ */ jsxs39("div", { ref, className: cn(statCardVariants({ variant }), className), ...props, children: [
3905
+ ({ className, variant, label, value, icon, caption, ...props }, ref) => /* @__PURE__ */ jsxs39("div", { ref, className: cn(statCardVariants({ variant }), className), ...props, children: [
3773
3906
  /* @__PURE__ */ jsx52("p", { className: "truncate text-ui-caption text-secondary-muted-foreground", children: label }),
3774
3907
  /* @__PURE__ */ jsxs39("p", { className: "flex items-center gap-2 text-body-base text-surface-foreground", children: [
3775
3908
  icon && /* @__PURE__ */ jsx52("span", { "aria-hidden": "true", className: "inline-flex size-6 shrink-0 items-center justify-center", children: icon }),
3776
3909
  value
3777
- ] })
3910
+ ] }),
3911
+ caption && /* @__PURE__ */ jsx52("p", { className: "text-ui-caption text-secondary-muted-foreground", children: caption })
3778
3912
  ] })
3779
3913
  );
3780
3914
  StatCard.displayName = "StatCard";