@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.cjs
CHANGED
|
@@ -43,6 +43,7 @@ __export(index_exports, {
|
|
|
43
43
|
ChatOption: () => ChatOption,
|
|
44
44
|
Checkbox: () => Checkbox,
|
|
45
45
|
CheckboxField: () => CheckboxField,
|
|
46
|
+
DataTable: () => DataTable,
|
|
46
47
|
DatePicker: () => DatePicker,
|
|
47
48
|
DateTimePicker: () => DateTimePicker,
|
|
48
49
|
Dialog: () => Dialog,
|
|
@@ -123,6 +124,7 @@ __export(index_exports, {
|
|
|
123
124
|
TableBody: () => TableBody,
|
|
124
125
|
TableCell: () => TableCell,
|
|
125
126
|
TableCellTwoLines: () => TableCellTwoLines,
|
|
127
|
+
TableFooter: () => TableFooter,
|
|
126
128
|
TableHead: () => TableHead,
|
|
127
129
|
TableHeader: () => TableHeader,
|
|
128
130
|
TableRow: () => TableRow,
|
|
@@ -198,6 +200,9 @@ var twMerge = (0, import_tailwind_merge.extendTailwindMerge)({
|
|
|
198
200
|
function cn(...inputs) {
|
|
199
201
|
return twMerge((0, import_clsx.clsx)(inputs));
|
|
200
202
|
}
|
|
203
|
+
function lengthOutOfRange(text, min, max) {
|
|
204
|
+
return min !== void 0 && text.trim().length < min || max !== void 0 && text.length > max;
|
|
205
|
+
}
|
|
201
206
|
|
|
202
207
|
// src/components/Buttons & Actions/Button.tsx
|
|
203
208
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -1615,37 +1620,96 @@ function splitMarks(text, marks) {
|
|
|
1615
1620
|
if (at < text.length) out.push({ text: text.slice(at) });
|
|
1616
1621
|
return out;
|
|
1617
1622
|
}
|
|
1618
|
-
var
|
|
1619
|
-
function
|
|
1620
|
-
const
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
const
|
|
1624
|
-
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1623
|
+
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"));
|
|
1624
|
+
function markLines(rects, origin, field) {
|
|
1625
|
+
const count = field ? Math.max(1, Math.round((field.contentBottom - field.contentTop) / field.lineHeight)) : 1;
|
|
1626
|
+
const boxes = rects.filter((r) => r.width > 0).map((r) => {
|
|
1627
|
+
if (!field) return { left: r.left - origin.left, top: r.top - origin.top, width: r.width, height: r.height };
|
|
1628
|
+
const index = Math.min(count - 1, Math.max(0, Math.floor((r.top + r.height / 2 - field.contentTop) / field.lineHeight)));
|
|
1629
|
+
const top = index === 0 ? field.top : field.contentTop + index * field.lineHeight;
|
|
1630
|
+
const bottom = index === count - 1 ? field.bottom : field.contentTop + (index + 1) * field.lineHeight;
|
|
1631
|
+
return { left: r.left - origin.left, top: top - origin.top, width: r.width, height: bottom - top };
|
|
1632
|
+
});
|
|
1633
|
+
return boxes.reduce((out, box) => {
|
|
1634
|
+
const same = field ? out.find((o) => Math.abs(o.top - box.top) < 0.5 && Math.abs(o.height - box.height) < 0.5) : void 0;
|
|
1635
|
+
if (!same) return [...out, box];
|
|
1636
|
+
const left = Math.min(same.left, box.left);
|
|
1637
|
+
const right = Math.max(same.left + same.width, box.left + box.width);
|
|
1638
|
+
return out.map((o) => o === same ? { ...o, left, width: right - left } : o);
|
|
1639
|
+
}, []);
|
|
1640
|
+
}
|
|
1641
|
+
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));
|
|
1642
|
+
function useMarkLines(anchorRef, markRef) {
|
|
1643
|
+
const [lines, setLines] = React24.useState([]);
|
|
1644
|
+
const measure = React24.useCallback(() => {
|
|
1645
|
+
const anchor = anchorRef.current;
|
|
1646
|
+
const mark = markRef.current;
|
|
1647
|
+
if (!anchor || !mark) return;
|
|
1648
|
+
const button = mark.closest("button");
|
|
1649
|
+
const a = anchor.getBoundingClientRect();
|
|
1650
|
+
let field;
|
|
1651
|
+
if (button) {
|
|
1627
1652
|
const b = button.getBoundingClientRect();
|
|
1628
|
-
const
|
|
1629
|
-
const
|
|
1630
|
-
const
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
setPadding((p) => Math.abs(p.top - next.top) < 0.5 && Math.abs(p.bottom - next.bottom) < 0.5 ? p : next);
|
|
1642
|
-
};
|
|
1643
|
-
align();
|
|
1644
|
-
const observer = new ResizeObserver(align);
|
|
1653
|
+
const style = getComputedStyle(button);
|
|
1654
|
+
const contentTop = b.top + (parseFloat(style.borderTopWidth) || 0) + (parseFloat(style.paddingTop) || 0);
|
|
1655
|
+
const contentBottom = b.bottom - (parseFloat(style.borderBottomWidth) || 0) - (parseFloat(style.paddingBottom) || 0);
|
|
1656
|
+
field = { top: b.top, bottom: b.bottom, contentTop, contentBottom, lineHeight: parseFloat(style.lineHeight) || contentBottom - contentTop };
|
|
1657
|
+
}
|
|
1658
|
+
const next = markLines([...mark.getClientRects()], a, field);
|
|
1659
|
+
setLines((prev) => sameLines(prev, next) ? prev : next);
|
|
1660
|
+
}, [anchorRef, markRef]);
|
|
1661
|
+
React24.useLayoutEffect(measure);
|
|
1662
|
+
React24.useLayoutEffect(() => {
|
|
1663
|
+
const button = markRef.current?.closest("button");
|
|
1664
|
+
if (!button) return;
|
|
1665
|
+
const observer = new ResizeObserver(measure);
|
|
1645
1666
|
observer.observe(button);
|
|
1646
1667
|
return () => observer.disconnect();
|
|
1647
|
-
}, [
|
|
1648
|
-
return
|
|
1668
|
+
}, [markRef, measure]);
|
|
1669
|
+
return lines;
|
|
1670
|
+
}
|
|
1671
|
+
function remapMarks(saved, draft, marks) {
|
|
1672
|
+
if (!marks?.length) return [];
|
|
1673
|
+
if (saved === draft) return marks;
|
|
1674
|
+
const max = Math.min(saved.length, draft.length);
|
|
1675
|
+
let before = 0;
|
|
1676
|
+
while (before < max && saved[before] === draft[before]) before += 1;
|
|
1677
|
+
let after = 0;
|
|
1678
|
+
while (after < max - before && saved[saved.length - 1 - after] === draft[draft.length - 1 - after]) after += 1;
|
|
1679
|
+
const editEnd = saved.length - after;
|
|
1680
|
+
const delta = draft.length - saved.length;
|
|
1681
|
+
return marks.flatMap((m) => m.end <= before ? [m] : m.start >= editEnd ? [{ ...m, start: m.start + delta, end: m.end + delta }] : []);
|
|
1682
|
+
}
|
|
1683
|
+
function DraftMarks({ text, marks, layer, className, scrollLeft = 0, singleLine }) {
|
|
1684
|
+
const rootRef = React24.useRef(null);
|
|
1685
|
+
const textRef = React24.useRef(null);
|
|
1686
|
+
const [boxes, setBoxes] = React24.useState([]);
|
|
1687
|
+
React24.useLayoutEffect(() => {
|
|
1688
|
+
if (textRef.current) textRef.current.scrollLeft = scrollLeft;
|
|
1689
|
+
}, [scrollLeft, text]);
|
|
1690
|
+
React24.useLayoutEffect(() => {
|
|
1691
|
+
const root = rootRef.current;
|
|
1692
|
+
const mirror = textRef.current;
|
|
1693
|
+
if (!root || !mirror) return;
|
|
1694
|
+
const r = root.getBoundingClientRect();
|
|
1695
|
+
const style = getComputedStyle(mirror);
|
|
1696
|
+
const contentTop = r.top + (parseFloat(style.borderTopWidth) || 0) + (parseFloat(style.paddingTop) || 0);
|
|
1697
|
+
const contentBottom = r.bottom - (parseFloat(style.borderBottomWidth) || 0) - (parseFloat(style.paddingBottom) || 0);
|
|
1698
|
+
const lineHeight = singleLine ? contentBottom - contentTop : parseFloat(style.lineHeight) || contentBottom - contentTop;
|
|
1699
|
+
const field = { top: r.top, bottom: r.bottom, contentTop, contentBottom, lineHeight };
|
|
1700
|
+
const next = [...mirror.querySelectorAll("[data-draft-mark]")].flatMap(
|
|
1701
|
+
(el) => markLines([...el.getClientRects()], { left: r.left, top: r.top }, field).map((box) => ({ tone: el.dataset.tone ?? "destructive", box }))
|
|
1702
|
+
);
|
|
1703
|
+
setBoxes((prev) => prev.length === next.length && prev.every((p, i) => p.tone === next[i].tone && sameLines([p.box], [next[i].box])) ? prev : next);
|
|
1704
|
+
});
|
|
1705
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { ref: rootRef, "aria-hidden": true, "data-draft-marks": true, "data-layer": layer, className: "pointer-events-none absolute inset-0", children: [
|
|
1706
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: textRef, className: cn(className, "absolute inset-0 overflow-hidden text-transparent"), children: splitMarks(text, marks).map(
|
|
1707
|
+
(piece, i) => piece.mark ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { "data-draft-mark": true, "data-tone": piece.mark.tone ?? "destructive", children: piece.text }, i) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: piece.text }, i)
|
|
1708
|
+
) }),
|
|
1709
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "absolute inset-0", style: { clipPath: "inset(-4px 0)" }, children: boxes.map(
|
|
1710
|
+
({ tone, box }, i) => layer === "behind" ? tone === "warning" && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { "data-draft-box": true, className: "absolute rounded-xxs bg-warning-background-highlight", style: box }, i) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { "data-draft-box": true, className: cn("absolute rounded-xxs border-b-2", tone === "warning" ? "border-warning-foreground" : "border-destructive-foreground"), style: box }, i)
|
|
1711
|
+
) })
|
|
1712
|
+
] });
|
|
1649
1713
|
}
|
|
1650
1714
|
var closeOpenMarkCard = null;
|
|
1651
1715
|
function MarkedText({ mark, text, onApply, onDismiss }) {
|
|
@@ -1658,12 +1722,19 @@ function MarkedText({ mark, text, onApply, onDismiss }) {
|
|
|
1658
1722
|
},
|
|
1659
1723
|
[close]
|
|
1660
1724
|
);
|
|
1661
|
-
const
|
|
1662
|
-
const
|
|
1725
|
+
const anchorRef = React24.useRef(null);
|
|
1726
|
+
const [hovered, setHovered] = React24.useState(false);
|
|
1727
|
+
const lines = useMarkLines(anchorRef, ref);
|
|
1728
|
+
const layers = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { ref: anchorRef, "aria-hidden": true, className: "relative isolate", children: lines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { "data-mark-line": true, className: lineClasses(mark.tone, hovered), style: line }, i)) });
|
|
1663
1729
|
if (!onApply && !onDismiss) {
|
|
1664
|
-
return /* @__PURE__ */ (0, import_jsx_runtime25.
|
|
1730
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
1731
|
+
layers,
|
|
1732
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { ref, "data-mark": true, "data-tone": mark.tone ?? "destructive", className: "relative", children: text })
|
|
1733
|
+
] });
|
|
1665
1734
|
}
|
|
1666
1735
|
const suggestions = (mark.suggestions ?? []).slice(0, 3);
|
|
1736
|
+
const warning = mark.tone === "warning";
|
|
1737
|
+
const struck = "text-destructive-foreground";
|
|
1667
1738
|
const handleOpenChange = (next) => {
|
|
1668
1739
|
if (next) {
|
|
1669
1740
|
if (closeOpenMarkCard && closeOpenMarkCard !== close) closeOpenMarkCard();
|
|
@@ -1675,7 +1746,22 @@ function MarkedText({ mark, text, onApply, onDismiss }) {
|
|
|
1675
1746
|
};
|
|
1676
1747
|
const stop = (event) => event.stopPropagation();
|
|
1677
1748
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_radix_ui14.Popover.Root, { open, onOpenChange: handleOpenChange, children: [
|
|
1678
|
-
|
|
1749
|
+
layers,
|
|
1750
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_radix_ui14.Popover.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1751
|
+
"span",
|
|
1752
|
+
{
|
|
1753
|
+
ref,
|
|
1754
|
+
"data-mark": true,
|
|
1755
|
+
"data-tone": mark.tone ?? "destructive",
|
|
1756
|
+
role: "button",
|
|
1757
|
+
tabIndex: -1,
|
|
1758
|
+
onClick: stop,
|
|
1759
|
+
onMouseEnter: () => setHovered(true),
|
|
1760
|
+
onMouseLeave: () => setHovered(false),
|
|
1761
|
+
className: "relative cursor-pointer",
|
|
1762
|
+
children: text
|
|
1763
|
+
}
|
|
1764
|
+
) }),
|
|
1679
1765
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_radix_ui14.Popover.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
1680
1766
|
import_radix_ui14.Popover.Content,
|
|
1681
1767
|
{
|
|
@@ -1690,18 +1776,19 @@ function MarkedText({ mark, text, onApply, onDismiss }) {
|
|
|
1690
1776
|
suggestions.length > 1 && onApply ? (
|
|
1691
1777
|
// Several possible fixes: each one is a choice, applied with a click, so there is no Apply button.
|
|
1692
1778
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex flex-col gap-1", role: "group", "aria-label": "Choose a correction", children: suggestions.map((suggestion) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Button, { type: "button", size: "sm", variant: "ghost", className: "h-auto justify-start px-2 py-1 whitespace-normal", onClick: () => onApply(mark, suggestion), children: [
|
|
1693
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("s", { className:
|
|
1779
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("s", { className: struck, children: text }),
|
|
1694
1780
|
" ",
|
|
1695
1781
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-semibold text-accent-foreground", children: suggestion === "" ? "Remove" : suggestion })
|
|
1696
1782
|
] }, suggestion)) })
|
|
1697
1783
|
) : suggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("p", { className: "min-w-0 break-words", children: [
|
|
1698
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("s", { className:
|
|
1784
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("s", { className: struck, children: text }),
|
|
1699
1785
|
suggestions[0] !== "" && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
1700
1786
|
" ",
|
|
1701
1787
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-semibold text-accent-foreground", children: suggestions[0] })
|
|
1702
1788
|
] })
|
|
1703
1789
|
] }),
|
|
1704
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.
|
|
1790
|
+
mark.message && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "min-w-0 break-words text-body-small text-surface-foreground", children: mark.message }),
|
|
1791
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: cn("flex items-center gap-3", warning ? "justify-end" : "justify-between"), children: [
|
|
1705
1792
|
onDismiss ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Button, { type: "button", size: "sm", variant: "ghost", onClick: () => onDismiss(mark), children: [
|
|
1706
1793
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react11.Trash, { size: 16, "aria-hidden": true }),
|
|
1707
1794
|
" Dismiss"
|
|
@@ -1753,7 +1840,10 @@ var InlineEdit = React25.forwardRef(
|
|
|
1753
1840
|
const [draft, setDraft] = React25.useState(value);
|
|
1754
1841
|
const [error, setError] = React25.useState(null);
|
|
1755
1842
|
const errorId = React25.useId();
|
|
1843
|
+
const limitsVisible = !!showLimits && (!!error || lengthOutOfRange(draft, minLength, maxLength));
|
|
1756
1844
|
const fieldRef = React25.useRef(null);
|
|
1845
|
+
const [scroll, setScroll] = React25.useState(0);
|
|
1846
|
+
const [draftMarks, setDraftMarks] = React25.useState([]);
|
|
1757
1847
|
const readRef = React25.useRef(null);
|
|
1758
1848
|
const cancelled = React25.useRef(false);
|
|
1759
1849
|
const restoreFocus = React25.useRef(false);
|
|
@@ -1775,6 +1865,7 @@ var InlineEdit = React25.forwardRef(
|
|
|
1775
1865
|
const start = () => {
|
|
1776
1866
|
if (disabled) return;
|
|
1777
1867
|
setDraft(value);
|
|
1868
|
+
setDraftMarks(marks ?? []);
|
|
1778
1869
|
setError(null);
|
|
1779
1870
|
cancelled.current = false;
|
|
1780
1871
|
setEditing(true);
|
|
@@ -1800,48 +1891,78 @@ var InlineEdit = React25.forwardRef(
|
|
|
1800
1891
|
};
|
|
1801
1892
|
const textClasses = cn("text-ui-input-value text-surface-foreground", textClassName);
|
|
1802
1893
|
const question = variant === "question";
|
|
1894
|
+
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);
|
|
1803
1895
|
const fill = multiline || question;
|
|
1804
1896
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1805
1897
|
"div",
|
|
1806
1898
|
{
|
|
1807
1899
|
ref,
|
|
1808
|
-
className: cn(fill ? "flex w-full min-w-0" : "inline-flex min-w-0 max-w-full", editing && (error ||
|
|
1900
|
+
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),
|
|
1809
1901
|
...props,
|
|
1810
1902
|
children: editing ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
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")),
|
|
1823
|
-
textClasses
|
|
1903
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: cn("relative flex w-full min-w-0", draftMarks.length > 0 && !question && "rounded-md bg-surface"), children: [
|
|
1904
|
+
draftMarks.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1905
|
+
DraftMarks,
|
|
1906
|
+
{
|
|
1907
|
+
layer: "behind",
|
|
1908
|
+
singleLine: !multiline,
|
|
1909
|
+
text: draft,
|
|
1910
|
+
marks: draftMarks,
|
|
1911
|
+
scrollLeft: multiline ? 0 : scroll,
|
|
1912
|
+
className: draftMarksClass
|
|
1913
|
+
}
|
|
1824
1914
|
),
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1915
|
+
React25.createElement(multiline ? "textarea" : "input", {
|
|
1916
|
+
ref: fieldRef,
|
|
1917
|
+
value: draft,
|
|
1918
|
+
maxLength,
|
|
1919
|
+
"aria-label": ariaLabel,
|
|
1920
|
+
"aria-invalid": error ? true : void 0,
|
|
1921
|
+
"aria-describedby": error || limitsVisible ? errorId : void 0,
|
|
1922
|
+
...multiline ? { rows: 1 } : { type: "text" },
|
|
1923
|
+
className: cn(
|
|
1924
|
+
"relative w-full px-3 py-1 outline-none",
|
|
1925
|
+
multiline && "field-sizing-content resize-none",
|
|
1926
|
+
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")),
|
|
1927
|
+
textClasses,
|
|
1928
|
+
// Transparent over the highlight layer, so the highlight and the browser's text selection show together.
|
|
1929
|
+
draftMarks.length > 0 && "bg-transparent"
|
|
1930
|
+
),
|
|
1931
|
+
onChange: (event) => {
|
|
1932
|
+
setDraft(event.target.value);
|
|
1933
|
+
setDraftMarks(remapMarks(draft, event.target.value, draftMarks));
|
|
1934
|
+
requestAnimationFrame(() => setScroll(fieldRef.current?.scrollLeft ?? 0));
|
|
1935
|
+
if (error) setError(problemWith(event.target.value));
|
|
1936
|
+
onDraftChange?.(event.target.value);
|
|
1937
|
+
},
|
|
1938
|
+
onKeyDown: (event) => {
|
|
1939
|
+
if (event.key === "Escape") {
|
|
1940
|
+
cancelled.current = true;
|
|
1941
|
+
setError(null);
|
|
1942
|
+
finish(false, true);
|
|
1943
|
+
} else if (event.key === "Enter" && (!multiline || event.metaKey || event.ctrlKey || (question || submitOnEnter) && !event.shiftKey)) {
|
|
1944
|
+
event.preventDefault();
|
|
1945
|
+
finish(true, true);
|
|
1946
|
+
}
|
|
1947
|
+
},
|
|
1948
|
+
onScroll: (event) => setScroll(event.currentTarget.scrollLeft),
|
|
1949
|
+
onBlur: () => {
|
|
1950
|
+
if (!cancelled.current) finish(true, false);
|
|
1838
1951
|
}
|
|
1839
|
-
},
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1952
|
+
}),
|
|
1953
|
+
draftMarks.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1954
|
+
DraftMarks,
|
|
1955
|
+
{
|
|
1956
|
+
layer: "over",
|
|
1957
|
+
singleLine: !multiline,
|
|
1958
|
+
text: draft,
|
|
1959
|
+
marks: draftMarks,
|
|
1960
|
+
scrollLeft: multiline ? 0 : scroll,
|
|
1961
|
+
className: draftMarksClass
|
|
1962
|
+
}
|
|
1963
|
+
)
|
|
1964
|
+
] }),
|
|
1965
|
+
(error || limitsVisible) && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
1845
1966
|
"p",
|
|
1846
1967
|
{
|
|
1847
1968
|
id: errorId,
|
|
@@ -1850,10 +1971,10 @@ var InlineEdit = React25.forwardRef(
|
|
|
1850
1971
|
children: [
|
|
1851
1972
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("span", { className: "flex items-start gap-2", children: [
|
|
1852
1973
|
error && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_react12.WarningCircle, { size: 16, "aria-hidden": true, className: "shrink-0" }),
|
|
1853
|
-
|
|
1854
|
-
|
|
1974
|
+
limitsVisible ? limitsText(minLength, maxLength) : error,
|
|
1975
|
+
limitsVisible && error && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "sr-only", children: error })
|
|
1855
1976
|
] }),
|
|
1856
|
-
|
|
1977
|
+
limitsVisible && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("span", { "aria-hidden": true, className: "shrink-0 tabular-nums", children: [
|
|
1857
1978
|
draft.length,
|
|
1858
1979
|
maxLength !== void 0 && `/${maxLength}`
|
|
1859
1980
|
] })
|
|
@@ -3054,7 +3175,7 @@ var QuestionHeader = React42.forwardRef(
|
|
|
3054
3175
|
}
|
|
3055
3176
|
),
|
|
3056
3177
|
long && titleRecommendedNote != null && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { className: "text-ui-caption text-secondary-muted-foreground", children: titleRecommendedNote }),
|
|
3057
|
-
showCounter && titleMinLength === void 0 && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
|
|
3178
|
+
showCounter && titleMinLength === void 0 && maxLength !== void 0 && count > maxLength && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
|
|
3058
3179
|
count,
|
|
3059
3180
|
"/",
|
|
3060
3181
|
maxLength,
|
|
@@ -3364,6 +3485,9 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
|
|
|
3364
3485
|
const [focused, setFocused] = React45.useState(false);
|
|
3365
3486
|
const showMarks = !!marks?.length && !focused && draft === null;
|
|
3366
3487
|
const fieldRef = React45.useRef(null);
|
|
3488
|
+
const [editMarks, setEditMarks] = React45.useState([]);
|
|
3489
|
+
const [scroll, setScroll] = React45.useState(0);
|
|
3490
|
+
const typed = guarded ? draft ?? label : label;
|
|
3367
3491
|
const skipBlur = React45.useRef(false);
|
|
3368
3492
|
const problemWith = (text) => minLength !== void 0 && text.trim().length < minLength ? `Enter at least ${minLength} ${minLength === 1 ? "character" : "characters"}.` : null;
|
|
3369
3493
|
const save = () => {
|
|
@@ -3434,6 +3558,7 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
|
|
|
3434
3558
|
] }) : locked ? null : grip }),
|
|
3435
3559
|
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
3436
3560
|
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "relative min-w-0", children: [
|
|
3561
|
+
focused && editMarks.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DraftMarks, { layer: "behind", singleLine: true, text: typed, marks: editMarks, scrollLeft: scroll, className: "flex items-center whitespace-pre text-body-base" }),
|
|
3437
3562
|
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
3438
3563
|
"input",
|
|
3439
3564
|
{
|
|
@@ -3446,13 +3571,17 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
|
|
|
3446
3571
|
value: guarded ? draft ?? label : label,
|
|
3447
3572
|
onFocus: () => {
|
|
3448
3573
|
setFocused(true);
|
|
3574
|
+
setEditMarks(marks ?? []);
|
|
3449
3575
|
if (guarded && draft === null) setDraft(label);
|
|
3450
3576
|
},
|
|
3451
3577
|
onChange: (event) => {
|
|
3578
|
+
requestAnimationFrame(() => setScroll(fieldRef.current?.scrollLeft ?? 0));
|
|
3579
|
+
setEditMarks(remapMarks(typed, event.target.value, editMarks));
|
|
3452
3580
|
if (!guarded) return onLabelChange?.(event.target.value);
|
|
3453
3581
|
setDraft(event.target.value);
|
|
3454
3582
|
if (error) setError(problemWith(event.target.value));
|
|
3455
3583
|
},
|
|
3584
|
+
onScroll: (event) => setScroll(event.currentTarget.scrollLeft),
|
|
3456
3585
|
onKeyDown: (event) => {
|
|
3457
3586
|
if (!guarded) return;
|
|
3458
3587
|
if (event.key === "Escape") {
|
|
@@ -3478,18 +3607,19 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
|
|
|
3478
3607
|
save();
|
|
3479
3608
|
},
|
|
3480
3609
|
className: cn(
|
|
3481
|
-
"w-full min-w-0 bg-transparent text-body-base text-surface-foreground outline-none",
|
|
3610
|
+
"relative w-full min-w-0 bg-transparent text-body-base text-surface-foreground outline-none",
|
|
3482
3611
|
placeholderTone === "regular" ? "placeholder:text-surface-foreground" : "placeholder:text-muted-foreground",
|
|
3483
3612
|
// The marked text is drawn over the field, so the field's own letters step aside until it is edited.
|
|
3484
3613
|
showMarks && "text-transparent"
|
|
3485
3614
|
)
|
|
3486
3615
|
}
|
|
3487
3616
|
),
|
|
3617
|
+
focused && editMarks.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DraftMarks, { layer: "over", singleLine: true, text: typed, marks: editMarks, scrollLeft: scroll, className: "flex items-center whitespace-pre text-body-base" }),
|
|
3488
3618
|
showMarks && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("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(
|
|
3489
3619
|
(piece, i) => piece.mark ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(MarkedText, { mark: piece.mark, text: piece.text, onApply: onMarkApply, onDismiss: onMarkDismiss }, `${piece.mark.start}:${piece.text}`) : /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { children: piece.text }, i)
|
|
3490
3620
|
) })
|
|
3491
3621
|
] }),
|
|
3492
|
-
guarded && draft !== null && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
3622
|
+
guarded && draft !== null && (error || lengthOutOfRange(draft, minLength, maxLength)) && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
3493
3623
|
"p",
|
|
3494
3624
|
{
|
|
3495
3625
|
id: helperId,
|
|
@@ -3747,7 +3877,7 @@ var StimulusCard = React48.forwardRef(
|
|
|
3747
3877
|
textClassName: "text-body-base"
|
|
3748
3878
|
}
|
|
3749
3879
|
) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { className: "w-full text-body-base [word-break:break-word]", children: caption }),
|
|
3750
|
-
onCaptionChange && showCounter && maxLength !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
|
|
3880
|
+
onCaptionChange && showCounter && maxLength !== void 0 && count > maxLength && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
|
|
3751
3881
|
count,
|
|
3752
3882
|
"/",
|
|
3753
3883
|
maxLength,
|
|
@@ -3807,7 +3937,7 @@ var React50 = __toESM(require("react"), 1);
|
|
|
3807
3937
|
var import_react27 = require("@phosphor-icons/react");
|
|
3808
3938
|
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
3809
3939
|
var Table = React50.forwardRef(
|
|
3810
|
-
({ className, containerClassName, striped, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: cn("relative w-full overflow-auto rounded-lg border border-border bg-surface", containerClassName), children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
3940
|
+
({ className, containerClassName, containerRef, striped, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { ref: containerRef, className: cn("relative w-full overflow-auto rounded-lg border border-border bg-surface", containerClassName), children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
3811
3941
|
"table",
|
|
3812
3942
|
{
|
|
3813
3943
|
ref,
|
|
@@ -3822,6 +3952,10 @@ var TableHeader = React50.forwardRef(
|
|
|
3822
3952
|
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("thead", { ref, className, ...props })
|
|
3823
3953
|
);
|
|
3824
3954
|
TableHeader.displayName = "TableHeader";
|
|
3955
|
+
var TableFooter = React50.forwardRef(
|
|
3956
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("tfoot", { ref, className: cn("border-t border-border bg-background text-ui-label", className), ...props })
|
|
3957
|
+
);
|
|
3958
|
+
TableFooter.displayName = "TableFooter";
|
|
3825
3959
|
var TableBody = React50.forwardRef(
|
|
3826
3960
|
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("tbody", { ref, className, ...props })
|
|
3827
3961
|
);
|
|
@@ -3845,9 +3979,9 @@ var TableRow = React50.forwardRef(
|
|
|
3845
3979
|
TableRow.displayName = "TableRow";
|
|
3846
3980
|
var ariaSort = { none: "none", asc: "ascending", desc: "descending" };
|
|
3847
3981
|
var TableHead = React50.forwardRef(
|
|
3848
|
-
({ className, align = "left", sortable, sort = "none", onSort, checkbox, children, ...props }, ref) => {
|
|
3982
|
+
({ className, align = "left", sortable, sort = "none", onSort, checkbox, resizer, children, ...props }, ref) => {
|
|
3849
3983
|
const caret = sort === "asc" ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_react27.CaretUp, { size: 16, "aria-hidden": true, className: "shrink-0" }) : /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_react27.CaretDown, { size: 16, "aria-hidden": true, className: "shrink-0" });
|
|
3850
|
-
return /* @__PURE__ */ (0, import_jsx_runtime51.
|
|
3984
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
3851
3985
|
"th",
|
|
3852
3986
|
{
|
|
3853
3987
|
ref,
|
|
@@ -3857,21 +3991,25 @@ var TableHead = React50.forwardRef(
|
|
|
3857
3991
|
"h-10 border-b border-border text-ui-label whitespace-nowrap",
|
|
3858
3992
|
checkbox ? "w-13 px-0 text-center" : "px-4 py-3",
|
|
3859
3993
|
align === "right" ? "text-right" : "text-left",
|
|
3994
|
+
resizer && "relative",
|
|
3860
3995
|
className
|
|
3861
3996
|
),
|
|
3862
3997
|
...props,
|
|
3863
|
-
children:
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
children
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3998
|
+
children: [
|
|
3999
|
+
sortable ? /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
4000
|
+
"button",
|
|
4001
|
+
{
|
|
4002
|
+
type: "button",
|
|
4003
|
+
onClick: onSort,
|
|
4004
|
+
className: cn("inline-flex items-center gap-1 rounded-xs", align === "right" && "flex-row-reverse"),
|
|
4005
|
+
children: [
|
|
4006
|
+
children,
|
|
4007
|
+
caret
|
|
4008
|
+
]
|
|
4009
|
+
}
|
|
4010
|
+
) : checkbox ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "flex items-center justify-center", children }) : children,
|
|
4011
|
+
resizer
|
|
4012
|
+
]
|
|
3875
4013
|
}
|
|
3876
4014
|
);
|
|
3877
4015
|
}
|
|
@@ -3906,10 +4044,904 @@ function TableCellTwoLines({ primary, secondary, avatar, className, ...props })
|
|
|
3906
4044
|
] });
|
|
3907
4045
|
}
|
|
3908
4046
|
|
|
3909
|
-
// src/components/Data Display/
|
|
4047
|
+
// src/components/Data Display/DataTable.tsx
|
|
4048
|
+
var React52 = __toESM(require("react"), 1);
|
|
4049
|
+
var import_react29 = require("@phosphor-icons/react");
|
|
4050
|
+
var import_react_table = require("@tanstack/react-table");
|
|
4051
|
+
var import_react_virtual = require("@tanstack/react-virtual");
|
|
4052
|
+
|
|
4053
|
+
// src/components/Utility/Pagination.tsx
|
|
3910
4054
|
var React51 = __toESM(require("react"), 1);
|
|
3911
|
-
var
|
|
4055
|
+
var import_react28 = require("@phosphor-icons/react");
|
|
3912
4056
|
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
4057
|
+
function getPaginationItems(page, pageCount, siblings = 1) {
|
|
4058
|
+
const keep = /* @__PURE__ */ new Set([1, pageCount]);
|
|
4059
|
+
for (let p = page - siblings; p <= page + siblings; p++) if (p >= 1 && p <= pageCount) keep.add(p);
|
|
4060
|
+
const sorted = [...keep].sort((a, b) => a - b);
|
|
4061
|
+
const items = [];
|
|
4062
|
+
sorted.forEach((p, index) => {
|
|
4063
|
+
const previous = sorted[index - 1];
|
|
4064
|
+
if (previous !== void 0 && p - previous === 2) items.push(previous + 1);
|
|
4065
|
+
else if (previous !== void 0 && p - previous > 2) items.push("ellipsis");
|
|
4066
|
+
items.push(p);
|
|
4067
|
+
});
|
|
4068
|
+
return items;
|
|
4069
|
+
}
|
|
4070
|
+
var Pagination = React51.forwardRef(
|
|
4071
|
+
({ className, page, pageCount, onPageChange, variant = "full", siblings = 1, ...props }, ref) => {
|
|
4072
|
+
const go = (next2) => onPageChange(Math.min(pageCount, Math.max(1, next2)));
|
|
4073
|
+
const previous = /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
4074
|
+
Button,
|
|
4075
|
+
{
|
|
4076
|
+
type: "button",
|
|
4077
|
+
variant: "outline",
|
|
4078
|
+
size: "icon-sm",
|
|
4079
|
+
"aria-label": "Previous page",
|
|
4080
|
+
disabled: page <= 1,
|
|
4081
|
+
onClick: () => go(page - 1),
|
|
4082
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_react28.ArrowLeft, { size: 16, "aria-hidden": true })
|
|
4083
|
+
}
|
|
4084
|
+
);
|
|
4085
|
+
const next = /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
4086
|
+
Button,
|
|
4087
|
+
{
|
|
4088
|
+
type: "button",
|
|
4089
|
+
variant: "outline",
|
|
4090
|
+
size: "icon-sm",
|
|
4091
|
+
"aria-label": "Next page",
|
|
4092
|
+
disabled: page >= pageCount,
|
|
4093
|
+
onClick: () => go(page + 1),
|
|
4094
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_react28.ArrowRight, { size: 16, "aria-hidden": true })
|
|
4095
|
+
}
|
|
4096
|
+
);
|
|
4097
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
|
|
4098
|
+
"nav",
|
|
4099
|
+
{
|
|
4100
|
+
ref,
|
|
4101
|
+
"aria-label": "Pagination",
|
|
4102
|
+
className: cn("flex items-center", variant === "compact" ? "w-35 justify-between" : "gap-2", className),
|
|
4103
|
+
...props,
|
|
4104
|
+
children: [
|
|
4105
|
+
previous,
|
|
4106
|
+
variant === "compact" ? /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { className: "text-body-small text-surface-foreground", "aria-live": "polite", children: [
|
|
4107
|
+
page,
|
|
4108
|
+
"/",
|
|
4109
|
+
pageCount
|
|
4110
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("ul", { className: "flex items-center gap-2", children: getPaginationItems(page, pageCount, siblings).map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("li", { children: item === "ellipsis" ? /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { className: "inline-flex size-8 items-center justify-center rounded-sm border border-border bg-surface text-surface-foreground", children: [
|
|
4111
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_react28.DotsThree, { size: 16, "aria-hidden": true }),
|
|
4112
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "sr-only", children: "More pages" })
|
|
4113
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
4114
|
+
Button,
|
|
4115
|
+
{
|
|
4116
|
+
type: "button",
|
|
4117
|
+
variant: item === page ? "subtle" : "outline",
|
|
4118
|
+
size: "sm",
|
|
4119
|
+
"aria-label": `Page ${item}`,
|
|
4120
|
+
"aria-current": item === page ? "page" : void 0,
|
|
4121
|
+
onClick: () => go(item),
|
|
4122
|
+
children: item
|
|
4123
|
+
}
|
|
4124
|
+
) }, item === "ellipsis" ? `ellipsis-${index}` : item)) }),
|
|
4125
|
+
next
|
|
4126
|
+
]
|
|
4127
|
+
}
|
|
4128
|
+
);
|
|
4129
|
+
}
|
|
4130
|
+
);
|
|
4131
|
+
Pagination.displayName = "Pagination";
|
|
4132
|
+
|
|
4133
|
+
// src/components/Data Display/DataTable.tsx
|
|
4134
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
4135
|
+
var features = (0, import_react_table.tableFeatures)({
|
|
4136
|
+
rowSortingFeature: import_react_table.rowSortingFeature,
|
|
4137
|
+
rowPaginationFeature: import_react_table.rowPaginationFeature,
|
|
4138
|
+
rowSelectionFeature: import_react_table.rowSelectionFeature,
|
|
4139
|
+
rowExpandingFeature: import_react_table.rowExpandingFeature,
|
|
4140
|
+
rowPinningFeature: import_react_table.rowPinningFeature,
|
|
4141
|
+
rowAggregationFeature: import_react_table.rowAggregationFeature,
|
|
4142
|
+
columnVisibilityFeature: import_react_table.columnVisibilityFeature,
|
|
4143
|
+
columnOrderingFeature: import_react_table.columnOrderingFeature,
|
|
4144
|
+
columnPinningFeature: import_react_table.columnPinningFeature,
|
|
4145
|
+
columnSizingFeature: import_react_table.columnSizingFeature,
|
|
4146
|
+
columnResizingFeature: import_react_table.columnResizingFeature,
|
|
4147
|
+
columnFilteringFeature: import_react_table.columnFilteringFeature,
|
|
4148
|
+
globalFilteringFeature: import_react_table.globalFilteringFeature,
|
|
4149
|
+
columnFacetingFeature: import_react_table.columnFacetingFeature,
|
|
4150
|
+
columnGroupingFeature: import_react_table.columnGroupingFeature,
|
|
4151
|
+
cellSelectionFeature: import_react_table.cellSelectionFeature,
|
|
4152
|
+
cellSpanningFeature: import_react_table.cellSpanningFeature,
|
|
4153
|
+
// Row-model pipeline order: filter → group → sort → expand → paginate.
|
|
4154
|
+
facetedRowModel: (0, import_react_table.createFacetedRowModel)(),
|
|
4155
|
+
facetedUniqueValues: (0, import_react_table.createFacetedUniqueValues)(),
|
|
4156
|
+
facetedMinMaxValues: (0, import_react_table.createFacetedMinMaxValues)(),
|
|
4157
|
+
filteredRowModel: (0, import_react_table.createFilteredRowModel)(),
|
|
4158
|
+
groupedRowModel: (0, import_react_table.createGroupedRowModel)(),
|
|
4159
|
+
sortedRowModel: (0, import_react_table.createSortedRowModel)(),
|
|
4160
|
+
expandedRowModel: (0, import_react_table.createExpandedRowModel)(),
|
|
4161
|
+
paginatedRowModel: (0, import_react_table.createPaginatedRowModel)(),
|
|
4162
|
+
sortFns: {
|
|
4163
|
+
alphanumeric: import_react_table.sortFn_alphanumeric,
|
|
4164
|
+
basic: import_react_table.sortFn_basic,
|
|
4165
|
+
datetime: import_react_table.sortFn_datetime,
|
|
4166
|
+
text: import_react_table.sortFn_text
|
|
4167
|
+
},
|
|
4168
|
+
filterFns: {
|
|
4169
|
+
arrIncludesSome: import_react_table.filterFn_arrIncludesSome,
|
|
4170
|
+
equals: import_react_table.filterFn_equals,
|
|
4171
|
+
equalsString: import_react_table.filterFn_equalsString,
|
|
4172
|
+
includesString: import_react_table.filterFn_includesString,
|
|
4173
|
+
inNumberRange: import_react_table.filterFn_inNumberRange
|
|
4174
|
+
},
|
|
4175
|
+
aggregationFns: {
|
|
4176
|
+
count: import_react_table.aggregationFn_count,
|
|
4177
|
+
extent: import_react_table.aggregationFn_extent,
|
|
4178
|
+
max: import_react_table.aggregationFn_max,
|
|
4179
|
+
mean: import_react_table.aggregationFn_mean,
|
|
4180
|
+
median: import_react_table.aggregationFn_median,
|
|
4181
|
+
min: import_react_table.aggregationFn_min,
|
|
4182
|
+
sum: import_react_table.aggregationFn_sum,
|
|
4183
|
+
unique: import_react_table.aggregationFn_unique,
|
|
4184
|
+
uniqueCount: import_react_table.aggregationFn_uniqueCount
|
|
4185
|
+
}
|
|
4186
|
+
});
|
|
4187
|
+
var getMeta = (meta) => meta ?? {};
|
|
4188
|
+
function useControllable(value, initial, onChange) {
|
|
4189
|
+
const [internal, setInternal] = React52.useState(initial);
|
|
4190
|
+
const current = value ?? internal;
|
|
4191
|
+
const update = React52.useCallback(
|
|
4192
|
+
(updater) => {
|
|
4193
|
+
const next = typeof updater === "function" ? updater(current) : updater;
|
|
4194
|
+
if (value === void 0) setInternal(next);
|
|
4195
|
+
onChange?.(next);
|
|
4196
|
+
},
|
|
4197
|
+
[current, value, onChange]
|
|
4198
|
+
);
|
|
4199
|
+
return [current, update];
|
|
4200
|
+
}
|
|
4201
|
+
var ALL = "__all__";
|
|
4202
|
+
var labelOf = (column) => getMeta(column.columnDef.meta).label ?? (typeof column.columnDef.header === "string" ? column.columnDef.header : column.id);
|
|
4203
|
+
function pinning(column, sized, header = false) {
|
|
4204
|
+
const side = column.getIsPinned();
|
|
4205
|
+
const style = {};
|
|
4206
|
+
if (sized) {
|
|
4207
|
+
style.width = column.getSize();
|
|
4208
|
+
style.minWidth = column.getSize();
|
|
4209
|
+
style.maxWidth = column.getSize();
|
|
4210
|
+
}
|
|
4211
|
+
if (side) {
|
|
4212
|
+
style.position = "sticky";
|
|
4213
|
+
if (side === "start") style.insetInlineStart = column.getStart("start");
|
|
4214
|
+
else style.insetInlineEnd = column.getAfter("end");
|
|
4215
|
+
}
|
|
4216
|
+
const className = side ? cn(
|
|
4217
|
+
header ? "z-30" : "z-10",
|
|
4218
|
+
"bg-surface",
|
|
4219
|
+
side === "start" && column.getIsLastColumn("start") && "border-r border-border",
|
|
4220
|
+
side === "end" && column.getIsFirstColumn("end") && "border-l border-border"
|
|
4221
|
+
) : void 0;
|
|
4222
|
+
return { style, className };
|
|
4223
|
+
}
|
|
4224
|
+
function ColumnFilter({ column }) {
|
|
4225
|
+
const variant = getMeta(column.columnDef.meta).filterVariant ?? "text";
|
|
4226
|
+
const label = labelOf(column);
|
|
4227
|
+
const value = column.getFilterValue();
|
|
4228
|
+
if (variant === "select") {
|
|
4229
|
+
const options = [...column.getFacetedUniqueValues().entries()].sort((a, b) => String(a[0]).localeCompare(String(b[0])));
|
|
4230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
4231
|
+
Select,
|
|
4232
|
+
{
|
|
4233
|
+
value: typeof value === "string" ? value : ALL,
|
|
4234
|
+
onValueChange: (next) => column.setFilterValue(next === ALL ? void 0 : next),
|
|
4235
|
+
children: [
|
|
4236
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(SelectTrigger, { "aria-label": `Filter ${label}`, className: "h-8 text-body-small", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(SelectValue, {}) }),
|
|
4237
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(SelectContent, { children: [
|
|
4238
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(SelectItem, { value: ALL, children: "All" }),
|
|
4239
|
+
options.map(([option, count]) => /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(SelectItem, { value: String(option), children: [
|
|
4240
|
+
String(option),
|
|
4241
|
+
" (",
|
|
4242
|
+
count,
|
|
4243
|
+
")"
|
|
4244
|
+
] }, String(option)))
|
|
4245
|
+
] })
|
|
4246
|
+
]
|
|
4247
|
+
}
|
|
4248
|
+
);
|
|
4249
|
+
}
|
|
4250
|
+
if (variant === "range") {
|
|
4251
|
+
const [min, max] = column.getFacetedMinMaxValues() ?? [];
|
|
4252
|
+
const range = Array.isArray(value) ? value : [];
|
|
4253
|
+
const update = (index, raw) => {
|
|
4254
|
+
const next = [range[0], range[1]];
|
|
4255
|
+
next[index] = raw === "" ? void 0 : Number(raw);
|
|
4256
|
+
column.setFilterValue(next[0] === void 0 && next[1] === void 0 ? void 0 : next);
|
|
4257
|
+
};
|
|
4258
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex gap-1", children: [
|
|
4259
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4260
|
+
Input,
|
|
4261
|
+
{
|
|
4262
|
+
type: "number",
|
|
4263
|
+
"aria-label": `${label} minimum`,
|
|
4264
|
+
placeholder: min !== void 0 ? String(min) : "Min",
|
|
4265
|
+
value: range[0] ?? "",
|
|
4266
|
+
onChange: (event) => update(0, event.target.value),
|
|
4267
|
+
className: "h-8 text-body-small"
|
|
4268
|
+
}
|
|
4269
|
+
),
|
|
4270
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4271
|
+
Input,
|
|
4272
|
+
{
|
|
4273
|
+
type: "number",
|
|
4274
|
+
"aria-label": `${label} maximum`,
|
|
4275
|
+
placeholder: max !== void 0 ? String(max) : "Max",
|
|
4276
|
+
value: range[1] ?? "",
|
|
4277
|
+
onChange: (event) => update(1, event.target.value),
|
|
4278
|
+
className: "h-8 text-body-small"
|
|
4279
|
+
}
|
|
4280
|
+
)
|
|
4281
|
+
] });
|
|
4282
|
+
}
|
|
4283
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4284
|
+
Input,
|
|
4285
|
+
{
|
|
4286
|
+
"aria-label": `Filter ${label}`,
|
|
4287
|
+
placeholder: "Filter\u2026",
|
|
4288
|
+
value: typeof value === "string" ? value : "",
|
|
4289
|
+
onChange: (event) => column.setFilterValue(event.target.value || void 0),
|
|
4290
|
+
className: "h-8 text-body-small"
|
|
4291
|
+
}
|
|
4292
|
+
);
|
|
4293
|
+
}
|
|
4294
|
+
function EditableCell({ value, label, type, onCommit }) {
|
|
4295
|
+
const initial = value == null ? "" : String(value);
|
|
4296
|
+
const [draft, setDraft] = React52.useState(null);
|
|
4297
|
+
const cancelled = React52.useRef(false);
|
|
4298
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4299
|
+
Input,
|
|
4300
|
+
{
|
|
4301
|
+
type,
|
|
4302
|
+
"aria-label": label,
|
|
4303
|
+
value: draft ?? initial,
|
|
4304
|
+
onChange: (event) => setDraft(event.target.value),
|
|
4305
|
+
onBlur: () => {
|
|
4306
|
+
if (!cancelled.current && draft !== null && draft !== initial) onCommit(draft);
|
|
4307
|
+
cancelled.current = false;
|
|
4308
|
+
setDraft(null);
|
|
4309
|
+
},
|
|
4310
|
+
onKeyDown: (event) => {
|
|
4311
|
+
if (event.key === "Enter") event.currentTarget.blur();
|
|
4312
|
+
if (event.key === "Escape") {
|
|
4313
|
+
cancelled.current = true;
|
|
4314
|
+
event.currentTarget.blur();
|
|
4315
|
+
}
|
|
4316
|
+
},
|
|
4317
|
+
className: cn("h-8 border-transparent bg-transparent text-body-small", type === "number" && "text-right")
|
|
4318
|
+
}
|
|
4319
|
+
);
|
|
4320
|
+
}
|
|
4321
|
+
function DataTableInner({
|
|
4322
|
+
columns,
|
|
4323
|
+
data,
|
|
4324
|
+
getRowId,
|
|
4325
|
+
initialState,
|
|
4326
|
+
enableSorting = false,
|
|
4327
|
+
enableRowSelection = false,
|
|
4328
|
+
enableColumnVisibility = false,
|
|
4329
|
+
enableColumnPinning = false,
|
|
4330
|
+
enableColumnSizing = false,
|
|
4331
|
+
enableColumnResizing = false,
|
|
4332
|
+
columnResizeMode = "onChange",
|
|
4333
|
+
enableColumnOrdering = false,
|
|
4334
|
+
enableColumnFilters = false,
|
|
4335
|
+
enableGlobalFilter = false,
|
|
4336
|
+
globalFilterPlaceholder = "Search",
|
|
4337
|
+
enableGrouping = false,
|
|
4338
|
+
enableExpanding = false,
|
|
4339
|
+
enableRowPinning = false,
|
|
4340
|
+
enableCellSelection = false,
|
|
4341
|
+
showFooter = false,
|
|
4342
|
+
enableDensityToggle = false,
|
|
4343
|
+
density: densityProp,
|
|
4344
|
+
onDensityChange,
|
|
4345
|
+
getSubRows,
|
|
4346
|
+
getRowCanExpand,
|
|
4347
|
+
renderSubComponent,
|
|
4348
|
+
pageSize = 10,
|
|
4349
|
+
serverSide = false,
|
|
4350
|
+
rowCount,
|
|
4351
|
+
sorting: sortingProp,
|
|
4352
|
+
onSortingChange,
|
|
4353
|
+
rowSelection: rowSelectionProp,
|
|
4354
|
+
onRowSelectionChange,
|
|
4355
|
+
pagination: paginationProp,
|
|
4356
|
+
onPaginationChange,
|
|
4357
|
+
columnVisibility: columnVisibilityProp,
|
|
4358
|
+
onColumnVisibilityChange,
|
|
4359
|
+
columnPinning: columnPinningProp,
|
|
4360
|
+
onColumnPinningChange,
|
|
4361
|
+
columnOrder: columnOrderProp,
|
|
4362
|
+
onColumnOrderChange,
|
|
4363
|
+
columnFilters: columnFiltersProp,
|
|
4364
|
+
onColumnFiltersChange,
|
|
4365
|
+
globalFilter: globalFilterProp,
|
|
4366
|
+
onGlobalFilterChange,
|
|
4367
|
+
grouping: groupingProp,
|
|
4368
|
+
onGroupingChange,
|
|
4369
|
+
expanded: expandedProp,
|
|
4370
|
+
onExpandedChange,
|
|
4371
|
+
rowPinning: rowPinningProp,
|
|
4372
|
+
onRowPinningChange,
|
|
4373
|
+
onCellSelectionChange,
|
|
4374
|
+
onCellEdit,
|
|
4375
|
+
virtualized = false,
|
|
4376
|
+
estimateRowHeight = 40,
|
|
4377
|
+
onLoadMore,
|
|
4378
|
+
hasMore = false,
|
|
4379
|
+
loadingMore = false,
|
|
4380
|
+
stickyHeader,
|
|
4381
|
+
loading = false,
|
|
4382
|
+
emptyState,
|
|
4383
|
+
onRowClick,
|
|
4384
|
+
toolbar,
|
|
4385
|
+
wrapperClassName,
|
|
4386
|
+
striped,
|
|
4387
|
+
containerClassName,
|
|
4388
|
+
containerRef,
|
|
4389
|
+
style: tableStyle,
|
|
4390
|
+
...tableProps
|
|
4391
|
+
}, ref) {
|
|
4392
|
+
const [sorting, setSorting] = useControllable(sortingProp, initialState?.sorting ?? [], onSortingChange);
|
|
4393
|
+
const [rowSelection, setRowSelection] = useControllable(
|
|
4394
|
+
rowSelectionProp,
|
|
4395
|
+
initialState?.rowSelection ?? {},
|
|
4396
|
+
onRowSelectionChange
|
|
4397
|
+
);
|
|
4398
|
+
const [columnVisibility, setColumnVisibility] = useControllable(
|
|
4399
|
+
columnVisibilityProp,
|
|
4400
|
+
initialState?.columnVisibility ?? {},
|
|
4401
|
+
onColumnVisibilityChange
|
|
4402
|
+
);
|
|
4403
|
+
const [columnPinning, setColumnPinning] = useControllable(
|
|
4404
|
+
columnPinningProp,
|
|
4405
|
+
{ start: initialState?.columnPinning?.start ?? [], end: initialState?.columnPinning?.end ?? [] },
|
|
4406
|
+
onColumnPinningChange
|
|
4407
|
+
);
|
|
4408
|
+
const [columnOrder, setColumnOrder] = useControllable(
|
|
4409
|
+
columnOrderProp,
|
|
4410
|
+
initialState?.columnOrder ?? [],
|
|
4411
|
+
onColumnOrderChange
|
|
4412
|
+
);
|
|
4413
|
+
const [columnFilters, setColumnFilters] = useControllable(
|
|
4414
|
+
columnFiltersProp,
|
|
4415
|
+
initialState?.columnFilters ?? [],
|
|
4416
|
+
onColumnFiltersChange
|
|
4417
|
+
);
|
|
4418
|
+
const [globalFilter, setGlobalFilter] = useControllable(
|
|
4419
|
+
globalFilterProp,
|
|
4420
|
+
initialState?.globalFilter ?? "",
|
|
4421
|
+
onGlobalFilterChange
|
|
4422
|
+
);
|
|
4423
|
+
const [grouping, setGrouping] = useControllable(groupingProp, initialState?.grouping ?? [], onGroupingChange);
|
|
4424
|
+
const [expanded, setExpanded] = useControllable(expandedProp, initialState?.expanded ?? {}, onExpandedChange);
|
|
4425
|
+
const [rowPinning, setRowPinning] = useControllable(
|
|
4426
|
+
rowPinningProp,
|
|
4427
|
+
{ top: initialState?.rowPinning?.top ?? [], bottom: initialState?.rowPinning?.bottom ?? [] },
|
|
4428
|
+
onRowPinningChange
|
|
4429
|
+
);
|
|
4430
|
+
const [pagination, setPagination] = useControllable(
|
|
4431
|
+
paginationProp,
|
|
4432
|
+
initialState?.pagination ?? { pageIndex: 0, pageSize },
|
|
4433
|
+
onPaginationChange
|
|
4434
|
+
);
|
|
4435
|
+
const [density, setDensity] = useControllable(densityProp, "default", onDensityChange);
|
|
4436
|
+
const [cellSelection, setCellSelection] = React52.useState([]);
|
|
4437
|
+
const infinite = Boolean(onLoadMore);
|
|
4438
|
+
const paginate = !virtualized && !infinite;
|
|
4439
|
+
const compact = density === "compact";
|
|
4440
|
+
const sized = enableColumnSizing || enableColumnResizing || enableColumnPinning;
|
|
4441
|
+
const sticky = stickyHeader ?? (enableRowPinning || virtualized);
|
|
4442
|
+
const table = (0, import_react_table.useTable)({
|
|
4443
|
+
features,
|
|
4444
|
+
columns,
|
|
4445
|
+
data,
|
|
4446
|
+
getRowId,
|
|
4447
|
+
getSubRows,
|
|
4448
|
+
getRowCanExpand: getRowCanExpand ?? (renderSubComponent ? () => true : void 0),
|
|
4449
|
+
enableSorting,
|
|
4450
|
+
enableRowSelection,
|
|
4451
|
+
enableColumnResizing,
|
|
4452
|
+
enableColumnPinning,
|
|
4453
|
+
enableColumnFilters,
|
|
4454
|
+
enableGlobalFilter,
|
|
4455
|
+
enableGrouping,
|
|
4456
|
+
enableRowPinning,
|
|
4457
|
+
enableCellSelection,
|
|
4458
|
+
columnResizeMode,
|
|
4459
|
+
globalFilterFn: "includesString",
|
|
4460
|
+
manualSorting: serverSide,
|
|
4461
|
+
manualFiltering: serverSide,
|
|
4462
|
+
manualPagination: serverSide || !paginate,
|
|
4463
|
+
rowCount: serverSide ? rowCount : void 0,
|
|
4464
|
+
autoResetPageIndex: !serverSide,
|
|
4465
|
+
state: {
|
|
4466
|
+
sorting,
|
|
4467
|
+
rowSelection,
|
|
4468
|
+
columnVisibility,
|
|
4469
|
+
columnPinning,
|
|
4470
|
+
columnOrder,
|
|
4471
|
+
columnFilters,
|
|
4472
|
+
globalFilter,
|
|
4473
|
+
grouping,
|
|
4474
|
+
expanded,
|
|
4475
|
+
rowPinning,
|
|
4476
|
+
cellSelection,
|
|
4477
|
+
pagination: { ...pagination, pageSize: paginationProp ? pagination.pageSize : pageSize }
|
|
4478
|
+
},
|
|
4479
|
+
onSortingChange: setSorting,
|
|
4480
|
+
onRowSelectionChange: setRowSelection,
|
|
4481
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
4482
|
+
onColumnPinningChange: setColumnPinning,
|
|
4483
|
+
onColumnOrderChange: setColumnOrder,
|
|
4484
|
+
onColumnFiltersChange: setColumnFilters,
|
|
4485
|
+
onGlobalFilterChange: setGlobalFilter,
|
|
4486
|
+
onGroupingChange: setGrouping,
|
|
4487
|
+
onExpandedChange: setExpanded,
|
|
4488
|
+
onRowPinningChange: setRowPinning,
|
|
4489
|
+
onCellSelectionChange: (updater) => {
|
|
4490
|
+
const next = typeof updater === "function" ? updater(cellSelection) : updater;
|
|
4491
|
+
setCellSelection(next);
|
|
4492
|
+
onCellSelectionChange?.(next);
|
|
4493
|
+
},
|
|
4494
|
+
onPaginationChange: setPagination
|
|
4495
|
+
});
|
|
4496
|
+
const headerGroups = table.getHeaderGroups();
|
|
4497
|
+
const leafColumns = table.getVisibleLeafColumns();
|
|
4498
|
+
const hasExpander = enableExpanding;
|
|
4499
|
+
const leadingCount = (enableRowSelection ? 1 : 0) + (hasExpander ? 1 : 0) + (enableRowPinning ? 1 : 0);
|
|
4500
|
+
const columnSpan = leafColumns.length + leadingCount;
|
|
4501
|
+
const pageCount = table.getPageCount();
|
|
4502
|
+
const selectedCount = Object.values(rowSelection).filter(Boolean).length;
|
|
4503
|
+
const hideableColumns = table.getAllLeafColumns().filter((column) => column.getCanHide());
|
|
4504
|
+
const groupableColumns = table.getAllLeafColumns().filter((column) => column.getCanGroup());
|
|
4505
|
+
const showToolbar = Boolean(toolbar) || enableColumnVisibility || enableGlobalFilter || enableGrouping || enableDensityToggle;
|
|
4506
|
+
const cellDensity = compact ? "h-8 py-1.5" : void 0;
|
|
4507
|
+
const allSelected = table.getIsAllPageRowsSelected();
|
|
4508
|
+
const someSelected = table.getIsSomePageRowsSelected();
|
|
4509
|
+
const dragged = React52.useRef(null);
|
|
4510
|
+
const topRows = enableRowPinning ? table.getTopRows() : [];
|
|
4511
|
+
const bottomRows = enableRowPinning ? table.getBottomRows() : [];
|
|
4512
|
+
const bodyRows = enableRowPinning ? table.getCenterRows() : table.getRowModel().rows;
|
|
4513
|
+
const scrollRef = React52.useRef(null);
|
|
4514
|
+
const setScrollRef = React52.useCallback(
|
|
4515
|
+
(node) => {
|
|
4516
|
+
scrollRef.current = node;
|
|
4517
|
+
if (typeof containerRef === "function") containerRef(node);
|
|
4518
|
+
else if (containerRef) containerRef.current = node;
|
|
4519
|
+
},
|
|
4520
|
+
[containerRef]
|
|
4521
|
+
);
|
|
4522
|
+
const virtualizer = (0, import_react_virtual.useVirtualizer)({
|
|
4523
|
+
count: bodyRows.length,
|
|
4524
|
+
getScrollElement: () => scrollRef.current,
|
|
4525
|
+
estimateSize: () => estimateRowHeight,
|
|
4526
|
+
overscan: 8,
|
|
4527
|
+
enabled: virtualized,
|
|
4528
|
+
initialRect: { width: 0, height: estimateRowHeight * 10 }
|
|
4529
|
+
});
|
|
4530
|
+
const virtualItems = virtualized ? virtualizer.getVirtualItems() : [];
|
|
4531
|
+
const paddingTop = virtualItems.length > 0 ? virtualItems[0]?.start ?? 0 : 0;
|
|
4532
|
+
const paddingBottom = virtualItems.length > 0 ? virtualizer.getTotalSize() - (virtualItems.at(-1)?.end ?? 0) : 0;
|
|
4533
|
+
const sentinelRef = React52.useRef(null);
|
|
4534
|
+
React52.useEffect(() => {
|
|
4535
|
+
const node = sentinelRef.current;
|
|
4536
|
+
if (!node || !onLoadMore || !hasMore || loadingMore || typeof IntersectionObserver === "undefined") return;
|
|
4537
|
+
const container = scrollRef.current;
|
|
4538
|
+
const root = container && container.scrollHeight > container.clientHeight ? container : null;
|
|
4539
|
+
const observer = new IntersectionObserver(
|
|
4540
|
+
(entries) => {
|
|
4541
|
+
if (entries.some((entry) => entry.isIntersecting)) onLoadMore();
|
|
4542
|
+
},
|
|
4543
|
+
{ root, rootMargin: "0px 0px 160px 0px" }
|
|
4544
|
+
);
|
|
4545
|
+
observer.observe(node);
|
|
4546
|
+
return () => observer.disconnect();
|
|
4547
|
+
}, [onLoadMore, hasMore, loadingMore, bodyRows.length]);
|
|
4548
|
+
const reorder = (activeId, overId) => {
|
|
4549
|
+
if (activeId === overId) return;
|
|
4550
|
+
const ids = table.getAllLeafColumns().map((column) => column.id);
|
|
4551
|
+
const next = ids.filter((id) => id !== activeId);
|
|
4552
|
+
const at = next.indexOf(overId);
|
|
4553
|
+
next.splice(at === -1 ? next.length : at, 0, activeId);
|
|
4554
|
+
table.setColumnOrder(next);
|
|
4555
|
+
};
|
|
4556
|
+
const onGridKeyDown = (event) => {
|
|
4557
|
+
const directions = {
|
|
4558
|
+
ArrowUp: "up",
|
|
4559
|
+
ArrowDown: "down",
|
|
4560
|
+
ArrowLeft: "left",
|
|
4561
|
+
ArrowRight: "right"
|
|
4562
|
+
};
|
|
4563
|
+
const direction = directions[event.key];
|
|
4564
|
+
if (direction) {
|
|
4565
|
+
event.preventDefault();
|
|
4566
|
+
if (event.shiftKey) table.extendCellSelection(direction);
|
|
4567
|
+
else table.moveCellSelection(direction);
|
|
4568
|
+
} else if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "a") {
|
|
4569
|
+
event.preventDefault();
|
|
4570
|
+
table.selectAllCells();
|
|
4571
|
+
} else if (event.key === "Escape") {
|
|
4572
|
+
table.resetCellSelection(true);
|
|
4573
|
+
}
|
|
4574
|
+
};
|
|
4575
|
+
const skeletonRow = (rowKey) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableRow, { className: "hover:bg-transparent", children: Array.from({ length: columnSpan }, (_, cell) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableCell, { checkbox: enableRowSelection && cell === 0, className: cellDensity, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { "aria-hidden": true, className: "block h-4 w-3/4 animate-pulse rounded-xs bg-border" }) }, cell)) }, rowKey);
|
|
4576
|
+
const renderRow = (row, options = {}) => {
|
|
4577
|
+
const { pinned, pinnedIndex = 0, pinnedCount = 1, virtualIndex } = options;
|
|
4578
|
+
const grouped = row.getIsGrouped();
|
|
4579
|
+
const rowUnits = compact ? 8 : 10;
|
|
4580
|
+
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;
|
|
4581
|
+
const cells = row.getVisibleCells();
|
|
4582
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(React52.Fragment, { children: [
|
|
4583
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
4584
|
+
TableRow,
|
|
4585
|
+
{
|
|
4586
|
+
ref: virtualized && virtualIndex !== void 0 ? virtualizer.measureElement : void 0,
|
|
4587
|
+
"data-index": virtualIndex,
|
|
4588
|
+
selected: row.getIsSelected(),
|
|
4589
|
+
style: pinStyle,
|
|
4590
|
+
onClick: onRowClick && !grouped ? () => onRowClick(row.original) : void 0,
|
|
4591
|
+
className: cn(pinned && "z-20 bg-surface", grouped && "bg-background", onRowClick && !grouped && "cursor-pointer"),
|
|
4592
|
+
children: [
|
|
4593
|
+
enableRowSelection && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableCell, { checkbox: true, className: cellDensity, onClick: (event) => event.stopPropagation(), children: !grouped && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4594
|
+
Checkbox,
|
|
4595
|
+
{
|
|
4596
|
+
"aria-label": "Select row",
|
|
4597
|
+
checked: row.getIsSelected(),
|
|
4598
|
+
disabled: !row.getCanSelect(),
|
|
4599
|
+
onCheckedChange: (checked) => row.toggleSelected(Boolean(checked))
|
|
4600
|
+
}
|
|
4601
|
+
) }),
|
|
4602
|
+
hasExpander && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableCell, { checkbox: true, className: cellDensity, onClick: (event) => event.stopPropagation(), children: !grouped && row.getCanExpand() && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4603
|
+
Button,
|
|
4604
|
+
{
|
|
4605
|
+
type: "button",
|
|
4606
|
+
variant: "ghost",
|
|
4607
|
+
size: "icon-sm",
|
|
4608
|
+
"aria-label": row.getIsExpanded() ? "Collapse row" : "Expand row",
|
|
4609
|
+
"aria-expanded": row.getIsExpanded(),
|
|
4610
|
+
onClick: () => row.toggleExpanded(),
|
|
4611
|
+
children: row.getIsExpanded() ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_react29.CaretDown, { size: 16, "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_react29.CaretRight, { size: 16, "aria-hidden": true })
|
|
4612
|
+
}
|
|
4613
|
+
) }),
|
|
4614
|
+
enableRowPinning && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableCell, { checkbox: true, className: cellDensity, onClick: (event) => event.stopPropagation(), children: !grouped && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4615
|
+
Button,
|
|
4616
|
+
{
|
|
4617
|
+
type: "button",
|
|
4618
|
+
variant: "ghost",
|
|
4619
|
+
size: "icon-sm",
|
|
4620
|
+
"aria-label": row.getIsPinned() ? "Unpin row" : "Pin row to top",
|
|
4621
|
+
"aria-pressed": Boolean(row.getIsPinned()),
|
|
4622
|
+
onClick: () => row.pin(row.getIsPinned() ? false : "top"),
|
|
4623
|
+
children: row.getIsPinned() ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_react29.PushPinSlash, { size: 16, "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_react29.PushPin, { size: 16, "aria-hidden": true })
|
|
4624
|
+
}
|
|
4625
|
+
) }),
|
|
4626
|
+
cells.map((cell, index) => {
|
|
4627
|
+
if (cell.getIsCovered()) return null;
|
|
4628
|
+
const meta = getMeta(cell.column.columnDef.meta);
|
|
4629
|
+
const pin = pinning(cell.column, sized);
|
|
4630
|
+
const rowSpan = cell.getRowSpan();
|
|
4631
|
+
const colSpan = cell.getColSpan();
|
|
4632
|
+
const edges = enableCellSelection && cell.getIsSelected() ? cell.getSelectionEdges() : void 0;
|
|
4633
|
+
const indent = index === 0 && hasExpander && row.depth > 0 ? row.depth * 4 : 0;
|
|
4634
|
+
let content;
|
|
4635
|
+
if (cell.getIsGrouped()) {
|
|
4636
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
4637
|
+
"button",
|
|
4638
|
+
{
|
|
4639
|
+
type: "button",
|
|
4640
|
+
className: "inline-flex items-center gap-1 rounded-xs text-ui-label",
|
|
4641
|
+
"aria-expanded": row.getIsExpanded(),
|
|
4642
|
+
onClick: row.getToggleExpandedHandler(),
|
|
4643
|
+
children: [
|
|
4644
|
+
row.getIsExpanded() ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_react29.CaretDown, { size: 16, "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_react29.CaretRight, { size: 16, "aria-hidden": true }),
|
|
4645
|
+
(0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()),
|
|
4646
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "text-secondary-muted-foreground", children: [
|
|
4647
|
+
"(",
|
|
4648
|
+
row.subRows.length,
|
|
4649
|
+
")"
|
|
4650
|
+
] })
|
|
4651
|
+
]
|
|
4652
|
+
}
|
|
4653
|
+
);
|
|
4654
|
+
} else if (cell.getIsAggregated()) {
|
|
4655
|
+
content = (0, import_react_table.flexRender)(cell.column.columnDef.aggregatedCell ?? cell.column.columnDef.cell, cell.getContext());
|
|
4656
|
+
} else if (cell.getIsPlaceholder()) {
|
|
4657
|
+
content = null;
|
|
4658
|
+
} else if (meta.editable) {
|
|
4659
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4660
|
+
EditableCell,
|
|
4661
|
+
{
|
|
4662
|
+
value: cell.getValue(),
|
|
4663
|
+
label: `${labelOf(cell.column)}, row ${row.index + 1}`,
|
|
4664
|
+
type: meta.editType ?? "text",
|
|
4665
|
+
onCommit: (value) => onCellEdit?.({ row: row.original, rowId: row.id, columnId: cell.column.id, value })
|
|
4666
|
+
}
|
|
4667
|
+
);
|
|
4668
|
+
} else {
|
|
4669
|
+
content = (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext());
|
|
4670
|
+
}
|
|
4671
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4672
|
+
TableCell,
|
|
4673
|
+
{
|
|
4674
|
+
align: meta.align,
|
|
4675
|
+
muted: meta.muted && !grouped,
|
|
4676
|
+
rowSpan: rowSpan > 1 ? rowSpan : void 0,
|
|
4677
|
+
colSpan: colSpan > 1 ? colSpan : void 0,
|
|
4678
|
+
style: {
|
|
4679
|
+
...pin.style,
|
|
4680
|
+
...indent ? { paddingInlineStart: `calc(var(--spacing) * ${indent + 4})` } : null
|
|
4681
|
+
},
|
|
4682
|
+
"data-selected": edges ? "" : void 0,
|
|
4683
|
+
onMouseDown: enableCellSelection ? cell.getSelectionStartHandler() : void 0,
|
|
4684
|
+
onMouseEnter: enableCellSelection ? cell.getSelectionExtendHandler() : void 0,
|
|
4685
|
+
className: cn(
|
|
4686
|
+
cellDensity,
|
|
4687
|
+
pin.className,
|
|
4688
|
+
enableCellSelection && "select-none",
|
|
4689
|
+
edges && "bg-accent-soft",
|
|
4690
|
+
edges?.top && "border-t-2 border-t-input-accent",
|
|
4691
|
+
edges?.bottom && "border-b-2 border-b-input-accent",
|
|
4692
|
+
edges?.left && "border-l-2 border-l-input-accent",
|
|
4693
|
+
edges?.right && "border-r-2 border-r-input-accent",
|
|
4694
|
+
meta.editable && "py-1"
|
|
4695
|
+
),
|
|
4696
|
+
children: content
|
|
4697
|
+
},
|
|
4698
|
+
cell.id
|
|
4699
|
+
);
|
|
4700
|
+
})
|
|
4701
|
+
]
|
|
4702
|
+
}
|
|
4703
|
+
),
|
|
4704
|
+
renderSubComponent && !grouped && row.getIsExpanded() && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableRow, { className: "bg-background hover:bg-background", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableCell, { colSpan: columnSpan, children: renderSubComponent(row.original) }) })
|
|
4705
|
+
] }, row.id);
|
|
4706
|
+
};
|
|
4707
|
+
const renderHeaderCell = (header) => {
|
|
4708
|
+
const { column } = header;
|
|
4709
|
+
const { align } = getMeta(column.columnDef.meta);
|
|
4710
|
+
const leaf = header.subHeaders.length === 0;
|
|
4711
|
+
const sortState = column.getIsSorted();
|
|
4712
|
+
const pin = pinning(column, sized, true);
|
|
4713
|
+
const reorderable = enableColumnOrdering && leaf && !column.getIsPinned();
|
|
4714
|
+
const label = labelOf(column);
|
|
4715
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4716
|
+
TableHead,
|
|
4717
|
+
{
|
|
4718
|
+
colSpan: header.colSpan > 1 ? header.colSpan : void 0,
|
|
4719
|
+
align: leaf ? align : void 0,
|
|
4720
|
+
sortable: leaf && column.getCanSort(),
|
|
4721
|
+
sort: sortState === false ? "none" : sortState,
|
|
4722
|
+
onSort: () => column.toggleSorting(sortState === "asc"),
|
|
4723
|
+
style: pin.style,
|
|
4724
|
+
draggable: reorderable || void 0,
|
|
4725
|
+
tabIndex: reorderable ? 0 : void 0,
|
|
4726
|
+
title: reorderable ? "Drag, or press Alt + arrow keys, to reorder" : void 0,
|
|
4727
|
+
onDragStart: reorderable ? () => dragged.current = column.id : void 0,
|
|
4728
|
+
onDragOver: reorderable ? (event) => event.preventDefault() : void 0,
|
|
4729
|
+
onDrop: reorderable ? (event) => {
|
|
4730
|
+
event.preventDefault();
|
|
4731
|
+
if (dragged.current) reorder(dragged.current, column.id);
|
|
4732
|
+
dragged.current = null;
|
|
4733
|
+
} : void 0,
|
|
4734
|
+
onKeyDown: reorderable ? (event) => {
|
|
4735
|
+
if (!event.altKey || event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
|
4736
|
+
event.preventDefault();
|
|
4737
|
+
const ids = table.getAllLeafColumns().map((item) => item.id);
|
|
4738
|
+
const at = ids.indexOf(column.id);
|
|
4739
|
+
const target = ids[at + (event.key === "ArrowLeft" ? -1 : 2)];
|
|
4740
|
+
if (event.key === "ArrowLeft" && ids[at - 1]) reorder(column.id, ids[at - 1]);
|
|
4741
|
+
else if (event.key === "ArrowRight" && at < ids.length - 1) reorder(column.id, target ?? "__end__");
|
|
4742
|
+
} : void 0,
|
|
4743
|
+
className: cn(
|
|
4744
|
+
pin.className,
|
|
4745
|
+
cellDensity,
|
|
4746
|
+
sticky && !column.getIsPinned() && "sticky top-0 z-20 bg-surface",
|
|
4747
|
+
sticky && column.getIsPinned() && "top-0",
|
|
4748
|
+
reorderable && "cursor-grab",
|
|
4749
|
+
!leaf && "text-center"
|
|
4750
|
+
),
|
|
4751
|
+
resizer: enableColumnResizing && column.getCanResize() ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4752
|
+
"div",
|
|
4753
|
+
{
|
|
4754
|
+
role: "separator",
|
|
4755
|
+
"aria-orientation": "vertical",
|
|
4756
|
+
"aria-label": `Resize ${label}`,
|
|
4757
|
+
onMouseDown: header.getResizeHandler(),
|
|
4758
|
+
onTouchStart: header.getResizeHandler(),
|
|
4759
|
+
onClick: (event) => event.stopPropagation(),
|
|
4760
|
+
className: cn(
|
|
4761
|
+
"absolute inset-y-0 end-0 w-1 cursor-col-resize touch-none select-none hover:bg-input-accent",
|
|
4762
|
+
column.getIsResizing() && "bg-input-accent"
|
|
4763
|
+
)
|
|
4764
|
+
}
|
|
4765
|
+
) : void 0,
|
|
4766
|
+
children: header.isPlaceholder ? null : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(table.FlexRender, { header })
|
|
4767
|
+
},
|
|
4768
|
+
header.id
|
|
4769
|
+
);
|
|
4770
|
+
};
|
|
4771
|
+
const stickyLeading = cn(cellDensity, sticky && "sticky top-0 z-20 bg-surface");
|
|
4772
|
+
const leadingHeaderCells = (rowSpan) => /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
|
|
4773
|
+
enableRowSelection && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableHead, { checkbox: true, rowSpan, className: stickyLeading, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4774
|
+
Checkbox,
|
|
4775
|
+
{
|
|
4776
|
+
"aria-label": "Select all rows",
|
|
4777
|
+
checked: allSelected ? true : someSelected ? "indeterminate" : false,
|
|
4778
|
+
disabled: loading,
|
|
4779
|
+
onCheckedChange: (checked) => table.toggleAllPageRowsSelected(Boolean(checked))
|
|
4780
|
+
}
|
|
4781
|
+
) }),
|
|
4782
|
+
hasExpander && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableHead, { checkbox: true, rowSpan, className: stickyLeading, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "sr-only", children: "Expand" }) }),
|
|
4783
|
+
enableRowPinning && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableHead, { checkbox: true, rowSpan, className: stickyLeading, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "sr-only", children: "Pin" }) })
|
|
4784
|
+
] });
|
|
4785
|
+
const rowsToRender = virtualized ? virtualItems.map((item) => ({ row: bodyRows[item.index], index: item.index })) : null;
|
|
4786
|
+
const totalRows = topRows.length + bodyRows.length + bottomRows.length;
|
|
4787
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: cn("flex w-full flex-col gap-2", wrapperClassName), children: [
|
|
4788
|
+
showToolbar && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
4789
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
4790
|
+
enableGlobalFilter && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4791
|
+
SearchBar,
|
|
4792
|
+
{
|
|
4793
|
+
"aria-label": "Search table",
|
|
4794
|
+
placeholder: globalFilterPlaceholder,
|
|
4795
|
+
value: globalFilter,
|
|
4796
|
+
onChange: (event) => table.setGlobalFilter(event.target.value),
|
|
4797
|
+
onClear: () => table.setGlobalFilter(""),
|
|
4798
|
+
className: "w-64"
|
|
4799
|
+
}
|
|
4800
|
+
),
|
|
4801
|
+
toolbar
|
|
4802
|
+
] }),
|
|
4803
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
4804
|
+
enableDensityToggle && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
4805
|
+
Button,
|
|
4806
|
+
{
|
|
4807
|
+
type: "button",
|
|
4808
|
+
variant: "outline",
|
|
4809
|
+
size: "sm",
|
|
4810
|
+
"aria-pressed": compact,
|
|
4811
|
+
onClick: () => setDensity(compact ? "default" : "compact"),
|
|
4812
|
+
children: [
|
|
4813
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_react29.Rows, { size: 16, "aria-hidden": true }),
|
|
4814
|
+
"Compact"
|
|
4815
|
+
]
|
|
4816
|
+
}
|
|
4817
|
+
),
|
|
4818
|
+
enableGrouping && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(DropdownMenu, { children: [
|
|
4819
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Button, { type: "button", variant: "outline", size: "sm", children: [
|
|
4820
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_react29.Stack, { size: 16, "aria-hidden": true }),
|
|
4821
|
+
"Group by"
|
|
4822
|
+
] }) }),
|
|
4823
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(DropdownMenuContent, { align: "end", children: [
|
|
4824
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DropdownMenuLabel, { children: "Group rows by" }),
|
|
4825
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DropdownMenuSeparator, {}),
|
|
4826
|
+
groupableColumns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4827
|
+
DropdownMenuCheckboxItem,
|
|
4828
|
+
{
|
|
4829
|
+
checked: column.getIsGrouped(),
|
|
4830
|
+
onCheckedChange: () => column.toggleGrouping(),
|
|
4831
|
+
children: labelOf(column)
|
|
4832
|
+
},
|
|
4833
|
+
column.id
|
|
4834
|
+
))
|
|
4835
|
+
] })
|
|
4836
|
+
] }),
|
|
4837
|
+
enableColumnVisibility && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(DropdownMenu, { children: [
|
|
4838
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Button, { type: "button", variant: "outline", size: "sm", children: [
|
|
4839
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_react29.Sliders, { size: 16, "aria-hidden": true }),
|
|
4840
|
+
"Columns"
|
|
4841
|
+
] }) }),
|
|
4842
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(DropdownMenuContent, { align: "end", children: [
|
|
4843
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DropdownMenuLabel, { children: "Toggle columns" }),
|
|
4844
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DropdownMenuSeparator, {}),
|
|
4845
|
+
hideableColumns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4846
|
+
DropdownMenuCheckboxItem,
|
|
4847
|
+
{
|
|
4848
|
+
checked: column.getIsVisible(),
|
|
4849
|
+
onCheckedChange: (checked) => column.toggleVisibility(Boolean(checked)),
|
|
4850
|
+
children: labelOf(column)
|
|
4851
|
+
},
|
|
4852
|
+
column.id
|
|
4853
|
+
))
|
|
4854
|
+
] })
|
|
4855
|
+
] })
|
|
4856
|
+
] })
|
|
4857
|
+
] }),
|
|
4858
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
4859
|
+
Table,
|
|
4860
|
+
{
|
|
4861
|
+
ref,
|
|
4862
|
+
containerRef: setScrollRef,
|
|
4863
|
+
containerClassName,
|
|
4864
|
+
striped,
|
|
4865
|
+
"aria-busy": loading || loadingMore || void 0,
|
|
4866
|
+
style: sized ? { width: table.getTotalSize(), minWidth: "100%", tableLayout: "fixed", ...tableStyle } : tableStyle,
|
|
4867
|
+
onKeyDown: enableCellSelection ? onGridKeyDown : void 0,
|
|
4868
|
+
tabIndex: enableCellSelection ? 0 : void 0,
|
|
4869
|
+
...tableProps,
|
|
4870
|
+
children: [
|
|
4871
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(TableHeader, { children: [
|
|
4872
|
+
headerGroups.map((group, groupIndex) => /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(TableRow, { className: "hover:bg-transparent", children: [
|
|
4873
|
+
groupIndex === 0 && leadingHeaderCells(headerGroups.length + (enableColumnFilters ? 1 : 0)),
|
|
4874
|
+
group.headers.map(renderHeaderCell)
|
|
4875
|
+
] }, group.id)),
|
|
4876
|
+
enableColumnFilters && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableRow, { className: "hover:bg-transparent", children: leafColumns.map((column) => {
|
|
4877
|
+
const pin = pinning(column, sized, true);
|
|
4878
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4879
|
+
TableHead,
|
|
4880
|
+
{
|
|
4881
|
+
style: pin.style,
|
|
4882
|
+
className: cn("h-auto py-2 font-normal", pin.className, sticky && !column.getIsPinned() && "bg-surface"),
|
|
4883
|
+
children: column.getCanFilter() ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ColumnFilter, { column }) : null
|
|
4884
|
+
},
|
|
4885
|
+
column.id
|
|
4886
|
+
);
|
|
4887
|
+
}) })
|
|
4888
|
+
] }),
|
|
4889
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(TableBody, { children: [
|
|
4890
|
+
loading ? Array.from({ length: pageSize }, (_, index) => skeletonRow(`loading-${index}`)) : totalRows === 0 ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableCell, { colSpan: columnSpan, muted: true, className: "h-24 text-center", children: emptyState ?? "No results." }) }) : /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
|
|
4891
|
+
topRows.map((row, index) => renderRow(row, { pinned: "top", pinnedIndex: index, pinnedCount: topRows.length })),
|
|
4892
|
+
virtualized && paddingTop > 0 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("tr", { "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("td", { colSpan: columnSpan, style: { height: paddingTop } }) }),
|
|
4893
|
+
rowsToRender ? rowsToRender.map(({ row, index }) => renderRow(row, { virtualIndex: index })) : bodyRows.map((row) => renderRow(row)),
|
|
4894
|
+
virtualized && paddingBottom > 0 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("tr", { "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("td", { colSpan: columnSpan, style: { height: paddingBottom } }) }),
|
|
4895
|
+
bottomRows.map(
|
|
4896
|
+
(row, index) => renderRow(row, { pinned: "bottom", pinnedIndex: index, pinnedCount: bottomRows.length })
|
|
4897
|
+
)
|
|
4898
|
+
] }),
|
|
4899
|
+
infinite && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
|
|
4900
|
+
loadingMore && Array.from({ length: 3 }, (_, index) => skeletonRow(`more-${index}`)),
|
|
4901
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("tr", { ref: sentinelRef, "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("td", { colSpan: columnSpan, className: "h-px p-0" }) })
|
|
4902
|
+
] })
|
|
4903
|
+
] }),
|
|
4904
|
+
showFooter && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableFooter, { children: table.getFooterGroups().map((group) => /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(TableRow, { className: "hover:bg-transparent", children: [
|
|
4905
|
+
leadingCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableCell, { colSpan: leadingCount, className: cellDensity }),
|
|
4906
|
+
group.headers.map((header) => {
|
|
4907
|
+
const { align } = getMeta(header.column.columnDef.meta);
|
|
4908
|
+
const pin = pinning(header.column, sized);
|
|
4909
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4910
|
+
TableCell,
|
|
4911
|
+
{
|
|
4912
|
+
align,
|
|
4913
|
+
colSpan: header.colSpan > 1 ? header.colSpan : void 0,
|
|
4914
|
+
style: pin.style,
|
|
4915
|
+
className: cn("text-ui-label", pin.className, cellDensity),
|
|
4916
|
+
children: header.isPlaceholder ? null : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(table.FlexRender, { footer: header })
|
|
4917
|
+
},
|
|
4918
|
+
header.id
|
|
4919
|
+
);
|
|
4920
|
+
})
|
|
4921
|
+
] }, group.id)) })
|
|
4922
|
+
]
|
|
4923
|
+
}
|
|
4924
|
+
),
|
|
4925
|
+
(enableRowSelection || paginate && pageCount > 1) && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
4926
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "text-body-small text-secondary-muted-foreground", "aria-live": "polite", children: enableRowSelection ? `${selectedCount} of ${table.getCoreRowModel().rows.length} row(s) selected` : null }),
|
|
4927
|
+
paginate && pageCount > 1 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4928
|
+
Pagination,
|
|
4929
|
+
{
|
|
4930
|
+
page: pagination.pageIndex + 1,
|
|
4931
|
+
pageCount,
|
|
4932
|
+
onPageChange: (page) => table.setPageIndex(page - 1)
|
|
4933
|
+
}
|
|
4934
|
+
)
|
|
4935
|
+
] })
|
|
4936
|
+
] });
|
|
4937
|
+
}
|
|
4938
|
+
var DataTable = React52.forwardRef(DataTableInner);
|
|
4939
|
+
DataTable.displayName = "DataTable";
|
|
4940
|
+
|
|
4941
|
+
// src/components/Data Display/StatCard.tsx
|
|
4942
|
+
var React53 = __toESM(require("react"), 1);
|
|
4943
|
+
var import_class_variance_authority6 = require("class-variance-authority");
|
|
4944
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
3913
4945
|
var statCardVariants = (0, import_class_variance_authority6.cva)("flex min-w-0 flex-col gap-2 rounded-md border p-3", {
|
|
3914
4946
|
variants: {
|
|
3915
4947
|
variant: {
|
|
@@ -3923,26 +4955,26 @@ var statCardVariants = (0, import_class_variance_authority6.cva)("flex min-w-0 f
|
|
|
3923
4955
|
},
|
|
3924
4956
|
defaultVariants: { variant: "default" }
|
|
3925
4957
|
});
|
|
3926
|
-
var StatCard =
|
|
3927
|
-
({ className, variant, label, value, icon, caption, ...props }, ref) => /* @__PURE__ */ (0,
|
|
3928
|
-
/* @__PURE__ */ (0,
|
|
3929
|
-
/* @__PURE__ */ (0,
|
|
3930
|
-
icon && /* @__PURE__ */ (0,
|
|
4958
|
+
var StatCard = React53.forwardRef(
|
|
4959
|
+
({ className, variant, label, value, icon, caption, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { ref, className: cn(statCardVariants({ variant }), className), ...props, children: [
|
|
4960
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "truncate text-ui-caption text-secondary-muted-foreground", children: label }),
|
|
4961
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("p", { className: "flex items-center gap-2 text-body-base text-surface-foreground", children: [
|
|
4962
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { "aria-hidden": "true", className: "inline-flex size-6 shrink-0 items-center justify-center", children: icon }),
|
|
3931
4963
|
value
|
|
3932
4964
|
] }),
|
|
3933
|
-
caption && /* @__PURE__ */ (0,
|
|
4965
|
+
caption && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "text-ui-caption text-secondary-muted-foreground", children: caption })
|
|
3934
4966
|
] })
|
|
3935
4967
|
);
|
|
3936
4968
|
StatCard.displayName = "StatCard";
|
|
3937
4969
|
|
|
3938
4970
|
// src/components/Research-Specific/ActivityStructure.tsx
|
|
3939
|
-
var
|
|
4971
|
+
var React55 = __toESM(require("react"), 1);
|
|
3940
4972
|
|
|
3941
4973
|
// src/components/Tags & Badges/EditableTag.tsx
|
|
3942
|
-
var
|
|
3943
|
-
var
|
|
4974
|
+
var React54 = __toESM(require("react"), 1);
|
|
4975
|
+
var import_react30 = require("@phosphor-icons/react");
|
|
3944
4976
|
var import_class_variance_authority7 = require("class-variance-authority");
|
|
3945
|
-
var
|
|
4977
|
+
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
3946
4978
|
var editableTagVariants = (0, import_class_variance_authority7.cva)(
|
|
3947
4979
|
"inline-flex h-6.5 items-center whitespace-nowrap rounded-sm py-1 text-ui-caption transition-colors",
|
|
3948
4980
|
{
|
|
@@ -3957,27 +4989,27 @@ var editableTagVariants = (0, import_class_variance_authority7.cva)(
|
|
|
3957
4989
|
defaultVariants: { type: "default" }
|
|
3958
4990
|
}
|
|
3959
4991
|
);
|
|
3960
|
-
var EditableTag =
|
|
4992
|
+
var EditableTag = React54.forwardRef(
|
|
3961
4993
|
({ className, type = "default", icon, onRemove, onClick, children, ...props }, ref) => {
|
|
3962
4994
|
const classes = cn(editableTagVariants({ type }), className);
|
|
3963
|
-
const leading = type === "add" ? /* @__PURE__ */ (0,
|
|
4995
|
+
const leading = type === "add" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_react30.Plus, { size: 12, "aria-hidden": true }) : icon !== void 0 ? icon : type === "default" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_react30.Crown, { size: 12, weight: "fill", "aria-hidden": true }) : null;
|
|
3964
4996
|
if (type === "add" || type === "multiple" && onClick) {
|
|
3965
|
-
return /* @__PURE__ */ (0,
|
|
4997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("button", { ref, type: "button", className: classes, onClick, ...props, children: [
|
|
3966
4998
|
leading,
|
|
3967
4999
|
children
|
|
3968
5000
|
] });
|
|
3969
5001
|
}
|
|
3970
|
-
return /* @__PURE__ */ (0,
|
|
5002
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("span", { ref, className: classes, ...props, children: [
|
|
3971
5003
|
leading,
|
|
3972
5004
|
children,
|
|
3973
|
-
onRemove && /* @__PURE__ */ (0,
|
|
5005
|
+
onRemove && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
3974
5006
|
"button",
|
|
3975
5007
|
{
|
|
3976
5008
|
type: "button",
|
|
3977
5009
|
"aria-label": typeof children === "string" ? `Remove ${children}` : "Remove",
|
|
3978
5010
|
onClick: onRemove,
|
|
3979
5011
|
className: "inline-flex size-3 items-center justify-center rounded-xs",
|
|
3980
|
-
children: /* @__PURE__ */ (0,
|
|
5012
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_react30.X, { size: 12, "aria-hidden": true })
|
|
3981
5013
|
}
|
|
3982
5014
|
)
|
|
3983
5015
|
] });
|
|
@@ -3986,26 +5018,26 @@ var EditableTag = React52.forwardRef(
|
|
|
3986
5018
|
EditableTag.displayName = "EditableTag";
|
|
3987
5019
|
|
|
3988
5020
|
// src/components/Research-Specific/ActivityStructure.tsx
|
|
3989
|
-
var
|
|
3990
|
-
var ActivityStructure =
|
|
3991
|
-
({ className, title = "Activity Structure", stats, sections, onRemoveTag, onAddTag, addTagLabel = "Add tag", action, children, ...props }, ref) => /* @__PURE__ */ (0,
|
|
5021
|
+
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
5022
|
+
var ActivityStructure = React55.forwardRef(
|
|
5023
|
+
({ className, title = "Activity Structure", stats, sections, onRemoveTag, onAddTag, addTagLabel = "Add tag", action, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
3992
5024
|
"section",
|
|
3993
5025
|
{
|
|
3994
5026
|
ref,
|
|
3995
5027
|
className: cn("flex w-full max-w-96.5 flex-col gap-4 rounded-xl bg-surface p-4", className),
|
|
3996
5028
|
...props,
|
|
3997
5029
|
children: [
|
|
3998
|
-
/* @__PURE__ */ (0,
|
|
3999
|
-
/* @__PURE__ */ (0,
|
|
5030
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
5031
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("h3", { className: "text-body-section text-surface-foreground", children: title }),
|
|
4000
5032
|
action
|
|
4001
5033
|
] }),
|
|
4002
|
-
stats.length > 0 && /* @__PURE__ */ (0,
|
|
4003
|
-
sections?.map(({ id, heading, body, tags }) => /* @__PURE__ */ (0,
|
|
4004
|
-
/* @__PURE__ */ (0,
|
|
4005
|
-
/* @__PURE__ */ (0,
|
|
4006
|
-
(tags?.length || onAddTag) && /* @__PURE__ */ (0,
|
|
4007
|
-
tags?.map((tag) => /* @__PURE__ */ (0,
|
|
4008
|
-
onAddTag && /* @__PURE__ */ (0,
|
|
5034
|
+
stats.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "grid grid-cols-2 gap-3", children: stats.map(({ id, ...stat }) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(StatCard, { ...stat }, id)) }),
|
|
5035
|
+
sections?.map(({ id, heading, body, tags }) => /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
5036
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("h4", { className: "text-heading-h4 text-surface-foreground", children: heading }),
|
|
5037
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "text-body-base text-surface-foreground", children: body }),
|
|
5038
|
+
(tags?.length || onAddTag) && /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
5039
|
+
tags?.map((tag) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(EditableTag, { type: "editable", onRemove: onRemoveTag && (() => onRemoveTag(id, tag)), children: tag }, tag)),
|
|
5040
|
+
onAddTag && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(EditableTag, { type: "add", onClick: () => onAddTag(id), children: addTagLabel })
|
|
4009
5041
|
] })
|
|
4010
5042
|
] }, id)),
|
|
4011
5043
|
children
|
|
@@ -4016,10 +5048,10 @@ var ActivityStructure = React53.forwardRef(
|
|
|
4016
5048
|
ActivityStructure.displayName = "ActivityStructure";
|
|
4017
5049
|
|
|
4018
5050
|
// src/components/Tags & Badges/Badge.tsx
|
|
4019
|
-
var
|
|
4020
|
-
var
|
|
5051
|
+
var React56 = __toESM(require("react"), 1);
|
|
5052
|
+
var import_react31 = require("@phosphor-icons/react");
|
|
4021
5053
|
var import_class_variance_authority8 = require("class-variance-authority");
|
|
4022
|
-
var
|
|
5054
|
+
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
4023
5055
|
var roleTagVariants = (0, import_class_variance_authority8.cva)(
|
|
4024
5056
|
"group inline-flex h-6 items-center whitespace-nowrap rounded-sm py-1 text-ui-caption transition-colors",
|
|
4025
5057
|
{
|
|
@@ -4045,11 +5077,11 @@ var roleTagVariants = (0, import_class_variance_authority8.cva)(
|
|
|
4045
5077
|
defaultVariants: { type: "primary", selected: false }
|
|
4046
5078
|
}
|
|
4047
5079
|
);
|
|
4048
|
-
var Badge =
|
|
5080
|
+
var Badge = React56.forwardRef(
|
|
4049
5081
|
({ className, type = "primary", selected = false, onClick, children, ...props }, ref) => {
|
|
4050
5082
|
const classes = cn(roleTagVariants({ type, selected: type === "interactable" ? selected : false }), className);
|
|
4051
5083
|
if (type === "interactable") {
|
|
4052
|
-
return /* @__PURE__ */ (0,
|
|
5084
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
4053
5085
|
"button",
|
|
4054
5086
|
{
|
|
4055
5087
|
ref,
|
|
@@ -4059,100 +5091,20 @@ var Badge = React54.forwardRef(
|
|
|
4059
5091
|
onClick,
|
|
4060
5092
|
...props,
|
|
4061
5093
|
children: [
|
|
4062
|
-
/* @__PURE__ */ (0,
|
|
5094
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_react31.DotsSixVertical, { size: 16, "aria-hidden": true, className: "hidden shrink-0 group-hover:block" }),
|
|
4063
5095
|
children
|
|
4064
5096
|
]
|
|
4065
5097
|
}
|
|
4066
5098
|
);
|
|
4067
5099
|
}
|
|
4068
|
-
return /* @__PURE__ */ (0,
|
|
4069
|
-
type === "question" && /* @__PURE__ */ (0,
|
|
4070
|
-
type === "id" && /* @__PURE__ */ (0,
|
|
5100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("span", { ref, className: classes, ...props, children: [
|
|
5101
|
+
type === "question" && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_react31.RadioButton, { size: 16, weight: "fill", "aria-hidden": true }),
|
|
5102
|
+
type === "id" && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "text-secondary-muted-foreground", children: "ID" }),
|
|
4071
5103
|
children
|
|
4072
5104
|
] });
|
|
4073
5105
|
}
|
|
4074
5106
|
);
|
|
4075
5107
|
Badge.displayName = "Badge";
|
|
4076
|
-
|
|
4077
|
-
// src/components/Utility/Pagination.tsx
|
|
4078
|
-
var React55 = __toESM(require("react"), 1);
|
|
4079
|
-
var import_react30 = require("@phosphor-icons/react");
|
|
4080
|
-
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
4081
|
-
function getPaginationItems(page, pageCount, siblings = 1) {
|
|
4082
|
-
const keep = /* @__PURE__ */ new Set([1, pageCount]);
|
|
4083
|
-
for (let p = page - siblings; p <= page + siblings; p++) if (p >= 1 && p <= pageCount) keep.add(p);
|
|
4084
|
-
const sorted = [...keep].sort((a, b) => a - b);
|
|
4085
|
-
const items = [];
|
|
4086
|
-
sorted.forEach((p, index) => {
|
|
4087
|
-
const previous = sorted[index - 1];
|
|
4088
|
-
if (previous !== void 0 && p - previous === 2) items.push(previous + 1);
|
|
4089
|
-
else if (previous !== void 0 && p - previous > 2) items.push("ellipsis");
|
|
4090
|
-
items.push(p);
|
|
4091
|
-
});
|
|
4092
|
-
return items;
|
|
4093
|
-
}
|
|
4094
|
-
var Pagination = React55.forwardRef(
|
|
4095
|
-
({ className, page, pageCount, onPageChange, variant = "full", siblings = 1, ...props }, ref) => {
|
|
4096
|
-
const go = (next2) => onPageChange(Math.min(pageCount, Math.max(1, next2)));
|
|
4097
|
-
const previous = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
4098
|
-
Button,
|
|
4099
|
-
{
|
|
4100
|
-
type: "button",
|
|
4101
|
-
variant: "outline",
|
|
4102
|
-
size: "icon-sm",
|
|
4103
|
-
"aria-label": "Previous page",
|
|
4104
|
-
disabled: page <= 1,
|
|
4105
|
-
onClick: () => go(page - 1),
|
|
4106
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_react30.ArrowLeft, { size: 16, "aria-hidden": true })
|
|
4107
|
-
}
|
|
4108
|
-
);
|
|
4109
|
-
const next = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
4110
|
-
Button,
|
|
4111
|
-
{
|
|
4112
|
-
type: "button",
|
|
4113
|
-
variant: "outline",
|
|
4114
|
-
size: "icon-sm",
|
|
4115
|
-
"aria-label": "Next page",
|
|
4116
|
-
disabled: page >= pageCount,
|
|
4117
|
-
onClick: () => go(page + 1),
|
|
4118
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_react30.ArrowRight, { size: 16, "aria-hidden": true })
|
|
4119
|
-
}
|
|
4120
|
-
);
|
|
4121
|
-
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
4122
|
-
"nav",
|
|
4123
|
-
{
|
|
4124
|
-
ref,
|
|
4125
|
-
"aria-label": "Pagination",
|
|
4126
|
-
className: cn("flex items-center", variant === "compact" ? "w-35 justify-between" : "gap-2", className),
|
|
4127
|
-
...props,
|
|
4128
|
-
children: [
|
|
4129
|
-
previous,
|
|
4130
|
-
variant === "compact" ? /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("span", { className: "text-body-small text-surface-foreground", "aria-live": "polite", children: [
|
|
4131
|
-
page,
|
|
4132
|
-
"/",
|
|
4133
|
-
pageCount
|
|
4134
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("ul", { className: "flex items-center gap-2", children: getPaginationItems(page, pageCount, siblings).map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("li", { children: item === "ellipsis" ? /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("span", { className: "inline-flex size-8 items-center justify-center rounded-sm border border-border bg-surface text-surface-foreground", children: [
|
|
4135
|
-
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_react30.DotsThree, { size: 16, "aria-hidden": true }),
|
|
4136
|
-
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "sr-only", children: "More pages" })
|
|
4137
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
4138
|
-
Button,
|
|
4139
|
-
{
|
|
4140
|
-
type: "button",
|
|
4141
|
-
variant: item === page ? "subtle" : "outline",
|
|
4142
|
-
size: "sm",
|
|
4143
|
-
"aria-label": `Page ${item}`,
|
|
4144
|
-
"aria-current": item === page ? "page" : void 0,
|
|
4145
|
-
onClick: () => go(item),
|
|
4146
|
-
children: item
|
|
4147
|
-
}
|
|
4148
|
-
) }, item === "ellipsis" ? `ellipsis-${index}` : item)) }),
|
|
4149
|
-
next
|
|
4150
|
-
]
|
|
4151
|
-
}
|
|
4152
|
-
);
|
|
4153
|
-
}
|
|
4154
|
-
);
|
|
4155
|
-
Pagination.displayName = "Pagination";
|
|
4156
5108
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4157
5109
|
0 && (module.exports = {
|
|
4158
5110
|
AIMiniAvatar,
|
|
@@ -4168,6 +5120,7 @@ Pagination.displayName = "Pagination";
|
|
|
4168
5120
|
ChatOption,
|
|
4169
5121
|
Checkbox,
|
|
4170
5122
|
CheckboxField,
|
|
5123
|
+
DataTable,
|
|
4171
5124
|
DatePicker,
|
|
4172
5125
|
DateTimePicker,
|
|
4173
5126
|
Dialog,
|
|
@@ -4248,6 +5201,7 @@ Pagination.displayName = "Pagination";
|
|
|
4248
5201
|
TableBody,
|
|
4249
5202
|
TableCell,
|
|
4250
5203
|
TableCellTwoLines,
|
|
5204
|
+
TableFooter,
|
|
4251
5205
|
TableHead,
|
|
4252
5206
|
TableHeader,
|
|
4253
5207
|
TableRow,
|