@discuss-ds/ui 0.33.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 +8 -0
- package/dist/index.cjs +973 -143
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +237 -6
- package/dist/index.d.ts +237 -6
- package/dist/index.js +1016 -141
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -39,6 +39,9 @@ var twMerge = extendTailwindMerge({
|
|
|
39
39
|
function cn(...inputs) {
|
|
40
40
|
return twMerge(clsx(inputs));
|
|
41
41
|
}
|
|
42
|
+
function lengthOutOfRange(text, min, max) {
|
|
43
|
+
return min !== void 0 && text.trim().length < min || max !== void 0 && text.length > max;
|
|
44
|
+
}
|
|
42
45
|
|
|
43
46
|
// src/components/Buttons & Actions/Button.tsx
|
|
44
47
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -1681,6 +1684,7 @@ var InlineEdit = React25.forwardRef(
|
|
|
1681
1684
|
const [draft, setDraft] = React25.useState(value);
|
|
1682
1685
|
const [error, setError] = React25.useState(null);
|
|
1683
1686
|
const errorId = React25.useId();
|
|
1687
|
+
const limitsVisible = !!showLimits && (!!error || lengthOutOfRange(draft, minLength, maxLength));
|
|
1684
1688
|
const fieldRef = React25.useRef(null);
|
|
1685
1689
|
const [scroll, setScroll] = React25.useState(0);
|
|
1686
1690
|
const [draftMarks, setDraftMarks] = React25.useState([]);
|
|
@@ -1737,7 +1741,7 @@ var InlineEdit = React25.forwardRef(
|
|
|
1737
1741
|
"div",
|
|
1738
1742
|
{
|
|
1739
1743
|
ref,
|
|
1740
|
-
className: cn(fill ? "flex w-full min-w-0" : "inline-flex min-w-0 max-w-full", editing && (error ||
|
|
1744
|
+
className: cn(fill ? "flex w-full min-w-0" : "inline-flex min-w-0 max-w-full", editing && (error || limitsVisible) && "flex-col gap-1.5", className),
|
|
1741
1745
|
...props,
|
|
1742
1746
|
children: editing ? /* @__PURE__ */ jsxs18(Fragment5, { children: [
|
|
1743
1747
|
/* @__PURE__ */ jsxs18("div", { className: cn("relative flex w-full min-w-0", draftMarks.length > 0 && !question && "rounded-md bg-surface"), children: [
|
|
@@ -1758,7 +1762,7 @@ var InlineEdit = React25.forwardRef(
|
|
|
1758
1762
|
maxLength,
|
|
1759
1763
|
"aria-label": ariaLabel,
|
|
1760
1764
|
"aria-invalid": error ? true : void 0,
|
|
1761
|
-
"aria-describedby": error ||
|
|
1765
|
+
"aria-describedby": error || limitsVisible ? errorId : void 0,
|
|
1762
1766
|
...multiline ? { rows: 1 } : { type: "text" },
|
|
1763
1767
|
className: cn(
|
|
1764
1768
|
"relative w-full px-3 py-1 outline-none",
|
|
@@ -1802,7 +1806,7 @@ var InlineEdit = React25.forwardRef(
|
|
|
1802
1806
|
}
|
|
1803
1807
|
)
|
|
1804
1808
|
] }),
|
|
1805
|
-
(error ||
|
|
1809
|
+
(error || limitsVisible) && /* @__PURE__ */ jsxs18(
|
|
1806
1810
|
"p",
|
|
1807
1811
|
{
|
|
1808
1812
|
id: errorId,
|
|
@@ -1811,10 +1815,10 @@ var InlineEdit = React25.forwardRef(
|
|
|
1811
1815
|
children: [
|
|
1812
1816
|
/* @__PURE__ */ jsxs18("span", { className: "flex items-start gap-2", children: [
|
|
1813
1817
|
error && /* @__PURE__ */ jsx26(WarningCircle2, { size: 16, "aria-hidden": true, className: "shrink-0" }),
|
|
1814
|
-
|
|
1815
|
-
|
|
1818
|
+
limitsVisible ? limitsText(minLength, maxLength) : error,
|
|
1819
|
+
limitsVisible && error && /* @__PURE__ */ jsx26("span", { className: "sr-only", children: error })
|
|
1816
1820
|
] }),
|
|
1817
|
-
|
|
1821
|
+
limitsVisible && /* @__PURE__ */ jsxs18("span", { "aria-hidden": true, className: "shrink-0 tabular-nums", children: [
|
|
1818
1822
|
draft.length,
|
|
1819
1823
|
maxLength !== void 0 && `/${maxLength}`
|
|
1820
1824
|
] })
|
|
@@ -3023,7 +3027,7 @@ var QuestionHeader = React42.forwardRef(
|
|
|
3023
3027
|
}
|
|
3024
3028
|
),
|
|
3025
3029
|
long && titleRecommendedNote != null && /* @__PURE__ */ jsx43("p", { className: "text-ui-caption text-secondary-muted-foreground", children: titleRecommendedNote }),
|
|
3026
|
-
showCounter && titleMinLength === void 0 && /* @__PURE__ */ jsxs30("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
|
|
3030
|
+
showCounter && titleMinLength === void 0 && maxLength !== void 0 && count > maxLength && /* @__PURE__ */ jsxs30("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
|
|
3027
3031
|
count,
|
|
3028
3032
|
"/",
|
|
3029
3033
|
maxLength,
|
|
@@ -3467,7 +3471,7 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
|
|
|
3467
3471
|
(piece, i) => piece.mark ? /* @__PURE__ */ jsx46(MarkedText, { mark: piece.mark, text: piece.text, onApply: onMarkApply, onDismiss: onMarkDismiss }, `${piece.mark.start}:${piece.text}`) : /* @__PURE__ */ jsx46("span", { children: piece.text }, i)
|
|
3468
3472
|
) })
|
|
3469
3473
|
] }),
|
|
3470
|
-
guarded && draft !== null && /* @__PURE__ */ jsxs33(
|
|
3474
|
+
guarded && draft !== null && (error || lengthOutOfRange(draft, minLength, maxLength)) && /* @__PURE__ */ jsxs33(
|
|
3471
3475
|
"p",
|
|
3472
3476
|
{
|
|
3473
3477
|
id: helperId,
|
|
@@ -3725,7 +3729,7 @@ var StimulusCard = React48.forwardRef(
|
|
|
3725
3729
|
textClassName: "text-body-base"
|
|
3726
3730
|
}
|
|
3727
3731
|
) : /* @__PURE__ */ jsx49("p", { className: "w-full text-body-base [word-break:break-word]", children: caption }),
|
|
3728
|
-
onCaptionChange && showCounter && maxLength !== void 0 && /* @__PURE__ */ jsxs36("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
|
|
3732
|
+
onCaptionChange && showCounter && maxLength !== void 0 && count > maxLength && /* @__PURE__ */ jsxs36("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
|
|
3729
3733
|
count,
|
|
3730
3734
|
"/",
|
|
3731
3735
|
maxLength,
|
|
@@ -3785,7 +3789,7 @@ import * as React50 from "react";
|
|
|
3785
3789
|
import { CaretDown as CaretDown4, CaretUp } from "@phosphor-icons/react";
|
|
3786
3790
|
import { jsx as jsx51, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
3787
3791
|
var Table = React50.forwardRef(
|
|
3788
|
-
({ className, containerClassName, striped, ...props }, ref) => /* @__PURE__ */ jsx51("div", { className: cn("relative w-full overflow-auto rounded-lg border border-border bg-surface", containerClassName), children: /* @__PURE__ */ jsx51(
|
|
3792
|
+
({ className, containerClassName, containerRef, striped, ...props }, ref) => /* @__PURE__ */ jsx51("div", { ref: containerRef, className: cn("relative w-full overflow-auto rounded-lg border border-border bg-surface", containerClassName), children: /* @__PURE__ */ jsx51(
|
|
3789
3793
|
"table",
|
|
3790
3794
|
{
|
|
3791
3795
|
ref,
|
|
@@ -3800,6 +3804,10 @@ var TableHeader = React50.forwardRef(
|
|
|
3800
3804
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx51("thead", { ref, className, ...props })
|
|
3801
3805
|
);
|
|
3802
3806
|
TableHeader.displayName = "TableHeader";
|
|
3807
|
+
var TableFooter = React50.forwardRef(
|
|
3808
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx51("tfoot", { ref, className: cn("border-t border-border bg-background text-ui-label", className), ...props })
|
|
3809
|
+
);
|
|
3810
|
+
TableFooter.displayName = "TableFooter";
|
|
3803
3811
|
var TableBody = React50.forwardRef(
|
|
3804
3812
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx51("tbody", { ref, className, ...props })
|
|
3805
3813
|
);
|
|
@@ -3823,9 +3831,9 @@ var TableRow = React50.forwardRef(
|
|
|
3823
3831
|
TableRow.displayName = "TableRow";
|
|
3824
3832
|
var ariaSort = { none: "none", asc: "ascending", desc: "descending" };
|
|
3825
3833
|
var TableHead = React50.forwardRef(
|
|
3826
|
-
({ className, align = "left", sortable, sort = "none", onSort, checkbox, children, ...props }, ref) => {
|
|
3834
|
+
({ className, align = "left", sortable, sort = "none", onSort, checkbox, resizer, children, ...props }, ref) => {
|
|
3827
3835
|
const caret = sort === "asc" ? /* @__PURE__ */ jsx51(CaretUp, { size: 16, "aria-hidden": true, className: "shrink-0" }) : /* @__PURE__ */ jsx51(CaretDown4, { size: 16, "aria-hidden": true, className: "shrink-0" });
|
|
3828
|
-
return /* @__PURE__ */
|
|
3836
|
+
return /* @__PURE__ */ jsxs38(
|
|
3829
3837
|
"th",
|
|
3830
3838
|
{
|
|
3831
3839
|
ref,
|
|
@@ -3835,21 +3843,25 @@ var TableHead = React50.forwardRef(
|
|
|
3835
3843
|
"h-10 border-b border-border text-ui-label whitespace-nowrap",
|
|
3836
3844
|
checkbox ? "w-13 px-0 text-center" : "px-4 py-3",
|
|
3837
3845
|
align === "right" ? "text-right" : "text-left",
|
|
3846
|
+
resizer && "relative",
|
|
3838
3847
|
className
|
|
3839
3848
|
),
|
|
3840
3849
|
...props,
|
|
3841
|
-
children:
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
children
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3850
|
+
children: [
|
|
3851
|
+
sortable ? /* @__PURE__ */ jsxs38(
|
|
3852
|
+
"button",
|
|
3853
|
+
{
|
|
3854
|
+
type: "button",
|
|
3855
|
+
onClick: onSort,
|
|
3856
|
+
className: cn("inline-flex items-center gap-1 rounded-xs", align === "right" && "flex-row-reverse"),
|
|
3857
|
+
children: [
|
|
3858
|
+
children,
|
|
3859
|
+
caret
|
|
3860
|
+
]
|
|
3861
|
+
}
|
|
3862
|
+
) : checkbox ? /* @__PURE__ */ jsx51("div", { className: "flex items-center justify-center", children }) : children,
|
|
3863
|
+
resizer
|
|
3864
|
+
]
|
|
3853
3865
|
}
|
|
3854
3866
|
);
|
|
3855
3867
|
}
|
|
@@ -3884,10 +3896,951 @@ function TableCellTwoLines({ primary, secondary, avatar, className, ...props })
|
|
|
3884
3896
|
] });
|
|
3885
3897
|
}
|
|
3886
3898
|
|
|
3887
|
-
// src/components/Data Display/
|
|
3899
|
+
// src/components/Data Display/DataTable.tsx
|
|
3900
|
+
import * as React52 from "react";
|
|
3901
|
+
import { CaretDown as CaretDown5, CaretRight as CaretRight4, PushPin, PushPinSlash, Rows, Sliders, Stack } from "@phosphor-icons/react";
|
|
3902
|
+
import {
|
|
3903
|
+
aggregationFn_count,
|
|
3904
|
+
aggregationFn_extent,
|
|
3905
|
+
aggregationFn_max,
|
|
3906
|
+
aggregationFn_mean,
|
|
3907
|
+
aggregationFn_median,
|
|
3908
|
+
aggregationFn_min,
|
|
3909
|
+
aggregationFn_sum,
|
|
3910
|
+
aggregationFn_unique,
|
|
3911
|
+
aggregationFn_uniqueCount,
|
|
3912
|
+
cellSelectionFeature,
|
|
3913
|
+
cellSpanningFeature,
|
|
3914
|
+
columnFacetingFeature,
|
|
3915
|
+
columnFilteringFeature,
|
|
3916
|
+
columnGroupingFeature,
|
|
3917
|
+
columnOrderingFeature,
|
|
3918
|
+
columnPinningFeature,
|
|
3919
|
+
columnResizingFeature,
|
|
3920
|
+
columnSizingFeature,
|
|
3921
|
+
columnVisibilityFeature,
|
|
3922
|
+
createExpandedRowModel,
|
|
3923
|
+
createFacetedMinMaxValues,
|
|
3924
|
+
createFacetedRowModel,
|
|
3925
|
+
createFacetedUniqueValues,
|
|
3926
|
+
createFilteredRowModel,
|
|
3927
|
+
createGroupedRowModel,
|
|
3928
|
+
createPaginatedRowModel,
|
|
3929
|
+
createSortedRowModel,
|
|
3930
|
+
filterFn_arrIncludesSome,
|
|
3931
|
+
filterFn_equals,
|
|
3932
|
+
filterFn_equalsString,
|
|
3933
|
+
filterFn_inNumberRange,
|
|
3934
|
+
filterFn_includesString,
|
|
3935
|
+
flexRender,
|
|
3936
|
+
globalFilteringFeature,
|
|
3937
|
+
rowAggregationFeature,
|
|
3938
|
+
rowExpandingFeature,
|
|
3939
|
+
rowPaginationFeature,
|
|
3940
|
+
rowPinningFeature,
|
|
3941
|
+
rowSelectionFeature,
|
|
3942
|
+
rowSortingFeature,
|
|
3943
|
+
sortFn_alphanumeric,
|
|
3944
|
+
sortFn_basic,
|
|
3945
|
+
sortFn_datetime,
|
|
3946
|
+
sortFn_text,
|
|
3947
|
+
tableFeatures,
|
|
3948
|
+
useTable
|
|
3949
|
+
} from "@tanstack/react-table";
|
|
3950
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
3951
|
+
|
|
3952
|
+
// src/components/Utility/Pagination.tsx
|
|
3888
3953
|
import * as React51 from "react";
|
|
3889
|
-
import {
|
|
3954
|
+
import { ArrowLeft, ArrowRight, DotsThree as DotsThree2 } from "@phosphor-icons/react";
|
|
3890
3955
|
import { jsx as jsx52, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
3956
|
+
function getPaginationItems(page, pageCount, siblings = 1) {
|
|
3957
|
+
const keep = /* @__PURE__ */ new Set([1, pageCount]);
|
|
3958
|
+
for (let p = page - siblings; p <= page + siblings; p++) if (p >= 1 && p <= pageCount) keep.add(p);
|
|
3959
|
+
const sorted = [...keep].sort((a, b) => a - b);
|
|
3960
|
+
const items = [];
|
|
3961
|
+
sorted.forEach((p, index) => {
|
|
3962
|
+
const previous = sorted[index - 1];
|
|
3963
|
+
if (previous !== void 0 && p - previous === 2) items.push(previous + 1);
|
|
3964
|
+
else if (previous !== void 0 && p - previous > 2) items.push("ellipsis");
|
|
3965
|
+
items.push(p);
|
|
3966
|
+
});
|
|
3967
|
+
return items;
|
|
3968
|
+
}
|
|
3969
|
+
var Pagination = React51.forwardRef(
|
|
3970
|
+
({ className, page, pageCount, onPageChange, variant = "full", siblings = 1, ...props }, ref) => {
|
|
3971
|
+
const go = (next2) => onPageChange(Math.min(pageCount, Math.max(1, next2)));
|
|
3972
|
+
const previous = /* @__PURE__ */ jsx52(
|
|
3973
|
+
Button,
|
|
3974
|
+
{
|
|
3975
|
+
type: "button",
|
|
3976
|
+
variant: "outline",
|
|
3977
|
+
size: "icon-sm",
|
|
3978
|
+
"aria-label": "Previous page",
|
|
3979
|
+
disabled: page <= 1,
|
|
3980
|
+
onClick: () => go(page - 1),
|
|
3981
|
+
children: /* @__PURE__ */ jsx52(ArrowLeft, { size: 16, "aria-hidden": true })
|
|
3982
|
+
}
|
|
3983
|
+
);
|
|
3984
|
+
const next = /* @__PURE__ */ jsx52(
|
|
3985
|
+
Button,
|
|
3986
|
+
{
|
|
3987
|
+
type: "button",
|
|
3988
|
+
variant: "outline",
|
|
3989
|
+
size: "icon-sm",
|
|
3990
|
+
"aria-label": "Next page",
|
|
3991
|
+
disabled: page >= pageCount,
|
|
3992
|
+
onClick: () => go(page + 1),
|
|
3993
|
+
children: /* @__PURE__ */ jsx52(ArrowRight, { size: 16, "aria-hidden": true })
|
|
3994
|
+
}
|
|
3995
|
+
);
|
|
3996
|
+
return /* @__PURE__ */ jsxs39(
|
|
3997
|
+
"nav",
|
|
3998
|
+
{
|
|
3999
|
+
ref,
|
|
4000
|
+
"aria-label": "Pagination",
|
|
4001
|
+
className: cn("flex items-center", variant === "compact" ? "w-35 justify-between" : "gap-2", className),
|
|
4002
|
+
...props,
|
|
4003
|
+
children: [
|
|
4004
|
+
previous,
|
|
4005
|
+
variant === "compact" ? /* @__PURE__ */ jsxs39("span", { className: "text-body-small text-surface-foreground", "aria-live": "polite", children: [
|
|
4006
|
+
page,
|
|
4007
|
+
"/",
|
|
4008
|
+
pageCount
|
|
4009
|
+
] }) : /* @__PURE__ */ jsx52("ul", { className: "flex items-center gap-2", children: getPaginationItems(page, pageCount, siblings).map((item, index) => /* @__PURE__ */ jsx52("li", { children: item === "ellipsis" ? /* @__PURE__ */ jsxs39("span", { className: "inline-flex size-8 items-center justify-center rounded-sm border border-border bg-surface text-surface-foreground", children: [
|
|
4010
|
+
/* @__PURE__ */ jsx52(DotsThree2, { size: 16, "aria-hidden": true }),
|
|
4011
|
+
/* @__PURE__ */ jsx52("span", { className: "sr-only", children: "More pages" })
|
|
4012
|
+
] }) : /* @__PURE__ */ jsx52(
|
|
4013
|
+
Button,
|
|
4014
|
+
{
|
|
4015
|
+
type: "button",
|
|
4016
|
+
variant: item === page ? "subtle" : "outline",
|
|
4017
|
+
size: "sm",
|
|
4018
|
+
"aria-label": `Page ${item}`,
|
|
4019
|
+
"aria-current": item === page ? "page" : void 0,
|
|
4020
|
+
onClick: () => go(item),
|
|
4021
|
+
children: item
|
|
4022
|
+
}
|
|
4023
|
+
) }, item === "ellipsis" ? `ellipsis-${index}` : item)) }),
|
|
4024
|
+
next
|
|
4025
|
+
]
|
|
4026
|
+
}
|
|
4027
|
+
);
|
|
4028
|
+
}
|
|
4029
|
+
);
|
|
4030
|
+
Pagination.displayName = "Pagination";
|
|
4031
|
+
|
|
4032
|
+
// src/components/Data Display/DataTable.tsx
|
|
4033
|
+
import { Fragment as Fragment14, jsx as jsx53, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
4034
|
+
var features = tableFeatures({
|
|
4035
|
+
rowSortingFeature,
|
|
4036
|
+
rowPaginationFeature,
|
|
4037
|
+
rowSelectionFeature,
|
|
4038
|
+
rowExpandingFeature,
|
|
4039
|
+
rowPinningFeature,
|
|
4040
|
+
rowAggregationFeature,
|
|
4041
|
+
columnVisibilityFeature,
|
|
4042
|
+
columnOrderingFeature,
|
|
4043
|
+
columnPinningFeature,
|
|
4044
|
+
columnSizingFeature,
|
|
4045
|
+
columnResizingFeature,
|
|
4046
|
+
columnFilteringFeature,
|
|
4047
|
+
globalFilteringFeature,
|
|
4048
|
+
columnFacetingFeature,
|
|
4049
|
+
columnGroupingFeature,
|
|
4050
|
+
cellSelectionFeature,
|
|
4051
|
+
cellSpanningFeature,
|
|
4052
|
+
// Row-model pipeline order: filter → group → sort → expand → paginate.
|
|
4053
|
+
facetedRowModel: createFacetedRowModel(),
|
|
4054
|
+
facetedUniqueValues: createFacetedUniqueValues(),
|
|
4055
|
+
facetedMinMaxValues: createFacetedMinMaxValues(),
|
|
4056
|
+
filteredRowModel: createFilteredRowModel(),
|
|
4057
|
+
groupedRowModel: createGroupedRowModel(),
|
|
4058
|
+
sortedRowModel: createSortedRowModel(),
|
|
4059
|
+
expandedRowModel: createExpandedRowModel(),
|
|
4060
|
+
paginatedRowModel: createPaginatedRowModel(),
|
|
4061
|
+
sortFns: {
|
|
4062
|
+
alphanumeric: sortFn_alphanumeric,
|
|
4063
|
+
basic: sortFn_basic,
|
|
4064
|
+
datetime: sortFn_datetime,
|
|
4065
|
+
text: sortFn_text
|
|
4066
|
+
},
|
|
4067
|
+
filterFns: {
|
|
4068
|
+
arrIncludesSome: filterFn_arrIncludesSome,
|
|
4069
|
+
equals: filterFn_equals,
|
|
4070
|
+
equalsString: filterFn_equalsString,
|
|
4071
|
+
includesString: filterFn_includesString,
|
|
4072
|
+
inNumberRange: filterFn_inNumberRange
|
|
4073
|
+
},
|
|
4074
|
+
aggregationFns: {
|
|
4075
|
+
count: aggregationFn_count,
|
|
4076
|
+
extent: aggregationFn_extent,
|
|
4077
|
+
max: aggregationFn_max,
|
|
4078
|
+
mean: aggregationFn_mean,
|
|
4079
|
+
median: aggregationFn_median,
|
|
4080
|
+
min: aggregationFn_min,
|
|
4081
|
+
sum: aggregationFn_sum,
|
|
4082
|
+
unique: aggregationFn_unique,
|
|
4083
|
+
uniqueCount: aggregationFn_uniqueCount
|
|
4084
|
+
}
|
|
4085
|
+
});
|
|
4086
|
+
var getMeta = (meta) => meta ?? {};
|
|
4087
|
+
function useControllable(value, initial, onChange) {
|
|
4088
|
+
const [internal, setInternal] = React52.useState(initial);
|
|
4089
|
+
const current = value ?? internal;
|
|
4090
|
+
const update = React52.useCallback(
|
|
4091
|
+
(updater) => {
|
|
4092
|
+
const next = typeof updater === "function" ? updater(current) : updater;
|
|
4093
|
+
if (value === void 0) setInternal(next);
|
|
4094
|
+
onChange?.(next);
|
|
4095
|
+
},
|
|
4096
|
+
[current, value, onChange]
|
|
4097
|
+
);
|
|
4098
|
+
return [current, update];
|
|
4099
|
+
}
|
|
4100
|
+
var ALL = "__all__";
|
|
4101
|
+
var labelOf = (column) => getMeta(column.columnDef.meta).label ?? (typeof column.columnDef.header === "string" ? column.columnDef.header : column.id);
|
|
4102
|
+
function pinning(column, sized, header = false) {
|
|
4103
|
+
const side = column.getIsPinned();
|
|
4104
|
+
const style = {};
|
|
4105
|
+
if (sized) {
|
|
4106
|
+
style.width = column.getSize();
|
|
4107
|
+
style.minWidth = column.getSize();
|
|
4108
|
+
style.maxWidth = column.getSize();
|
|
4109
|
+
}
|
|
4110
|
+
if (side) {
|
|
4111
|
+
style.position = "sticky";
|
|
4112
|
+
if (side === "start") style.insetInlineStart = column.getStart("start");
|
|
4113
|
+
else style.insetInlineEnd = column.getAfter("end");
|
|
4114
|
+
}
|
|
4115
|
+
const className = side ? cn(
|
|
4116
|
+
header ? "z-30" : "z-10",
|
|
4117
|
+
"bg-surface",
|
|
4118
|
+
side === "start" && column.getIsLastColumn("start") && "border-r border-border",
|
|
4119
|
+
side === "end" && column.getIsFirstColumn("end") && "border-l border-border"
|
|
4120
|
+
) : void 0;
|
|
4121
|
+
return { style, className };
|
|
4122
|
+
}
|
|
4123
|
+
function ColumnFilter({ column }) {
|
|
4124
|
+
const variant = getMeta(column.columnDef.meta).filterVariant ?? "text";
|
|
4125
|
+
const label = labelOf(column);
|
|
4126
|
+
const value = column.getFilterValue();
|
|
4127
|
+
if (variant === "select") {
|
|
4128
|
+
const options = [...column.getFacetedUniqueValues().entries()].sort((a, b) => String(a[0]).localeCompare(String(b[0])));
|
|
4129
|
+
return /* @__PURE__ */ jsxs40(
|
|
4130
|
+
Select,
|
|
4131
|
+
{
|
|
4132
|
+
value: typeof value === "string" ? value : ALL,
|
|
4133
|
+
onValueChange: (next) => column.setFilterValue(next === ALL ? void 0 : next),
|
|
4134
|
+
children: [
|
|
4135
|
+
/* @__PURE__ */ jsx53(SelectTrigger, { "aria-label": `Filter ${label}`, className: "h-8 text-body-small", children: /* @__PURE__ */ jsx53(SelectValue, {}) }),
|
|
4136
|
+
/* @__PURE__ */ jsxs40(SelectContent, { children: [
|
|
4137
|
+
/* @__PURE__ */ jsx53(SelectItem, { value: ALL, children: "All" }),
|
|
4138
|
+
options.map(([option, count]) => /* @__PURE__ */ jsxs40(SelectItem, { value: String(option), children: [
|
|
4139
|
+
String(option),
|
|
4140
|
+
" (",
|
|
4141
|
+
count,
|
|
4142
|
+
")"
|
|
4143
|
+
] }, String(option)))
|
|
4144
|
+
] })
|
|
4145
|
+
]
|
|
4146
|
+
}
|
|
4147
|
+
);
|
|
4148
|
+
}
|
|
4149
|
+
if (variant === "range") {
|
|
4150
|
+
const [min, max] = column.getFacetedMinMaxValues() ?? [];
|
|
4151
|
+
const range = Array.isArray(value) ? value : [];
|
|
4152
|
+
const update = (index, raw) => {
|
|
4153
|
+
const next = [range[0], range[1]];
|
|
4154
|
+
next[index] = raw === "" ? void 0 : Number(raw);
|
|
4155
|
+
column.setFilterValue(next[0] === void 0 && next[1] === void 0 ? void 0 : next);
|
|
4156
|
+
};
|
|
4157
|
+
return /* @__PURE__ */ jsxs40("div", { className: "flex gap-1", children: [
|
|
4158
|
+
/* @__PURE__ */ jsx53(
|
|
4159
|
+
Input,
|
|
4160
|
+
{
|
|
4161
|
+
type: "number",
|
|
4162
|
+
"aria-label": `${label} minimum`,
|
|
4163
|
+
placeholder: min !== void 0 ? String(min) : "Min",
|
|
4164
|
+
value: range[0] ?? "",
|
|
4165
|
+
onChange: (event) => update(0, event.target.value),
|
|
4166
|
+
className: "h-8 text-body-small"
|
|
4167
|
+
}
|
|
4168
|
+
),
|
|
4169
|
+
/* @__PURE__ */ jsx53(
|
|
4170
|
+
Input,
|
|
4171
|
+
{
|
|
4172
|
+
type: "number",
|
|
4173
|
+
"aria-label": `${label} maximum`,
|
|
4174
|
+
placeholder: max !== void 0 ? String(max) : "Max",
|
|
4175
|
+
value: range[1] ?? "",
|
|
4176
|
+
onChange: (event) => update(1, event.target.value),
|
|
4177
|
+
className: "h-8 text-body-small"
|
|
4178
|
+
}
|
|
4179
|
+
)
|
|
4180
|
+
] });
|
|
4181
|
+
}
|
|
4182
|
+
return /* @__PURE__ */ jsx53(
|
|
4183
|
+
Input,
|
|
4184
|
+
{
|
|
4185
|
+
"aria-label": `Filter ${label}`,
|
|
4186
|
+
placeholder: "Filter\u2026",
|
|
4187
|
+
value: typeof value === "string" ? value : "",
|
|
4188
|
+
onChange: (event) => column.setFilterValue(event.target.value || void 0),
|
|
4189
|
+
className: "h-8 text-body-small"
|
|
4190
|
+
}
|
|
4191
|
+
);
|
|
4192
|
+
}
|
|
4193
|
+
function EditableCell({ value, label, type, onCommit }) {
|
|
4194
|
+
const initial = value == null ? "" : String(value);
|
|
4195
|
+
const [draft, setDraft] = React52.useState(null);
|
|
4196
|
+
const cancelled = React52.useRef(false);
|
|
4197
|
+
return /* @__PURE__ */ jsx53(
|
|
4198
|
+
Input,
|
|
4199
|
+
{
|
|
4200
|
+
type,
|
|
4201
|
+
"aria-label": label,
|
|
4202
|
+
value: draft ?? initial,
|
|
4203
|
+
onChange: (event) => setDraft(event.target.value),
|
|
4204
|
+
onBlur: () => {
|
|
4205
|
+
if (!cancelled.current && draft !== null && draft !== initial) onCommit(draft);
|
|
4206
|
+
cancelled.current = false;
|
|
4207
|
+
setDraft(null);
|
|
4208
|
+
},
|
|
4209
|
+
onKeyDown: (event) => {
|
|
4210
|
+
if (event.key === "Enter") event.currentTarget.blur();
|
|
4211
|
+
if (event.key === "Escape") {
|
|
4212
|
+
cancelled.current = true;
|
|
4213
|
+
event.currentTarget.blur();
|
|
4214
|
+
}
|
|
4215
|
+
},
|
|
4216
|
+
className: cn("h-8 border-transparent bg-transparent text-body-small", type === "number" && "text-right")
|
|
4217
|
+
}
|
|
4218
|
+
);
|
|
4219
|
+
}
|
|
4220
|
+
function DataTableInner({
|
|
4221
|
+
columns,
|
|
4222
|
+
data,
|
|
4223
|
+
getRowId,
|
|
4224
|
+
initialState,
|
|
4225
|
+
enableSorting = false,
|
|
4226
|
+
enableRowSelection = false,
|
|
4227
|
+
enableColumnVisibility = false,
|
|
4228
|
+
enableColumnPinning = false,
|
|
4229
|
+
enableColumnSizing = false,
|
|
4230
|
+
enableColumnResizing = false,
|
|
4231
|
+
columnResizeMode = "onChange",
|
|
4232
|
+
enableColumnOrdering = false,
|
|
4233
|
+
enableColumnFilters = false,
|
|
4234
|
+
enableGlobalFilter = false,
|
|
4235
|
+
globalFilterPlaceholder = "Search",
|
|
4236
|
+
enableGrouping = false,
|
|
4237
|
+
enableExpanding = false,
|
|
4238
|
+
enableRowPinning = false,
|
|
4239
|
+
enableCellSelection = false,
|
|
4240
|
+
showFooter = false,
|
|
4241
|
+
enableDensityToggle = false,
|
|
4242
|
+
density: densityProp,
|
|
4243
|
+
onDensityChange,
|
|
4244
|
+
getSubRows,
|
|
4245
|
+
getRowCanExpand,
|
|
4246
|
+
renderSubComponent,
|
|
4247
|
+
pageSize = 10,
|
|
4248
|
+
serverSide = false,
|
|
4249
|
+
rowCount,
|
|
4250
|
+
sorting: sortingProp,
|
|
4251
|
+
onSortingChange,
|
|
4252
|
+
rowSelection: rowSelectionProp,
|
|
4253
|
+
onRowSelectionChange,
|
|
4254
|
+
pagination: paginationProp,
|
|
4255
|
+
onPaginationChange,
|
|
4256
|
+
columnVisibility: columnVisibilityProp,
|
|
4257
|
+
onColumnVisibilityChange,
|
|
4258
|
+
columnPinning: columnPinningProp,
|
|
4259
|
+
onColumnPinningChange,
|
|
4260
|
+
columnOrder: columnOrderProp,
|
|
4261
|
+
onColumnOrderChange,
|
|
4262
|
+
columnFilters: columnFiltersProp,
|
|
4263
|
+
onColumnFiltersChange,
|
|
4264
|
+
globalFilter: globalFilterProp,
|
|
4265
|
+
onGlobalFilterChange,
|
|
4266
|
+
grouping: groupingProp,
|
|
4267
|
+
onGroupingChange,
|
|
4268
|
+
expanded: expandedProp,
|
|
4269
|
+
onExpandedChange,
|
|
4270
|
+
rowPinning: rowPinningProp,
|
|
4271
|
+
onRowPinningChange,
|
|
4272
|
+
onCellSelectionChange,
|
|
4273
|
+
onCellEdit,
|
|
4274
|
+
virtualized = false,
|
|
4275
|
+
estimateRowHeight = 40,
|
|
4276
|
+
onLoadMore,
|
|
4277
|
+
hasMore = false,
|
|
4278
|
+
loadingMore = false,
|
|
4279
|
+
stickyHeader,
|
|
4280
|
+
loading = false,
|
|
4281
|
+
emptyState,
|
|
4282
|
+
onRowClick,
|
|
4283
|
+
toolbar,
|
|
4284
|
+
wrapperClassName,
|
|
4285
|
+
striped,
|
|
4286
|
+
containerClassName,
|
|
4287
|
+
containerRef,
|
|
4288
|
+
style: tableStyle,
|
|
4289
|
+
...tableProps
|
|
4290
|
+
}, ref) {
|
|
4291
|
+
const [sorting, setSorting] = useControllable(sortingProp, initialState?.sorting ?? [], onSortingChange);
|
|
4292
|
+
const [rowSelection, setRowSelection] = useControllable(
|
|
4293
|
+
rowSelectionProp,
|
|
4294
|
+
initialState?.rowSelection ?? {},
|
|
4295
|
+
onRowSelectionChange
|
|
4296
|
+
);
|
|
4297
|
+
const [columnVisibility, setColumnVisibility] = useControllable(
|
|
4298
|
+
columnVisibilityProp,
|
|
4299
|
+
initialState?.columnVisibility ?? {},
|
|
4300
|
+
onColumnVisibilityChange
|
|
4301
|
+
);
|
|
4302
|
+
const [columnPinning, setColumnPinning] = useControllable(
|
|
4303
|
+
columnPinningProp,
|
|
4304
|
+
{ start: initialState?.columnPinning?.start ?? [], end: initialState?.columnPinning?.end ?? [] },
|
|
4305
|
+
onColumnPinningChange
|
|
4306
|
+
);
|
|
4307
|
+
const [columnOrder, setColumnOrder] = useControllable(
|
|
4308
|
+
columnOrderProp,
|
|
4309
|
+
initialState?.columnOrder ?? [],
|
|
4310
|
+
onColumnOrderChange
|
|
4311
|
+
);
|
|
4312
|
+
const [columnFilters, setColumnFilters] = useControllable(
|
|
4313
|
+
columnFiltersProp,
|
|
4314
|
+
initialState?.columnFilters ?? [],
|
|
4315
|
+
onColumnFiltersChange
|
|
4316
|
+
);
|
|
4317
|
+
const [globalFilter, setGlobalFilter] = useControllable(
|
|
4318
|
+
globalFilterProp,
|
|
4319
|
+
initialState?.globalFilter ?? "",
|
|
4320
|
+
onGlobalFilterChange
|
|
4321
|
+
);
|
|
4322
|
+
const [grouping, setGrouping] = useControllable(groupingProp, initialState?.grouping ?? [], onGroupingChange);
|
|
4323
|
+
const [expanded, setExpanded] = useControllable(expandedProp, initialState?.expanded ?? {}, onExpandedChange);
|
|
4324
|
+
const [rowPinning, setRowPinning] = useControllable(
|
|
4325
|
+
rowPinningProp,
|
|
4326
|
+
{ top: initialState?.rowPinning?.top ?? [], bottom: initialState?.rowPinning?.bottom ?? [] },
|
|
4327
|
+
onRowPinningChange
|
|
4328
|
+
);
|
|
4329
|
+
const [pagination, setPagination] = useControllable(
|
|
4330
|
+
paginationProp,
|
|
4331
|
+
initialState?.pagination ?? { pageIndex: 0, pageSize },
|
|
4332
|
+
onPaginationChange
|
|
4333
|
+
);
|
|
4334
|
+
const [density, setDensity] = useControllable(densityProp, "default", onDensityChange);
|
|
4335
|
+
const [cellSelection, setCellSelection] = React52.useState([]);
|
|
4336
|
+
const infinite = Boolean(onLoadMore);
|
|
4337
|
+
const paginate = !virtualized && !infinite;
|
|
4338
|
+
const compact = density === "compact";
|
|
4339
|
+
const sized = enableColumnSizing || enableColumnResizing || enableColumnPinning;
|
|
4340
|
+
const sticky = stickyHeader ?? (enableRowPinning || virtualized);
|
|
4341
|
+
const table = useTable({
|
|
4342
|
+
features,
|
|
4343
|
+
columns,
|
|
4344
|
+
data,
|
|
4345
|
+
getRowId,
|
|
4346
|
+
getSubRows,
|
|
4347
|
+
getRowCanExpand: getRowCanExpand ?? (renderSubComponent ? () => true : void 0),
|
|
4348
|
+
enableSorting,
|
|
4349
|
+
enableRowSelection,
|
|
4350
|
+
enableColumnResizing,
|
|
4351
|
+
enableColumnPinning,
|
|
4352
|
+
enableColumnFilters,
|
|
4353
|
+
enableGlobalFilter,
|
|
4354
|
+
enableGrouping,
|
|
4355
|
+
enableRowPinning,
|
|
4356
|
+
enableCellSelection,
|
|
4357
|
+
columnResizeMode,
|
|
4358
|
+
globalFilterFn: "includesString",
|
|
4359
|
+
manualSorting: serverSide,
|
|
4360
|
+
manualFiltering: serverSide,
|
|
4361
|
+
manualPagination: serverSide || !paginate,
|
|
4362
|
+
rowCount: serverSide ? rowCount : void 0,
|
|
4363
|
+
autoResetPageIndex: !serverSide,
|
|
4364
|
+
state: {
|
|
4365
|
+
sorting,
|
|
4366
|
+
rowSelection,
|
|
4367
|
+
columnVisibility,
|
|
4368
|
+
columnPinning,
|
|
4369
|
+
columnOrder,
|
|
4370
|
+
columnFilters,
|
|
4371
|
+
globalFilter,
|
|
4372
|
+
grouping,
|
|
4373
|
+
expanded,
|
|
4374
|
+
rowPinning,
|
|
4375
|
+
cellSelection,
|
|
4376
|
+
pagination: { ...pagination, pageSize: paginationProp ? pagination.pageSize : pageSize }
|
|
4377
|
+
},
|
|
4378
|
+
onSortingChange: setSorting,
|
|
4379
|
+
onRowSelectionChange: setRowSelection,
|
|
4380
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
4381
|
+
onColumnPinningChange: setColumnPinning,
|
|
4382
|
+
onColumnOrderChange: setColumnOrder,
|
|
4383
|
+
onColumnFiltersChange: setColumnFilters,
|
|
4384
|
+
onGlobalFilterChange: setGlobalFilter,
|
|
4385
|
+
onGroupingChange: setGrouping,
|
|
4386
|
+
onExpandedChange: setExpanded,
|
|
4387
|
+
onRowPinningChange: setRowPinning,
|
|
4388
|
+
onCellSelectionChange: (updater) => {
|
|
4389
|
+
const next = typeof updater === "function" ? updater(cellSelection) : updater;
|
|
4390
|
+
setCellSelection(next);
|
|
4391
|
+
onCellSelectionChange?.(next);
|
|
4392
|
+
},
|
|
4393
|
+
onPaginationChange: setPagination
|
|
4394
|
+
});
|
|
4395
|
+
const headerGroups = table.getHeaderGroups();
|
|
4396
|
+
const leafColumns = table.getVisibleLeafColumns();
|
|
4397
|
+
const hasExpander = enableExpanding;
|
|
4398
|
+
const leadingCount = (enableRowSelection ? 1 : 0) + (hasExpander ? 1 : 0) + (enableRowPinning ? 1 : 0);
|
|
4399
|
+
const columnSpan = leafColumns.length + leadingCount;
|
|
4400
|
+
const pageCount = table.getPageCount();
|
|
4401
|
+
const selectedCount = Object.values(rowSelection).filter(Boolean).length;
|
|
4402
|
+
const hideableColumns = table.getAllLeafColumns().filter((column) => column.getCanHide());
|
|
4403
|
+
const groupableColumns = table.getAllLeafColumns().filter((column) => column.getCanGroup());
|
|
4404
|
+
const showToolbar = Boolean(toolbar) || enableColumnVisibility || enableGlobalFilter || enableGrouping || enableDensityToggle;
|
|
4405
|
+
const cellDensity = compact ? "h-8 py-1.5" : void 0;
|
|
4406
|
+
const allSelected = table.getIsAllPageRowsSelected();
|
|
4407
|
+
const someSelected = table.getIsSomePageRowsSelected();
|
|
4408
|
+
const dragged = React52.useRef(null);
|
|
4409
|
+
const topRows = enableRowPinning ? table.getTopRows() : [];
|
|
4410
|
+
const bottomRows = enableRowPinning ? table.getBottomRows() : [];
|
|
4411
|
+
const bodyRows = enableRowPinning ? table.getCenterRows() : table.getRowModel().rows;
|
|
4412
|
+
const scrollRef = React52.useRef(null);
|
|
4413
|
+
const setScrollRef = React52.useCallback(
|
|
4414
|
+
(node) => {
|
|
4415
|
+
scrollRef.current = node;
|
|
4416
|
+
if (typeof containerRef === "function") containerRef(node);
|
|
4417
|
+
else if (containerRef) containerRef.current = node;
|
|
4418
|
+
},
|
|
4419
|
+
[containerRef]
|
|
4420
|
+
);
|
|
4421
|
+
const virtualizer = useVirtualizer({
|
|
4422
|
+
count: bodyRows.length,
|
|
4423
|
+
getScrollElement: () => scrollRef.current,
|
|
4424
|
+
estimateSize: () => estimateRowHeight,
|
|
4425
|
+
overscan: 8,
|
|
4426
|
+
enabled: virtualized,
|
|
4427
|
+
initialRect: { width: 0, height: estimateRowHeight * 10 }
|
|
4428
|
+
});
|
|
4429
|
+
const virtualItems = virtualized ? virtualizer.getVirtualItems() : [];
|
|
4430
|
+
const paddingTop = virtualItems.length > 0 ? virtualItems[0]?.start ?? 0 : 0;
|
|
4431
|
+
const paddingBottom = virtualItems.length > 0 ? virtualizer.getTotalSize() - (virtualItems.at(-1)?.end ?? 0) : 0;
|
|
4432
|
+
const sentinelRef = React52.useRef(null);
|
|
4433
|
+
React52.useEffect(() => {
|
|
4434
|
+
const node = sentinelRef.current;
|
|
4435
|
+
if (!node || !onLoadMore || !hasMore || loadingMore || typeof IntersectionObserver === "undefined") return;
|
|
4436
|
+
const container = scrollRef.current;
|
|
4437
|
+
const root = container && container.scrollHeight > container.clientHeight ? container : null;
|
|
4438
|
+
const observer = new IntersectionObserver(
|
|
4439
|
+
(entries) => {
|
|
4440
|
+
if (entries.some((entry) => entry.isIntersecting)) onLoadMore();
|
|
4441
|
+
},
|
|
4442
|
+
{ root, rootMargin: "0px 0px 160px 0px" }
|
|
4443
|
+
);
|
|
4444
|
+
observer.observe(node);
|
|
4445
|
+
return () => observer.disconnect();
|
|
4446
|
+
}, [onLoadMore, hasMore, loadingMore, bodyRows.length]);
|
|
4447
|
+
const reorder = (activeId, overId) => {
|
|
4448
|
+
if (activeId === overId) return;
|
|
4449
|
+
const ids = table.getAllLeafColumns().map((column) => column.id);
|
|
4450
|
+
const next = ids.filter((id) => id !== activeId);
|
|
4451
|
+
const at = next.indexOf(overId);
|
|
4452
|
+
next.splice(at === -1 ? next.length : at, 0, activeId);
|
|
4453
|
+
table.setColumnOrder(next);
|
|
4454
|
+
};
|
|
4455
|
+
const onGridKeyDown = (event) => {
|
|
4456
|
+
const directions = {
|
|
4457
|
+
ArrowUp: "up",
|
|
4458
|
+
ArrowDown: "down",
|
|
4459
|
+
ArrowLeft: "left",
|
|
4460
|
+
ArrowRight: "right"
|
|
4461
|
+
};
|
|
4462
|
+
const direction = directions[event.key];
|
|
4463
|
+
if (direction) {
|
|
4464
|
+
event.preventDefault();
|
|
4465
|
+
if (event.shiftKey) table.extendCellSelection(direction);
|
|
4466
|
+
else table.moveCellSelection(direction);
|
|
4467
|
+
} else if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "a") {
|
|
4468
|
+
event.preventDefault();
|
|
4469
|
+
table.selectAllCells();
|
|
4470
|
+
} else if (event.key === "Escape") {
|
|
4471
|
+
table.resetCellSelection(true);
|
|
4472
|
+
}
|
|
4473
|
+
};
|
|
4474
|
+
const skeletonRow = (rowKey) => /* @__PURE__ */ jsx53(TableRow, { className: "hover:bg-transparent", children: Array.from({ length: columnSpan }, (_, cell) => /* @__PURE__ */ jsx53(TableCell, { checkbox: enableRowSelection && cell === 0, className: cellDensity, children: /* @__PURE__ */ jsx53("span", { "aria-hidden": true, className: "block h-4 w-3/4 animate-pulse rounded-xs bg-border" }) }, cell)) }, rowKey);
|
|
4475
|
+
const renderRow = (row, options = {}) => {
|
|
4476
|
+
const { pinned, pinnedIndex = 0, pinnedCount = 1, virtualIndex } = options;
|
|
4477
|
+
const grouped = row.getIsGrouped();
|
|
4478
|
+
const rowUnits = compact ? 8 : 10;
|
|
4479
|
+
const pinStyle = pinned ? pinned === "top" ? { position: "sticky", top: `calc(var(--spacing) * ${rowUnits * (pinnedIndex + 1)})` } : { position: "sticky", bottom: `calc(var(--spacing) * ${rowUnits * (pinnedCount - 1 - pinnedIndex)})` } : void 0;
|
|
4480
|
+
const cells = row.getVisibleCells();
|
|
4481
|
+
return /* @__PURE__ */ jsxs40(React52.Fragment, { children: [
|
|
4482
|
+
/* @__PURE__ */ jsxs40(
|
|
4483
|
+
TableRow,
|
|
4484
|
+
{
|
|
4485
|
+
ref: virtualized && virtualIndex !== void 0 ? virtualizer.measureElement : void 0,
|
|
4486
|
+
"data-index": virtualIndex,
|
|
4487
|
+
selected: row.getIsSelected(),
|
|
4488
|
+
style: pinStyle,
|
|
4489
|
+
onClick: onRowClick && !grouped ? () => onRowClick(row.original) : void 0,
|
|
4490
|
+
className: cn(pinned && "z-20 bg-surface", grouped && "bg-background", onRowClick && !grouped && "cursor-pointer"),
|
|
4491
|
+
children: [
|
|
4492
|
+
enableRowSelection && /* @__PURE__ */ jsx53(TableCell, { checkbox: true, className: cellDensity, onClick: (event) => event.stopPropagation(), children: !grouped && /* @__PURE__ */ jsx53(
|
|
4493
|
+
Checkbox,
|
|
4494
|
+
{
|
|
4495
|
+
"aria-label": "Select row",
|
|
4496
|
+
checked: row.getIsSelected(),
|
|
4497
|
+
disabled: !row.getCanSelect(),
|
|
4498
|
+
onCheckedChange: (checked) => row.toggleSelected(Boolean(checked))
|
|
4499
|
+
}
|
|
4500
|
+
) }),
|
|
4501
|
+
hasExpander && /* @__PURE__ */ jsx53(TableCell, { checkbox: true, className: cellDensity, onClick: (event) => event.stopPropagation(), children: !grouped && row.getCanExpand() && /* @__PURE__ */ jsx53(
|
|
4502
|
+
Button,
|
|
4503
|
+
{
|
|
4504
|
+
type: "button",
|
|
4505
|
+
variant: "ghost",
|
|
4506
|
+
size: "icon-sm",
|
|
4507
|
+
"aria-label": row.getIsExpanded() ? "Collapse row" : "Expand row",
|
|
4508
|
+
"aria-expanded": row.getIsExpanded(),
|
|
4509
|
+
onClick: () => row.toggleExpanded(),
|
|
4510
|
+
children: row.getIsExpanded() ? /* @__PURE__ */ jsx53(CaretDown5, { size: 16, "aria-hidden": true }) : /* @__PURE__ */ jsx53(CaretRight4, { size: 16, "aria-hidden": true })
|
|
4511
|
+
}
|
|
4512
|
+
) }),
|
|
4513
|
+
enableRowPinning && /* @__PURE__ */ jsx53(TableCell, { checkbox: true, className: cellDensity, onClick: (event) => event.stopPropagation(), children: !grouped && /* @__PURE__ */ jsx53(
|
|
4514
|
+
Button,
|
|
4515
|
+
{
|
|
4516
|
+
type: "button",
|
|
4517
|
+
variant: "ghost",
|
|
4518
|
+
size: "icon-sm",
|
|
4519
|
+
"aria-label": row.getIsPinned() ? "Unpin row" : "Pin row to top",
|
|
4520
|
+
"aria-pressed": Boolean(row.getIsPinned()),
|
|
4521
|
+
onClick: () => row.pin(row.getIsPinned() ? false : "top"),
|
|
4522
|
+
children: row.getIsPinned() ? /* @__PURE__ */ jsx53(PushPinSlash, { size: 16, "aria-hidden": true }) : /* @__PURE__ */ jsx53(PushPin, { size: 16, "aria-hidden": true })
|
|
4523
|
+
}
|
|
4524
|
+
) }),
|
|
4525
|
+
cells.map((cell, index) => {
|
|
4526
|
+
if (cell.getIsCovered()) return null;
|
|
4527
|
+
const meta = getMeta(cell.column.columnDef.meta);
|
|
4528
|
+
const pin = pinning(cell.column, sized);
|
|
4529
|
+
const rowSpan = cell.getRowSpan();
|
|
4530
|
+
const colSpan = cell.getColSpan();
|
|
4531
|
+
const edges = enableCellSelection && cell.getIsSelected() ? cell.getSelectionEdges() : void 0;
|
|
4532
|
+
const indent = index === 0 && hasExpander && row.depth > 0 ? row.depth * 4 : 0;
|
|
4533
|
+
let content;
|
|
4534
|
+
if (cell.getIsGrouped()) {
|
|
4535
|
+
content = /* @__PURE__ */ jsxs40(
|
|
4536
|
+
"button",
|
|
4537
|
+
{
|
|
4538
|
+
type: "button",
|
|
4539
|
+
className: "inline-flex items-center gap-1 rounded-xs text-ui-label",
|
|
4540
|
+
"aria-expanded": row.getIsExpanded(),
|
|
4541
|
+
onClick: row.getToggleExpandedHandler(),
|
|
4542
|
+
children: [
|
|
4543
|
+
row.getIsExpanded() ? /* @__PURE__ */ jsx53(CaretDown5, { size: 16, "aria-hidden": true }) : /* @__PURE__ */ jsx53(CaretRight4, { size: 16, "aria-hidden": true }),
|
|
4544
|
+
flexRender(cell.column.columnDef.cell, cell.getContext()),
|
|
4545
|
+
/* @__PURE__ */ jsxs40("span", { className: "text-secondary-muted-foreground", children: [
|
|
4546
|
+
"(",
|
|
4547
|
+
row.subRows.length,
|
|
4548
|
+
")"
|
|
4549
|
+
] })
|
|
4550
|
+
]
|
|
4551
|
+
}
|
|
4552
|
+
);
|
|
4553
|
+
} else if (cell.getIsAggregated()) {
|
|
4554
|
+
content = flexRender(cell.column.columnDef.aggregatedCell ?? cell.column.columnDef.cell, cell.getContext());
|
|
4555
|
+
} else if (cell.getIsPlaceholder()) {
|
|
4556
|
+
content = null;
|
|
4557
|
+
} else if (meta.editable) {
|
|
4558
|
+
content = /* @__PURE__ */ jsx53(
|
|
4559
|
+
EditableCell,
|
|
4560
|
+
{
|
|
4561
|
+
value: cell.getValue(),
|
|
4562
|
+
label: `${labelOf(cell.column)}, row ${row.index + 1}`,
|
|
4563
|
+
type: meta.editType ?? "text",
|
|
4564
|
+
onCommit: (value) => onCellEdit?.({ row: row.original, rowId: row.id, columnId: cell.column.id, value })
|
|
4565
|
+
}
|
|
4566
|
+
);
|
|
4567
|
+
} else {
|
|
4568
|
+
content = flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
4569
|
+
}
|
|
4570
|
+
return /* @__PURE__ */ jsx53(
|
|
4571
|
+
TableCell,
|
|
4572
|
+
{
|
|
4573
|
+
align: meta.align,
|
|
4574
|
+
muted: meta.muted && !grouped,
|
|
4575
|
+
rowSpan: rowSpan > 1 ? rowSpan : void 0,
|
|
4576
|
+
colSpan: colSpan > 1 ? colSpan : void 0,
|
|
4577
|
+
style: {
|
|
4578
|
+
...pin.style,
|
|
4579
|
+
...indent ? { paddingInlineStart: `calc(var(--spacing) * ${indent + 4})` } : null
|
|
4580
|
+
},
|
|
4581
|
+
"data-selected": edges ? "" : void 0,
|
|
4582
|
+
onMouseDown: enableCellSelection ? cell.getSelectionStartHandler() : void 0,
|
|
4583
|
+
onMouseEnter: enableCellSelection ? cell.getSelectionExtendHandler() : void 0,
|
|
4584
|
+
className: cn(
|
|
4585
|
+
cellDensity,
|
|
4586
|
+
pin.className,
|
|
4587
|
+
enableCellSelection && "select-none",
|
|
4588
|
+
edges && "bg-accent-soft",
|
|
4589
|
+
edges?.top && "border-t-2 border-t-input-accent",
|
|
4590
|
+
edges?.bottom && "border-b-2 border-b-input-accent",
|
|
4591
|
+
edges?.left && "border-l-2 border-l-input-accent",
|
|
4592
|
+
edges?.right && "border-r-2 border-r-input-accent",
|
|
4593
|
+
meta.editable && "py-1"
|
|
4594
|
+
),
|
|
4595
|
+
children: content
|
|
4596
|
+
},
|
|
4597
|
+
cell.id
|
|
4598
|
+
);
|
|
4599
|
+
})
|
|
4600
|
+
]
|
|
4601
|
+
}
|
|
4602
|
+
),
|
|
4603
|
+
renderSubComponent && !grouped && row.getIsExpanded() && /* @__PURE__ */ jsx53(TableRow, { className: "bg-background hover:bg-background", children: /* @__PURE__ */ jsx53(TableCell, { colSpan: columnSpan, children: renderSubComponent(row.original) }) })
|
|
4604
|
+
] }, row.id);
|
|
4605
|
+
};
|
|
4606
|
+
const renderHeaderCell = (header) => {
|
|
4607
|
+
const { column } = header;
|
|
4608
|
+
const { align } = getMeta(column.columnDef.meta);
|
|
4609
|
+
const leaf = header.subHeaders.length === 0;
|
|
4610
|
+
const sortState = column.getIsSorted();
|
|
4611
|
+
const pin = pinning(column, sized, true);
|
|
4612
|
+
const reorderable = enableColumnOrdering && leaf && !column.getIsPinned();
|
|
4613
|
+
const label = labelOf(column);
|
|
4614
|
+
return /* @__PURE__ */ jsx53(
|
|
4615
|
+
TableHead,
|
|
4616
|
+
{
|
|
4617
|
+
colSpan: header.colSpan > 1 ? header.colSpan : void 0,
|
|
4618
|
+
align: leaf ? align : void 0,
|
|
4619
|
+
sortable: leaf && column.getCanSort(),
|
|
4620
|
+
sort: sortState === false ? "none" : sortState,
|
|
4621
|
+
onSort: () => column.toggleSorting(sortState === "asc"),
|
|
4622
|
+
style: pin.style,
|
|
4623
|
+
draggable: reorderable || void 0,
|
|
4624
|
+
tabIndex: reorderable ? 0 : void 0,
|
|
4625
|
+
title: reorderable ? "Drag, or press Alt + arrow keys, to reorder" : void 0,
|
|
4626
|
+
onDragStart: reorderable ? () => dragged.current = column.id : void 0,
|
|
4627
|
+
onDragOver: reorderable ? (event) => event.preventDefault() : void 0,
|
|
4628
|
+
onDrop: reorderable ? (event) => {
|
|
4629
|
+
event.preventDefault();
|
|
4630
|
+
if (dragged.current) reorder(dragged.current, column.id);
|
|
4631
|
+
dragged.current = null;
|
|
4632
|
+
} : void 0,
|
|
4633
|
+
onKeyDown: reorderable ? (event) => {
|
|
4634
|
+
if (!event.altKey || event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
|
4635
|
+
event.preventDefault();
|
|
4636
|
+
const ids = table.getAllLeafColumns().map((item) => item.id);
|
|
4637
|
+
const at = ids.indexOf(column.id);
|
|
4638
|
+
const target = ids[at + (event.key === "ArrowLeft" ? -1 : 2)];
|
|
4639
|
+
if (event.key === "ArrowLeft" && ids[at - 1]) reorder(column.id, ids[at - 1]);
|
|
4640
|
+
else if (event.key === "ArrowRight" && at < ids.length - 1) reorder(column.id, target ?? "__end__");
|
|
4641
|
+
} : void 0,
|
|
4642
|
+
className: cn(
|
|
4643
|
+
pin.className,
|
|
4644
|
+
cellDensity,
|
|
4645
|
+
sticky && !column.getIsPinned() && "sticky top-0 z-20 bg-surface",
|
|
4646
|
+
sticky && column.getIsPinned() && "top-0",
|
|
4647
|
+
reorderable && "cursor-grab",
|
|
4648
|
+
!leaf && "text-center"
|
|
4649
|
+
),
|
|
4650
|
+
resizer: enableColumnResizing && column.getCanResize() ? /* @__PURE__ */ jsx53(
|
|
4651
|
+
"div",
|
|
4652
|
+
{
|
|
4653
|
+
role: "separator",
|
|
4654
|
+
"aria-orientation": "vertical",
|
|
4655
|
+
"aria-label": `Resize ${label}`,
|
|
4656
|
+
onMouseDown: header.getResizeHandler(),
|
|
4657
|
+
onTouchStart: header.getResizeHandler(),
|
|
4658
|
+
onClick: (event) => event.stopPropagation(),
|
|
4659
|
+
className: cn(
|
|
4660
|
+
"absolute inset-y-0 end-0 w-1 cursor-col-resize touch-none select-none hover:bg-input-accent",
|
|
4661
|
+
column.getIsResizing() && "bg-input-accent"
|
|
4662
|
+
)
|
|
4663
|
+
}
|
|
4664
|
+
) : void 0,
|
|
4665
|
+
children: header.isPlaceholder ? null : /* @__PURE__ */ jsx53(table.FlexRender, { header })
|
|
4666
|
+
},
|
|
4667
|
+
header.id
|
|
4668
|
+
);
|
|
4669
|
+
};
|
|
4670
|
+
const stickyLeading = cn(cellDensity, sticky && "sticky top-0 z-20 bg-surface");
|
|
4671
|
+
const leadingHeaderCells = (rowSpan) => /* @__PURE__ */ jsxs40(Fragment14, { children: [
|
|
4672
|
+
enableRowSelection && /* @__PURE__ */ jsx53(TableHead, { checkbox: true, rowSpan, className: stickyLeading, children: /* @__PURE__ */ jsx53(
|
|
4673
|
+
Checkbox,
|
|
4674
|
+
{
|
|
4675
|
+
"aria-label": "Select all rows",
|
|
4676
|
+
checked: allSelected ? true : someSelected ? "indeterminate" : false,
|
|
4677
|
+
disabled: loading,
|
|
4678
|
+
onCheckedChange: (checked) => table.toggleAllPageRowsSelected(Boolean(checked))
|
|
4679
|
+
}
|
|
4680
|
+
) }),
|
|
4681
|
+
hasExpander && /* @__PURE__ */ jsx53(TableHead, { checkbox: true, rowSpan, className: stickyLeading, children: /* @__PURE__ */ jsx53("span", { className: "sr-only", children: "Expand" }) }),
|
|
4682
|
+
enableRowPinning && /* @__PURE__ */ jsx53(TableHead, { checkbox: true, rowSpan, className: stickyLeading, children: /* @__PURE__ */ jsx53("span", { className: "sr-only", children: "Pin" }) })
|
|
4683
|
+
] });
|
|
4684
|
+
const rowsToRender = virtualized ? virtualItems.map((item) => ({ row: bodyRows[item.index], index: item.index })) : null;
|
|
4685
|
+
const totalRows = topRows.length + bodyRows.length + bottomRows.length;
|
|
4686
|
+
return /* @__PURE__ */ jsxs40("div", { className: cn("flex w-full flex-col gap-2", wrapperClassName), children: [
|
|
4687
|
+
showToolbar && /* @__PURE__ */ jsxs40("div", { className: "flex items-center justify-between gap-2", children: [
|
|
4688
|
+
/* @__PURE__ */ jsxs40("div", { className: "flex items-center gap-2", children: [
|
|
4689
|
+
enableGlobalFilter && /* @__PURE__ */ jsx53(
|
|
4690
|
+
SearchBar,
|
|
4691
|
+
{
|
|
4692
|
+
"aria-label": "Search table",
|
|
4693
|
+
placeholder: globalFilterPlaceholder,
|
|
4694
|
+
value: globalFilter,
|
|
4695
|
+
onChange: (event) => table.setGlobalFilter(event.target.value),
|
|
4696
|
+
onClear: () => table.setGlobalFilter(""),
|
|
4697
|
+
className: "w-64"
|
|
4698
|
+
}
|
|
4699
|
+
),
|
|
4700
|
+
toolbar
|
|
4701
|
+
] }),
|
|
4702
|
+
/* @__PURE__ */ jsxs40("div", { className: "flex items-center gap-2", children: [
|
|
4703
|
+
enableDensityToggle && /* @__PURE__ */ jsxs40(
|
|
4704
|
+
Button,
|
|
4705
|
+
{
|
|
4706
|
+
type: "button",
|
|
4707
|
+
variant: "outline",
|
|
4708
|
+
size: "sm",
|
|
4709
|
+
"aria-pressed": compact,
|
|
4710
|
+
onClick: () => setDensity(compact ? "default" : "compact"),
|
|
4711
|
+
children: [
|
|
4712
|
+
/* @__PURE__ */ jsx53(Rows, { size: 16, "aria-hidden": true }),
|
|
4713
|
+
"Compact"
|
|
4714
|
+
]
|
|
4715
|
+
}
|
|
4716
|
+
),
|
|
4717
|
+
enableGrouping && /* @__PURE__ */ jsxs40(DropdownMenu, { children: [
|
|
4718
|
+
/* @__PURE__ */ jsx53(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs40(Button, { type: "button", variant: "outline", size: "sm", children: [
|
|
4719
|
+
/* @__PURE__ */ jsx53(Stack, { size: 16, "aria-hidden": true }),
|
|
4720
|
+
"Group by"
|
|
4721
|
+
] }) }),
|
|
4722
|
+
/* @__PURE__ */ jsxs40(DropdownMenuContent, { align: "end", children: [
|
|
4723
|
+
/* @__PURE__ */ jsx53(DropdownMenuLabel, { children: "Group rows by" }),
|
|
4724
|
+
/* @__PURE__ */ jsx53(DropdownMenuSeparator, {}),
|
|
4725
|
+
groupableColumns.map((column) => /* @__PURE__ */ jsx53(
|
|
4726
|
+
DropdownMenuCheckboxItem,
|
|
4727
|
+
{
|
|
4728
|
+
checked: column.getIsGrouped(),
|
|
4729
|
+
onCheckedChange: () => column.toggleGrouping(),
|
|
4730
|
+
children: labelOf(column)
|
|
4731
|
+
},
|
|
4732
|
+
column.id
|
|
4733
|
+
))
|
|
4734
|
+
] })
|
|
4735
|
+
] }),
|
|
4736
|
+
enableColumnVisibility && /* @__PURE__ */ jsxs40(DropdownMenu, { children: [
|
|
4737
|
+
/* @__PURE__ */ jsx53(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs40(Button, { type: "button", variant: "outline", size: "sm", children: [
|
|
4738
|
+
/* @__PURE__ */ jsx53(Sliders, { size: 16, "aria-hidden": true }),
|
|
4739
|
+
"Columns"
|
|
4740
|
+
] }) }),
|
|
4741
|
+
/* @__PURE__ */ jsxs40(DropdownMenuContent, { align: "end", children: [
|
|
4742
|
+
/* @__PURE__ */ jsx53(DropdownMenuLabel, { children: "Toggle columns" }),
|
|
4743
|
+
/* @__PURE__ */ jsx53(DropdownMenuSeparator, {}),
|
|
4744
|
+
hideableColumns.map((column) => /* @__PURE__ */ jsx53(
|
|
4745
|
+
DropdownMenuCheckboxItem,
|
|
4746
|
+
{
|
|
4747
|
+
checked: column.getIsVisible(),
|
|
4748
|
+
onCheckedChange: (checked) => column.toggleVisibility(Boolean(checked)),
|
|
4749
|
+
children: labelOf(column)
|
|
4750
|
+
},
|
|
4751
|
+
column.id
|
|
4752
|
+
))
|
|
4753
|
+
] })
|
|
4754
|
+
] })
|
|
4755
|
+
] })
|
|
4756
|
+
] }),
|
|
4757
|
+
/* @__PURE__ */ jsxs40(
|
|
4758
|
+
Table,
|
|
4759
|
+
{
|
|
4760
|
+
ref,
|
|
4761
|
+
containerRef: setScrollRef,
|
|
4762
|
+
containerClassName,
|
|
4763
|
+
striped,
|
|
4764
|
+
"aria-busy": loading || loadingMore || void 0,
|
|
4765
|
+
style: sized ? { width: table.getTotalSize(), minWidth: "100%", tableLayout: "fixed", ...tableStyle } : tableStyle,
|
|
4766
|
+
onKeyDown: enableCellSelection ? onGridKeyDown : void 0,
|
|
4767
|
+
tabIndex: enableCellSelection ? 0 : void 0,
|
|
4768
|
+
...tableProps,
|
|
4769
|
+
children: [
|
|
4770
|
+
/* @__PURE__ */ jsxs40(TableHeader, { children: [
|
|
4771
|
+
headerGroups.map((group, groupIndex) => /* @__PURE__ */ jsxs40(TableRow, { className: "hover:bg-transparent", children: [
|
|
4772
|
+
groupIndex === 0 && leadingHeaderCells(headerGroups.length + (enableColumnFilters ? 1 : 0)),
|
|
4773
|
+
group.headers.map(renderHeaderCell)
|
|
4774
|
+
] }, group.id)),
|
|
4775
|
+
enableColumnFilters && /* @__PURE__ */ jsx53(TableRow, { className: "hover:bg-transparent", children: leafColumns.map((column) => {
|
|
4776
|
+
const pin = pinning(column, sized, true);
|
|
4777
|
+
return /* @__PURE__ */ jsx53(
|
|
4778
|
+
TableHead,
|
|
4779
|
+
{
|
|
4780
|
+
style: pin.style,
|
|
4781
|
+
className: cn("h-auto py-2 font-normal", pin.className, sticky && !column.getIsPinned() && "bg-surface"),
|
|
4782
|
+
children: column.getCanFilter() ? /* @__PURE__ */ jsx53(ColumnFilter, { column }) : null
|
|
4783
|
+
},
|
|
4784
|
+
column.id
|
|
4785
|
+
);
|
|
4786
|
+
}) })
|
|
4787
|
+
] }),
|
|
4788
|
+
/* @__PURE__ */ jsxs40(TableBody, { children: [
|
|
4789
|
+
loading ? Array.from({ length: pageSize }, (_, index) => skeletonRow(`loading-${index}`)) : totalRows === 0 ? /* @__PURE__ */ jsx53(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsx53(TableCell, { colSpan: columnSpan, muted: true, className: "h-24 text-center", children: emptyState ?? "No results." }) }) : /* @__PURE__ */ jsxs40(Fragment14, { children: [
|
|
4790
|
+
topRows.map((row, index) => renderRow(row, { pinned: "top", pinnedIndex: index, pinnedCount: topRows.length })),
|
|
4791
|
+
virtualized && paddingTop > 0 && /* @__PURE__ */ jsx53("tr", { "aria-hidden": true, children: /* @__PURE__ */ jsx53("td", { colSpan: columnSpan, style: { height: paddingTop } }) }),
|
|
4792
|
+
rowsToRender ? rowsToRender.map(({ row, index }) => renderRow(row, { virtualIndex: index })) : bodyRows.map((row) => renderRow(row)),
|
|
4793
|
+
virtualized && paddingBottom > 0 && /* @__PURE__ */ jsx53("tr", { "aria-hidden": true, children: /* @__PURE__ */ jsx53("td", { colSpan: columnSpan, style: { height: paddingBottom } }) }),
|
|
4794
|
+
bottomRows.map(
|
|
4795
|
+
(row, index) => renderRow(row, { pinned: "bottom", pinnedIndex: index, pinnedCount: bottomRows.length })
|
|
4796
|
+
)
|
|
4797
|
+
] }),
|
|
4798
|
+
infinite && /* @__PURE__ */ jsxs40(Fragment14, { children: [
|
|
4799
|
+
loadingMore && Array.from({ length: 3 }, (_, index) => skeletonRow(`more-${index}`)),
|
|
4800
|
+
/* @__PURE__ */ jsx53("tr", { ref: sentinelRef, "aria-hidden": true, children: /* @__PURE__ */ jsx53("td", { colSpan: columnSpan, className: "h-px p-0" }) })
|
|
4801
|
+
] })
|
|
4802
|
+
] }),
|
|
4803
|
+
showFooter && /* @__PURE__ */ jsx53(TableFooter, { children: table.getFooterGroups().map((group) => /* @__PURE__ */ jsxs40(TableRow, { className: "hover:bg-transparent", children: [
|
|
4804
|
+
leadingCount > 0 && /* @__PURE__ */ jsx53(TableCell, { colSpan: leadingCount, className: cellDensity }),
|
|
4805
|
+
group.headers.map((header) => {
|
|
4806
|
+
const { align } = getMeta(header.column.columnDef.meta);
|
|
4807
|
+
const pin = pinning(header.column, sized);
|
|
4808
|
+
return /* @__PURE__ */ jsx53(
|
|
4809
|
+
TableCell,
|
|
4810
|
+
{
|
|
4811
|
+
align,
|
|
4812
|
+
colSpan: header.colSpan > 1 ? header.colSpan : void 0,
|
|
4813
|
+
style: pin.style,
|
|
4814
|
+
className: cn("text-ui-label", pin.className, cellDensity),
|
|
4815
|
+
children: header.isPlaceholder ? null : /* @__PURE__ */ jsx53(table.FlexRender, { footer: header })
|
|
4816
|
+
},
|
|
4817
|
+
header.id
|
|
4818
|
+
);
|
|
4819
|
+
})
|
|
4820
|
+
] }, group.id)) })
|
|
4821
|
+
]
|
|
4822
|
+
}
|
|
4823
|
+
),
|
|
4824
|
+
(enableRowSelection || paginate && pageCount > 1) && /* @__PURE__ */ jsxs40("div", { className: "flex items-center justify-between gap-2", children: [
|
|
4825
|
+
/* @__PURE__ */ jsx53("span", { className: "text-body-small text-secondary-muted-foreground", "aria-live": "polite", children: enableRowSelection ? `${selectedCount} of ${table.getCoreRowModel().rows.length} row(s) selected` : null }),
|
|
4826
|
+
paginate && pageCount > 1 && /* @__PURE__ */ jsx53(
|
|
4827
|
+
Pagination,
|
|
4828
|
+
{
|
|
4829
|
+
page: pagination.pageIndex + 1,
|
|
4830
|
+
pageCount,
|
|
4831
|
+
onPageChange: (page) => table.setPageIndex(page - 1)
|
|
4832
|
+
}
|
|
4833
|
+
)
|
|
4834
|
+
] })
|
|
4835
|
+
] });
|
|
4836
|
+
}
|
|
4837
|
+
var DataTable = React52.forwardRef(DataTableInner);
|
|
4838
|
+
DataTable.displayName = "DataTable";
|
|
4839
|
+
|
|
4840
|
+
// src/components/Data Display/StatCard.tsx
|
|
4841
|
+
import * as React53 from "react";
|
|
4842
|
+
import { cva as cva6 } from "class-variance-authority";
|
|
4843
|
+
import { jsx as jsx54, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
3891
4844
|
var statCardVariants = cva6("flex min-w-0 flex-col gap-2 rounded-md border p-3", {
|
|
3892
4845
|
variants: {
|
|
3893
4846
|
variant: {
|
|
@@ -3901,26 +4854,26 @@ var statCardVariants = cva6("flex min-w-0 flex-col gap-2 rounded-md border p-3",
|
|
|
3901
4854
|
},
|
|
3902
4855
|
defaultVariants: { variant: "default" }
|
|
3903
4856
|
});
|
|
3904
|
-
var StatCard =
|
|
3905
|
-
({ className, variant, label, value, icon, caption, ...props }, ref) => /* @__PURE__ */
|
|
3906
|
-
/* @__PURE__ */
|
|
3907
|
-
/* @__PURE__ */
|
|
3908
|
-
icon && /* @__PURE__ */
|
|
4857
|
+
var StatCard = React53.forwardRef(
|
|
4858
|
+
({ className, variant, label, value, icon, caption, ...props }, ref) => /* @__PURE__ */ jsxs41("div", { ref, className: cn(statCardVariants({ variant }), className), ...props, children: [
|
|
4859
|
+
/* @__PURE__ */ jsx54("p", { className: "truncate text-ui-caption text-secondary-muted-foreground", children: label }),
|
|
4860
|
+
/* @__PURE__ */ jsxs41("p", { className: "flex items-center gap-2 text-body-base text-surface-foreground", children: [
|
|
4861
|
+
icon && /* @__PURE__ */ jsx54("span", { "aria-hidden": "true", className: "inline-flex size-6 shrink-0 items-center justify-center", children: icon }),
|
|
3909
4862
|
value
|
|
3910
4863
|
] }),
|
|
3911
|
-
caption && /* @__PURE__ */
|
|
4864
|
+
caption && /* @__PURE__ */ jsx54("p", { className: "text-ui-caption text-secondary-muted-foreground", children: caption })
|
|
3912
4865
|
] })
|
|
3913
4866
|
);
|
|
3914
4867
|
StatCard.displayName = "StatCard";
|
|
3915
4868
|
|
|
3916
4869
|
// src/components/Research-Specific/ActivityStructure.tsx
|
|
3917
|
-
import * as
|
|
4870
|
+
import * as React55 from "react";
|
|
3918
4871
|
|
|
3919
4872
|
// src/components/Tags & Badges/EditableTag.tsx
|
|
3920
|
-
import * as
|
|
4873
|
+
import * as React54 from "react";
|
|
3921
4874
|
import { Crown, Plus as Plus5, X as X6 } from "@phosphor-icons/react";
|
|
3922
4875
|
import { cva as cva7 } from "class-variance-authority";
|
|
3923
|
-
import { jsx as
|
|
4876
|
+
import { jsx as jsx55, jsxs as jsxs42 } from "react/jsx-runtime";
|
|
3924
4877
|
var editableTagVariants = cva7(
|
|
3925
4878
|
"inline-flex h-6.5 items-center whitespace-nowrap rounded-sm py-1 text-ui-caption transition-colors",
|
|
3926
4879
|
{
|
|
@@ -3935,27 +4888,27 @@ var editableTagVariants = cva7(
|
|
|
3935
4888
|
defaultVariants: { type: "default" }
|
|
3936
4889
|
}
|
|
3937
4890
|
);
|
|
3938
|
-
var EditableTag =
|
|
4891
|
+
var EditableTag = React54.forwardRef(
|
|
3939
4892
|
({ className, type = "default", icon, onRemove, onClick, children, ...props }, ref) => {
|
|
3940
4893
|
const classes = cn(editableTagVariants({ type }), className);
|
|
3941
|
-
const leading = type === "add" ? /* @__PURE__ */
|
|
4894
|
+
const leading = type === "add" ? /* @__PURE__ */ jsx55(Plus5, { size: 12, "aria-hidden": true }) : icon !== void 0 ? icon : type === "default" ? /* @__PURE__ */ jsx55(Crown, { size: 12, weight: "fill", "aria-hidden": true }) : null;
|
|
3942
4895
|
if (type === "add" || type === "multiple" && onClick) {
|
|
3943
|
-
return /* @__PURE__ */
|
|
4896
|
+
return /* @__PURE__ */ jsxs42("button", { ref, type: "button", className: classes, onClick, ...props, children: [
|
|
3944
4897
|
leading,
|
|
3945
4898
|
children
|
|
3946
4899
|
] });
|
|
3947
4900
|
}
|
|
3948
|
-
return /* @__PURE__ */
|
|
4901
|
+
return /* @__PURE__ */ jsxs42("span", { ref, className: classes, ...props, children: [
|
|
3949
4902
|
leading,
|
|
3950
4903
|
children,
|
|
3951
|
-
onRemove && /* @__PURE__ */
|
|
4904
|
+
onRemove && /* @__PURE__ */ jsx55(
|
|
3952
4905
|
"button",
|
|
3953
4906
|
{
|
|
3954
4907
|
type: "button",
|
|
3955
4908
|
"aria-label": typeof children === "string" ? `Remove ${children}` : "Remove",
|
|
3956
4909
|
onClick: onRemove,
|
|
3957
4910
|
className: "inline-flex size-3 items-center justify-center rounded-xs",
|
|
3958
|
-
children: /* @__PURE__ */
|
|
4911
|
+
children: /* @__PURE__ */ jsx55(X6, { size: 12, "aria-hidden": true })
|
|
3959
4912
|
}
|
|
3960
4913
|
)
|
|
3961
4914
|
] });
|
|
@@ -3964,26 +4917,26 @@ var EditableTag = React52.forwardRef(
|
|
|
3964
4917
|
EditableTag.displayName = "EditableTag";
|
|
3965
4918
|
|
|
3966
4919
|
// src/components/Research-Specific/ActivityStructure.tsx
|
|
3967
|
-
import { jsx as
|
|
3968
|
-
var ActivityStructure =
|
|
3969
|
-
({ className, title = "Activity Structure", stats, sections, onRemoveTag, onAddTag, addTagLabel = "Add tag", action, children, ...props }, ref) => /* @__PURE__ */
|
|
4920
|
+
import { jsx as jsx56, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
4921
|
+
var ActivityStructure = React55.forwardRef(
|
|
4922
|
+
({ className, title = "Activity Structure", stats, sections, onRemoveTag, onAddTag, addTagLabel = "Add tag", action, children, ...props }, ref) => /* @__PURE__ */ jsxs43(
|
|
3970
4923
|
"section",
|
|
3971
4924
|
{
|
|
3972
4925
|
ref,
|
|
3973
4926
|
className: cn("flex w-full max-w-96.5 flex-col gap-4 rounded-xl bg-surface p-4", className),
|
|
3974
4927
|
...props,
|
|
3975
4928
|
children: [
|
|
3976
|
-
/* @__PURE__ */
|
|
3977
|
-
/* @__PURE__ */
|
|
4929
|
+
/* @__PURE__ */ jsxs43("div", { className: "flex items-center justify-between gap-2", children: [
|
|
4930
|
+
/* @__PURE__ */ jsx56("h3", { className: "text-body-section text-surface-foreground", children: title }),
|
|
3978
4931
|
action
|
|
3979
4932
|
] }),
|
|
3980
|
-
stats.length > 0 && /* @__PURE__ */
|
|
3981
|
-
sections?.map(({ id, heading, body, tags }) => /* @__PURE__ */
|
|
3982
|
-
/* @__PURE__ */
|
|
3983
|
-
/* @__PURE__ */
|
|
3984
|
-
(tags?.length || onAddTag) && /* @__PURE__ */
|
|
3985
|
-
tags?.map((tag) => /* @__PURE__ */
|
|
3986
|
-
onAddTag && /* @__PURE__ */
|
|
4933
|
+
stats.length > 0 && /* @__PURE__ */ jsx56("div", { className: "grid grid-cols-2 gap-3", children: stats.map(({ id, ...stat }) => /* @__PURE__ */ jsx56(StatCard, { ...stat }, id)) }),
|
|
4934
|
+
sections?.map(({ id, heading, body, tags }) => /* @__PURE__ */ jsxs43("div", { className: "flex flex-col gap-2", children: [
|
|
4935
|
+
/* @__PURE__ */ jsx56("h4", { className: "text-heading-h4 text-surface-foreground", children: heading }),
|
|
4936
|
+
/* @__PURE__ */ jsx56("div", { className: "text-body-base text-surface-foreground", children: body }),
|
|
4937
|
+
(tags?.length || onAddTag) && /* @__PURE__ */ jsxs43("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
4938
|
+
tags?.map((tag) => /* @__PURE__ */ jsx56(EditableTag, { type: "editable", onRemove: onRemoveTag && (() => onRemoveTag(id, tag)), children: tag }, tag)),
|
|
4939
|
+
onAddTag && /* @__PURE__ */ jsx56(EditableTag, { type: "add", onClick: () => onAddTag(id), children: addTagLabel })
|
|
3987
4940
|
] })
|
|
3988
4941
|
] }, id)),
|
|
3989
4942
|
children
|
|
@@ -3994,10 +4947,10 @@ var ActivityStructure = React53.forwardRef(
|
|
|
3994
4947
|
ActivityStructure.displayName = "ActivityStructure";
|
|
3995
4948
|
|
|
3996
4949
|
// src/components/Tags & Badges/Badge.tsx
|
|
3997
|
-
import * as
|
|
4950
|
+
import * as React56 from "react";
|
|
3998
4951
|
import { DotsSixVertical as DotsSixVertical5, RadioButton as RadioButton2 } from "@phosphor-icons/react";
|
|
3999
4952
|
import { cva as cva8 } from "class-variance-authority";
|
|
4000
|
-
import { jsx as
|
|
4953
|
+
import { jsx as jsx57, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
4001
4954
|
var roleTagVariants = cva8(
|
|
4002
4955
|
"group inline-flex h-6 items-center whitespace-nowrap rounded-sm py-1 text-ui-caption transition-colors",
|
|
4003
4956
|
{
|
|
@@ -4023,11 +4976,11 @@ var roleTagVariants = cva8(
|
|
|
4023
4976
|
defaultVariants: { type: "primary", selected: false }
|
|
4024
4977
|
}
|
|
4025
4978
|
);
|
|
4026
|
-
var Badge =
|
|
4979
|
+
var Badge = React56.forwardRef(
|
|
4027
4980
|
({ className, type = "primary", selected = false, onClick, children, ...props }, ref) => {
|
|
4028
4981
|
const classes = cn(roleTagVariants({ type, selected: type === "interactable" ? selected : false }), className);
|
|
4029
4982
|
if (type === "interactable") {
|
|
4030
|
-
return /* @__PURE__ */
|
|
4983
|
+
return /* @__PURE__ */ jsxs44(
|
|
4031
4984
|
"button",
|
|
4032
4985
|
{
|
|
4033
4986
|
ref,
|
|
@@ -4037,100 +4990,20 @@ var Badge = React54.forwardRef(
|
|
|
4037
4990
|
onClick,
|
|
4038
4991
|
...props,
|
|
4039
4992
|
children: [
|
|
4040
|
-
/* @__PURE__ */
|
|
4993
|
+
/* @__PURE__ */ jsx57(DotsSixVertical5, { size: 16, "aria-hidden": true, className: "hidden shrink-0 group-hover:block" }),
|
|
4041
4994
|
children
|
|
4042
4995
|
]
|
|
4043
4996
|
}
|
|
4044
4997
|
);
|
|
4045
4998
|
}
|
|
4046
|
-
return /* @__PURE__ */
|
|
4047
|
-
type === "question" && /* @__PURE__ */
|
|
4048
|
-
type === "id" && /* @__PURE__ */
|
|
4999
|
+
return /* @__PURE__ */ jsxs44("span", { ref, className: classes, ...props, children: [
|
|
5000
|
+
type === "question" && /* @__PURE__ */ jsx57(RadioButton2, { size: 16, weight: "fill", "aria-hidden": true }),
|
|
5001
|
+
type === "id" && /* @__PURE__ */ jsx57("span", { className: "text-secondary-muted-foreground", children: "ID" }),
|
|
4049
5002
|
children
|
|
4050
5003
|
] });
|
|
4051
5004
|
}
|
|
4052
5005
|
);
|
|
4053
5006
|
Badge.displayName = "Badge";
|
|
4054
|
-
|
|
4055
|
-
// src/components/Utility/Pagination.tsx
|
|
4056
|
-
import * as React55 from "react";
|
|
4057
|
-
import { ArrowLeft, ArrowRight, DotsThree as DotsThree2 } from "@phosphor-icons/react";
|
|
4058
|
-
import { jsx as jsx56, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
4059
|
-
function getPaginationItems(page, pageCount, siblings = 1) {
|
|
4060
|
-
const keep = /* @__PURE__ */ new Set([1, pageCount]);
|
|
4061
|
-
for (let p = page - siblings; p <= page + siblings; p++) if (p >= 1 && p <= pageCount) keep.add(p);
|
|
4062
|
-
const sorted = [...keep].sort((a, b) => a - b);
|
|
4063
|
-
const items = [];
|
|
4064
|
-
sorted.forEach((p, index) => {
|
|
4065
|
-
const previous = sorted[index - 1];
|
|
4066
|
-
if (previous !== void 0 && p - previous === 2) items.push(previous + 1);
|
|
4067
|
-
else if (previous !== void 0 && p - previous > 2) items.push("ellipsis");
|
|
4068
|
-
items.push(p);
|
|
4069
|
-
});
|
|
4070
|
-
return items;
|
|
4071
|
-
}
|
|
4072
|
-
var Pagination = React55.forwardRef(
|
|
4073
|
-
({ className, page, pageCount, onPageChange, variant = "full", siblings = 1, ...props }, ref) => {
|
|
4074
|
-
const go = (next2) => onPageChange(Math.min(pageCount, Math.max(1, next2)));
|
|
4075
|
-
const previous = /* @__PURE__ */ jsx56(
|
|
4076
|
-
Button,
|
|
4077
|
-
{
|
|
4078
|
-
type: "button",
|
|
4079
|
-
variant: "outline",
|
|
4080
|
-
size: "icon-sm",
|
|
4081
|
-
"aria-label": "Previous page",
|
|
4082
|
-
disabled: page <= 1,
|
|
4083
|
-
onClick: () => go(page - 1),
|
|
4084
|
-
children: /* @__PURE__ */ jsx56(ArrowLeft, { size: 16, "aria-hidden": true })
|
|
4085
|
-
}
|
|
4086
|
-
);
|
|
4087
|
-
const next = /* @__PURE__ */ jsx56(
|
|
4088
|
-
Button,
|
|
4089
|
-
{
|
|
4090
|
-
type: "button",
|
|
4091
|
-
variant: "outline",
|
|
4092
|
-
size: "icon-sm",
|
|
4093
|
-
"aria-label": "Next page",
|
|
4094
|
-
disabled: page >= pageCount,
|
|
4095
|
-
onClick: () => go(page + 1),
|
|
4096
|
-
children: /* @__PURE__ */ jsx56(ArrowRight, { size: 16, "aria-hidden": true })
|
|
4097
|
-
}
|
|
4098
|
-
);
|
|
4099
|
-
return /* @__PURE__ */ jsxs43(
|
|
4100
|
-
"nav",
|
|
4101
|
-
{
|
|
4102
|
-
ref,
|
|
4103
|
-
"aria-label": "Pagination",
|
|
4104
|
-
className: cn("flex items-center", variant === "compact" ? "w-35 justify-between" : "gap-2", className),
|
|
4105
|
-
...props,
|
|
4106
|
-
children: [
|
|
4107
|
-
previous,
|
|
4108
|
-
variant === "compact" ? /* @__PURE__ */ jsxs43("span", { className: "text-body-small text-surface-foreground", "aria-live": "polite", children: [
|
|
4109
|
-
page,
|
|
4110
|
-
"/",
|
|
4111
|
-
pageCount
|
|
4112
|
-
] }) : /* @__PURE__ */ jsx56("ul", { className: "flex items-center gap-2", children: getPaginationItems(page, pageCount, siblings).map((item, index) => /* @__PURE__ */ jsx56("li", { children: item === "ellipsis" ? /* @__PURE__ */ jsxs43("span", { className: "inline-flex size-8 items-center justify-center rounded-sm border border-border bg-surface text-surface-foreground", children: [
|
|
4113
|
-
/* @__PURE__ */ jsx56(DotsThree2, { size: 16, "aria-hidden": true }),
|
|
4114
|
-
/* @__PURE__ */ jsx56("span", { className: "sr-only", children: "More pages" })
|
|
4115
|
-
] }) : /* @__PURE__ */ jsx56(
|
|
4116
|
-
Button,
|
|
4117
|
-
{
|
|
4118
|
-
type: "button",
|
|
4119
|
-
variant: item === page ? "subtle" : "outline",
|
|
4120
|
-
size: "sm",
|
|
4121
|
-
"aria-label": `Page ${item}`,
|
|
4122
|
-
"aria-current": item === page ? "page" : void 0,
|
|
4123
|
-
onClick: () => go(item),
|
|
4124
|
-
children: item
|
|
4125
|
-
}
|
|
4126
|
-
) }, item === "ellipsis" ? `ellipsis-${index}` : item)) }),
|
|
4127
|
-
next
|
|
4128
|
-
]
|
|
4129
|
-
}
|
|
4130
|
-
);
|
|
4131
|
-
}
|
|
4132
|
-
);
|
|
4133
|
-
Pagination.displayName = "Pagination";
|
|
4134
5007
|
export {
|
|
4135
5008
|
AIMiniAvatar,
|
|
4136
5009
|
AIResponseContainer,
|
|
@@ -4145,6 +5018,7 @@ export {
|
|
|
4145
5018
|
ChatOption,
|
|
4146
5019
|
Checkbox,
|
|
4147
5020
|
CheckboxField,
|
|
5021
|
+
DataTable,
|
|
4148
5022
|
DatePicker,
|
|
4149
5023
|
DateTimePicker,
|
|
4150
5024
|
Dialog,
|
|
@@ -4225,6 +5099,7 @@ export {
|
|
|
4225
5099
|
TableBody,
|
|
4226
5100
|
TableCell,
|
|
4227
5101
|
TableCellTwoLines,
|
|
5102
|
+
TableFooter,
|
|
4228
5103
|
TableHead,
|
|
4229
5104
|
TableHeader,
|
|
4230
5105
|
TableRow,
|