@discuss-ds/ui 0.32.0 → 0.34.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/CHANGELOG.md +36 -0
- package/dist/index.cjs +1163 -209
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +246 -10
- package/dist/index.d.ts +246 -10
- package/dist/index.js +1206 -207
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
- package/src/styles/globals.css +1 -0
package/dist/index.js
CHANGED
|
@@ -39,6 +39,9 @@ var twMerge = extendTailwindMerge({
|
|
|
39
39
|
function cn(...inputs) {
|
|
40
40
|
return twMerge(clsx(inputs));
|
|
41
41
|
}
|
|
42
|
+
function lengthOutOfRange(text, min, max) {
|
|
43
|
+
return min !== void 0 && text.trim().length < min || max !== void 0 && text.length > max;
|
|
44
|
+
}
|
|
42
45
|
|
|
43
46
|
// src/components/Buttons & Actions/Button.tsx
|
|
44
47
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -1461,37 +1464,96 @@ function splitMarks(text, marks) {
|
|
|
1461
1464
|
if (at < text.length) out.push({ text: text.slice(at) });
|
|
1462
1465
|
return out;
|
|
1463
1466
|
}
|
|
1464
|
-
var
|
|
1465
|
-
function
|
|
1466
|
-
const
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
const
|
|
1470
|
-
|
|
1471
|
-
const
|
|
1472
|
-
|
|
1467
|
+
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"));
|
|
1468
|
+
function markLines(rects, origin, field) {
|
|
1469
|
+
const count = field ? Math.max(1, Math.round((field.contentBottom - field.contentTop) / field.lineHeight)) : 1;
|
|
1470
|
+
const boxes = rects.filter((r) => r.width > 0).map((r) => {
|
|
1471
|
+
if (!field) return { left: r.left - origin.left, top: r.top - origin.top, width: r.width, height: r.height };
|
|
1472
|
+
const index = Math.min(count - 1, Math.max(0, Math.floor((r.top + r.height / 2 - field.contentTop) / field.lineHeight)));
|
|
1473
|
+
const top = index === 0 ? field.top : field.contentTop + index * field.lineHeight;
|
|
1474
|
+
const bottom = index === count - 1 ? field.bottom : field.contentTop + (index + 1) * field.lineHeight;
|
|
1475
|
+
return { left: r.left - origin.left, top: top - origin.top, width: r.width, height: bottom - top };
|
|
1476
|
+
});
|
|
1477
|
+
return boxes.reduce((out, box) => {
|
|
1478
|
+
const same = field ? out.find((o) => Math.abs(o.top - box.top) < 0.5 && Math.abs(o.height - box.height) < 0.5) : void 0;
|
|
1479
|
+
if (!same) return [...out, box];
|
|
1480
|
+
const left = Math.min(same.left, box.left);
|
|
1481
|
+
const right = Math.max(same.left + same.width, box.left + box.width);
|
|
1482
|
+
return out.map((o) => o === same ? { ...o, left, width: right - left } : o);
|
|
1483
|
+
}, []);
|
|
1484
|
+
}
|
|
1485
|
+
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));
|
|
1486
|
+
function useMarkLines(anchorRef, markRef) {
|
|
1487
|
+
const [lines, setLines] = React24.useState([]);
|
|
1488
|
+
const measure = React24.useCallback(() => {
|
|
1489
|
+
const anchor = anchorRef.current;
|
|
1490
|
+
const mark = markRef.current;
|
|
1491
|
+
if (!anchor || !mark) return;
|
|
1492
|
+
const button = mark.closest("button");
|
|
1493
|
+
const a = anchor.getBoundingClientRect();
|
|
1494
|
+
let field;
|
|
1495
|
+
if (button) {
|
|
1473
1496
|
const b = button.getBoundingClientRect();
|
|
1474
|
-
const
|
|
1475
|
-
const
|
|
1476
|
-
const
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
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);
|
|
1497
|
+
const style = getComputedStyle(button);
|
|
1498
|
+
const contentTop = b.top + (parseFloat(style.borderTopWidth) || 0) + (parseFloat(style.paddingTop) || 0);
|
|
1499
|
+
const contentBottom = b.bottom - (parseFloat(style.borderBottomWidth) || 0) - (parseFloat(style.paddingBottom) || 0);
|
|
1500
|
+
field = { top: b.top, bottom: b.bottom, contentTop, contentBottom, lineHeight: parseFloat(style.lineHeight) || contentBottom - contentTop };
|
|
1501
|
+
}
|
|
1502
|
+
const next = markLines([...mark.getClientRects()], a, field);
|
|
1503
|
+
setLines((prev) => sameLines(prev, next) ? prev : next);
|
|
1504
|
+
}, [anchorRef, markRef]);
|
|
1505
|
+
React24.useLayoutEffect(measure);
|
|
1506
|
+
React24.useLayoutEffect(() => {
|
|
1507
|
+
const button = markRef.current?.closest("button");
|
|
1508
|
+
if (!button) return;
|
|
1509
|
+
const observer = new ResizeObserver(measure);
|
|
1491
1510
|
observer.observe(button);
|
|
1492
1511
|
return () => observer.disconnect();
|
|
1493
|
-
}, [
|
|
1494
|
-
return
|
|
1512
|
+
}, [markRef, measure]);
|
|
1513
|
+
return lines;
|
|
1514
|
+
}
|
|
1515
|
+
function remapMarks(saved, draft, marks) {
|
|
1516
|
+
if (!marks?.length) return [];
|
|
1517
|
+
if (saved === draft) return marks;
|
|
1518
|
+
const max = Math.min(saved.length, draft.length);
|
|
1519
|
+
let before = 0;
|
|
1520
|
+
while (before < max && saved[before] === draft[before]) before += 1;
|
|
1521
|
+
let after = 0;
|
|
1522
|
+
while (after < max - before && saved[saved.length - 1 - after] === draft[draft.length - 1 - after]) after += 1;
|
|
1523
|
+
const editEnd = saved.length - after;
|
|
1524
|
+
const delta = draft.length - saved.length;
|
|
1525
|
+
return marks.flatMap((m) => m.end <= before ? [m] : m.start >= editEnd ? [{ ...m, start: m.start + delta, end: m.end + delta }] : []);
|
|
1526
|
+
}
|
|
1527
|
+
function DraftMarks({ text, marks, layer, className, scrollLeft = 0, singleLine }) {
|
|
1528
|
+
const rootRef = React24.useRef(null);
|
|
1529
|
+
const textRef = React24.useRef(null);
|
|
1530
|
+
const [boxes, setBoxes] = React24.useState([]);
|
|
1531
|
+
React24.useLayoutEffect(() => {
|
|
1532
|
+
if (textRef.current) textRef.current.scrollLeft = scrollLeft;
|
|
1533
|
+
}, [scrollLeft, text]);
|
|
1534
|
+
React24.useLayoutEffect(() => {
|
|
1535
|
+
const root = rootRef.current;
|
|
1536
|
+
const mirror = textRef.current;
|
|
1537
|
+
if (!root || !mirror) return;
|
|
1538
|
+
const r = root.getBoundingClientRect();
|
|
1539
|
+
const style = getComputedStyle(mirror);
|
|
1540
|
+
const contentTop = r.top + (parseFloat(style.borderTopWidth) || 0) + (parseFloat(style.paddingTop) || 0);
|
|
1541
|
+
const contentBottom = r.bottom - (parseFloat(style.borderBottomWidth) || 0) - (parseFloat(style.paddingBottom) || 0);
|
|
1542
|
+
const lineHeight = singleLine ? contentBottom - contentTop : parseFloat(style.lineHeight) || contentBottom - contentTop;
|
|
1543
|
+
const field = { top: r.top, bottom: r.bottom, contentTop, contentBottom, lineHeight };
|
|
1544
|
+
const next = [...mirror.querySelectorAll("[data-draft-mark]")].flatMap(
|
|
1545
|
+
(el) => markLines([...el.getClientRects()], { left: r.left, top: r.top }, field).map((box) => ({ tone: el.dataset.tone ?? "destructive", box }))
|
|
1546
|
+
);
|
|
1547
|
+
setBoxes((prev) => prev.length === next.length && prev.every((p, i) => p.tone === next[i].tone && sameLines([p.box], [next[i].box])) ? prev : next);
|
|
1548
|
+
});
|
|
1549
|
+
return /* @__PURE__ */ jsxs17("div", { ref: rootRef, "aria-hidden": true, "data-draft-marks": true, "data-layer": layer, className: "pointer-events-none absolute inset-0", children: [
|
|
1550
|
+
/* @__PURE__ */ jsx25("div", { ref: textRef, className: cn(className, "absolute inset-0 overflow-hidden text-transparent"), children: splitMarks(text, marks).map(
|
|
1551
|
+
(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)
|
|
1552
|
+
) }),
|
|
1553
|
+
/* @__PURE__ */ jsx25("div", { className: "absolute inset-0", style: { clipPath: "inset(-4px 0)" }, children: boxes.map(
|
|
1554
|
+
({ 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)
|
|
1555
|
+
) })
|
|
1556
|
+
] });
|
|
1495
1557
|
}
|
|
1496
1558
|
var closeOpenMarkCard = null;
|
|
1497
1559
|
function MarkedText({ mark, text, onApply, onDismiss }) {
|
|
@@ -1504,12 +1566,19 @@ function MarkedText({ mark, text, onApply, onDismiss }) {
|
|
|
1504
1566
|
},
|
|
1505
1567
|
[close]
|
|
1506
1568
|
);
|
|
1507
|
-
const
|
|
1508
|
-
const
|
|
1569
|
+
const anchorRef = React24.useRef(null);
|
|
1570
|
+
const [hovered, setHovered] = React24.useState(false);
|
|
1571
|
+
const lines = useMarkLines(anchorRef, ref);
|
|
1572
|
+
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
1573
|
if (!onApply && !onDismiss) {
|
|
1510
|
-
return /* @__PURE__ */
|
|
1574
|
+
return /* @__PURE__ */ jsxs17(Fragment4, { children: [
|
|
1575
|
+
layers,
|
|
1576
|
+
/* @__PURE__ */ jsx25("span", { ref, "data-mark": true, "data-tone": mark.tone ?? "destructive", className: "relative", children: text })
|
|
1577
|
+
] });
|
|
1511
1578
|
}
|
|
1512
1579
|
const suggestions = (mark.suggestions ?? []).slice(0, 3);
|
|
1580
|
+
const warning = mark.tone === "warning";
|
|
1581
|
+
const struck = "text-destructive-foreground";
|
|
1513
1582
|
const handleOpenChange = (next) => {
|
|
1514
1583
|
if (next) {
|
|
1515
1584
|
if (closeOpenMarkCard && closeOpenMarkCard !== close) closeOpenMarkCard();
|
|
@@ -1521,7 +1590,22 @@ function MarkedText({ mark, text, onApply, onDismiss }) {
|
|
|
1521
1590
|
};
|
|
1522
1591
|
const stop = (event) => event.stopPropagation();
|
|
1523
1592
|
return /* @__PURE__ */ jsxs17(PopoverPrimitive2.Root, { open, onOpenChange: handleOpenChange, children: [
|
|
1524
|
-
|
|
1593
|
+
layers,
|
|
1594
|
+
/* @__PURE__ */ jsx25(PopoverPrimitive2.Trigger, { asChild: true, children: /* @__PURE__ */ jsx25(
|
|
1595
|
+
"span",
|
|
1596
|
+
{
|
|
1597
|
+
ref,
|
|
1598
|
+
"data-mark": true,
|
|
1599
|
+
"data-tone": mark.tone ?? "destructive",
|
|
1600
|
+
role: "button",
|
|
1601
|
+
tabIndex: -1,
|
|
1602
|
+
onClick: stop,
|
|
1603
|
+
onMouseEnter: () => setHovered(true),
|
|
1604
|
+
onMouseLeave: () => setHovered(false),
|
|
1605
|
+
className: "relative cursor-pointer",
|
|
1606
|
+
children: text
|
|
1607
|
+
}
|
|
1608
|
+
) }),
|
|
1525
1609
|
/* @__PURE__ */ jsx25(PopoverPrimitive2.Portal, { children: /* @__PURE__ */ jsxs17(
|
|
1526
1610
|
PopoverPrimitive2.Content,
|
|
1527
1611
|
{
|
|
@@ -1536,18 +1620,19 @@ function MarkedText({ mark, text, onApply, onDismiss }) {
|
|
|
1536
1620
|
suggestions.length > 1 && onApply ? (
|
|
1537
1621
|
// Several possible fixes: each one is a choice, applied with a click, so there is no Apply button.
|
|
1538
1622
|
/* @__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:
|
|
1623
|
+
/* @__PURE__ */ jsx25("s", { className: struck, children: text }),
|
|
1540
1624
|
" ",
|
|
1541
1625
|
/* @__PURE__ */ jsx25("span", { className: "font-semibold text-accent-foreground", children: suggestion === "" ? "Remove" : suggestion })
|
|
1542
1626
|
] }, suggestion)) })
|
|
1543
1627
|
) : suggestions.length > 0 && /* @__PURE__ */ jsxs17("p", { className: "min-w-0 break-words", children: [
|
|
1544
|
-
/* @__PURE__ */ jsx25("s", { className:
|
|
1628
|
+
/* @__PURE__ */ jsx25("s", { className: struck, children: text }),
|
|
1545
1629
|
suggestions[0] !== "" && /* @__PURE__ */ jsxs17(Fragment4, { children: [
|
|
1546
1630
|
" ",
|
|
1547
1631
|
/* @__PURE__ */ jsx25("span", { className: "font-semibold text-accent-foreground", children: suggestions[0] })
|
|
1548
1632
|
] })
|
|
1549
1633
|
] }),
|
|
1550
|
-
/* @__PURE__ */
|
|
1634
|
+
mark.message && /* @__PURE__ */ jsx25("p", { className: "min-w-0 break-words text-body-small text-surface-foreground", children: mark.message }),
|
|
1635
|
+
/* @__PURE__ */ jsxs17("div", { className: cn("flex items-center gap-3", warning ? "justify-end" : "justify-between"), children: [
|
|
1551
1636
|
onDismiss ? /* @__PURE__ */ jsxs17(Button, { type: "button", size: "sm", variant: "ghost", onClick: () => onDismiss(mark), children: [
|
|
1552
1637
|
/* @__PURE__ */ jsx25(Trash2, { size: 16, "aria-hidden": true }),
|
|
1553
1638
|
" Dismiss"
|
|
@@ -1599,7 +1684,10 @@ var InlineEdit = React25.forwardRef(
|
|
|
1599
1684
|
const [draft, setDraft] = React25.useState(value);
|
|
1600
1685
|
const [error, setError] = React25.useState(null);
|
|
1601
1686
|
const errorId = React25.useId();
|
|
1687
|
+
const limitsVisible = !!showLimits && (!!error || lengthOutOfRange(draft, minLength, maxLength));
|
|
1602
1688
|
const fieldRef = React25.useRef(null);
|
|
1689
|
+
const [scroll, setScroll] = React25.useState(0);
|
|
1690
|
+
const [draftMarks, setDraftMarks] = React25.useState([]);
|
|
1603
1691
|
const readRef = React25.useRef(null);
|
|
1604
1692
|
const cancelled = React25.useRef(false);
|
|
1605
1693
|
const restoreFocus = React25.useRef(false);
|
|
@@ -1621,6 +1709,7 @@ var InlineEdit = React25.forwardRef(
|
|
|
1621
1709
|
const start = () => {
|
|
1622
1710
|
if (disabled) return;
|
|
1623
1711
|
setDraft(value);
|
|
1712
|
+
setDraftMarks(marks ?? []);
|
|
1624
1713
|
setError(null);
|
|
1625
1714
|
cancelled.current = false;
|
|
1626
1715
|
setEditing(true);
|
|
@@ -1646,48 +1735,78 @@ var InlineEdit = React25.forwardRef(
|
|
|
1646
1735
|
};
|
|
1647
1736
|
const textClasses = cn("text-ui-input-value text-surface-foreground", textClassName);
|
|
1648
1737
|
const question = variant === "question";
|
|
1738
|
+
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
1739
|
const fill = multiline || question;
|
|
1650
1740
|
return /* @__PURE__ */ jsx26(
|
|
1651
1741
|
"div",
|
|
1652
1742
|
{
|
|
1653
1743
|
ref,
|
|
1654
|
-
className: cn(fill ? "flex w-full min-w-0" : "inline-flex min-w-0 max-w-full", editing && (error ||
|
|
1744
|
+
className: cn(fill ? "flex w-full min-w-0" : "inline-flex min-w-0 max-w-full", editing && (error || limitsVisible) && "flex-col gap-1.5", className),
|
|
1655
1745
|
...props,
|
|
1656
1746
|
children: editing ? /* @__PURE__ */ jsxs18(Fragment5, { children: [
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
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
|
|
1747
|
+
/* @__PURE__ */ jsxs18("div", { className: cn("relative flex w-full min-w-0", draftMarks.length > 0 && !question && "rounded-md bg-surface"), children: [
|
|
1748
|
+
draftMarks.length > 0 && /* @__PURE__ */ jsx26(
|
|
1749
|
+
DraftMarks,
|
|
1750
|
+
{
|
|
1751
|
+
layer: "behind",
|
|
1752
|
+
singleLine: !multiline,
|
|
1753
|
+
text: draft,
|
|
1754
|
+
marks: draftMarks,
|
|
1755
|
+
scrollLeft: multiline ? 0 : scroll,
|
|
1756
|
+
className: draftMarksClass
|
|
1757
|
+
}
|
|
1670
1758
|
),
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1759
|
+
React25.createElement(multiline ? "textarea" : "input", {
|
|
1760
|
+
ref: fieldRef,
|
|
1761
|
+
value: draft,
|
|
1762
|
+
maxLength,
|
|
1763
|
+
"aria-label": ariaLabel,
|
|
1764
|
+
"aria-invalid": error ? true : void 0,
|
|
1765
|
+
"aria-describedby": error || limitsVisible ? errorId : void 0,
|
|
1766
|
+
...multiline ? { rows: 1 } : { type: "text" },
|
|
1767
|
+
className: cn(
|
|
1768
|
+
"relative w-full px-3 py-1 outline-none",
|
|
1769
|
+
multiline && "field-sizing-content resize-none",
|
|
1770
|
+
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")),
|
|
1771
|
+
textClasses,
|
|
1772
|
+
// Transparent over the highlight layer, so the highlight and the browser's text selection show together.
|
|
1773
|
+
draftMarks.length > 0 && "bg-transparent"
|
|
1774
|
+
),
|
|
1775
|
+
onChange: (event) => {
|
|
1776
|
+
setDraft(event.target.value);
|
|
1777
|
+
setDraftMarks(remapMarks(draft, event.target.value, draftMarks));
|
|
1778
|
+
requestAnimationFrame(() => setScroll(fieldRef.current?.scrollLeft ?? 0));
|
|
1779
|
+
if (error) setError(problemWith(event.target.value));
|
|
1780
|
+
onDraftChange?.(event.target.value);
|
|
1781
|
+
},
|
|
1782
|
+
onKeyDown: (event) => {
|
|
1783
|
+
if (event.key === "Escape") {
|
|
1784
|
+
cancelled.current = true;
|
|
1785
|
+
setError(null);
|
|
1786
|
+
finish(false, true);
|
|
1787
|
+
} else if (event.key === "Enter" && (!multiline || event.metaKey || event.ctrlKey || (question || submitOnEnter) && !event.shiftKey)) {
|
|
1788
|
+
event.preventDefault();
|
|
1789
|
+
finish(true, true);
|
|
1790
|
+
}
|
|
1791
|
+
},
|
|
1792
|
+
onScroll: (event) => setScroll(event.currentTarget.scrollLeft),
|
|
1793
|
+
onBlur: () => {
|
|
1794
|
+
if (!cancelled.current) finish(true, false);
|
|
1684
1795
|
}
|
|
1685
|
-
},
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1796
|
+
}),
|
|
1797
|
+
draftMarks.length > 0 && /* @__PURE__ */ jsx26(
|
|
1798
|
+
DraftMarks,
|
|
1799
|
+
{
|
|
1800
|
+
layer: "over",
|
|
1801
|
+
singleLine: !multiline,
|
|
1802
|
+
text: draft,
|
|
1803
|
+
marks: draftMarks,
|
|
1804
|
+
scrollLeft: multiline ? 0 : scroll,
|
|
1805
|
+
className: draftMarksClass
|
|
1806
|
+
}
|
|
1807
|
+
)
|
|
1808
|
+
] }),
|
|
1809
|
+
(error || limitsVisible) && /* @__PURE__ */ jsxs18(
|
|
1691
1810
|
"p",
|
|
1692
1811
|
{
|
|
1693
1812
|
id: errorId,
|
|
@@ -1696,10 +1815,10 @@ var InlineEdit = React25.forwardRef(
|
|
|
1696
1815
|
children: [
|
|
1697
1816
|
/* @__PURE__ */ jsxs18("span", { className: "flex items-start gap-2", children: [
|
|
1698
1817
|
error && /* @__PURE__ */ jsx26(WarningCircle2, { size: 16, "aria-hidden": true, className: "shrink-0" }),
|
|
1699
|
-
|
|
1700
|
-
|
|
1818
|
+
limitsVisible ? limitsText(minLength, maxLength) : error,
|
|
1819
|
+
limitsVisible && error && /* @__PURE__ */ jsx26("span", { className: "sr-only", children: error })
|
|
1701
1820
|
] }),
|
|
1702
|
-
|
|
1821
|
+
limitsVisible && /* @__PURE__ */ jsxs18("span", { "aria-hidden": true, className: "shrink-0 tabular-nums", children: [
|
|
1703
1822
|
draft.length,
|
|
1704
1823
|
maxLength !== void 0 && `/${maxLength}`
|
|
1705
1824
|
] })
|
|
@@ -2908,7 +3027,7 @@ var QuestionHeader = React42.forwardRef(
|
|
|
2908
3027
|
}
|
|
2909
3028
|
),
|
|
2910
3029
|
long && titleRecommendedNote != null && /* @__PURE__ */ jsx43("p", { className: "text-ui-caption text-secondary-muted-foreground", children: titleRecommendedNote }),
|
|
2911
|
-
showCounter && titleMinLength === void 0 && /* @__PURE__ */ jsxs30("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
|
|
3030
|
+
showCounter && titleMinLength === void 0 && maxLength !== void 0 && count > maxLength && /* @__PURE__ */ jsxs30("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
|
|
2912
3031
|
count,
|
|
2913
3032
|
"/",
|
|
2914
3033
|
maxLength,
|
|
@@ -3218,6 +3337,9 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
|
|
|
3218
3337
|
const [focused, setFocused] = React45.useState(false);
|
|
3219
3338
|
const showMarks = !!marks?.length && !focused && draft === null;
|
|
3220
3339
|
const fieldRef = React45.useRef(null);
|
|
3340
|
+
const [editMarks, setEditMarks] = React45.useState([]);
|
|
3341
|
+
const [scroll, setScroll] = React45.useState(0);
|
|
3342
|
+
const typed = guarded ? draft ?? label : label;
|
|
3221
3343
|
const skipBlur = React45.useRef(false);
|
|
3222
3344
|
const problemWith = (text) => minLength !== void 0 && text.trim().length < minLength ? `Enter at least ${minLength} ${minLength === 1 ? "character" : "characters"}.` : null;
|
|
3223
3345
|
const save = () => {
|
|
@@ -3288,6 +3410,7 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
|
|
|
3288
3410
|
] }) : locked ? null : grip }),
|
|
3289
3411
|
/* @__PURE__ */ jsxs33("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
3290
3412
|
/* @__PURE__ */ jsxs33("div", { className: "relative min-w-0", children: [
|
|
3413
|
+
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" }),
|
|
3291
3414
|
/* @__PURE__ */ jsx46(
|
|
3292
3415
|
"input",
|
|
3293
3416
|
{
|
|
@@ -3300,13 +3423,17 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
|
|
|
3300
3423
|
value: guarded ? draft ?? label : label,
|
|
3301
3424
|
onFocus: () => {
|
|
3302
3425
|
setFocused(true);
|
|
3426
|
+
setEditMarks(marks ?? []);
|
|
3303
3427
|
if (guarded && draft === null) setDraft(label);
|
|
3304
3428
|
},
|
|
3305
3429
|
onChange: (event) => {
|
|
3430
|
+
requestAnimationFrame(() => setScroll(fieldRef.current?.scrollLeft ?? 0));
|
|
3431
|
+
setEditMarks(remapMarks(typed, event.target.value, editMarks));
|
|
3306
3432
|
if (!guarded) return onLabelChange?.(event.target.value);
|
|
3307
3433
|
setDraft(event.target.value);
|
|
3308
3434
|
if (error) setError(problemWith(event.target.value));
|
|
3309
3435
|
},
|
|
3436
|
+
onScroll: (event) => setScroll(event.currentTarget.scrollLeft),
|
|
3310
3437
|
onKeyDown: (event) => {
|
|
3311
3438
|
if (!guarded) return;
|
|
3312
3439
|
if (event.key === "Escape") {
|
|
@@ -3332,18 +3459,19 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
|
|
|
3332
3459
|
save();
|
|
3333
3460
|
},
|
|
3334
3461
|
className: cn(
|
|
3335
|
-
"w-full min-w-0 bg-transparent text-body-base text-surface-foreground outline-none",
|
|
3462
|
+
"relative w-full min-w-0 bg-transparent text-body-base text-surface-foreground outline-none",
|
|
3336
3463
|
placeholderTone === "regular" ? "placeholder:text-surface-foreground" : "placeholder:text-muted-foreground",
|
|
3337
3464
|
// The marked text is drawn over the field, so the field's own letters step aside until it is edited.
|
|
3338
3465
|
showMarks && "text-transparent"
|
|
3339
3466
|
)
|
|
3340
3467
|
}
|
|
3341
3468
|
),
|
|
3469
|
+
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" }),
|
|
3342
3470
|
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(
|
|
3343
3471
|
(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)
|
|
3344
3472
|
) })
|
|
3345
3473
|
] }),
|
|
3346
|
-
guarded && draft !== null && /* @__PURE__ */ jsxs33(
|
|
3474
|
+
guarded && draft !== null && (error || lengthOutOfRange(draft, minLength, maxLength)) && /* @__PURE__ */ jsxs33(
|
|
3347
3475
|
"p",
|
|
3348
3476
|
{
|
|
3349
3477
|
id: helperId,
|
|
@@ -3601,7 +3729,7 @@ var StimulusCard = React48.forwardRef(
|
|
|
3601
3729
|
textClassName: "text-body-base"
|
|
3602
3730
|
}
|
|
3603
3731
|
) : /* @__PURE__ */ jsx49("p", { className: "w-full text-body-base [word-break:break-word]", children: caption }),
|
|
3604
|
-
onCaptionChange && showCounter && maxLength !== void 0 && /* @__PURE__ */ jsxs36("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
|
|
3732
|
+
onCaptionChange && showCounter && maxLength !== void 0 && count > maxLength && /* @__PURE__ */ jsxs36("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
|
|
3605
3733
|
count,
|
|
3606
3734
|
"/",
|
|
3607
3735
|
maxLength,
|
|
@@ -3661,7 +3789,7 @@ import * as React50 from "react";
|
|
|
3661
3789
|
import { CaretDown as CaretDown4, CaretUp } from "@phosphor-icons/react";
|
|
3662
3790
|
import { jsx as jsx51, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
3663
3791
|
var Table = React50.forwardRef(
|
|
3664
|
-
({ className, containerClassName, striped, ...props }, ref) => /* @__PURE__ */ jsx51("div", { className: cn("relative w-full overflow-auto rounded-lg border border-border bg-surface", containerClassName), children: /* @__PURE__ */ jsx51(
|
|
3792
|
+
({ className, containerClassName, containerRef, striped, ...props }, ref) => /* @__PURE__ */ jsx51("div", { ref: containerRef, className: cn("relative w-full overflow-auto rounded-lg border border-border bg-surface", containerClassName), children: /* @__PURE__ */ jsx51(
|
|
3665
3793
|
"table",
|
|
3666
3794
|
{
|
|
3667
3795
|
ref,
|
|
@@ -3676,6 +3804,10 @@ var TableHeader = React50.forwardRef(
|
|
|
3676
3804
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx51("thead", { ref, className, ...props })
|
|
3677
3805
|
);
|
|
3678
3806
|
TableHeader.displayName = "TableHeader";
|
|
3807
|
+
var TableFooter = React50.forwardRef(
|
|
3808
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx51("tfoot", { ref, className: cn("border-t border-border bg-background text-ui-label", className), ...props })
|
|
3809
|
+
);
|
|
3810
|
+
TableFooter.displayName = "TableFooter";
|
|
3679
3811
|
var TableBody = React50.forwardRef(
|
|
3680
3812
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx51("tbody", { ref, className, ...props })
|
|
3681
3813
|
);
|
|
@@ -3699,9 +3831,9 @@ var TableRow = React50.forwardRef(
|
|
|
3699
3831
|
TableRow.displayName = "TableRow";
|
|
3700
3832
|
var ariaSort = { none: "none", asc: "ascending", desc: "descending" };
|
|
3701
3833
|
var TableHead = React50.forwardRef(
|
|
3702
|
-
({ className, align = "left", sortable, sort = "none", onSort, checkbox, children, ...props }, ref) => {
|
|
3834
|
+
({ className, align = "left", sortable, sort = "none", onSort, checkbox, resizer, children, ...props }, ref) => {
|
|
3703
3835
|
const caret = sort === "asc" ? /* @__PURE__ */ jsx51(CaretUp, { size: 16, "aria-hidden": true, className: "shrink-0" }) : /* @__PURE__ */ jsx51(CaretDown4, { size: 16, "aria-hidden": true, className: "shrink-0" });
|
|
3704
|
-
return /* @__PURE__ */
|
|
3836
|
+
return /* @__PURE__ */ jsxs38(
|
|
3705
3837
|
"th",
|
|
3706
3838
|
{
|
|
3707
3839
|
ref,
|
|
@@ -3711,21 +3843,25 @@ var TableHead = React50.forwardRef(
|
|
|
3711
3843
|
"h-10 border-b border-border text-ui-label whitespace-nowrap",
|
|
3712
3844
|
checkbox ? "w-13 px-0 text-center" : "px-4 py-3",
|
|
3713
3845
|
align === "right" ? "text-right" : "text-left",
|
|
3846
|
+
resizer && "relative",
|
|
3714
3847
|
className
|
|
3715
3848
|
),
|
|
3716
3849
|
...props,
|
|
3717
|
-
children:
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
children
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3850
|
+
children: [
|
|
3851
|
+
sortable ? /* @__PURE__ */ jsxs38(
|
|
3852
|
+
"button",
|
|
3853
|
+
{
|
|
3854
|
+
type: "button",
|
|
3855
|
+
onClick: onSort,
|
|
3856
|
+
className: cn("inline-flex items-center gap-1 rounded-xs", align === "right" && "flex-row-reverse"),
|
|
3857
|
+
children: [
|
|
3858
|
+
children,
|
|
3859
|
+
caret
|
|
3860
|
+
]
|
|
3861
|
+
}
|
|
3862
|
+
) : checkbox ? /* @__PURE__ */ jsx51("div", { className: "flex items-center justify-center", children }) : children,
|
|
3863
|
+
resizer
|
|
3864
|
+
]
|
|
3729
3865
|
}
|
|
3730
3866
|
);
|
|
3731
3867
|
}
|
|
@@ -3760,10 +3896,951 @@ function TableCellTwoLines({ primary, secondary, avatar, className, ...props })
|
|
|
3760
3896
|
] });
|
|
3761
3897
|
}
|
|
3762
3898
|
|
|
3763
|
-
// src/components/Data Display/
|
|
3899
|
+
// src/components/Data Display/DataTable.tsx
|
|
3900
|
+
import * as React52 from "react";
|
|
3901
|
+
import { CaretDown as CaretDown5, CaretRight as CaretRight4, PushPin, PushPinSlash, Rows, Sliders, Stack } from "@phosphor-icons/react";
|
|
3902
|
+
import {
|
|
3903
|
+
aggregationFn_count,
|
|
3904
|
+
aggregationFn_extent,
|
|
3905
|
+
aggregationFn_max,
|
|
3906
|
+
aggregationFn_mean,
|
|
3907
|
+
aggregationFn_median,
|
|
3908
|
+
aggregationFn_min,
|
|
3909
|
+
aggregationFn_sum,
|
|
3910
|
+
aggregationFn_unique,
|
|
3911
|
+
aggregationFn_uniqueCount,
|
|
3912
|
+
cellSelectionFeature,
|
|
3913
|
+
cellSpanningFeature,
|
|
3914
|
+
columnFacetingFeature,
|
|
3915
|
+
columnFilteringFeature,
|
|
3916
|
+
columnGroupingFeature,
|
|
3917
|
+
columnOrderingFeature,
|
|
3918
|
+
columnPinningFeature,
|
|
3919
|
+
columnResizingFeature,
|
|
3920
|
+
columnSizingFeature,
|
|
3921
|
+
columnVisibilityFeature,
|
|
3922
|
+
createExpandedRowModel,
|
|
3923
|
+
createFacetedMinMaxValues,
|
|
3924
|
+
createFacetedRowModel,
|
|
3925
|
+
createFacetedUniqueValues,
|
|
3926
|
+
createFilteredRowModel,
|
|
3927
|
+
createGroupedRowModel,
|
|
3928
|
+
createPaginatedRowModel,
|
|
3929
|
+
createSortedRowModel,
|
|
3930
|
+
filterFn_arrIncludesSome,
|
|
3931
|
+
filterFn_equals,
|
|
3932
|
+
filterFn_equalsString,
|
|
3933
|
+
filterFn_inNumberRange,
|
|
3934
|
+
filterFn_includesString,
|
|
3935
|
+
flexRender,
|
|
3936
|
+
globalFilteringFeature,
|
|
3937
|
+
rowAggregationFeature,
|
|
3938
|
+
rowExpandingFeature,
|
|
3939
|
+
rowPaginationFeature,
|
|
3940
|
+
rowPinningFeature,
|
|
3941
|
+
rowSelectionFeature,
|
|
3942
|
+
rowSortingFeature,
|
|
3943
|
+
sortFn_alphanumeric,
|
|
3944
|
+
sortFn_basic,
|
|
3945
|
+
sortFn_datetime,
|
|
3946
|
+
sortFn_text,
|
|
3947
|
+
tableFeatures,
|
|
3948
|
+
useTable
|
|
3949
|
+
} from "@tanstack/react-table";
|
|
3950
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
3951
|
+
|
|
3952
|
+
// src/components/Utility/Pagination.tsx
|
|
3764
3953
|
import * as React51 from "react";
|
|
3765
|
-
import {
|
|
3954
|
+
import { ArrowLeft, ArrowRight, DotsThree as DotsThree2 } from "@phosphor-icons/react";
|
|
3766
3955
|
import { jsx as jsx52, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
3956
|
+
function getPaginationItems(page, pageCount, siblings = 1) {
|
|
3957
|
+
const keep = /* @__PURE__ */ new Set([1, pageCount]);
|
|
3958
|
+
for (let p = page - siblings; p <= page + siblings; p++) if (p >= 1 && p <= pageCount) keep.add(p);
|
|
3959
|
+
const sorted = [...keep].sort((a, b) => a - b);
|
|
3960
|
+
const items = [];
|
|
3961
|
+
sorted.forEach((p, index) => {
|
|
3962
|
+
const previous = sorted[index - 1];
|
|
3963
|
+
if (previous !== void 0 && p - previous === 2) items.push(previous + 1);
|
|
3964
|
+
else if (previous !== void 0 && p - previous > 2) items.push("ellipsis");
|
|
3965
|
+
items.push(p);
|
|
3966
|
+
});
|
|
3967
|
+
return items;
|
|
3968
|
+
}
|
|
3969
|
+
var Pagination = React51.forwardRef(
|
|
3970
|
+
({ className, page, pageCount, onPageChange, variant = "full", siblings = 1, ...props }, ref) => {
|
|
3971
|
+
const go = (next2) => onPageChange(Math.min(pageCount, Math.max(1, next2)));
|
|
3972
|
+
const previous = /* @__PURE__ */ jsx52(
|
|
3973
|
+
Button,
|
|
3974
|
+
{
|
|
3975
|
+
type: "button",
|
|
3976
|
+
variant: "outline",
|
|
3977
|
+
size: "icon-sm",
|
|
3978
|
+
"aria-label": "Previous page",
|
|
3979
|
+
disabled: page <= 1,
|
|
3980
|
+
onClick: () => go(page - 1),
|
|
3981
|
+
children: /* @__PURE__ */ jsx52(ArrowLeft, { size: 16, "aria-hidden": true })
|
|
3982
|
+
}
|
|
3983
|
+
);
|
|
3984
|
+
const next = /* @__PURE__ */ jsx52(
|
|
3985
|
+
Button,
|
|
3986
|
+
{
|
|
3987
|
+
type: "button",
|
|
3988
|
+
variant: "outline",
|
|
3989
|
+
size: "icon-sm",
|
|
3990
|
+
"aria-label": "Next page",
|
|
3991
|
+
disabled: page >= pageCount,
|
|
3992
|
+
onClick: () => go(page + 1),
|
|
3993
|
+
children: /* @__PURE__ */ jsx52(ArrowRight, { size: 16, "aria-hidden": true })
|
|
3994
|
+
}
|
|
3995
|
+
);
|
|
3996
|
+
return /* @__PURE__ */ jsxs39(
|
|
3997
|
+
"nav",
|
|
3998
|
+
{
|
|
3999
|
+
ref,
|
|
4000
|
+
"aria-label": "Pagination",
|
|
4001
|
+
className: cn("flex items-center", variant === "compact" ? "w-35 justify-between" : "gap-2", className),
|
|
4002
|
+
...props,
|
|
4003
|
+
children: [
|
|
4004
|
+
previous,
|
|
4005
|
+
variant === "compact" ? /* @__PURE__ */ jsxs39("span", { className: "text-body-small text-surface-foreground", "aria-live": "polite", children: [
|
|
4006
|
+
page,
|
|
4007
|
+
"/",
|
|
4008
|
+
pageCount
|
|
4009
|
+
] }) : /* @__PURE__ */ jsx52("ul", { className: "flex items-center gap-2", children: getPaginationItems(page, pageCount, siblings).map((item, index) => /* @__PURE__ */ jsx52("li", { children: item === "ellipsis" ? /* @__PURE__ */ jsxs39("span", { className: "inline-flex size-8 items-center justify-center rounded-sm border border-border bg-surface text-surface-foreground", children: [
|
|
4010
|
+
/* @__PURE__ */ jsx52(DotsThree2, { size: 16, "aria-hidden": true }),
|
|
4011
|
+
/* @__PURE__ */ jsx52("span", { className: "sr-only", children: "More pages" })
|
|
4012
|
+
] }) : /* @__PURE__ */ jsx52(
|
|
4013
|
+
Button,
|
|
4014
|
+
{
|
|
4015
|
+
type: "button",
|
|
4016
|
+
variant: item === page ? "subtle" : "outline",
|
|
4017
|
+
size: "sm",
|
|
4018
|
+
"aria-label": `Page ${item}`,
|
|
4019
|
+
"aria-current": item === page ? "page" : void 0,
|
|
4020
|
+
onClick: () => go(item),
|
|
4021
|
+
children: item
|
|
4022
|
+
}
|
|
4023
|
+
) }, item === "ellipsis" ? `ellipsis-${index}` : item)) }),
|
|
4024
|
+
next
|
|
4025
|
+
]
|
|
4026
|
+
}
|
|
4027
|
+
);
|
|
4028
|
+
}
|
|
4029
|
+
);
|
|
4030
|
+
Pagination.displayName = "Pagination";
|
|
4031
|
+
|
|
4032
|
+
// src/components/Data Display/DataTable.tsx
|
|
4033
|
+
import { Fragment as Fragment14, jsx as jsx53, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
4034
|
+
var features = tableFeatures({
|
|
4035
|
+
rowSortingFeature,
|
|
4036
|
+
rowPaginationFeature,
|
|
4037
|
+
rowSelectionFeature,
|
|
4038
|
+
rowExpandingFeature,
|
|
4039
|
+
rowPinningFeature,
|
|
4040
|
+
rowAggregationFeature,
|
|
4041
|
+
columnVisibilityFeature,
|
|
4042
|
+
columnOrderingFeature,
|
|
4043
|
+
columnPinningFeature,
|
|
4044
|
+
columnSizingFeature,
|
|
4045
|
+
columnResizingFeature,
|
|
4046
|
+
columnFilteringFeature,
|
|
4047
|
+
globalFilteringFeature,
|
|
4048
|
+
columnFacetingFeature,
|
|
4049
|
+
columnGroupingFeature,
|
|
4050
|
+
cellSelectionFeature,
|
|
4051
|
+
cellSpanningFeature,
|
|
4052
|
+
// Row-model pipeline order: filter → group → sort → expand → paginate.
|
|
4053
|
+
facetedRowModel: createFacetedRowModel(),
|
|
4054
|
+
facetedUniqueValues: createFacetedUniqueValues(),
|
|
4055
|
+
facetedMinMaxValues: createFacetedMinMaxValues(),
|
|
4056
|
+
filteredRowModel: createFilteredRowModel(),
|
|
4057
|
+
groupedRowModel: createGroupedRowModel(),
|
|
4058
|
+
sortedRowModel: createSortedRowModel(),
|
|
4059
|
+
expandedRowModel: createExpandedRowModel(),
|
|
4060
|
+
paginatedRowModel: createPaginatedRowModel(),
|
|
4061
|
+
sortFns: {
|
|
4062
|
+
alphanumeric: sortFn_alphanumeric,
|
|
4063
|
+
basic: sortFn_basic,
|
|
4064
|
+
datetime: sortFn_datetime,
|
|
4065
|
+
text: sortFn_text
|
|
4066
|
+
},
|
|
4067
|
+
filterFns: {
|
|
4068
|
+
arrIncludesSome: filterFn_arrIncludesSome,
|
|
4069
|
+
equals: filterFn_equals,
|
|
4070
|
+
equalsString: filterFn_equalsString,
|
|
4071
|
+
includesString: filterFn_includesString,
|
|
4072
|
+
inNumberRange: filterFn_inNumberRange
|
|
4073
|
+
},
|
|
4074
|
+
aggregationFns: {
|
|
4075
|
+
count: aggregationFn_count,
|
|
4076
|
+
extent: aggregationFn_extent,
|
|
4077
|
+
max: aggregationFn_max,
|
|
4078
|
+
mean: aggregationFn_mean,
|
|
4079
|
+
median: aggregationFn_median,
|
|
4080
|
+
min: aggregationFn_min,
|
|
4081
|
+
sum: aggregationFn_sum,
|
|
4082
|
+
unique: aggregationFn_unique,
|
|
4083
|
+
uniqueCount: aggregationFn_uniqueCount
|
|
4084
|
+
}
|
|
4085
|
+
});
|
|
4086
|
+
var getMeta = (meta) => meta ?? {};
|
|
4087
|
+
function useControllable(value, initial, onChange) {
|
|
4088
|
+
const [internal, setInternal] = React52.useState(initial);
|
|
4089
|
+
const current = value ?? internal;
|
|
4090
|
+
const update = React52.useCallback(
|
|
4091
|
+
(updater) => {
|
|
4092
|
+
const next = typeof updater === "function" ? updater(current) : updater;
|
|
4093
|
+
if (value === void 0) setInternal(next);
|
|
4094
|
+
onChange?.(next);
|
|
4095
|
+
},
|
|
4096
|
+
[current, value, onChange]
|
|
4097
|
+
);
|
|
4098
|
+
return [current, update];
|
|
4099
|
+
}
|
|
4100
|
+
var ALL = "__all__";
|
|
4101
|
+
var labelOf = (column) => getMeta(column.columnDef.meta).label ?? (typeof column.columnDef.header === "string" ? column.columnDef.header : column.id);
|
|
4102
|
+
function pinning(column, sized, header = false) {
|
|
4103
|
+
const side = column.getIsPinned();
|
|
4104
|
+
const style = {};
|
|
4105
|
+
if (sized) {
|
|
4106
|
+
style.width = column.getSize();
|
|
4107
|
+
style.minWidth = column.getSize();
|
|
4108
|
+
style.maxWidth = column.getSize();
|
|
4109
|
+
}
|
|
4110
|
+
if (side) {
|
|
4111
|
+
style.position = "sticky";
|
|
4112
|
+
if (side === "start") style.insetInlineStart = column.getStart("start");
|
|
4113
|
+
else style.insetInlineEnd = column.getAfter("end");
|
|
4114
|
+
}
|
|
4115
|
+
const className = side ? cn(
|
|
4116
|
+
header ? "z-30" : "z-10",
|
|
4117
|
+
"bg-surface",
|
|
4118
|
+
side === "start" && column.getIsLastColumn("start") && "border-r border-border",
|
|
4119
|
+
side === "end" && column.getIsFirstColumn("end") && "border-l border-border"
|
|
4120
|
+
) : void 0;
|
|
4121
|
+
return { style, className };
|
|
4122
|
+
}
|
|
4123
|
+
function ColumnFilter({ column }) {
|
|
4124
|
+
const variant = getMeta(column.columnDef.meta).filterVariant ?? "text";
|
|
4125
|
+
const label = labelOf(column);
|
|
4126
|
+
const value = column.getFilterValue();
|
|
4127
|
+
if (variant === "select") {
|
|
4128
|
+
const options = [...column.getFacetedUniqueValues().entries()].sort((a, b) => String(a[0]).localeCompare(String(b[0])));
|
|
4129
|
+
return /* @__PURE__ */ jsxs40(
|
|
4130
|
+
Select,
|
|
4131
|
+
{
|
|
4132
|
+
value: typeof value === "string" ? value : ALL,
|
|
4133
|
+
onValueChange: (next) => column.setFilterValue(next === ALL ? void 0 : next),
|
|
4134
|
+
children: [
|
|
4135
|
+
/* @__PURE__ */ jsx53(SelectTrigger, { "aria-label": `Filter ${label}`, className: "h-8 text-body-small", children: /* @__PURE__ */ jsx53(SelectValue, {}) }),
|
|
4136
|
+
/* @__PURE__ */ jsxs40(SelectContent, { children: [
|
|
4137
|
+
/* @__PURE__ */ jsx53(SelectItem, { value: ALL, children: "All" }),
|
|
4138
|
+
options.map(([option, count]) => /* @__PURE__ */ jsxs40(SelectItem, { value: String(option), children: [
|
|
4139
|
+
String(option),
|
|
4140
|
+
" (",
|
|
4141
|
+
count,
|
|
4142
|
+
")"
|
|
4143
|
+
] }, String(option)))
|
|
4144
|
+
] })
|
|
4145
|
+
]
|
|
4146
|
+
}
|
|
4147
|
+
);
|
|
4148
|
+
}
|
|
4149
|
+
if (variant === "range") {
|
|
4150
|
+
const [min, max] = column.getFacetedMinMaxValues() ?? [];
|
|
4151
|
+
const range = Array.isArray(value) ? value : [];
|
|
4152
|
+
const update = (index, raw) => {
|
|
4153
|
+
const next = [range[0], range[1]];
|
|
4154
|
+
next[index] = raw === "" ? void 0 : Number(raw);
|
|
4155
|
+
column.setFilterValue(next[0] === void 0 && next[1] === void 0 ? void 0 : next);
|
|
4156
|
+
};
|
|
4157
|
+
return /* @__PURE__ */ jsxs40("div", { className: "flex gap-1", children: [
|
|
4158
|
+
/* @__PURE__ */ jsx53(
|
|
4159
|
+
Input,
|
|
4160
|
+
{
|
|
4161
|
+
type: "number",
|
|
4162
|
+
"aria-label": `${label} minimum`,
|
|
4163
|
+
placeholder: min !== void 0 ? String(min) : "Min",
|
|
4164
|
+
value: range[0] ?? "",
|
|
4165
|
+
onChange: (event) => update(0, event.target.value),
|
|
4166
|
+
className: "h-8 text-body-small"
|
|
4167
|
+
}
|
|
4168
|
+
),
|
|
4169
|
+
/* @__PURE__ */ jsx53(
|
|
4170
|
+
Input,
|
|
4171
|
+
{
|
|
4172
|
+
type: "number",
|
|
4173
|
+
"aria-label": `${label} maximum`,
|
|
4174
|
+
placeholder: max !== void 0 ? String(max) : "Max",
|
|
4175
|
+
value: range[1] ?? "",
|
|
4176
|
+
onChange: (event) => update(1, event.target.value),
|
|
4177
|
+
className: "h-8 text-body-small"
|
|
4178
|
+
}
|
|
4179
|
+
)
|
|
4180
|
+
] });
|
|
4181
|
+
}
|
|
4182
|
+
return /* @__PURE__ */ jsx53(
|
|
4183
|
+
Input,
|
|
4184
|
+
{
|
|
4185
|
+
"aria-label": `Filter ${label}`,
|
|
4186
|
+
placeholder: "Filter\u2026",
|
|
4187
|
+
value: typeof value === "string" ? value : "",
|
|
4188
|
+
onChange: (event) => column.setFilterValue(event.target.value || void 0),
|
|
4189
|
+
className: "h-8 text-body-small"
|
|
4190
|
+
}
|
|
4191
|
+
);
|
|
4192
|
+
}
|
|
4193
|
+
function EditableCell({ value, label, type, onCommit }) {
|
|
4194
|
+
const initial = value == null ? "" : String(value);
|
|
4195
|
+
const [draft, setDraft] = React52.useState(null);
|
|
4196
|
+
const cancelled = React52.useRef(false);
|
|
4197
|
+
return /* @__PURE__ */ jsx53(
|
|
4198
|
+
Input,
|
|
4199
|
+
{
|
|
4200
|
+
type,
|
|
4201
|
+
"aria-label": label,
|
|
4202
|
+
value: draft ?? initial,
|
|
4203
|
+
onChange: (event) => setDraft(event.target.value),
|
|
4204
|
+
onBlur: () => {
|
|
4205
|
+
if (!cancelled.current && draft !== null && draft !== initial) onCommit(draft);
|
|
4206
|
+
cancelled.current = false;
|
|
4207
|
+
setDraft(null);
|
|
4208
|
+
},
|
|
4209
|
+
onKeyDown: (event) => {
|
|
4210
|
+
if (event.key === "Enter") event.currentTarget.blur();
|
|
4211
|
+
if (event.key === "Escape") {
|
|
4212
|
+
cancelled.current = true;
|
|
4213
|
+
event.currentTarget.blur();
|
|
4214
|
+
}
|
|
4215
|
+
},
|
|
4216
|
+
className: cn("h-8 border-transparent bg-transparent text-body-small", type === "number" && "text-right")
|
|
4217
|
+
}
|
|
4218
|
+
);
|
|
4219
|
+
}
|
|
4220
|
+
function DataTableInner({
|
|
4221
|
+
columns,
|
|
4222
|
+
data,
|
|
4223
|
+
getRowId,
|
|
4224
|
+
initialState,
|
|
4225
|
+
enableSorting = false,
|
|
4226
|
+
enableRowSelection = false,
|
|
4227
|
+
enableColumnVisibility = false,
|
|
4228
|
+
enableColumnPinning = false,
|
|
4229
|
+
enableColumnSizing = false,
|
|
4230
|
+
enableColumnResizing = false,
|
|
4231
|
+
columnResizeMode = "onChange",
|
|
4232
|
+
enableColumnOrdering = false,
|
|
4233
|
+
enableColumnFilters = false,
|
|
4234
|
+
enableGlobalFilter = false,
|
|
4235
|
+
globalFilterPlaceholder = "Search",
|
|
4236
|
+
enableGrouping = false,
|
|
4237
|
+
enableExpanding = false,
|
|
4238
|
+
enableRowPinning = false,
|
|
4239
|
+
enableCellSelection = false,
|
|
4240
|
+
showFooter = false,
|
|
4241
|
+
enableDensityToggle = false,
|
|
4242
|
+
density: densityProp,
|
|
4243
|
+
onDensityChange,
|
|
4244
|
+
getSubRows,
|
|
4245
|
+
getRowCanExpand,
|
|
4246
|
+
renderSubComponent,
|
|
4247
|
+
pageSize = 10,
|
|
4248
|
+
serverSide = false,
|
|
4249
|
+
rowCount,
|
|
4250
|
+
sorting: sortingProp,
|
|
4251
|
+
onSortingChange,
|
|
4252
|
+
rowSelection: rowSelectionProp,
|
|
4253
|
+
onRowSelectionChange,
|
|
4254
|
+
pagination: paginationProp,
|
|
4255
|
+
onPaginationChange,
|
|
4256
|
+
columnVisibility: columnVisibilityProp,
|
|
4257
|
+
onColumnVisibilityChange,
|
|
4258
|
+
columnPinning: columnPinningProp,
|
|
4259
|
+
onColumnPinningChange,
|
|
4260
|
+
columnOrder: columnOrderProp,
|
|
4261
|
+
onColumnOrderChange,
|
|
4262
|
+
columnFilters: columnFiltersProp,
|
|
4263
|
+
onColumnFiltersChange,
|
|
4264
|
+
globalFilter: globalFilterProp,
|
|
4265
|
+
onGlobalFilterChange,
|
|
4266
|
+
grouping: groupingProp,
|
|
4267
|
+
onGroupingChange,
|
|
4268
|
+
expanded: expandedProp,
|
|
4269
|
+
onExpandedChange,
|
|
4270
|
+
rowPinning: rowPinningProp,
|
|
4271
|
+
onRowPinningChange,
|
|
4272
|
+
onCellSelectionChange,
|
|
4273
|
+
onCellEdit,
|
|
4274
|
+
virtualized = false,
|
|
4275
|
+
estimateRowHeight = 40,
|
|
4276
|
+
onLoadMore,
|
|
4277
|
+
hasMore = false,
|
|
4278
|
+
loadingMore = false,
|
|
4279
|
+
stickyHeader,
|
|
4280
|
+
loading = false,
|
|
4281
|
+
emptyState,
|
|
4282
|
+
onRowClick,
|
|
4283
|
+
toolbar,
|
|
4284
|
+
wrapperClassName,
|
|
4285
|
+
striped,
|
|
4286
|
+
containerClassName,
|
|
4287
|
+
containerRef,
|
|
4288
|
+
style: tableStyle,
|
|
4289
|
+
...tableProps
|
|
4290
|
+
}, ref) {
|
|
4291
|
+
const [sorting, setSorting] = useControllable(sortingProp, initialState?.sorting ?? [], onSortingChange);
|
|
4292
|
+
const [rowSelection, setRowSelection] = useControllable(
|
|
4293
|
+
rowSelectionProp,
|
|
4294
|
+
initialState?.rowSelection ?? {},
|
|
4295
|
+
onRowSelectionChange
|
|
4296
|
+
);
|
|
4297
|
+
const [columnVisibility, setColumnVisibility] = useControllable(
|
|
4298
|
+
columnVisibilityProp,
|
|
4299
|
+
initialState?.columnVisibility ?? {},
|
|
4300
|
+
onColumnVisibilityChange
|
|
4301
|
+
);
|
|
4302
|
+
const [columnPinning, setColumnPinning] = useControllable(
|
|
4303
|
+
columnPinningProp,
|
|
4304
|
+
{ start: initialState?.columnPinning?.start ?? [], end: initialState?.columnPinning?.end ?? [] },
|
|
4305
|
+
onColumnPinningChange
|
|
4306
|
+
);
|
|
4307
|
+
const [columnOrder, setColumnOrder] = useControllable(
|
|
4308
|
+
columnOrderProp,
|
|
4309
|
+
initialState?.columnOrder ?? [],
|
|
4310
|
+
onColumnOrderChange
|
|
4311
|
+
);
|
|
4312
|
+
const [columnFilters, setColumnFilters] = useControllable(
|
|
4313
|
+
columnFiltersProp,
|
|
4314
|
+
initialState?.columnFilters ?? [],
|
|
4315
|
+
onColumnFiltersChange
|
|
4316
|
+
);
|
|
4317
|
+
const [globalFilter, setGlobalFilter] = useControllable(
|
|
4318
|
+
globalFilterProp,
|
|
4319
|
+
initialState?.globalFilter ?? "",
|
|
4320
|
+
onGlobalFilterChange
|
|
4321
|
+
);
|
|
4322
|
+
const [grouping, setGrouping] = useControllable(groupingProp, initialState?.grouping ?? [], onGroupingChange);
|
|
4323
|
+
const [expanded, setExpanded] = useControllable(expandedProp, initialState?.expanded ?? {}, onExpandedChange);
|
|
4324
|
+
const [rowPinning, setRowPinning] = useControllable(
|
|
4325
|
+
rowPinningProp,
|
|
4326
|
+
{ top: initialState?.rowPinning?.top ?? [], bottom: initialState?.rowPinning?.bottom ?? [] },
|
|
4327
|
+
onRowPinningChange
|
|
4328
|
+
);
|
|
4329
|
+
const [pagination, setPagination] = useControllable(
|
|
4330
|
+
paginationProp,
|
|
4331
|
+
initialState?.pagination ?? { pageIndex: 0, pageSize },
|
|
4332
|
+
onPaginationChange
|
|
4333
|
+
);
|
|
4334
|
+
const [density, setDensity] = useControllable(densityProp, "default", onDensityChange);
|
|
4335
|
+
const [cellSelection, setCellSelection] = React52.useState([]);
|
|
4336
|
+
const infinite = Boolean(onLoadMore);
|
|
4337
|
+
const paginate = !virtualized && !infinite;
|
|
4338
|
+
const compact = density === "compact";
|
|
4339
|
+
const sized = enableColumnSizing || enableColumnResizing || enableColumnPinning;
|
|
4340
|
+
const sticky = stickyHeader ?? (enableRowPinning || virtualized);
|
|
4341
|
+
const table = useTable({
|
|
4342
|
+
features,
|
|
4343
|
+
columns,
|
|
4344
|
+
data,
|
|
4345
|
+
getRowId,
|
|
4346
|
+
getSubRows,
|
|
4347
|
+
getRowCanExpand: getRowCanExpand ?? (renderSubComponent ? () => true : void 0),
|
|
4348
|
+
enableSorting,
|
|
4349
|
+
enableRowSelection,
|
|
4350
|
+
enableColumnResizing,
|
|
4351
|
+
enableColumnPinning,
|
|
4352
|
+
enableColumnFilters,
|
|
4353
|
+
enableGlobalFilter,
|
|
4354
|
+
enableGrouping,
|
|
4355
|
+
enableRowPinning,
|
|
4356
|
+
enableCellSelection,
|
|
4357
|
+
columnResizeMode,
|
|
4358
|
+
globalFilterFn: "includesString",
|
|
4359
|
+
manualSorting: serverSide,
|
|
4360
|
+
manualFiltering: serverSide,
|
|
4361
|
+
manualPagination: serverSide || !paginate,
|
|
4362
|
+
rowCount: serverSide ? rowCount : void 0,
|
|
4363
|
+
autoResetPageIndex: !serverSide,
|
|
4364
|
+
state: {
|
|
4365
|
+
sorting,
|
|
4366
|
+
rowSelection,
|
|
4367
|
+
columnVisibility,
|
|
4368
|
+
columnPinning,
|
|
4369
|
+
columnOrder,
|
|
4370
|
+
columnFilters,
|
|
4371
|
+
globalFilter,
|
|
4372
|
+
grouping,
|
|
4373
|
+
expanded,
|
|
4374
|
+
rowPinning,
|
|
4375
|
+
cellSelection,
|
|
4376
|
+
pagination: { ...pagination, pageSize: paginationProp ? pagination.pageSize : pageSize }
|
|
4377
|
+
},
|
|
4378
|
+
onSortingChange: setSorting,
|
|
4379
|
+
onRowSelectionChange: setRowSelection,
|
|
4380
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
4381
|
+
onColumnPinningChange: setColumnPinning,
|
|
4382
|
+
onColumnOrderChange: setColumnOrder,
|
|
4383
|
+
onColumnFiltersChange: setColumnFilters,
|
|
4384
|
+
onGlobalFilterChange: setGlobalFilter,
|
|
4385
|
+
onGroupingChange: setGrouping,
|
|
4386
|
+
onExpandedChange: setExpanded,
|
|
4387
|
+
onRowPinningChange: setRowPinning,
|
|
4388
|
+
onCellSelectionChange: (updater) => {
|
|
4389
|
+
const next = typeof updater === "function" ? updater(cellSelection) : updater;
|
|
4390
|
+
setCellSelection(next);
|
|
4391
|
+
onCellSelectionChange?.(next);
|
|
4392
|
+
},
|
|
4393
|
+
onPaginationChange: setPagination
|
|
4394
|
+
});
|
|
4395
|
+
const headerGroups = table.getHeaderGroups();
|
|
4396
|
+
const leafColumns = table.getVisibleLeafColumns();
|
|
4397
|
+
const hasExpander = enableExpanding;
|
|
4398
|
+
const leadingCount = (enableRowSelection ? 1 : 0) + (hasExpander ? 1 : 0) + (enableRowPinning ? 1 : 0);
|
|
4399
|
+
const columnSpan = leafColumns.length + leadingCount;
|
|
4400
|
+
const pageCount = table.getPageCount();
|
|
4401
|
+
const selectedCount = Object.values(rowSelection).filter(Boolean).length;
|
|
4402
|
+
const hideableColumns = table.getAllLeafColumns().filter((column) => column.getCanHide());
|
|
4403
|
+
const groupableColumns = table.getAllLeafColumns().filter((column) => column.getCanGroup());
|
|
4404
|
+
const showToolbar = Boolean(toolbar) || enableColumnVisibility || enableGlobalFilter || enableGrouping || enableDensityToggle;
|
|
4405
|
+
const cellDensity = compact ? "h-8 py-1.5" : void 0;
|
|
4406
|
+
const allSelected = table.getIsAllPageRowsSelected();
|
|
4407
|
+
const someSelected = table.getIsSomePageRowsSelected();
|
|
4408
|
+
const dragged = React52.useRef(null);
|
|
4409
|
+
const topRows = enableRowPinning ? table.getTopRows() : [];
|
|
4410
|
+
const bottomRows = enableRowPinning ? table.getBottomRows() : [];
|
|
4411
|
+
const bodyRows = enableRowPinning ? table.getCenterRows() : table.getRowModel().rows;
|
|
4412
|
+
const scrollRef = React52.useRef(null);
|
|
4413
|
+
const setScrollRef = React52.useCallback(
|
|
4414
|
+
(node) => {
|
|
4415
|
+
scrollRef.current = node;
|
|
4416
|
+
if (typeof containerRef === "function") containerRef(node);
|
|
4417
|
+
else if (containerRef) containerRef.current = node;
|
|
4418
|
+
},
|
|
4419
|
+
[containerRef]
|
|
4420
|
+
);
|
|
4421
|
+
const virtualizer = useVirtualizer({
|
|
4422
|
+
count: bodyRows.length,
|
|
4423
|
+
getScrollElement: () => scrollRef.current,
|
|
4424
|
+
estimateSize: () => estimateRowHeight,
|
|
4425
|
+
overscan: 8,
|
|
4426
|
+
enabled: virtualized,
|
|
4427
|
+
initialRect: { width: 0, height: estimateRowHeight * 10 }
|
|
4428
|
+
});
|
|
4429
|
+
const virtualItems = virtualized ? virtualizer.getVirtualItems() : [];
|
|
4430
|
+
const paddingTop = virtualItems.length > 0 ? virtualItems[0]?.start ?? 0 : 0;
|
|
4431
|
+
const paddingBottom = virtualItems.length > 0 ? virtualizer.getTotalSize() - (virtualItems.at(-1)?.end ?? 0) : 0;
|
|
4432
|
+
const sentinelRef = React52.useRef(null);
|
|
4433
|
+
React52.useEffect(() => {
|
|
4434
|
+
const node = sentinelRef.current;
|
|
4435
|
+
if (!node || !onLoadMore || !hasMore || loadingMore || typeof IntersectionObserver === "undefined") return;
|
|
4436
|
+
const container = scrollRef.current;
|
|
4437
|
+
const root = container && container.scrollHeight > container.clientHeight ? container : null;
|
|
4438
|
+
const observer = new IntersectionObserver(
|
|
4439
|
+
(entries) => {
|
|
4440
|
+
if (entries.some((entry) => entry.isIntersecting)) onLoadMore();
|
|
4441
|
+
},
|
|
4442
|
+
{ root, rootMargin: "0px 0px 160px 0px" }
|
|
4443
|
+
);
|
|
4444
|
+
observer.observe(node);
|
|
4445
|
+
return () => observer.disconnect();
|
|
4446
|
+
}, [onLoadMore, hasMore, loadingMore, bodyRows.length]);
|
|
4447
|
+
const reorder = (activeId, overId) => {
|
|
4448
|
+
if (activeId === overId) return;
|
|
4449
|
+
const ids = table.getAllLeafColumns().map((column) => column.id);
|
|
4450
|
+
const next = ids.filter((id) => id !== activeId);
|
|
4451
|
+
const at = next.indexOf(overId);
|
|
4452
|
+
next.splice(at === -1 ? next.length : at, 0, activeId);
|
|
4453
|
+
table.setColumnOrder(next);
|
|
4454
|
+
};
|
|
4455
|
+
const onGridKeyDown = (event) => {
|
|
4456
|
+
const directions = {
|
|
4457
|
+
ArrowUp: "up",
|
|
4458
|
+
ArrowDown: "down",
|
|
4459
|
+
ArrowLeft: "left",
|
|
4460
|
+
ArrowRight: "right"
|
|
4461
|
+
};
|
|
4462
|
+
const direction = directions[event.key];
|
|
4463
|
+
if (direction) {
|
|
4464
|
+
event.preventDefault();
|
|
4465
|
+
if (event.shiftKey) table.extendCellSelection(direction);
|
|
4466
|
+
else table.moveCellSelection(direction);
|
|
4467
|
+
} else if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "a") {
|
|
4468
|
+
event.preventDefault();
|
|
4469
|
+
table.selectAllCells();
|
|
4470
|
+
} else if (event.key === "Escape") {
|
|
4471
|
+
table.resetCellSelection(true);
|
|
4472
|
+
}
|
|
4473
|
+
};
|
|
4474
|
+
const skeletonRow = (rowKey) => /* @__PURE__ */ jsx53(TableRow, { className: "hover:bg-transparent", children: Array.from({ length: columnSpan }, (_, cell) => /* @__PURE__ */ jsx53(TableCell, { checkbox: enableRowSelection && cell === 0, className: cellDensity, children: /* @__PURE__ */ jsx53("span", { "aria-hidden": true, className: "block h-4 w-3/4 animate-pulse rounded-xs bg-border" }) }, cell)) }, rowKey);
|
|
4475
|
+
const renderRow = (row, options = {}) => {
|
|
4476
|
+
const { pinned, pinnedIndex = 0, pinnedCount = 1, virtualIndex } = options;
|
|
4477
|
+
const grouped = row.getIsGrouped();
|
|
4478
|
+
const rowUnits = compact ? 8 : 10;
|
|
4479
|
+
const pinStyle = pinned ? pinned === "top" ? { position: "sticky", top: `calc(var(--spacing) * ${rowUnits * (pinnedIndex + 1)})` } : { position: "sticky", bottom: `calc(var(--spacing) * ${rowUnits * (pinnedCount - 1 - pinnedIndex)})` } : void 0;
|
|
4480
|
+
const cells = row.getVisibleCells();
|
|
4481
|
+
return /* @__PURE__ */ jsxs40(React52.Fragment, { children: [
|
|
4482
|
+
/* @__PURE__ */ jsxs40(
|
|
4483
|
+
TableRow,
|
|
4484
|
+
{
|
|
4485
|
+
ref: virtualized && virtualIndex !== void 0 ? virtualizer.measureElement : void 0,
|
|
4486
|
+
"data-index": virtualIndex,
|
|
4487
|
+
selected: row.getIsSelected(),
|
|
4488
|
+
style: pinStyle,
|
|
4489
|
+
onClick: onRowClick && !grouped ? () => onRowClick(row.original) : void 0,
|
|
4490
|
+
className: cn(pinned && "z-20 bg-surface", grouped && "bg-background", onRowClick && !grouped && "cursor-pointer"),
|
|
4491
|
+
children: [
|
|
4492
|
+
enableRowSelection && /* @__PURE__ */ jsx53(TableCell, { checkbox: true, className: cellDensity, onClick: (event) => event.stopPropagation(), children: !grouped && /* @__PURE__ */ jsx53(
|
|
4493
|
+
Checkbox,
|
|
4494
|
+
{
|
|
4495
|
+
"aria-label": "Select row",
|
|
4496
|
+
checked: row.getIsSelected(),
|
|
4497
|
+
disabled: !row.getCanSelect(),
|
|
4498
|
+
onCheckedChange: (checked) => row.toggleSelected(Boolean(checked))
|
|
4499
|
+
}
|
|
4500
|
+
) }),
|
|
4501
|
+
hasExpander && /* @__PURE__ */ jsx53(TableCell, { checkbox: true, className: cellDensity, onClick: (event) => event.stopPropagation(), children: !grouped && row.getCanExpand() && /* @__PURE__ */ jsx53(
|
|
4502
|
+
Button,
|
|
4503
|
+
{
|
|
4504
|
+
type: "button",
|
|
4505
|
+
variant: "ghost",
|
|
4506
|
+
size: "icon-sm",
|
|
4507
|
+
"aria-label": row.getIsExpanded() ? "Collapse row" : "Expand row",
|
|
4508
|
+
"aria-expanded": row.getIsExpanded(),
|
|
4509
|
+
onClick: () => row.toggleExpanded(),
|
|
4510
|
+
children: row.getIsExpanded() ? /* @__PURE__ */ jsx53(CaretDown5, { size: 16, "aria-hidden": true }) : /* @__PURE__ */ jsx53(CaretRight4, { size: 16, "aria-hidden": true })
|
|
4511
|
+
}
|
|
4512
|
+
) }),
|
|
4513
|
+
enableRowPinning && /* @__PURE__ */ jsx53(TableCell, { checkbox: true, className: cellDensity, onClick: (event) => event.stopPropagation(), children: !grouped && /* @__PURE__ */ jsx53(
|
|
4514
|
+
Button,
|
|
4515
|
+
{
|
|
4516
|
+
type: "button",
|
|
4517
|
+
variant: "ghost",
|
|
4518
|
+
size: "icon-sm",
|
|
4519
|
+
"aria-label": row.getIsPinned() ? "Unpin row" : "Pin row to top",
|
|
4520
|
+
"aria-pressed": Boolean(row.getIsPinned()),
|
|
4521
|
+
onClick: () => row.pin(row.getIsPinned() ? false : "top"),
|
|
4522
|
+
children: row.getIsPinned() ? /* @__PURE__ */ jsx53(PushPinSlash, { size: 16, "aria-hidden": true }) : /* @__PURE__ */ jsx53(PushPin, { size: 16, "aria-hidden": true })
|
|
4523
|
+
}
|
|
4524
|
+
) }),
|
|
4525
|
+
cells.map((cell, index) => {
|
|
4526
|
+
if (cell.getIsCovered()) return null;
|
|
4527
|
+
const meta = getMeta(cell.column.columnDef.meta);
|
|
4528
|
+
const pin = pinning(cell.column, sized);
|
|
4529
|
+
const rowSpan = cell.getRowSpan();
|
|
4530
|
+
const colSpan = cell.getColSpan();
|
|
4531
|
+
const edges = enableCellSelection && cell.getIsSelected() ? cell.getSelectionEdges() : void 0;
|
|
4532
|
+
const indent = index === 0 && hasExpander && row.depth > 0 ? row.depth * 4 : 0;
|
|
4533
|
+
let content;
|
|
4534
|
+
if (cell.getIsGrouped()) {
|
|
4535
|
+
content = /* @__PURE__ */ jsxs40(
|
|
4536
|
+
"button",
|
|
4537
|
+
{
|
|
4538
|
+
type: "button",
|
|
4539
|
+
className: "inline-flex items-center gap-1 rounded-xs text-ui-label",
|
|
4540
|
+
"aria-expanded": row.getIsExpanded(),
|
|
4541
|
+
onClick: row.getToggleExpandedHandler(),
|
|
4542
|
+
children: [
|
|
4543
|
+
row.getIsExpanded() ? /* @__PURE__ */ jsx53(CaretDown5, { size: 16, "aria-hidden": true }) : /* @__PURE__ */ jsx53(CaretRight4, { size: 16, "aria-hidden": true }),
|
|
4544
|
+
flexRender(cell.column.columnDef.cell, cell.getContext()),
|
|
4545
|
+
/* @__PURE__ */ jsxs40("span", { className: "text-secondary-muted-foreground", children: [
|
|
4546
|
+
"(",
|
|
4547
|
+
row.subRows.length,
|
|
4548
|
+
")"
|
|
4549
|
+
] })
|
|
4550
|
+
]
|
|
4551
|
+
}
|
|
4552
|
+
);
|
|
4553
|
+
} else if (cell.getIsAggregated()) {
|
|
4554
|
+
content = flexRender(cell.column.columnDef.aggregatedCell ?? cell.column.columnDef.cell, cell.getContext());
|
|
4555
|
+
} else if (cell.getIsPlaceholder()) {
|
|
4556
|
+
content = null;
|
|
4557
|
+
} else if (meta.editable) {
|
|
4558
|
+
content = /* @__PURE__ */ jsx53(
|
|
4559
|
+
EditableCell,
|
|
4560
|
+
{
|
|
4561
|
+
value: cell.getValue(),
|
|
4562
|
+
label: `${labelOf(cell.column)}, row ${row.index + 1}`,
|
|
4563
|
+
type: meta.editType ?? "text",
|
|
4564
|
+
onCommit: (value) => onCellEdit?.({ row: row.original, rowId: row.id, columnId: cell.column.id, value })
|
|
4565
|
+
}
|
|
4566
|
+
);
|
|
4567
|
+
} else {
|
|
4568
|
+
content = flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
4569
|
+
}
|
|
4570
|
+
return /* @__PURE__ */ jsx53(
|
|
4571
|
+
TableCell,
|
|
4572
|
+
{
|
|
4573
|
+
align: meta.align,
|
|
4574
|
+
muted: meta.muted && !grouped,
|
|
4575
|
+
rowSpan: rowSpan > 1 ? rowSpan : void 0,
|
|
4576
|
+
colSpan: colSpan > 1 ? colSpan : void 0,
|
|
4577
|
+
style: {
|
|
4578
|
+
...pin.style,
|
|
4579
|
+
...indent ? { paddingInlineStart: `calc(var(--spacing) * ${indent + 4})` } : null
|
|
4580
|
+
},
|
|
4581
|
+
"data-selected": edges ? "" : void 0,
|
|
4582
|
+
onMouseDown: enableCellSelection ? cell.getSelectionStartHandler() : void 0,
|
|
4583
|
+
onMouseEnter: enableCellSelection ? cell.getSelectionExtendHandler() : void 0,
|
|
4584
|
+
className: cn(
|
|
4585
|
+
cellDensity,
|
|
4586
|
+
pin.className,
|
|
4587
|
+
enableCellSelection && "select-none",
|
|
4588
|
+
edges && "bg-accent-soft",
|
|
4589
|
+
edges?.top && "border-t-2 border-t-input-accent",
|
|
4590
|
+
edges?.bottom && "border-b-2 border-b-input-accent",
|
|
4591
|
+
edges?.left && "border-l-2 border-l-input-accent",
|
|
4592
|
+
edges?.right && "border-r-2 border-r-input-accent",
|
|
4593
|
+
meta.editable && "py-1"
|
|
4594
|
+
),
|
|
4595
|
+
children: content
|
|
4596
|
+
},
|
|
4597
|
+
cell.id
|
|
4598
|
+
);
|
|
4599
|
+
})
|
|
4600
|
+
]
|
|
4601
|
+
}
|
|
4602
|
+
),
|
|
4603
|
+
renderSubComponent && !grouped && row.getIsExpanded() && /* @__PURE__ */ jsx53(TableRow, { className: "bg-background hover:bg-background", children: /* @__PURE__ */ jsx53(TableCell, { colSpan: columnSpan, children: renderSubComponent(row.original) }) })
|
|
4604
|
+
] }, row.id);
|
|
4605
|
+
};
|
|
4606
|
+
const renderHeaderCell = (header) => {
|
|
4607
|
+
const { column } = header;
|
|
4608
|
+
const { align } = getMeta(column.columnDef.meta);
|
|
4609
|
+
const leaf = header.subHeaders.length === 0;
|
|
4610
|
+
const sortState = column.getIsSorted();
|
|
4611
|
+
const pin = pinning(column, sized, true);
|
|
4612
|
+
const reorderable = enableColumnOrdering && leaf && !column.getIsPinned();
|
|
4613
|
+
const label = labelOf(column);
|
|
4614
|
+
return /* @__PURE__ */ jsx53(
|
|
4615
|
+
TableHead,
|
|
4616
|
+
{
|
|
4617
|
+
colSpan: header.colSpan > 1 ? header.colSpan : void 0,
|
|
4618
|
+
align: leaf ? align : void 0,
|
|
4619
|
+
sortable: leaf && column.getCanSort(),
|
|
4620
|
+
sort: sortState === false ? "none" : sortState,
|
|
4621
|
+
onSort: () => column.toggleSorting(sortState === "asc"),
|
|
4622
|
+
style: pin.style,
|
|
4623
|
+
draggable: reorderable || void 0,
|
|
4624
|
+
tabIndex: reorderable ? 0 : void 0,
|
|
4625
|
+
title: reorderable ? "Drag, or press Alt + arrow keys, to reorder" : void 0,
|
|
4626
|
+
onDragStart: reorderable ? () => dragged.current = column.id : void 0,
|
|
4627
|
+
onDragOver: reorderable ? (event) => event.preventDefault() : void 0,
|
|
4628
|
+
onDrop: reorderable ? (event) => {
|
|
4629
|
+
event.preventDefault();
|
|
4630
|
+
if (dragged.current) reorder(dragged.current, column.id);
|
|
4631
|
+
dragged.current = null;
|
|
4632
|
+
} : void 0,
|
|
4633
|
+
onKeyDown: reorderable ? (event) => {
|
|
4634
|
+
if (!event.altKey || event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
|
4635
|
+
event.preventDefault();
|
|
4636
|
+
const ids = table.getAllLeafColumns().map((item) => item.id);
|
|
4637
|
+
const at = ids.indexOf(column.id);
|
|
4638
|
+
const target = ids[at + (event.key === "ArrowLeft" ? -1 : 2)];
|
|
4639
|
+
if (event.key === "ArrowLeft" && ids[at - 1]) reorder(column.id, ids[at - 1]);
|
|
4640
|
+
else if (event.key === "ArrowRight" && at < ids.length - 1) reorder(column.id, target ?? "__end__");
|
|
4641
|
+
} : void 0,
|
|
4642
|
+
className: cn(
|
|
4643
|
+
pin.className,
|
|
4644
|
+
cellDensity,
|
|
4645
|
+
sticky && !column.getIsPinned() && "sticky top-0 z-20 bg-surface",
|
|
4646
|
+
sticky && column.getIsPinned() && "top-0",
|
|
4647
|
+
reorderable && "cursor-grab",
|
|
4648
|
+
!leaf && "text-center"
|
|
4649
|
+
),
|
|
4650
|
+
resizer: enableColumnResizing && column.getCanResize() ? /* @__PURE__ */ jsx53(
|
|
4651
|
+
"div",
|
|
4652
|
+
{
|
|
4653
|
+
role: "separator",
|
|
4654
|
+
"aria-orientation": "vertical",
|
|
4655
|
+
"aria-label": `Resize ${label}`,
|
|
4656
|
+
onMouseDown: header.getResizeHandler(),
|
|
4657
|
+
onTouchStart: header.getResizeHandler(),
|
|
4658
|
+
onClick: (event) => event.stopPropagation(),
|
|
4659
|
+
className: cn(
|
|
4660
|
+
"absolute inset-y-0 end-0 w-1 cursor-col-resize touch-none select-none hover:bg-input-accent",
|
|
4661
|
+
column.getIsResizing() && "bg-input-accent"
|
|
4662
|
+
)
|
|
4663
|
+
}
|
|
4664
|
+
) : void 0,
|
|
4665
|
+
children: header.isPlaceholder ? null : /* @__PURE__ */ jsx53(table.FlexRender, { header })
|
|
4666
|
+
},
|
|
4667
|
+
header.id
|
|
4668
|
+
);
|
|
4669
|
+
};
|
|
4670
|
+
const stickyLeading = cn(cellDensity, sticky && "sticky top-0 z-20 bg-surface");
|
|
4671
|
+
const leadingHeaderCells = (rowSpan) => /* @__PURE__ */ jsxs40(Fragment14, { children: [
|
|
4672
|
+
enableRowSelection && /* @__PURE__ */ jsx53(TableHead, { checkbox: true, rowSpan, className: stickyLeading, children: /* @__PURE__ */ jsx53(
|
|
4673
|
+
Checkbox,
|
|
4674
|
+
{
|
|
4675
|
+
"aria-label": "Select all rows",
|
|
4676
|
+
checked: allSelected ? true : someSelected ? "indeterminate" : false,
|
|
4677
|
+
disabled: loading,
|
|
4678
|
+
onCheckedChange: (checked) => table.toggleAllPageRowsSelected(Boolean(checked))
|
|
4679
|
+
}
|
|
4680
|
+
) }),
|
|
4681
|
+
hasExpander && /* @__PURE__ */ jsx53(TableHead, { checkbox: true, rowSpan, className: stickyLeading, children: /* @__PURE__ */ jsx53("span", { className: "sr-only", children: "Expand" }) }),
|
|
4682
|
+
enableRowPinning && /* @__PURE__ */ jsx53(TableHead, { checkbox: true, rowSpan, className: stickyLeading, children: /* @__PURE__ */ jsx53("span", { className: "sr-only", children: "Pin" }) })
|
|
4683
|
+
] });
|
|
4684
|
+
const rowsToRender = virtualized ? virtualItems.map((item) => ({ row: bodyRows[item.index], index: item.index })) : null;
|
|
4685
|
+
const totalRows = topRows.length + bodyRows.length + bottomRows.length;
|
|
4686
|
+
return /* @__PURE__ */ jsxs40("div", { className: cn("flex w-full flex-col gap-2", wrapperClassName), children: [
|
|
4687
|
+
showToolbar && /* @__PURE__ */ jsxs40("div", { className: "flex items-center justify-between gap-2", children: [
|
|
4688
|
+
/* @__PURE__ */ jsxs40("div", { className: "flex items-center gap-2", children: [
|
|
4689
|
+
enableGlobalFilter && /* @__PURE__ */ jsx53(
|
|
4690
|
+
SearchBar,
|
|
4691
|
+
{
|
|
4692
|
+
"aria-label": "Search table",
|
|
4693
|
+
placeholder: globalFilterPlaceholder,
|
|
4694
|
+
value: globalFilter,
|
|
4695
|
+
onChange: (event) => table.setGlobalFilter(event.target.value),
|
|
4696
|
+
onClear: () => table.setGlobalFilter(""),
|
|
4697
|
+
className: "w-64"
|
|
4698
|
+
}
|
|
4699
|
+
),
|
|
4700
|
+
toolbar
|
|
4701
|
+
] }),
|
|
4702
|
+
/* @__PURE__ */ jsxs40("div", { className: "flex items-center gap-2", children: [
|
|
4703
|
+
enableDensityToggle && /* @__PURE__ */ jsxs40(
|
|
4704
|
+
Button,
|
|
4705
|
+
{
|
|
4706
|
+
type: "button",
|
|
4707
|
+
variant: "outline",
|
|
4708
|
+
size: "sm",
|
|
4709
|
+
"aria-pressed": compact,
|
|
4710
|
+
onClick: () => setDensity(compact ? "default" : "compact"),
|
|
4711
|
+
children: [
|
|
4712
|
+
/* @__PURE__ */ jsx53(Rows, { size: 16, "aria-hidden": true }),
|
|
4713
|
+
"Compact"
|
|
4714
|
+
]
|
|
4715
|
+
}
|
|
4716
|
+
),
|
|
4717
|
+
enableGrouping && /* @__PURE__ */ jsxs40(DropdownMenu, { children: [
|
|
4718
|
+
/* @__PURE__ */ jsx53(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs40(Button, { type: "button", variant: "outline", size: "sm", children: [
|
|
4719
|
+
/* @__PURE__ */ jsx53(Stack, { size: 16, "aria-hidden": true }),
|
|
4720
|
+
"Group by"
|
|
4721
|
+
] }) }),
|
|
4722
|
+
/* @__PURE__ */ jsxs40(DropdownMenuContent, { align: "end", children: [
|
|
4723
|
+
/* @__PURE__ */ jsx53(DropdownMenuLabel, { children: "Group rows by" }),
|
|
4724
|
+
/* @__PURE__ */ jsx53(DropdownMenuSeparator, {}),
|
|
4725
|
+
groupableColumns.map((column) => /* @__PURE__ */ jsx53(
|
|
4726
|
+
DropdownMenuCheckboxItem,
|
|
4727
|
+
{
|
|
4728
|
+
checked: column.getIsGrouped(),
|
|
4729
|
+
onCheckedChange: () => column.toggleGrouping(),
|
|
4730
|
+
children: labelOf(column)
|
|
4731
|
+
},
|
|
4732
|
+
column.id
|
|
4733
|
+
))
|
|
4734
|
+
] })
|
|
4735
|
+
] }),
|
|
4736
|
+
enableColumnVisibility && /* @__PURE__ */ jsxs40(DropdownMenu, { children: [
|
|
4737
|
+
/* @__PURE__ */ jsx53(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs40(Button, { type: "button", variant: "outline", size: "sm", children: [
|
|
4738
|
+
/* @__PURE__ */ jsx53(Sliders, { size: 16, "aria-hidden": true }),
|
|
4739
|
+
"Columns"
|
|
4740
|
+
] }) }),
|
|
4741
|
+
/* @__PURE__ */ jsxs40(DropdownMenuContent, { align: "end", children: [
|
|
4742
|
+
/* @__PURE__ */ jsx53(DropdownMenuLabel, { children: "Toggle columns" }),
|
|
4743
|
+
/* @__PURE__ */ jsx53(DropdownMenuSeparator, {}),
|
|
4744
|
+
hideableColumns.map((column) => /* @__PURE__ */ jsx53(
|
|
4745
|
+
DropdownMenuCheckboxItem,
|
|
4746
|
+
{
|
|
4747
|
+
checked: column.getIsVisible(),
|
|
4748
|
+
onCheckedChange: (checked) => column.toggleVisibility(Boolean(checked)),
|
|
4749
|
+
children: labelOf(column)
|
|
4750
|
+
},
|
|
4751
|
+
column.id
|
|
4752
|
+
))
|
|
4753
|
+
] })
|
|
4754
|
+
] })
|
|
4755
|
+
] })
|
|
4756
|
+
] }),
|
|
4757
|
+
/* @__PURE__ */ jsxs40(
|
|
4758
|
+
Table,
|
|
4759
|
+
{
|
|
4760
|
+
ref,
|
|
4761
|
+
containerRef: setScrollRef,
|
|
4762
|
+
containerClassName,
|
|
4763
|
+
striped,
|
|
4764
|
+
"aria-busy": loading || loadingMore || void 0,
|
|
4765
|
+
style: sized ? { width: table.getTotalSize(), minWidth: "100%", tableLayout: "fixed", ...tableStyle } : tableStyle,
|
|
4766
|
+
onKeyDown: enableCellSelection ? onGridKeyDown : void 0,
|
|
4767
|
+
tabIndex: enableCellSelection ? 0 : void 0,
|
|
4768
|
+
...tableProps,
|
|
4769
|
+
children: [
|
|
4770
|
+
/* @__PURE__ */ jsxs40(TableHeader, { children: [
|
|
4771
|
+
headerGroups.map((group, groupIndex) => /* @__PURE__ */ jsxs40(TableRow, { className: "hover:bg-transparent", children: [
|
|
4772
|
+
groupIndex === 0 && leadingHeaderCells(headerGroups.length + (enableColumnFilters ? 1 : 0)),
|
|
4773
|
+
group.headers.map(renderHeaderCell)
|
|
4774
|
+
] }, group.id)),
|
|
4775
|
+
enableColumnFilters && /* @__PURE__ */ jsx53(TableRow, { className: "hover:bg-transparent", children: leafColumns.map((column) => {
|
|
4776
|
+
const pin = pinning(column, sized, true);
|
|
4777
|
+
return /* @__PURE__ */ jsx53(
|
|
4778
|
+
TableHead,
|
|
4779
|
+
{
|
|
4780
|
+
style: pin.style,
|
|
4781
|
+
className: cn("h-auto py-2 font-normal", pin.className, sticky && !column.getIsPinned() && "bg-surface"),
|
|
4782
|
+
children: column.getCanFilter() ? /* @__PURE__ */ jsx53(ColumnFilter, { column }) : null
|
|
4783
|
+
},
|
|
4784
|
+
column.id
|
|
4785
|
+
);
|
|
4786
|
+
}) })
|
|
4787
|
+
] }),
|
|
4788
|
+
/* @__PURE__ */ jsxs40(TableBody, { children: [
|
|
4789
|
+
loading ? Array.from({ length: pageSize }, (_, index) => skeletonRow(`loading-${index}`)) : totalRows === 0 ? /* @__PURE__ */ jsx53(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsx53(TableCell, { colSpan: columnSpan, muted: true, className: "h-24 text-center", children: emptyState ?? "No results." }) }) : /* @__PURE__ */ jsxs40(Fragment14, { children: [
|
|
4790
|
+
topRows.map((row, index) => renderRow(row, { pinned: "top", pinnedIndex: index, pinnedCount: topRows.length })),
|
|
4791
|
+
virtualized && paddingTop > 0 && /* @__PURE__ */ jsx53("tr", { "aria-hidden": true, children: /* @__PURE__ */ jsx53("td", { colSpan: columnSpan, style: { height: paddingTop } }) }),
|
|
4792
|
+
rowsToRender ? rowsToRender.map(({ row, index }) => renderRow(row, { virtualIndex: index })) : bodyRows.map((row) => renderRow(row)),
|
|
4793
|
+
virtualized && paddingBottom > 0 && /* @__PURE__ */ jsx53("tr", { "aria-hidden": true, children: /* @__PURE__ */ jsx53("td", { colSpan: columnSpan, style: { height: paddingBottom } }) }),
|
|
4794
|
+
bottomRows.map(
|
|
4795
|
+
(row, index) => renderRow(row, { pinned: "bottom", pinnedIndex: index, pinnedCount: bottomRows.length })
|
|
4796
|
+
)
|
|
4797
|
+
] }),
|
|
4798
|
+
infinite && /* @__PURE__ */ jsxs40(Fragment14, { children: [
|
|
4799
|
+
loadingMore && Array.from({ length: 3 }, (_, index) => skeletonRow(`more-${index}`)),
|
|
4800
|
+
/* @__PURE__ */ jsx53("tr", { ref: sentinelRef, "aria-hidden": true, children: /* @__PURE__ */ jsx53("td", { colSpan: columnSpan, className: "h-px p-0" }) })
|
|
4801
|
+
] })
|
|
4802
|
+
] }),
|
|
4803
|
+
showFooter && /* @__PURE__ */ jsx53(TableFooter, { children: table.getFooterGroups().map((group) => /* @__PURE__ */ jsxs40(TableRow, { className: "hover:bg-transparent", children: [
|
|
4804
|
+
leadingCount > 0 && /* @__PURE__ */ jsx53(TableCell, { colSpan: leadingCount, className: cellDensity }),
|
|
4805
|
+
group.headers.map((header) => {
|
|
4806
|
+
const { align } = getMeta(header.column.columnDef.meta);
|
|
4807
|
+
const pin = pinning(header.column, sized);
|
|
4808
|
+
return /* @__PURE__ */ jsx53(
|
|
4809
|
+
TableCell,
|
|
4810
|
+
{
|
|
4811
|
+
align,
|
|
4812
|
+
colSpan: header.colSpan > 1 ? header.colSpan : void 0,
|
|
4813
|
+
style: pin.style,
|
|
4814
|
+
className: cn("text-ui-label", pin.className, cellDensity),
|
|
4815
|
+
children: header.isPlaceholder ? null : /* @__PURE__ */ jsx53(table.FlexRender, { footer: header })
|
|
4816
|
+
},
|
|
4817
|
+
header.id
|
|
4818
|
+
);
|
|
4819
|
+
})
|
|
4820
|
+
] }, group.id)) })
|
|
4821
|
+
]
|
|
4822
|
+
}
|
|
4823
|
+
),
|
|
4824
|
+
(enableRowSelection || paginate && pageCount > 1) && /* @__PURE__ */ jsxs40("div", { className: "flex items-center justify-between gap-2", children: [
|
|
4825
|
+
/* @__PURE__ */ jsx53("span", { className: "text-body-small text-secondary-muted-foreground", "aria-live": "polite", children: enableRowSelection ? `${selectedCount} of ${table.getCoreRowModel().rows.length} row(s) selected` : null }),
|
|
4826
|
+
paginate && pageCount > 1 && /* @__PURE__ */ jsx53(
|
|
4827
|
+
Pagination,
|
|
4828
|
+
{
|
|
4829
|
+
page: pagination.pageIndex + 1,
|
|
4830
|
+
pageCount,
|
|
4831
|
+
onPageChange: (page) => table.setPageIndex(page - 1)
|
|
4832
|
+
}
|
|
4833
|
+
)
|
|
4834
|
+
] })
|
|
4835
|
+
] });
|
|
4836
|
+
}
|
|
4837
|
+
var DataTable = React52.forwardRef(DataTableInner);
|
|
4838
|
+
DataTable.displayName = "DataTable";
|
|
4839
|
+
|
|
4840
|
+
// src/components/Data Display/StatCard.tsx
|
|
4841
|
+
import * as React53 from "react";
|
|
4842
|
+
import { cva as cva6 } from "class-variance-authority";
|
|
4843
|
+
import { jsx as jsx54, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
3767
4844
|
var statCardVariants = cva6("flex min-w-0 flex-col gap-2 rounded-md border p-3", {
|
|
3768
4845
|
variants: {
|
|
3769
4846
|
variant: {
|
|
@@ -3777,26 +4854,26 @@ var statCardVariants = cva6("flex min-w-0 flex-col gap-2 rounded-md border p-3",
|
|
|
3777
4854
|
},
|
|
3778
4855
|
defaultVariants: { variant: "default" }
|
|
3779
4856
|
});
|
|
3780
|
-
var StatCard =
|
|
3781
|
-
({ className, variant, label, value, icon, caption, ...props }, ref) => /* @__PURE__ */
|
|
3782
|
-
/* @__PURE__ */
|
|
3783
|
-
/* @__PURE__ */
|
|
3784
|
-
icon && /* @__PURE__ */
|
|
4857
|
+
var StatCard = React53.forwardRef(
|
|
4858
|
+
({ className, variant, label, value, icon, caption, ...props }, ref) => /* @__PURE__ */ jsxs41("div", { ref, className: cn(statCardVariants({ variant }), className), ...props, children: [
|
|
4859
|
+
/* @__PURE__ */ jsx54("p", { className: "truncate text-ui-caption text-secondary-muted-foreground", children: label }),
|
|
4860
|
+
/* @__PURE__ */ jsxs41("p", { className: "flex items-center gap-2 text-body-base text-surface-foreground", children: [
|
|
4861
|
+
icon && /* @__PURE__ */ jsx54("span", { "aria-hidden": "true", className: "inline-flex size-6 shrink-0 items-center justify-center", children: icon }),
|
|
3785
4862
|
value
|
|
3786
4863
|
] }),
|
|
3787
|
-
caption && /* @__PURE__ */
|
|
4864
|
+
caption && /* @__PURE__ */ jsx54("p", { className: "text-ui-caption text-secondary-muted-foreground", children: caption })
|
|
3788
4865
|
] })
|
|
3789
4866
|
);
|
|
3790
4867
|
StatCard.displayName = "StatCard";
|
|
3791
4868
|
|
|
3792
4869
|
// src/components/Research-Specific/ActivityStructure.tsx
|
|
3793
|
-
import * as
|
|
4870
|
+
import * as React55 from "react";
|
|
3794
4871
|
|
|
3795
4872
|
// src/components/Tags & Badges/EditableTag.tsx
|
|
3796
|
-
import * as
|
|
4873
|
+
import * as React54 from "react";
|
|
3797
4874
|
import { Crown, Plus as Plus5, X as X6 } from "@phosphor-icons/react";
|
|
3798
4875
|
import { cva as cva7 } from "class-variance-authority";
|
|
3799
|
-
import { jsx as
|
|
4876
|
+
import { jsx as jsx55, jsxs as jsxs42 } from "react/jsx-runtime";
|
|
3800
4877
|
var editableTagVariants = cva7(
|
|
3801
4878
|
"inline-flex h-6.5 items-center whitespace-nowrap rounded-sm py-1 text-ui-caption transition-colors",
|
|
3802
4879
|
{
|
|
@@ -3811,27 +4888,27 @@ var editableTagVariants = cva7(
|
|
|
3811
4888
|
defaultVariants: { type: "default" }
|
|
3812
4889
|
}
|
|
3813
4890
|
);
|
|
3814
|
-
var EditableTag =
|
|
4891
|
+
var EditableTag = React54.forwardRef(
|
|
3815
4892
|
({ className, type = "default", icon, onRemove, onClick, children, ...props }, ref) => {
|
|
3816
4893
|
const classes = cn(editableTagVariants({ type }), className);
|
|
3817
|
-
const leading = type === "add" ? /* @__PURE__ */
|
|
4894
|
+
const leading = type === "add" ? /* @__PURE__ */ jsx55(Plus5, { size: 12, "aria-hidden": true }) : icon !== void 0 ? icon : type === "default" ? /* @__PURE__ */ jsx55(Crown, { size: 12, weight: "fill", "aria-hidden": true }) : null;
|
|
3818
4895
|
if (type === "add" || type === "multiple" && onClick) {
|
|
3819
|
-
return /* @__PURE__ */
|
|
4896
|
+
return /* @__PURE__ */ jsxs42("button", { ref, type: "button", className: classes, onClick, ...props, children: [
|
|
3820
4897
|
leading,
|
|
3821
4898
|
children
|
|
3822
4899
|
] });
|
|
3823
4900
|
}
|
|
3824
|
-
return /* @__PURE__ */
|
|
4901
|
+
return /* @__PURE__ */ jsxs42("span", { ref, className: classes, ...props, children: [
|
|
3825
4902
|
leading,
|
|
3826
4903
|
children,
|
|
3827
|
-
onRemove && /* @__PURE__ */
|
|
4904
|
+
onRemove && /* @__PURE__ */ jsx55(
|
|
3828
4905
|
"button",
|
|
3829
4906
|
{
|
|
3830
4907
|
type: "button",
|
|
3831
4908
|
"aria-label": typeof children === "string" ? `Remove ${children}` : "Remove",
|
|
3832
4909
|
onClick: onRemove,
|
|
3833
4910
|
className: "inline-flex size-3 items-center justify-center rounded-xs",
|
|
3834
|
-
children: /* @__PURE__ */
|
|
4911
|
+
children: /* @__PURE__ */ jsx55(X6, { size: 12, "aria-hidden": true })
|
|
3835
4912
|
}
|
|
3836
4913
|
)
|
|
3837
4914
|
] });
|
|
@@ -3840,26 +4917,26 @@ var EditableTag = React52.forwardRef(
|
|
|
3840
4917
|
EditableTag.displayName = "EditableTag";
|
|
3841
4918
|
|
|
3842
4919
|
// src/components/Research-Specific/ActivityStructure.tsx
|
|
3843
|
-
import { jsx as
|
|
3844
|
-
var ActivityStructure =
|
|
3845
|
-
({ className, title = "Activity Structure", stats, sections, onRemoveTag, onAddTag, addTagLabel = "Add tag", action, children, ...props }, ref) => /* @__PURE__ */
|
|
4920
|
+
import { jsx as jsx56, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
4921
|
+
var ActivityStructure = React55.forwardRef(
|
|
4922
|
+
({ className, title = "Activity Structure", stats, sections, onRemoveTag, onAddTag, addTagLabel = "Add tag", action, children, ...props }, ref) => /* @__PURE__ */ jsxs43(
|
|
3846
4923
|
"section",
|
|
3847
4924
|
{
|
|
3848
4925
|
ref,
|
|
3849
4926
|
className: cn("flex w-full max-w-96.5 flex-col gap-4 rounded-xl bg-surface p-4", className),
|
|
3850
4927
|
...props,
|
|
3851
4928
|
children: [
|
|
3852
|
-
/* @__PURE__ */
|
|
3853
|
-
/* @__PURE__ */
|
|
4929
|
+
/* @__PURE__ */ jsxs43("div", { className: "flex items-center justify-between gap-2", children: [
|
|
4930
|
+
/* @__PURE__ */ jsx56("h3", { className: "text-body-section text-surface-foreground", children: title }),
|
|
3854
4931
|
action
|
|
3855
4932
|
] }),
|
|
3856
|
-
stats.length > 0 && /* @__PURE__ */
|
|
3857
|
-
sections?.map(({ id, heading, body, tags }) => /* @__PURE__ */
|
|
3858
|
-
/* @__PURE__ */
|
|
3859
|
-
/* @__PURE__ */
|
|
3860
|
-
(tags?.length || onAddTag) && /* @__PURE__ */
|
|
3861
|
-
tags?.map((tag) => /* @__PURE__ */
|
|
3862
|
-
onAddTag && /* @__PURE__ */
|
|
4933
|
+
stats.length > 0 && /* @__PURE__ */ jsx56("div", { className: "grid grid-cols-2 gap-3", children: stats.map(({ id, ...stat }) => /* @__PURE__ */ jsx56(StatCard, { ...stat }, id)) }),
|
|
4934
|
+
sections?.map(({ id, heading, body, tags }) => /* @__PURE__ */ jsxs43("div", { className: "flex flex-col gap-2", children: [
|
|
4935
|
+
/* @__PURE__ */ jsx56("h4", { className: "text-heading-h4 text-surface-foreground", children: heading }),
|
|
4936
|
+
/* @__PURE__ */ jsx56("div", { className: "text-body-base text-surface-foreground", children: body }),
|
|
4937
|
+
(tags?.length || onAddTag) && /* @__PURE__ */ jsxs43("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
4938
|
+
tags?.map((tag) => /* @__PURE__ */ jsx56(EditableTag, { type: "editable", onRemove: onRemoveTag && (() => onRemoveTag(id, tag)), children: tag }, tag)),
|
|
4939
|
+
onAddTag && /* @__PURE__ */ jsx56(EditableTag, { type: "add", onClick: () => onAddTag(id), children: addTagLabel })
|
|
3863
4940
|
] })
|
|
3864
4941
|
] }, id)),
|
|
3865
4942
|
children
|
|
@@ -3870,10 +4947,10 @@ var ActivityStructure = React53.forwardRef(
|
|
|
3870
4947
|
ActivityStructure.displayName = "ActivityStructure";
|
|
3871
4948
|
|
|
3872
4949
|
// src/components/Tags & Badges/Badge.tsx
|
|
3873
|
-
import * as
|
|
4950
|
+
import * as React56 from "react";
|
|
3874
4951
|
import { DotsSixVertical as DotsSixVertical5, RadioButton as RadioButton2 } from "@phosphor-icons/react";
|
|
3875
4952
|
import { cva as cva8 } from "class-variance-authority";
|
|
3876
|
-
import { jsx as
|
|
4953
|
+
import { jsx as jsx57, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
3877
4954
|
var roleTagVariants = cva8(
|
|
3878
4955
|
"group inline-flex h-6 items-center whitespace-nowrap rounded-sm py-1 text-ui-caption transition-colors",
|
|
3879
4956
|
{
|
|
@@ -3899,11 +4976,11 @@ var roleTagVariants = cva8(
|
|
|
3899
4976
|
defaultVariants: { type: "primary", selected: false }
|
|
3900
4977
|
}
|
|
3901
4978
|
);
|
|
3902
|
-
var Badge =
|
|
4979
|
+
var Badge = React56.forwardRef(
|
|
3903
4980
|
({ className, type = "primary", selected = false, onClick, children, ...props }, ref) => {
|
|
3904
4981
|
const classes = cn(roleTagVariants({ type, selected: type === "interactable" ? selected : false }), className);
|
|
3905
4982
|
if (type === "interactable") {
|
|
3906
|
-
return /* @__PURE__ */
|
|
4983
|
+
return /* @__PURE__ */ jsxs44(
|
|
3907
4984
|
"button",
|
|
3908
4985
|
{
|
|
3909
4986
|
ref,
|
|
@@ -3913,100 +4990,20 @@ var Badge = React54.forwardRef(
|
|
|
3913
4990
|
onClick,
|
|
3914
4991
|
...props,
|
|
3915
4992
|
children: [
|
|
3916
|
-
/* @__PURE__ */
|
|
4993
|
+
/* @__PURE__ */ jsx57(DotsSixVertical5, { size: 16, "aria-hidden": true, className: "hidden shrink-0 group-hover:block" }),
|
|
3917
4994
|
children
|
|
3918
4995
|
]
|
|
3919
4996
|
}
|
|
3920
4997
|
);
|
|
3921
4998
|
}
|
|
3922
|
-
return /* @__PURE__ */
|
|
3923
|
-
type === "question" && /* @__PURE__ */
|
|
3924
|
-
type === "id" && /* @__PURE__ */
|
|
4999
|
+
return /* @__PURE__ */ jsxs44("span", { ref, className: classes, ...props, children: [
|
|
5000
|
+
type === "question" && /* @__PURE__ */ jsx57(RadioButton2, { size: 16, weight: "fill", "aria-hidden": true }),
|
|
5001
|
+
type === "id" && /* @__PURE__ */ jsx57("span", { className: "text-secondary-muted-foreground", children: "ID" }),
|
|
3925
5002
|
children
|
|
3926
5003
|
] });
|
|
3927
5004
|
}
|
|
3928
5005
|
);
|
|
3929
5006
|
Badge.displayName = "Badge";
|
|
3930
|
-
|
|
3931
|
-
// src/components/Utility/Pagination.tsx
|
|
3932
|
-
import * as React55 from "react";
|
|
3933
|
-
import { ArrowLeft, ArrowRight, DotsThree as DotsThree2 } from "@phosphor-icons/react";
|
|
3934
|
-
import { jsx as jsx56, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
3935
|
-
function getPaginationItems(page, pageCount, siblings = 1) {
|
|
3936
|
-
const keep = /* @__PURE__ */ new Set([1, pageCount]);
|
|
3937
|
-
for (let p = page - siblings; p <= page + siblings; p++) if (p >= 1 && p <= pageCount) keep.add(p);
|
|
3938
|
-
const sorted = [...keep].sort((a, b) => a - b);
|
|
3939
|
-
const items = [];
|
|
3940
|
-
sorted.forEach((p, index) => {
|
|
3941
|
-
const previous = sorted[index - 1];
|
|
3942
|
-
if (previous !== void 0 && p - previous === 2) items.push(previous + 1);
|
|
3943
|
-
else if (previous !== void 0 && p - previous > 2) items.push("ellipsis");
|
|
3944
|
-
items.push(p);
|
|
3945
|
-
});
|
|
3946
|
-
return items;
|
|
3947
|
-
}
|
|
3948
|
-
var Pagination = React55.forwardRef(
|
|
3949
|
-
({ className, page, pageCount, onPageChange, variant = "full", siblings = 1, ...props }, ref) => {
|
|
3950
|
-
const go = (next2) => onPageChange(Math.min(pageCount, Math.max(1, next2)));
|
|
3951
|
-
const previous = /* @__PURE__ */ jsx56(
|
|
3952
|
-
Button,
|
|
3953
|
-
{
|
|
3954
|
-
type: "button",
|
|
3955
|
-
variant: "outline",
|
|
3956
|
-
size: "icon-sm",
|
|
3957
|
-
"aria-label": "Previous page",
|
|
3958
|
-
disabled: page <= 1,
|
|
3959
|
-
onClick: () => go(page - 1),
|
|
3960
|
-
children: /* @__PURE__ */ jsx56(ArrowLeft, { size: 16, "aria-hidden": true })
|
|
3961
|
-
}
|
|
3962
|
-
);
|
|
3963
|
-
const next = /* @__PURE__ */ jsx56(
|
|
3964
|
-
Button,
|
|
3965
|
-
{
|
|
3966
|
-
type: "button",
|
|
3967
|
-
variant: "outline",
|
|
3968
|
-
size: "icon-sm",
|
|
3969
|
-
"aria-label": "Next page",
|
|
3970
|
-
disabled: page >= pageCount,
|
|
3971
|
-
onClick: () => go(page + 1),
|
|
3972
|
-
children: /* @__PURE__ */ jsx56(ArrowRight, { size: 16, "aria-hidden": true })
|
|
3973
|
-
}
|
|
3974
|
-
);
|
|
3975
|
-
return /* @__PURE__ */ jsxs43(
|
|
3976
|
-
"nav",
|
|
3977
|
-
{
|
|
3978
|
-
ref,
|
|
3979
|
-
"aria-label": "Pagination",
|
|
3980
|
-
className: cn("flex items-center", variant === "compact" ? "w-35 justify-between" : "gap-2", className),
|
|
3981
|
-
...props,
|
|
3982
|
-
children: [
|
|
3983
|
-
previous,
|
|
3984
|
-
variant === "compact" ? /* @__PURE__ */ jsxs43("span", { className: "text-body-small text-surface-foreground", "aria-live": "polite", children: [
|
|
3985
|
-
page,
|
|
3986
|
-
"/",
|
|
3987
|
-
pageCount
|
|
3988
|
-
] }) : /* @__PURE__ */ jsx56("ul", { className: "flex items-center gap-2", children: getPaginationItems(page, pageCount, siblings).map((item, index) => /* @__PURE__ */ jsx56("li", { children: item === "ellipsis" ? /* @__PURE__ */ jsxs43("span", { className: "inline-flex size-8 items-center justify-center rounded-sm border border-border bg-surface text-surface-foreground", children: [
|
|
3989
|
-
/* @__PURE__ */ jsx56(DotsThree2, { size: 16, "aria-hidden": true }),
|
|
3990
|
-
/* @__PURE__ */ jsx56("span", { className: "sr-only", children: "More pages" })
|
|
3991
|
-
] }) : /* @__PURE__ */ jsx56(
|
|
3992
|
-
Button,
|
|
3993
|
-
{
|
|
3994
|
-
type: "button",
|
|
3995
|
-
variant: item === page ? "subtle" : "outline",
|
|
3996
|
-
size: "sm",
|
|
3997
|
-
"aria-label": `Page ${item}`,
|
|
3998
|
-
"aria-current": item === page ? "page" : void 0,
|
|
3999
|
-
onClick: () => go(item),
|
|
4000
|
-
children: item
|
|
4001
|
-
}
|
|
4002
|
-
) }, item === "ellipsis" ? `ellipsis-${index}` : item)) }),
|
|
4003
|
-
next
|
|
4004
|
-
]
|
|
4005
|
-
}
|
|
4006
|
-
);
|
|
4007
|
-
}
|
|
4008
|
-
);
|
|
4009
|
-
Pagination.displayName = "Pagination";
|
|
4010
5007
|
export {
|
|
4011
5008
|
AIMiniAvatar,
|
|
4012
5009
|
AIResponseContainer,
|
|
@@ -4021,6 +5018,7 @@ export {
|
|
|
4021
5018
|
ChatOption,
|
|
4022
5019
|
Checkbox,
|
|
4023
5020
|
CheckboxField,
|
|
5021
|
+
DataTable,
|
|
4024
5022
|
DatePicker,
|
|
4025
5023
|
DateTimePicker,
|
|
4026
5024
|
Dialog,
|
|
@@ -4101,6 +5099,7 @@ export {
|
|
|
4101
5099
|
TableBody,
|
|
4102
5100
|
TableCell,
|
|
4103
5101
|
TableCellTwoLines,
|
|
5102
|
+
TableFooter,
|
|
4104
5103
|
TableHead,
|
|
4105
5104
|
TableHeader,
|
|
4106
5105
|
TableRow,
|