@discuss-ds/ui 0.33.0 → 0.35.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 +14 -0
- package/dist/index.cjs +980 -148
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +240 -7
- package/dist/index.d.ts +240 -7
- package/dist/index.js +1026 -149
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
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");
|
|
@@ -1835,6 +1840,7 @@ var InlineEdit = React25.forwardRef(
|
|
|
1835
1840
|
const [draft, setDraft] = React25.useState(value);
|
|
1836
1841
|
const [error, setError] = React25.useState(null);
|
|
1837
1842
|
const errorId = React25.useId();
|
|
1843
|
+
const limitsVisible = !!showLimits && (!!error || lengthOutOfRange(draft, minLength, maxLength));
|
|
1838
1844
|
const fieldRef = React25.useRef(null);
|
|
1839
1845
|
const [scroll, setScroll] = React25.useState(0);
|
|
1840
1846
|
const [draftMarks, setDraftMarks] = React25.useState([]);
|
|
@@ -1891,7 +1897,7 @@ var InlineEdit = React25.forwardRef(
|
|
|
1891
1897
|
"div",
|
|
1892
1898
|
{
|
|
1893
1899
|
ref,
|
|
1894
|
-
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),
|
|
1895
1901
|
...props,
|
|
1896
1902
|
children: editing ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
1897
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: [
|
|
@@ -1912,7 +1918,7 @@ var InlineEdit = React25.forwardRef(
|
|
|
1912
1918
|
maxLength,
|
|
1913
1919
|
"aria-label": ariaLabel,
|
|
1914
1920
|
"aria-invalid": error ? true : void 0,
|
|
1915
|
-
"aria-describedby": error ||
|
|
1921
|
+
"aria-describedby": error || limitsVisible ? errorId : void 0,
|
|
1916
1922
|
...multiline ? { rows: 1 } : { type: "text" },
|
|
1917
1923
|
className: cn(
|
|
1918
1924
|
"relative w-full px-3 py-1 outline-none",
|
|
@@ -1956,7 +1962,7 @@ var InlineEdit = React25.forwardRef(
|
|
|
1956
1962
|
}
|
|
1957
1963
|
)
|
|
1958
1964
|
] }),
|
|
1959
|
-
(error ||
|
|
1965
|
+
(error || limitsVisible) && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
1960
1966
|
"p",
|
|
1961
1967
|
{
|
|
1962
1968
|
id: errorId,
|
|
@@ -1965,10 +1971,10 @@ var InlineEdit = React25.forwardRef(
|
|
|
1965
1971
|
children: [
|
|
1966
1972
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("span", { className: "flex items-start gap-2", children: [
|
|
1967
1973
|
error && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_react12.WarningCircle, { size: 16, "aria-hidden": true, className: "shrink-0" }),
|
|
1968
|
-
|
|
1969
|
-
|
|
1974
|
+
limitsVisible ? limitsText(minLength, maxLength) : error,
|
|
1975
|
+
limitsVisible && error && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "sr-only", children: error })
|
|
1970
1976
|
] }),
|
|
1971
|
-
|
|
1977
|
+
limitsVisible && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("span", { "aria-hidden": true, className: "shrink-0 tabular-nums", children: [
|
|
1972
1978
|
draft.length,
|
|
1973
1979
|
maxLength !== void 0 && `/${maxLength}`
|
|
1974
1980
|
] })
|
|
@@ -3169,7 +3175,7 @@ var QuestionHeader = React42.forwardRef(
|
|
|
3169
3175
|
}
|
|
3170
3176
|
),
|
|
3171
3177
|
long && titleRecommendedNote != null && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { className: "text-ui-caption text-secondary-muted-foreground", children: titleRecommendedNote }),
|
|
3172
|
-
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: [
|
|
3173
3179
|
count,
|
|
3174
3180
|
"/",
|
|
3175
3181
|
maxLength,
|
|
@@ -3367,8 +3373,9 @@ var import_react23 = require("@phosphor-icons/react");
|
|
|
3367
3373
|
var import_radix_ui22 = require("radix-ui");
|
|
3368
3374
|
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
3369
3375
|
var QuestionNavItem = React44.forwardRef(
|
|
3370
|
-
({ className, questionType = "select-one", selected, error, asChild, showDragHandle = true, hovered, children, ...props }, ref) => {
|
|
3376
|
+
({ className, questionType = "select-one", selected, error, warning, asChild, showDragHandle = true, hovered, children, ...props }, ref) => {
|
|
3371
3377
|
const Comp = asChild ? import_radix_ui22.Slot.Root : "button";
|
|
3378
|
+
const warn = !error && !!warning;
|
|
3372
3379
|
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
3373
3380
|
Comp,
|
|
3374
3381
|
{
|
|
@@ -3378,19 +3385,19 @@ var QuestionNavItem = React44.forwardRef(
|
|
|
3378
3385
|
"data-hovered": hovered ? "" : void 0,
|
|
3379
3386
|
className: cn(
|
|
3380
3387
|
"group/nav flex h-9.5 w-full max-w-106.5 items-center gap-2 rounded-sm border bg-surface p-2 text-left text-body-small text-surface-foreground transition-colors focus-visible:outline-none",
|
|
3381
|
-
error ? ["hover:bg-destructive-soft focus-visible:border-destructive", selected ? "border-destructive" : "border-border"] : [
|
|
3388
|
+
error ? ["hover:bg-destructive-soft focus-visible:border-destructive", selected ? "border-destructive" : "border-border"] : warn ? ["hover:bg-warning-soft focus-visible:border-warning-foreground", selected ? "border-warning-foreground" : "border-border"] : [
|
|
3382
3389
|
// Hover only changes the fill; the border stays as it is (default grey, or accent when selected).
|
|
3383
3390
|
"hover:bg-accent-soft focus-visible:border-input-accent",
|
|
3384
3391
|
selected ? "border-input-accent" : "border-border"
|
|
3385
3392
|
],
|
|
3386
|
-
hovered && (error ? "bg-destructive-soft" : "bg-accent-soft"),
|
|
3393
|
+
hovered && (error ? "bg-destructive-soft" : warn ? "bg-warning-soft" : "bg-accent-soft"),
|
|
3387
3394
|
className
|
|
3388
3395
|
),
|
|
3389
3396
|
...props,
|
|
3390
3397
|
children: [
|
|
3391
3398
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { "aria-hidden": "true", className: "relative flex size-4 shrink-0 items-center justify-center", children: [
|
|
3392
3399
|
showDragHandle && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_react23.DotsSixVertical, { size: 16, className: "hidden group-hover/nav:block group-data-[hovered]/nav:block" }),
|
|
3393
|
-
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: showDragHandle ? "group-hover/nav:hidden group-data-[hovered]/nav:hidden" : void 0, children: error ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_react23.
|
|
3400
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: showDragHandle ? "group-hover/nav:hidden group-data-[hovered]/nav:hidden" : void 0, children: error ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_react23.WarningCircle, { size: 16, className: "text-destructive-foreground" }) : warn ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_react23.Warning, { size: 16, className: "text-warning-foreground" }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
3394
3401
|
QuestionTypeIcon,
|
|
3395
3402
|
{
|
|
3396
3403
|
type: questionType,
|
|
@@ -3400,7 +3407,8 @@ var QuestionNavItem = React44.forwardRef(
|
|
|
3400
3407
|
) })
|
|
3401
3408
|
] }),
|
|
3402
3409
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "min-w-0 flex-1 truncate", children }),
|
|
3403
|
-
error && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "sr-only", children: ", has errors" })
|
|
3410
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "sr-only", children: ", has errors" }),
|
|
3411
|
+
warn && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "sr-only", children: ", has warnings" })
|
|
3404
3412
|
]
|
|
3405
3413
|
}
|
|
3406
3414
|
);
|
|
@@ -3613,7 +3621,7 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
|
|
|
3613
3621
|
(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)
|
|
3614
3622
|
) })
|
|
3615
3623
|
] }),
|
|
3616
|
-
guarded && draft !== null && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
3624
|
+
guarded && draft !== null && (error || lengthOutOfRange(draft, minLength, maxLength)) && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
3617
3625
|
"p",
|
|
3618
3626
|
{
|
|
3619
3627
|
id: helperId,
|
|
@@ -3871,7 +3879,7 @@ var StimulusCard = React48.forwardRef(
|
|
|
3871
3879
|
textClassName: "text-body-base"
|
|
3872
3880
|
}
|
|
3873
3881
|
) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { className: "w-full text-body-base [word-break:break-word]", children: caption }),
|
|
3874
|
-
onCaptionChange && showCounter && maxLength !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
|
|
3882
|
+
onCaptionChange && showCounter && maxLength !== void 0 && count > maxLength && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
|
|
3875
3883
|
count,
|
|
3876
3884
|
"/",
|
|
3877
3885
|
maxLength,
|
|
@@ -3931,7 +3939,7 @@ var React50 = __toESM(require("react"), 1);
|
|
|
3931
3939
|
var import_react27 = require("@phosphor-icons/react");
|
|
3932
3940
|
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
3933
3941
|
var Table = React50.forwardRef(
|
|
3934
|
-
({ 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)(
|
|
3942
|
+
({ 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)(
|
|
3935
3943
|
"table",
|
|
3936
3944
|
{
|
|
3937
3945
|
ref,
|
|
@@ -3946,6 +3954,10 @@ var TableHeader = React50.forwardRef(
|
|
|
3946
3954
|
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("thead", { ref, className, ...props })
|
|
3947
3955
|
);
|
|
3948
3956
|
TableHeader.displayName = "TableHeader";
|
|
3957
|
+
var TableFooter = React50.forwardRef(
|
|
3958
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("tfoot", { ref, className: cn("border-t border-border bg-background text-ui-label", className), ...props })
|
|
3959
|
+
);
|
|
3960
|
+
TableFooter.displayName = "TableFooter";
|
|
3949
3961
|
var TableBody = React50.forwardRef(
|
|
3950
3962
|
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("tbody", { ref, className, ...props })
|
|
3951
3963
|
);
|
|
@@ -3969,9 +3981,9 @@ var TableRow = React50.forwardRef(
|
|
|
3969
3981
|
TableRow.displayName = "TableRow";
|
|
3970
3982
|
var ariaSort = { none: "none", asc: "ascending", desc: "descending" };
|
|
3971
3983
|
var TableHead = React50.forwardRef(
|
|
3972
|
-
({ className, align = "left", sortable, sort = "none", onSort, checkbox, children, ...props }, ref) => {
|
|
3984
|
+
({ className, align = "left", sortable, sort = "none", onSort, checkbox, resizer, children, ...props }, ref) => {
|
|
3973
3985
|
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" });
|
|
3974
|
-
return /* @__PURE__ */ (0, import_jsx_runtime51.
|
|
3986
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
3975
3987
|
"th",
|
|
3976
3988
|
{
|
|
3977
3989
|
ref,
|
|
@@ -3981,21 +3993,25 @@ var TableHead = React50.forwardRef(
|
|
|
3981
3993
|
"h-10 border-b border-border text-ui-label whitespace-nowrap",
|
|
3982
3994
|
checkbox ? "w-13 px-0 text-center" : "px-4 py-3",
|
|
3983
3995
|
align === "right" ? "text-right" : "text-left",
|
|
3996
|
+
resizer && "relative",
|
|
3984
3997
|
className
|
|
3985
3998
|
),
|
|
3986
3999
|
...props,
|
|
3987
|
-
children:
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
children
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
4000
|
+
children: [
|
|
4001
|
+
sortable ? /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
4002
|
+
"button",
|
|
4003
|
+
{
|
|
4004
|
+
type: "button",
|
|
4005
|
+
onClick: onSort,
|
|
4006
|
+
className: cn("inline-flex items-center gap-1 rounded-xs", align === "right" && "flex-row-reverse"),
|
|
4007
|
+
children: [
|
|
4008
|
+
children,
|
|
4009
|
+
caret
|
|
4010
|
+
]
|
|
4011
|
+
}
|
|
4012
|
+
) : checkbox ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "flex items-center justify-center", children }) : children,
|
|
4013
|
+
resizer
|
|
4014
|
+
]
|
|
3999
4015
|
}
|
|
4000
4016
|
);
|
|
4001
4017
|
}
|
|
@@ -4030,10 +4046,904 @@ function TableCellTwoLines({ primary, secondary, avatar, className, ...props })
|
|
|
4030
4046
|
] });
|
|
4031
4047
|
}
|
|
4032
4048
|
|
|
4033
|
-
// src/components/Data Display/
|
|
4049
|
+
// src/components/Data Display/DataTable.tsx
|
|
4050
|
+
var React52 = __toESM(require("react"), 1);
|
|
4051
|
+
var import_react29 = require("@phosphor-icons/react");
|
|
4052
|
+
var import_react_table = require("@tanstack/react-table");
|
|
4053
|
+
var import_react_virtual = require("@tanstack/react-virtual");
|
|
4054
|
+
|
|
4055
|
+
// src/components/Utility/Pagination.tsx
|
|
4034
4056
|
var React51 = __toESM(require("react"), 1);
|
|
4035
|
-
var
|
|
4057
|
+
var import_react28 = require("@phosphor-icons/react");
|
|
4036
4058
|
var import_jsx_runtime52 = require("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 = React51.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__ */ (0, import_jsx_runtime52.jsx)(
|
|
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__ */ (0, import_jsx_runtime52.jsx)(import_react28.ArrowLeft, { size: 16, "aria-hidden": true })
|
|
4085
|
+
}
|
|
4086
|
+
);
|
|
4087
|
+
const next = /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
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__ */ (0, import_jsx_runtime52.jsx)(import_react28.ArrowRight, { size: 16, "aria-hidden": true })
|
|
4097
|
+
}
|
|
4098
|
+
);
|
|
4099
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
|
|
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__ */ (0, import_jsx_runtime52.jsxs)("span", { className: "text-body-small text-surface-foreground", "aria-live": "polite", children: [
|
|
4109
|
+
page,
|
|
4110
|
+
"/",
|
|
4111
|
+
pageCount
|
|
4112
|
+
] }) : /* @__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: [
|
|
4113
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_react28.DotsThree, { size: 16, "aria-hidden": true }),
|
|
4114
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "sr-only", children: "More pages" })
|
|
4115
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
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
|
+
|
|
4135
|
+
// src/components/Data Display/DataTable.tsx
|
|
4136
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
4137
|
+
var features = (0, import_react_table.tableFeatures)({
|
|
4138
|
+
rowSortingFeature: import_react_table.rowSortingFeature,
|
|
4139
|
+
rowPaginationFeature: import_react_table.rowPaginationFeature,
|
|
4140
|
+
rowSelectionFeature: import_react_table.rowSelectionFeature,
|
|
4141
|
+
rowExpandingFeature: import_react_table.rowExpandingFeature,
|
|
4142
|
+
rowPinningFeature: import_react_table.rowPinningFeature,
|
|
4143
|
+
rowAggregationFeature: import_react_table.rowAggregationFeature,
|
|
4144
|
+
columnVisibilityFeature: import_react_table.columnVisibilityFeature,
|
|
4145
|
+
columnOrderingFeature: import_react_table.columnOrderingFeature,
|
|
4146
|
+
columnPinningFeature: import_react_table.columnPinningFeature,
|
|
4147
|
+
columnSizingFeature: import_react_table.columnSizingFeature,
|
|
4148
|
+
columnResizingFeature: import_react_table.columnResizingFeature,
|
|
4149
|
+
columnFilteringFeature: import_react_table.columnFilteringFeature,
|
|
4150
|
+
globalFilteringFeature: import_react_table.globalFilteringFeature,
|
|
4151
|
+
columnFacetingFeature: import_react_table.columnFacetingFeature,
|
|
4152
|
+
columnGroupingFeature: import_react_table.columnGroupingFeature,
|
|
4153
|
+
cellSelectionFeature: import_react_table.cellSelectionFeature,
|
|
4154
|
+
cellSpanningFeature: import_react_table.cellSpanningFeature,
|
|
4155
|
+
// Row-model pipeline order: filter → group → sort → expand → paginate.
|
|
4156
|
+
facetedRowModel: (0, import_react_table.createFacetedRowModel)(),
|
|
4157
|
+
facetedUniqueValues: (0, import_react_table.createFacetedUniqueValues)(),
|
|
4158
|
+
facetedMinMaxValues: (0, import_react_table.createFacetedMinMaxValues)(),
|
|
4159
|
+
filteredRowModel: (0, import_react_table.createFilteredRowModel)(),
|
|
4160
|
+
groupedRowModel: (0, import_react_table.createGroupedRowModel)(),
|
|
4161
|
+
sortedRowModel: (0, import_react_table.createSortedRowModel)(),
|
|
4162
|
+
expandedRowModel: (0, import_react_table.createExpandedRowModel)(),
|
|
4163
|
+
paginatedRowModel: (0, import_react_table.createPaginatedRowModel)(),
|
|
4164
|
+
sortFns: {
|
|
4165
|
+
alphanumeric: import_react_table.sortFn_alphanumeric,
|
|
4166
|
+
basic: import_react_table.sortFn_basic,
|
|
4167
|
+
datetime: import_react_table.sortFn_datetime,
|
|
4168
|
+
text: import_react_table.sortFn_text
|
|
4169
|
+
},
|
|
4170
|
+
filterFns: {
|
|
4171
|
+
arrIncludesSome: import_react_table.filterFn_arrIncludesSome,
|
|
4172
|
+
equals: import_react_table.filterFn_equals,
|
|
4173
|
+
equalsString: import_react_table.filterFn_equalsString,
|
|
4174
|
+
includesString: import_react_table.filterFn_includesString,
|
|
4175
|
+
inNumberRange: import_react_table.filterFn_inNumberRange
|
|
4176
|
+
},
|
|
4177
|
+
aggregationFns: {
|
|
4178
|
+
count: import_react_table.aggregationFn_count,
|
|
4179
|
+
extent: import_react_table.aggregationFn_extent,
|
|
4180
|
+
max: import_react_table.aggregationFn_max,
|
|
4181
|
+
mean: import_react_table.aggregationFn_mean,
|
|
4182
|
+
median: import_react_table.aggregationFn_median,
|
|
4183
|
+
min: import_react_table.aggregationFn_min,
|
|
4184
|
+
sum: import_react_table.aggregationFn_sum,
|
|
4185
|
+
unique: import_react_table.aggregationFn_unique,
|
|
4186
|
+
uniqueCount: import_react_table.aggregationFn_uniqueCount
|
|
4187
|
+
}
|
|
4188
|
+
});
|
|
4189
|
+
var getMeta = (meta) => meta ?? {};
|
|
4190
|
+
function useControllable(value, initial, onChange) {
|
|
4191
|
+
const [internal, setInternal] = React52.useState(initial);
|
|
4192
|
+
const current = value ?? internal;
|
|
4193
|
+
const update = React52.useCallback(
|
|
4194
|
+
(updater) => {
|
|
4195
|
+
const next = typeof updater === "function" ? updater(current) : updater;
|
|
4196
|
+
if (value === void 0) setInternal(next);
|
|
4197
|
+
onChange?.(next);
|
|
4198
|
+
},
|
|
4199
|
+
[current, value, onChange]
|
|
4200
|
+
);
|
|
4201
|
+
return [current, update];
|
|
4202
|
+
}
|
|
4203
|
+
var ALL = "__all__";
|
|
4204
|
+
var labelOf = (column) => getMeta(column.columnDef.meta).label ?? (typeof column.columnDef.header === "string" ? column.columnDef.header : column.id);
|
|
4205
|
+
function pinning(column, sized, header = false) {
|
|
4206
|
+
const side = column.getIsPinned();
|
|
4207
|
+
const style = {};
|
|
4208
|
+
if (sized) {
|
|
4209
|
+
style.width = column.getSize();
|
|
4210
|
+
style.minWidth = column.getSize();
|
|
4211
|
+
style.maxWidth = column.getSize();
|
|
4212
|
+
}
|
|
4213
|
+
if (side) {
|
|
4214
|
+
style.position = "sticky";
|
|
4215
|
+
if (side === "start") style.insetInlineStart = column.getStart("start");
|
|
4216
|
+
else style.insetInlineEnd = column.getAfter("end");
|
|
4217
|
+
}
|
|
4218
|
+
const className = side ? cn(
|
|
4219
|
+
header ? "z-30" : "z-10",
|
|
4220
|
+
"bg-surface",
|
|
4221
|
+
side === "start" && column.getIsLastColumn("start") && "border-r border-border",
|
|
4222
|
+
side === "end" && column.getIsFirstColumn("end") && "border-l border-border"
|
|
4223
|
+
) : void 0;
|
|
4224
|
+
return { style, className };
|
|
4225
|
+
}
|
|
4226
|
+
function ColumnFilter({ column }) {
|
|
4227
|
+
const variant = getMeta(column.columnDef.meta).filterVariant ?? "text";
|
|
4228
|
+
const label = labelOf(column);
|
|
4229
|
+
const value = column.getFilterValue();
|
|
4230
|
+
if (variant === "select") {
|
|
4231
|
+
const options = [...column.getFacetedUniqueValues().entries()].sort((a, b) => String(a[0]).localeCompare(String(b[0])));
|
|
4232
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
4233
|
+
Select,
|
|
4234
|
+
{
|
|
4235
|
+
value: typeof value === "string" ? value : ALL,
|
|
4236
|
+
onValueChange: (next) => column.setFilterValue(next === ALL ? void 0 : next),
|
|
4237
|
+
children: [
|
|
4238
|
+
/* @__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, {}) }),
|
|
4239
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(SelectContent, { children: [
|
|
4240
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(SelectItem, { value: ALL, children: "All" }),
|
|
4241
|
+
options.map(([option, count]) => /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(SelectItem, { value: String(option), children: [
|
|
4242
|
+
String(option),
|
|
4243
|
+
" (",
|
|
4244
|
+
count,
|
|
4245
|
+
")"
|
|
4246
|
+
] }, String(option)))
|
|
4247
|
+
] })
|
|
4248
|
+
]
|
|
4249
|
+
}
|
|
4250
|
+
);
|
|
4251
|
+
}
|
|
4252
|
+
if (variant === "range") {
|
|
4253
|
+
const [min, max] = column.getFacetedMinMaxValues() ?? [];
|
|
4254
|
+
const range = Array.isArray(value) ? value : [];
|
|
4255
|
+
const update = (index, raw) => {
|
|
4256
|
+
const next = [range[0], range[1]];
|
|
4257
|
+
next[index] = raw === "" ? void 0 : Number(raw);
|
|
4258
|
+
column.setFilterValue(next[0] === void 0 && next[1] === void 0 ? void 0 : next);
|
|
4259
|
+
};
|
|
4260
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex gap-1", children: [
|
|
4261
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4262
|
+
Input,
|
|
4263
|
+
{
|
|
4264
|
+
type: "number",
|
|
4265
|
+
"aria-label": `${label} minimum`,
|
|
4266
|
+
placeholder: min !== void 0 ? String(min) : "Min",
|
|
4267
|
+
value: range[0] ?? "",
|
|
4268
|
+
onChange: (event) => update(0, event.target.value),
|
|
4269
|
+
className: "h-8 text-body-small"
|
|
4270
|
+
}
|
|
4271
|
+
),
|
|
4272
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4273
|
+
Input,
|
|
4274
|
+
{
|
|
4275
|
+
type: "number",
|
|
4276
|
+
"aria-label": `${label} maximum`,
|
|
4277
|
+
placeholder: max !== void 0 ? String(max) : "Max",
|
|
4278
|
+
value: range[1] ?? "",
|
|
4279
|
+
onChange: (event) => update(1, event.target.value),
|
|
4280
|
+
className: "h-8 text-body-small"
|
|
4281
|
+
}
|
|
4282
|
+
)
|
|
4283
|
+
] });
|
|
4284
|
+
}
|
|
4285
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4286
|
+
Input,
|
|
4287
|
+
{
|
|
4288
|
+
"aria-label": `Filter ${label}`,
|
|
4289
|
+
placeholder: "Filter\u2026",
|
|
4290
|
+
value: typeof value === "string" ? value : "",
|
|
4291
|
+
onChange: (event) => column.setFilterValue(event.target.value || void 0),
|
|
4292
|
+
className: "h-8 text-body-small"
|
|
4293
|
+
}
|
|
4294
|
+
);
|
|
4295
|
+
}
|
|
4296
|
+
function EditableCell({ value, label, type, onCommit }) {
|
|
4297
|
+
const initial = value == null ? "" : String(value);
|
|
4298
|
+
const [draft, setDraft] = React52.useState(null);
|
|
4299
|
+
const cancelled = React52.useRef(false);
|
|
4300
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4301
|
+
Input,
|
|
4302
|
+
{
|
|
4303
|
+
type,
|
|
4304
|
+
"aria-label": label,
|
|
4305
|
+
value: draft ?? initial,
|
|
4306
|
+
onChange: (event) => setDraft(event.target.value),
|
|
4307
|
+
onBlur: () => {
|
|
4308
|
+
if (!cancelled.current && draft !== null && draft !== initial) onCommit(draft);
|
|
4309
|
+
cancelled.current = false;
|
|
4310
|
+
setDraft(null);
|
|
4311
|
+
},
|
|
4312
|
+
onKeyDown: (event) => {
|
|
4313
|
+
if (event.key === "Enter") event.currentTarget.blur();
|
|
4314
|
+
if (event.key === "Escape") {
|
|
4315
|
+
cancelled.current = true;
|
|
4316
|
+
event.currentTarget.blur();
|
|
4317
|
+
}
|
|
4318
|
+
},
|
|
4319
|
+
className: cn("h-8 border-transparent bg-transparent text-body-small", type === "number" && "text-right")
|
|
4320
|
+
}
|
|
4321
|
+
);
|
|
4322
|
+
}
|
|
4323
|
+
function DataTableInner({
|
|
4324
|
+
columns,
|
|
4325
|
+
data,
|
|
4326
|
+
getRowId,
|
|
4327
|
+
initialState,
|
|
4328
|
+
enableSorting = false,
|
|
4329
|
+
enableRowSelection = false,
|
|
4330
|
+
enableColumnVisibility = false,
|
|
4331
|
+
enableColumnPinning = false,
|
|
4332
|
+
enableColumnSizing = false,
|
|
4333
|
+
enableColumnResizing = false,
|
|
4334
|
+
columnResizeMode = "onChange",
|
|
4335
|
+
enableColumnOrdering = false,
|
|
4336
|
+
enableColumnFilters = false,
|
|
4337
|
+
enableGlobalFilter = false,
|
|
4338
|
+
globalFilterPlaceholder = "Search",
|
|
4339
|
+
enableGrouping = false,
|
|
4340
|
+
enableExpanding = false,
|
|
4341
|
+
enableRowPinning = false,
|
|
4342
|
+
enableCellSelection = false,
|
|
4343
|
+
showFooter = false,
|
|
4344
|
+
enableDensityToggle = false,
|
|
4345
|
+
density: densityProp,
|
|
4346
|
+
onDensityChange,
|
|
4347
|
+
getSubRows,
|
|
4348
|
+
getRowCanExpand,
|
|
4349
|
+
renderSubComponent,
|
|
4350
|
+
pageSize = 10,
|
|
4351
|
+
serverSide = false,
|
|
4352
|
+
rowCount,
|
|
4353
|
+
sorting: sortingProp,
|
|
4354
|
+
onSortingChange,
|
|
4355
|
+
rowSelection: rowSelectionProp,
|
|
4356
|
+
onRowSelectionChange,
|
|
4357
|
+
pagination: paginationProp,
|
|
4358
|
+
onPaginationChange,
|
|
4359
|
+
columnVisibility: columnVisibilityProp,
|
|
4360
|
+
onColumnVisibilityChange,
|
|
4361
|
+
columnPinning: columnPinningProp,
|
|
4362
|
+
onColumnPinningChange,
|
|
4363
|
+
columnOrder: columnOrderProp,
|
|
4364
|
+
onColumnOrderChange,
|
|
4365
|
+
columnFilters: columnFiltersProp,
|
|
4366
|
+
onColumnFiltersChange,
|
|
4367
|
+
globalFilter: globalFilterProp,
|
|
4368
|
+
onGlobalFilterChange,
|
|
4369
|
+
grouping: groupingProp,
|
|
4370
|
+
onGroupingChange,
|
|
4371
|
+
expanded: expandedProp,
|
|
4372
|
+
onExpandedChange,
|
|
4373
|
+
rowPinning: rowPinningProp,
|
|
4374
|
+
onRowPinningChange,
|
|
4375
|
+
onCellSelectionChange,
|
|
4376
|
+
onCellEdit,
|
|
4377
|
+
virtualized = false,
|
|
4378
|
+
estimateRowHeight = 40,
|
|
4379
|
+
onLoadMore,
|
|
4380
|
+
hasMore = false,
|
|
4381
|
+
loadingMore = false,
|
|
4382
|
+
stickyHeader,
|
|
4383
|
+
loading = false,
|
|
4384
|
+
emptyState,
|
|
4385
|
+
onRowClick,
|
|
4386
|
+
toolbar,
|
|
4387
|
+
wrapperClassName,
|
|
4388
|
+
striped,
|
|
4389
|
+
containerClassName,
|
|
4390
|
+
containerRef,
|
|
4391
|
+
style: tableStyle,
|
|
4392
|
+
...tableProps
|
|
4393
|
+
}, ref) {
|
|
4394
|
+
const [sorting, setSorting] = useControllable(sortingProp, initialState?.sorting ?? [], onSortingChange);
|
|
4395
|
+
const [rowSelection, setRowSelection] = useControllable(
|
|
4396
|
+
rowSelectionProp,
|
|
4397
|
+
initialState?.rowSelection ?? {},
|
|
4398
|
+
onRowSelectionChange
|
|
4399
|
+
);
|
|
4400
|
+
const [columnVisibility, setColumnVisibility] = useControllable(
|
|
4401
|
+
columnVisibilityProp,
|
|
4402
|
+
initialState?.columnVisibility ?? {},
|
|
4403
|
+
onColumnVisibilityChange
|
|
4404
|
+
);
|
|
4405
|
+
const [columnPinning, setColumnPinning] = useControllable(
|
|
4406
|
+
columnPinningProp,
|
|
4407
|
+
{ start: initialState?.columnPinning?.start ?? [], end: initialState?.columnPinning?.end ?? [] },
|
|
4408
|
+
onColumnPinningChange
|
|
4409
|
+
);
|
|
4410
|
+
const [columnOrder, setColumnOrder] = useControllable(
|
|
4411
|
+
columnOrderProp,
|
|
4412
|
+
initialState?.columnOrder ?? [],
|
|
4413
|
+
onColumnOrderChange
|
|
4414
|
+
);
|
|
4415
|
+
const [columnFilters, setColumnFilters] = useControllable(
|
|
4416
|
+
columnFiltersProp,
|
|
4417
|
+
initialState?.columnFilters ?? [],
|
|
4418
|
+
onColumnFiltersChange
|
|
4419
|
+
);
|
|
4420
|
+
const [globalFilter, setGlobalFilter] = useControllable(
|
|
4421
|
+
globalFilterProp,
|
|
4422
|
+
initialState?.globalFilter ?? "",
|
|
4423
|
+
onGlobalFilterChange
|
|
4424
|
+
);
|
|
4425
|
+
const [grouping, setGrouping] = useControllable(groupingProp, initialState?.grouping ?? [], onGroupingChange);
|
|
4426
|
+
const [expanded, setExpanded] = useControllable(expandedProp, initialState?.expanded ?? {}, onExpandedChange);
|
|
4427
|
+
const [rowPinning, setRowPinning] = useControllable(
|
|
4428
|
+
rowPinningProp,
|
|
4429
|
+
{ top: initialState?.rowPinning?.top ?? [], bottom: initialState?.rowPinning?.bottom ?? [] },
|
|
4430
|
+
onRowPinningChange
|
|
4431
|
+
);
|
|
4432
|
+
const [pagination, setPagination] = useControllable(
|
|
4433
|
+
paginationProp,
|
|
4434
|
+
initialState?.pagination ?? { pageIndex: 0, pageSize },
|
|
4435
|
+
onPaginationChange
|
|
4436
|
+
);
|
|
4437
|
+
const [density, setDensity] = useControllable(densityProp, "default", onDensityChange);
|
|
4438
|
+
const [cellSelection, setCellSelection] = React52.useState([]);
|
|
4439
|
+
const infinite = Boolean(onLoadMore);
|
|
4440
|
+
const paginate = !virtualized && !infinite;
|
|
4441
|
+
const compact = density === "compact";
|
|
4442
|
+
const sized = enableColumnSizing || enableColumnResizing || enableColumnPinning;
|
|
4443
|
+
const sticky = stickyHeader ?? (enableRowPinning || virtualized);
|
|
4444
|
+
const table = (0, import_react_table.useTable)({
|
|
4445
|
+
features,
|
|
4446
|
+
columns,
|
|
4447
|
+
data,
|
|
4448
|
+
getRowId,
|
|
4449
|
+
getSubRows,
|
|
4450
|
+
getRowCanExpand: getRowCanExpand ?? (renderSubComponent ? () => true : void 0),
|
|
4451
|
+
enableSorting,
|
|
4452
|
+
enableRowSelection,
|
|
4453
|
+
enableColumnResizing,
|
|
4454
|
+
enableColumnPinning,
|
|
4455
|
+
enableColumnFilters,
|
|
4456
|
+
enableGlobalFilter,
|
|
4457
|
+
enableGrouping,
|
|
4458
|
+
enableRowPinning,
|
|
4459
|
+
enableCellSelection,
|
|
4460
|
+
columnResizeMode,
|
|
4461
|
+
globalFilterFn: "includesString",
|
|
4462
|
+
manualSorting: serverSide,
|
|
4463
|
+
manualFiltering: serverSide,
|
|
4464
|
+
manualPagination: serverSide || !paginate,
|
|
4465
|
+
rowCount: serverSide ? rowCount : void 0,
|
|
4466
|
+
autoResetPageIndex: !serverSide,
|
|
4467
|
+
state: {
|
|
4468
|
+
sorting,
|
|
4469
|
+
rowSelection,
|
|
4470
|
+
columnVisibility,
|
|
4471
|
+
columnPinning,
|
|
4472
|
+
columnOrder,
|
|
4473
|
+
columnFilters,
|
|
4474
|
+
globalFilter,
|
|
4475
|
+
grouping,
|
|
4476
|
+
expanded,
|
|
4477
|
+
rowPinning,
|
|
4478
|
+
cellSelection,
|
|
4479
|
+
pagination: { ...pagination, pageSize: paginationProp ? pagination.pageSize : pageSize }
|
|
4480
|
+
},
|
|
4481
|
+
onSortingChange: setSorting,
|
|
4482
|
+
onRowSelectionChange: setRowSelection,
|
|
4483
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
4484
|
+
onColumnPinningChange: setColumnPinning,
|
|
4485
|
+
onColumnOrderChange: setColumnOrder,
|
|
4486
|
+
onColumnFiltersChange: setColumnFilters,
|
|
4487
|
+
onGlobalFilterChange: setGlobalFilter,
|
|
4488
|
+
onGroupingChange: setGrouping,
|
|
4489
|
+
onExpandedChange: setExpanded,
|
|
4490
|
+
onRowPinningChange: setRowPinning,
|
|
4491
|
+
onCellSelectionChange: (updater) => {
|
|
4492
|
+
const next = typeof updater === "function" ? updater(cellSelection) : updater;
|
|
4493
|
+
setCellSelection(next);
|
|
4494
|
+
onCellSelectionChange?.(next);
|
|
4495
|
+
},
|
|
4496
|
+
onPaginationChange: setPagination
|
|
4497
|
+
});
|
|
4498
|
+
const headerGroups = table.getHeaderGroups();
|
|
4499
|
+
const leafColumns = table.getVisibleLeafColumns();
|
|
4500
|
+
const hasExpander = enableExpanding;
|
|
4501
|
+
const leadingCount = (enableRowSelection ? 1 : 0) + (hasExpander ? 1 : 0) + (enableRowPinning ? 1 : 0);
|
|
4502
|
+
const columnSpan = leafColumns.length + leadingCount;
|
|
4503
|
+
const pageCount = table.getPageCount();
|
|
4504
|
+
const selectedCount = Object.values(rowSelection).filter(Boolean).length;
|
|
4505
|
+
const hideableColumns = table.getAllLeafColumns().filter((column) => column.getCanHide());
|
|
4506
|
+
const groupableColumns = table.getAllLeafColumns().filter((column) => column.getCanGroup());
|
|
4507
|
+
const showToolbar = Boolean(toolbar) || enableColumnVisibility || enableGlobalFilter || enableGrouping || enableDensityToggle;
|
|
4508
|
+
const cellDensity = compact ? "h-8 py-1.5" : void 0;
|
|
4509
|
+
const allSelected = table.getIsAllPageRowsSelected();
|
|
4510
|
+
const someSelected = table.getIsSomePageRowsSelected();
|
|
4511
|
+
const dragged = React52.useRef(null);
|
|
4512
|
+
const topRows = enableRowPinning ? table.getTopRows() : [];
|
|
4513
|
+
const bottomRows = enableRowPinning ? table.getBottomRows() : [];
|
|
4514
|
+
const bodyRows = enableRowPinning ? table.getCenterRows() : table.getRowModel().rows;
|
|
4515
|
+
const scrollRef = React52.useRef(null);
|
|
4516
|
+
const setScrollRef = React52.useCallback(
|
|
4517
|
+
(node) => {
|
|
4518
|
+
scrollRef.current = node;
|
|
4519
|
+
if (typeof containerRef === "function") containerRef(node);
|
|
4520
|
+
else if (containerRef) containerRef.current = node;
|
|
4521
|
+
},
|
|
4522
|
+
[containerRef]
|
|
4523
|
+
);
|
|
4524
|
+
const virtualizer = (0, import_react_virtual.useVirtualizer)({
|
|
4525
|
+
count: bodyRows.length,
|
|
4526
|
+
getScrollElement: () => scrollRef.current,
|
|
4527
|
+
estimateSize: () => estimateRowHeight,
|
|
4528
|
+
overscan: 8,
|
|
4529
|
+
enabled: virtualized,
|
|
4530
|
+
initialRect: { width: 0, height: estimateRowHeight * 10 }
|
|
4531
|
+
});
|
|
4532
|
+
const virtualItems = virtualized ? virtualizer.getVirtualItems() : [];
|
|
4533
|
+
const paddingTop = virtualItems.length > 0 ? virtualItems[0]?.start ?? 0 : 0;
|
|
4534
|
+
const paddingBottom = virtualItems.length > 0 ? virtualizer.getTotalSize() - (virtualItems.at(-1)?.end ?? 0) : 0;
|
|
4535
|
+
const sentinelRef = React52.useRef(null);
|
|
4536
|
+
React52.useEffect(() => {
|
|
4537
|
+
const node = sentinelRef.current;
|
|
4538
|
+
if (!node || !onLoadMore || !hasMore || loadingMore || typeof IntersectionObserver === "undefined") return;
|
|
4539
|
+
const container = scrollRef.current;
|
|
4540
|
+
const root = container && container.scrollHeight > container.clientHeight ? container : null;
|
|
4541
|
+
const observer = new IntersectionObserver(
|
|
4542
|
+
(entries) => {
|
|
4543
|
+
if (entries.some((entry) => entry.isIntersecting)) onLoadMore();
|
|
4544
|
+
},
|
|
4545
|
+
{ root, rootMargin: "0px 0px 160px 0px" }
|
|
4546
|
+
);
|
|
4547
|
+
observer.observe(node);
|
|
4548
|
+
return () => observer.disconnect();
|
|
4549
|
+
}, [onLoadMore, hasMore, loadingMore, bodyRows.length]);
|
|
4550
|
+
const reorder = (activeId, overId) => {
|
|
4551
|
+
if (activeId === overId) return;
|
|
4552
|
+
const ids = table.getAllLeafColumns().map((column) => column.id);
|
|
4553
|
+
const next = ids.filter((id) => id !== activeId);
|
|
4554
|
+
const at = next.indexOf(overId);
|
|
4555
|
+
next.splice(at === -1 ? next.length : at, 0, activeId);
|
|
4556
|
+
table.setColumnOrder(next);
|
|
4557
|
+
};
|
|
4558
|
+
const onGridKeyDown = (event) => {
|
|
4559
|
+
const directions = {
|
|
4560
|
+
ArrowUp: "up",
|
|
4561
|
+
ArrowDown: "down",
|
|
4562
|
+
ArrowLeft: "left",
|
|
4563
|
+
ArrowRight: "right"
|
|
4564
|
+
};
|
|
4565
|
+
const direction = directions[event.key];
|
|
4566
|
+
if (direction) {
|
|
4567
|
+
event.preventDefault();
|
|
4568
|
+
if (event.shiftKey) table.extendCellSelection(direction);
|
|
4569
|
+
else table.moveCellSelection(direction);
|
|
4570
|
+
} else if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "a") {
|
|
4571
|
+
event.preventDefault();
|
|
4572
|
+
table.selectAllCells();
|
|
4573
|
+
} else if (event.key === "Escape") {
|
|
4574
|
+
table.resetCellSelection(true);
|
|
4575
|
+
}
|
|
4576
|
+
};
|
|
4577
|
+
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);
|
|
4578
|
+
const renderRow = (row, options = {}) => {
|
|
4579
|
+
const { pinned, pinnedIndex = 0, pinnedCount = 1, virtualIndex } = options;
|
|
4580
|
+
const grouped = row.getIsGrouped();
|
|
4581
|
+
const rowUnits = compact ? 8 : 10;
|
|
4582
|
+
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;
|
|
4583
|
+
const cells = row.getVisibleCells();
|
|
4584
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(React52.Fragment, { children: [
|
|
4585
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
4586
|
+
TableRow,
|
|
4587
|
+
{
|
|
4588
|
+
ref: virtualized && virtualIndex !== void 0 ? virtualizer.measureElement : void 0,
|
|
4589
|
+
"data-index": virtualIndex,
|
|
4590
|
+
selected: row.getIsSelected(),
|
|
4591
|
+
style: pinStyle,
|
|
4592
|
+
onClick: onRowClick && !grouped ? () => onRowClick(row.original) : void 0,
|
|
4593
|
+
className: cn(pinned && "z-20 bg-surface", grouped && "bg-background", onRowClick && !grouped && "cursor-pointer"),
|
|
4594
|
+
children: [
|
|
4595
|
+
enableRowSelection && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableCell, { checkbox: true, className: cellDensity, onClick: (event) => event.stopPropagation(), children: !grouped && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4596
|
+
Checkbox,
|
|
4597
|
+
{
|
|
4598
|
+
"aria-label": "Select row",
|
|
4599
|
+
checked: row.getIsSelected(),
|
|
4600
|
+
disabled: !row.getCanSelect(),
|
|
4601
|
+
onCheckedChange: (checked) => row.toggleSelected(Boolean(checked))
|
|
4602
|
+
}
|
|
4603
|
+
) }),
|
|
4604
|
+
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)(
|
|
4605
|
+
Button,
|
|
4606
|
+
{
|
|
4607
|
+
type: "button",
|
|
4608
|
+
variant: "ghost",
|
|
4609
|
+
size: "icon-sm",
|
|
4610
|
+
"aria-label": row.getIsExpanded() ? "Collapse row" : "Expand row",
|
|
4611
|
+
"aria-expanded": row.getIsExpanded(),
|
|
4612
|
+
onClick: () => row.toggleExpanded(),
|
|
4613
|
+
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 })
|
|
4614
|
+
}
|
|
4615
|
+
) }),
|
|
4616
|
+
enableRowPinning && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableCell, { checkbox: true, className: cellDensity, onClick: (event) => event.stopPropagation(), children: !grouped && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4617
|
+
Button,
|
|
4618
|
+
{
|
|
4619
|
+
type: "button",
|
|
4620
|
+
variant: "ghost",
|
|
4621
|
+
size: "icon-sm",
|
|
4622
|
+
"aria-label": row.getIsPinned() ? "Unpin row" : "Pin row to top",
|
|
4623
|
+
"aria-pressed": Boolean(row.getIsPinned()),
|
|
4624
|
+
onClick: () => row.pin(row.getIsPinned() ? false : "top"),
|
|
4625
|
+
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 })
|
|
4626
|
+
}
|
|
4627
|
+
) }),
|
|
4628
|
+
cells.map((cell, index) => {
|
|
4629
|
+
if (cell.getIsCovered()) return null;
|
|
4630
|
+
const meta = getMeta(cell.column.columnDef.meta);
|
|
4631
|
+
const pin = pinning(cell.column, sized);
|
|
4632
|
+
const rowSpan = cell.getRowSpan();
|
|
4633
|
+
const colSpan = cell.getColSpan();
|
|
4634
|
+
const edges = enableCellSelection && cell.getIsSelected() ? cell.getSelectionEdges() : void 0;
|
|
4635
|
+
const indent = index === 0 && hasExpander && row.depth > 0 ? row.depth * 4 : 0;
|
|
4636
|
+
let content;
|
|
4637
|
+
if (cell.getIsGrouped()) {
|
|
4638
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
4639
|
+
"button",
|
|
4640
|
+
{
|
|
4641
|
+
type: "button",
|
|
4642
|
+
className: "inline-flex items-center gap-1 rounded-xs text-ui-label",
|
|
4643
|
+
"aria-expanded": row.getIsExpanded(),
|
|
4644
|
+
onClick: row.getToggleExpandedHandler(),
|
|
4645
|
+
children: [
|
|
4646
|
+
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 }),
|
|
4647
|
+
(0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()),
|
|
4648
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "text-secondary-muted-foreground", children: [
|
|
4649
|
+
"(",
|
|
4650
|
+
row.subRows.length,
|
|
4651
|
+
")"
|
|
4652
|
+
] })
|
|
4653
|
+
]
|
|
4654
|
+
}
|
|
4655
|
+
);
|
|
4656
|
+
} else if (cell.getIsAggregated()) {
|
|
4657
|
+
content = (0, import_react_table.flexRender)(cell.column.columnDef.aggregatedCell ?? cell.column.columnDef.cell, cell.getContext());
|
|
4658
|
+
} else if (cell.getIsPlaceholder()) {
|
|
4659
|
+
content = null;
|
|
4660
|
+
} else if (meta.editable) {
|
|
4661
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4662
|
+
EditableCell,
|
|
4663
|
+
{
|
|
4664
|
+
value: cell.getValue(),
|
|
4665
|
+
label: `${labelOf(cell.column)}, row ${row.index + 1}`,
|
|
4666
|
+
type: meta.editType ?? "text",
|
|
4667
|
+
onCommit: (value) => onCellEdit?.({ row: row.original, rowId: row.id, columnId: cell.column.id, value })
|
|
4668
|
+
}
|
|
4669
|
+
);
|
|
4670
|
+
} else {
|
|
4671
|
+
content = (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext());
|
|
4672
|
+
}
|
|
4673
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4674
|
+
TableCell,
|
|
4675
|
+
{
|
|
4676
|
+
align: meta.align,
|
|
4677
|
+
muted: meta.muted && !grouped,
|
|
4678
|
+
rowSpan: rowSpan > 1 ? rowSpan : void 0,
|
|
4679
|
+
colSpan: colSpan > 1 ? colSpan : void 0,
|
|
4680
|
+
style: {
|
|
4681
|
+
...pin.style,
|
|
4682
|
+
...indent ? { paddingInlineStart: `calc(var(--spacing) * ${indent + 4})` } : null
|
|
4683
|
+
},
|
|
4684
|
+
"data-selected": edges ? "" : void 0,
|
|
4685
|
+
onMouseDown: enableCellSelection ? cell.getSelectionStartHandler() : void 0,
|
|
4686
|
+
onMouseEnter: enableCellSelection ? cell.getSelectionExtendHandler() : void 0,
|
|
4687
|
+
className: cn(
|
|
4688
|
+
cellDensity,
|
|
4689
|
+
pin.className,
|
|
4690
|
+
enableCellSelection && "select-none",
|
|
4691
|
+
edges && "bg-accent-soft",
|
|
4692
|
+
edges?.top && "border-t-2 border-t-input-accent",
|
|
4693
|
+
edges?.bottom && "border-b-2 border-b-input-accent",
|
|
4694
|
+
edges?.left && "border-l-2 border-l-input-accent",
|
|
4695
|
+
edges?.right && "border-r-2 border-r-input-accent",
|
|
4696
|
+
meta.editable && "py-1"
|
|
4697
|
+
),
|
|
4698
|
+
children: content
|
|
4699
|
+
},
|
|
4700
|
+
cell.id
|
|
4701
|
+
);
|
|
4702
|
+
})
|
|
4703
|
+
]
|
|
4704
|
+
}
|
|
4705
|
+
),
|
|
4706
|
+
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) }) })
|
|
4707
|
+
] }, row.id);
|
|
4708
|
+
};
|
|
4709
|
+
const renderHeaderCell = (header) => {
|
|
4710
|
+
const { column } = header;
|
|
4711
|
+
const { align } = getMeta(column.columnDef.meta);
|
|
4712
|
+
const leaf = header.subHeaders.length === 0;
|
|
4713
|
+
const sortState = column.getIsSorted();
|
|
4714
|
+
const pin = pinning(column, sized, true);
|
|
4715
|
+
const reorderable = enableColumnOrdering && leaf && !column.getIsPinned();
|
|
4716
|
+
const label = labelOf(column);
|
|
4717
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4718
|
+
TableHead,
|
|
4719
|
+
{
|
|
4720
|
+
colSpan: header.colSpan > 1 ? header.colSpan : void 0,
|
|
4721
|
+
align: leaf ? align : void 0,
|
|
4722
|
+
sortable: leaf && column.getCanSort(),
|
|
4723
|
+
sort: sortState === false ? "none" : sortState,
|
|
4724
|
+
onSort: () => column.toggleSorting(sortState === "asc"),
|
|
4725
|
+
style: pin.style,
|
|
4726
|
+
draggable: reorderable || void 0,
|
|
4727
|
+
tabIndex: reorderable ? 0 : void 0,
|
|
4728
|
+
title: reorderable ? "Drag, or press Alt + arrow keys, to reorder" : void 0,
|
|
4729
|
+
onDragStart: reorderable ? () => dragged.current = column.id : void 0,
|
|
4730
|
+
onDragOver: reorderable ? (event) => event.preventDefault() : void 0,
|
|
4731
|
+
onDrop: reorderable ? (event) => {
|
|
4732
|
+
event.preventDefault();
|
|
4733
|
+
if (dragged.current) reorder(dragged.current, column.id);
|
|
4734
|
+
dragged.current = null;
|
|
4735
|
+
} : void 0,
|
|
4736
|
+
onKeyDown: reorderable ? (event) => {
|
|
4737
|
+
if (!event.altKey || event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
|
4738
|
+
event.preventDefault();
|
|
4739
|
+
const ids = table.getAllLeafColumns().map((item) => item.id);
|
|
4740
|
+
const at = ids.indexOf(column.id);
|
|
4741
|
+
const target = ids[at + (event.key === "ArrowLeft" ? -1 : 2)];
|
|
4742
|
+
if (event.key === "ArrowLeft" && ids[at - 1]) reorder(column.id, ids[at - 1]);
|
|
4743
|
+
else if (event.key === "ArrowRight" && at < ids.length - 1) reorder(column.id, target ?? "__end__");
|
|
4744
|
+
} : void 0,
|
|
4745
|
+
className: cn(
|
|
4746
|
+
pin.className,
|
|
4747
|
+
cellDensity,
|
|
4748
|
+
sticky && !column.getIsPinned() && "sticky top-0 z-20 bg-surface",
|
|
4749
|
+
sticky && column.getIsPinned() && "top-0",
|
|
4750
|
+
reorderable && "cursor-grab",
|
|
4751
|
+
!leaf && "text-center"
|
|
4752
|
+
),
|
|
4753
|
+
resizer: enableColumnResizing && column.getCanResize() ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4754
|
+
"div",
|
|
4755
|
+
{
|
|
4756
|
+
role: "separator",
|
|
4757
|
+
"aria-orientation": "vertical",
|
|
4758
|
+
"aria-label": `Resize ${label}`,
|
|
4759
|
+
onMouseDown: header.getResizeHandler(),
|
|
4760
|
+
onTouchStart: header.getResizeHandler(),
|
|
4761
|
+
onClick: (event) => event.stopPropagation(),
|
|
4762
|
+
className: cn(
|
|
4763
|
+
"absolute inset-y-0 end-0 w-1 cursor-col-resize touch-none select-none hover:bg-input-accent",
|
|
4764
|
+
column.getIsResizing() && "bg-input-accent"
|
|
4765
|
+
)
|
|
4766
|
+
}
|
|
4767
|
+
) : void 0,
|
|
4768
|
+
children: header.isPlaceholder ? null : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(table.FlexRender, { header })
|
|
4769
|
+
},
|
|
4770
|
+
header.id
|
|
4771
|
+
);
|
|
4772
|
+
};
|
|
4773
|
+
const stickyLeading = cn(cellDensity, sticky && "sticky top-0 z-20 bg-surface");
|
|
4774
|
+
const leadingHeaderCells = (rowSpan) => /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
|
|
4775
|
+
enableRowSelection && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableHead, { checkbox: true, rowSpan, className: stickyLeading, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4776
|
+
Checkbox,
|
|
4777
|
+
{
|
|
4778
|
+
"aria-label": "Select all rows",
|
|
4779
|
+
checked: allSelected ? true : someSelected ? "indeterminate" : false,
|
|
4780
|
+
disabled: loading,
|
|
4781
|
+
onCheckedChange: (checked) => table.toggleAllPageRowsSelected(Boolean(checked))
|
|
4782
|
+
}
|
|
4783
|
+
) }),
|
|
4784
|
+
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" }) }),
|
|
4785
|
+
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" }) })
|
|
4786
|
+
] });
|
|
4787
|
+
const rowsToRender = virtualized ? virtualItems.map((item) => ({ row: bodyRows[item.index], index: item.index })) : null;
|
|
4788
|
+
const totalRows = topRows.length + bodyRows.length + bottomRows.length;
|
|
4789
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: cn("flex w-full flex-col gap-2", wrapperClassName), children: [
|
|
4790
|
+
showToolbar && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
4791
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
4792
|
+
enableGlobalFilter && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4793
|
+
SearchBar,
|
|
4794
|
+
{
|
|
4795
|
+
"aria-label": "Search table",
|
|
4796
|
+
placeholder: globalFilterPlaceholder,
|
|
4797
|
+
value: globalFilter,
|
|
4798
|
+
onChange: (event) => table.setGlobalFilter(event.target.value),
|
|
4799
|
+
onClear: () => table.setGlobalFilter(""),
|
|
4800
|
+
className: "w-64"
|
|
4801
|
+
}
|
|
4802
|
+
),
|
|
4803
|
+
toolbar
|
|
4804
|
+
] }),
|
|
4805
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
4806
|
+
enableDensityToggle && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
4807
|
+
Button,
|
|
4808
|
+
{
|
|
4809
|
+
type: "button",
|
|
4810
|
+
variant: "outline",
|
|
4811
|
+
size: "sm",
|
|
4812
|
+
"aria-pressed": compact,
|
|
4813
|
+
onClick: () => setDensity(compact ? "default" : "compact"),
|
|
4814
|
+
children: [
|
|
4815
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_react29.Rows, { size: 16, "aria-hidden": true }),
|
|
4816
|
+
"Compact"
|
|
4817
|
+
]
|
|
4818
|
+
}
|
|
4819
|
+
),
|
|
4820
|
+
enableGrouping && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(DropdownMenu, { children: [
|
|
4821
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Button, { type: "button", variant: "outline", size: "sm", children: [
|
|
4822
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_react29.Stack, { size: 16, "aria-hidden": true }),
|
|
4823
|
+
"Group by"
|
|
4824
|
+
] }) }),
|
|
4825
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(DropdownMenuContent, { align: "end", children: [
|
|
4826
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DropdownMenuLabel, { children: "Group rows by" }),
|
|
4827
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DropdownMenuSeparator, {}),
|
|
4828
|
+
groupableColumns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4829
|
+
DropdownMenuCheckboxItem,
|
|
4830
|
+
{
|
|
4831
|
+
checked: column.getIsGrouped(),
|
|
4832
|
+
onCheckedChange: () => column.toggleGrouping(),
|
|
4833
|
+
children: labelOf(column)
|
|
4834
|
+
},
|
|
4835
|
+
column.id
|
|
4836
|
+
))
|
|
4837
|
+
] })
|
|
4838
|
+
] }),
|
|
4839
|
+
enableColumnVisibility && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(DropdownMenu, { children: [
|
|
4840
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Button, { type: "button", variant: "outline", size: "sm", children: [
|
|
4841
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_react29.Sliders, { size: 16, "aria-hidden": true }),
|
|
4842
|
+
"Columns"
|
|
4843
|
+
] }) }),
|
|
4844
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(DropdownMenuContent, { align: "end", children: [
|
|
4845
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DropdownMenuLabel, { children: "Toggle columns" }),
|
|
4846
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DropdownMenuSeparator, {}),
|
|
4847
|
+
hideableColumns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4848
|
+
DropdownMenuCheckboxItem,
|
|
4849
|
+
{
|
|
4850
|
+
checked: column.getIsVisible(),
|
|
4851
|
+
onCheckedChange: (checked) => column.toggleVisibility(Boolean(checked)),
|
|
4852
|
+
children: labelOf(column)
|
|
4853
|
+
},
|
|
4854
|
+
column.id
|
|
4855
|
+
))
|
|
4856
|
+
] })
|
|
4857
|
+
] })
|
|
4858
|
+
] })
|
|
4859
|
+
] }),
|
|
4860
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
4861
|
+
Table,
|
|
4862
|
+
{
|
|
4863
|
+
ref,
|
|
4864
|
+
containerRef: setScrollRef,
|
|
4865
|
+
containerClassName,
|
|
4866
|
+
striped,
|
|
4867
|
+
"aria-busy": loading || loadingMore || void 0,
|
|
4868
|
+
style: sized ? { width: table.getTotalSize(), minWidth: "100%", tableLayout: "fixed", ...tableStyle } : tableStyle,
|
|
4869
|
+
onKeyDown: enableCellSelection ? onGridKeyDown : void 0,
|
|
4870
|
+
tabIndex: enableCellSelection ? 0 : void 0,
|
|
4871
|
+
...tableProps,
|
|
4872
|
+
children: [
|
|
4873
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(TableHeader, { children: [
|
|
4874
|
+
headerGroups.map((group, groupIndex) => /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(TableRow, { className: "hover:bg-transparent", children: [
|
|
4875
|
+
groupIndex === 0 && leadingHeaderCells(headerGroups.length + (enableColumnFilters ? 1 : 0)),
|
|
4876
|
+
group.headers.map(renderHeaderCell)
|
|
4877
|
+
] }, group.id)),
|
|
4878
|
+
enableColumnFilters && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableRow, { className: "hover:bg-transparent", children: leafColumns.map((column) => {
|
|
4879
|
+
const pin = pinning(column, sized, true);
|
|
4880
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4881
|
+
TableHead,
|
|
4882
|
+
{
|
|
4883
|
+
style: pin.style,
|
|
4884
|
+
className: cn("h-auto py-2 font-normal", pin.className, sticky && !column.getIsPinned() && "bg-surface"),
|
|
4885
|
+
children: column.getCanFilter() ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ColumnFilter, { column }) : null
|
|
4886
|
+
},
|
|
4887
|
+
column.id
|
|
4888
|
+
);
|
|
4889
|
+
}) })
|
|
4890
|
+
] }),
|
|
4891
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(TableBody, { children: [
|
|
4892
|
+
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: [
|
|
4893
|
+
topRows.map((row, index) => renderRow(row, { pinned: "top", pinnedIndex: index, pinnedCount: topRows.length })),
|
|
4894
|
+
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 } }) }),
|
|
4895
|
+
rowsToRender ? rowsToRender.map(({ row, index }) => renderRow(row, { virtualIndex: index })) : bodyRows.map((row) => renderRow(row)),
|
|
4896
|
+
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 } }) }),
|
|
4897
|
+
bottomRows.map(
|
|
4898
|
+
(row, index) => renderRow(row, { pinned: "bottom", pinnedIndex: index, pinnedCount: bottomRows.length })
|
|
4899
|
+
)
|
|
4900
|
+
] }),
|
|
4901
|
+
infinite && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
|
|
4902
|
+
loadingMore && Array.from({ length: 3 }, (_, index) => skeletonRow(`more-${index}`)),
|
|
4903
|
+
/* @__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" }) })
|
|
4904
|
+
] })
|
|
4905
|
+
] }),
|
|
4906
|
+
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: [
|
|
4907
|
+
leadingCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableCell, { colSpan: leadingCount, className: cellDensity }),
|
|
4908
|
+
group.headers.map((header) => {
|
|
4909
|
+
const { align } = getMeta(header.column.columnDef.meta);
|
|
4910
|
+
const pin = pinning(header.column, sized);
|
|
4911
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4912
|
+
TableCell,
|
|
4913
|
+
{
|
|
4914
|
+
align,
|
|
4915
|
+
colSpan: header.colSpan > 1 ? header.colSpan : void 0,
|
|
4916
|
+
style: pin.style,
|
|
4917
|
+
className: cn("text-ui-label", pin.className, cellDensity),
|
|
4918
|
+
children: header.isPlaceholder ? null : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(table.FlexRender, { footer: header })
|
|
4919
|
+
},
|
|
4920
|
+
header.id
|
|
4921
|
+
);
|
|
4922
|
+
})
|
|
4923
|
+
] }, group.id)) })
|
|
4924
|
+
]
|
|
4925
|
+
}
|
|
4926
|
+
),
|
|
4927
|
+
(enableRowSelection || paginate && pageCount > 1) && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
4928
|
+
/* @__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 }),
|
|
4929
|
+
paginate && pageCount > 1 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4930
|
+
Pagination,
|
|
4931
|
+
{
|
|
4932
|
+
page: pagination.pageIndex + 1,
|
|
4933
|
+
pageCount,
|
|
4934
|
+
onPageChange: (page) => table.setPageIndex(page - 1)
|
|
4935
|
+
}
|
|
4936
|
+
)
|
|
4937
|
+
] })
|
|
4938
|
+
] });
|
|
4939
|
+
}
|
|
4940
|
+
var DataTable = React52.forwardRef(DataTableInner);
|
|
4941
|
+
DataTable.displayName = "DataTable";
|
|
4942
|
+
|
|
4943
|
+
// src/components/Data Display/StatCard.tsx
|
|
4944
|
+
var React53 = __toESM(require("react"), 1);
|
|
4945
|
+
var import_class_variance_authority6 = require("class-variance-authority");
|
|
4946
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
4037
4947
|
var statCardVariants = (0, import_class_variance_authority6.cva)("flex min-w-0 flex-col gap-2 rounded-md border p-3", {
|
|
4038
4948
|
variants: {
|
|
4039
4949
|
variant: {
|
|
@@ -4047,26 +4957,26 @@ var statCardVariants = (0, import_class_variance_authority6.cva)("flex min-w-0 f
|
|
|
4047
4957
|
},
|
|
4048
4958
|
defaultVariants: { variant: "default" }
|
|
4049
4959
|
});
|
|
4050
|
-
var StatCard =
|
|
4051
|
-
({ className, variant, label, value, icon, caption, ...props }, ref) => /* @__PURE__ */ (0,
|
|
4052
|
-
/* @__PURE__ */ (0,
|
|
4053
|
-
/* @__PURE__ */ (0,
|
|
4054
|
-
icon && /* @__PURE__ */ (0,
|
|
4960
|
+
var StatCard = React53.forwardRef(
|
|
4961
|
+
({ className, variant, label, value, icon, caption, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { ref, className: cn(statCardVariants({ variant }), className), ...props, children: [
|
|
4962
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "truncate text-ui-caption text-secondary-muted-foreground", children: label }),
|
|
4963
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("p", { className: "flex items-center gap-2 text-body-base text-surface-foreground", children: [
|
|
4964
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { "aria-hidden": "true", className: "inline-flex size-6 shrink-0 items-center justify-center", children: icon }),
|
|
4055
4965
|
value
|
|
4056
4966
|
] }),
|
|
4057
|
-
caption && /* @__PURE__ */ (0,
|
|
4967
|
+
caption && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "text-ui-caption text-secondary-muted-foreground", children: caption })
|
|
4058
4968
|
] })
|
|
4059
4969
|
);
|
|
4060
4970
|
StatCard.displayName = "StatCard";
|
|
4061
4971
|
|
|
4062
4972
|
// src/components/Research-Specific/ActivityStructure.tsx
|
|
4063
|
-
var
|
|
4973
|
+
var React55 = __toESM(require("react"), 1);
|
|
4064
4974
|
|
|
4065
4975
|
// src/components/Tags & Badges/EditableTag.tsx
|
|
4066
|
-
var
|
|
4067
|
-
var
|
|
4976
|
+
var React54 = __toESM(require("react"), 1);
|
|
4977
|
+
var import_react30 = require("@phosphor-icons/react");
|
|
4068
4978
|
var import_class_variance_authority7 = require("class-variance-authority");
|
|
4069
|
-
var
|
|
4979
|
+
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
4070
4980
|
var editableTagVariants = (0, import_class_variance_authority7.cva)(
|
|
4071
4981
|
"inline-flex h-6.5 items-center whitespace-nowrap rounded-sm py-1 text-ui-caption transition-colors",
|
|
4072
4982
|
{
|
|
@@ -4081,27 +4991,27 @@ var editableTagVariants = (0, import_class_variance_authority7.cva)(
|
|
|
4081
4991
|
defaultVariants: { type: "default" }
|
|
4082
4992
|
}
|
|
4083
4993
|
);
|
|
4084
|
-
var EditableTag =
|
|
4994
|
+
var EditableTag = React54.forwardRef(
|
|
4085
4995
|
({ className, type = "default", icon, onRemove, onClick, children, ...props }, ref) => {
|
|
4086
4996
|
const classes = cn(editableTagVariants({ type }), className);
|
|
4087
|
-
const leading = type === "add" ? /* @__PURE__ */ (0,
|
|
4997
|
+
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;
|
|
4088
4998
|
if (type === "add" || type === "multiple" && onClick) {
|
|
4089
|
-
return /* @__PURE__ */ (0,
|
|
4999
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("button", { ref, type: "button", className: classes, onClick, ...props, children: [
|
|
4090
5000
|
leading,
|
|
4091
5001
|
children
|
|
4092
5002
|
] });
|
|
4093
5003
|
}
|
|
4094
|
-
return /* @__PURE__ */ (0,
|
|
5004
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("span", { ref, className: classes, ...props, children: [
|
|
4095
5005
|
leading,
|
|
4096
5006
|
children,
|
|
4097
|
-
onRemove && /* @__PURE__ */ (0,
|
|
5007
|
+
onRemove && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
4098
5008
|
"button",
|
|
4099
5009
|
{
|
|
4100
5010
|
type: "button",
|
|
4101
5011
|
"aria-label": typeof children === "string" ? `Remove ${children}` : "Remove",
|
|
4102
5012
|
onClick: onRemove,
|
|
4103
5013
|
className: "inline-flex size-3 items-center justify-center rounded-xs",
|
|
4104
|
-
children: /* @__PURE__ */ (0,
|
|
5014
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_react30.X, { size: 12, "aria-hidden": true })
|
|
4105
5015
|
}
|
|
4106
5016
|
)
|
|
4107
5017
|
] });
|
|
@@ -4110,26 +5020,26 @@ var EditableTag = React52.forwardRef(
|
|
|
4110
5020
|
EditableTag.displayName = "EditableTag";
|
|
4111
5021
|
|
|
4112
5022
|
// src/components/Research-Specific/ActivityStructure.tsx
|
|
4113
|
-
var
|
|
4114
|
-
var ActivityStructure =
|
|
4115
|
-
({ className, title = "Activity Structure", stats, sections, onRemoveTag, onAddTag, addTagLabel = "Add tag", action, children, ...props }, ref) => /* @__PURE__ */ (0,
|
|
5023
|
+
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
5024
|
+
var ActivityStructure = React55.forwardRef(
|
|
5025
|
+
({ className, title = "Activity Structure", stats, sections, onRemoveTag, onAddTag, addTagLabel = "Add tag", action, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
4116
5026
|
"section",
|
|
4117
5027
|
{
|
|
4118
5028
|
ref,
|
|
4119
5029
|
className: cn("flex w-full max-w-96.5 flex-col gap-4 rounded-xl bg-surface p-4", className),
|
|
4120
5030
|
...props,
|
|
4121
5031
|
children: [
|
|
4122
|
-
/* @__PURE__ */ (0,
|
|
4123
|
-
/* @__PURE__ */ (0,
|
|
5032
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
5033
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("h3", { className: "text-body-section text-surface-foreground", children: title }),
|
|
4124
5034
|
action
|
|
4125
5035
|
] }),
|
|
4126
|
-
stats.length > 0 && /* @__PURE__ */ (0,
|
|
4127
|
-
sections?.map(({ id, heading, body, tags }) => /* @__PURE__ */ (0,
|
|
4128
|
-
/* @__PURE__ */ (0,
|
|
4129
|
-
/* @__PURE__ */ (0,
|
|
4130
|
-
(tags?.length || onAddTag) && /* @__PURE__ */ (0,
|
|
4131
|
-
tags?.map((tag) => /* @__PURE__ */ (0,
|
|
4132
|
-
onAddTag && /* @__PURE__ */ (0,
|
|
5036
|
+
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)) }),
|
|
5037
|
+
sections?.map(({ id, heading, body, tags }) => /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
5038
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("h4", { className: "text-heading-h4 text-surface-foreground", children: heading }),
|
|
5039
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "text-body-base text-surface-foreground", children: body }),
|
|
5040
|
+
(tags?.length || onAddTag) && /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
5041
|
+
tags?.map((tag) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(EditableTag, { type: "editable", onRemove: onRemoveTag && (() => onRemoveTag(id, tag)), children: tag }, tag)),
|
|
5042
|
+
onAddTag && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(EditableTag, { type: "add", onClick: () => onAddTag(id), children: addTagLabel })
|
|
4133
5043
|
] })
|
|
4134
5044
|
] }, id)),
|
|
4135
5045
|
children
|
|
@@ -4140,10 +5050,10 @@ var ActivityStructure = React53.forwardRef(
|
|
|
4140
5050
|
ActivityStructure.displayName = "ActivityStructure";
|
|
4141
5051
|
|
|
4142
5052
|
// src/components/Tags & Badges/Badge.tsx
|
|
4143
|
-
var
|
|
4144
|
-
var
|
|
5053
|
+
var React56 = __toESM(require("react"), 1);
|
|
5054
|
+
var import_react31 = require("@phosphor-icons/react");
|
|
4145
5055
|
var import_class_variance_authority8 = require("class-variance-authority");
|
|
4146
|
-
var
|
|
5056
|
+
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
4147
5057
|
var roleTagVariants = (0, import_class_variance_authority8.cva)(
|
|
4148
5058
|
"group inline-flex h-6 items-center whitespace-nowrap rounded-sm py-1 text-ui-caption transition-colors",
|
|
4149
5059
|
{
|
|
@@ -4169,11 +5079,11 @@ var roleTagVariants = (0, import_class_variance_authority8.cva)(
|
|
|
4169
5079
|
defaultVariants: { type: "primary", selected: false }
|
|
4170
5080
|
}
|
|
4171
5081
|
);
|
|
4172
|
-
var Badge =
|
|
5082
|
+
var Badge = React56.forwardRef(
|
|
4173
5083
|
({ className, type = "primary", selected = false, onClick, children, ...props }, ref) => {
|
|
4174
5084
|
const classes = cn(roleTagVariants({ type, selected: type === "interactable" ? selected : false }), className);
|
|
4175
5085
|
if (type === "interactable") {
|
|
4176
|
-
return /* @__PURE__ */ (0,
|
|
5086
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
4177
5087
|
"button",
|
|
4178
5088
|
{
|
|
4179
5089
|
ref,
|
|
@@ -4183,100 +5093,20 @@ var Badge = React54.forwardRef(
|
|
|
4183
5093
|
onClick,
|
|
4184
5094
|
...props,
|
|
4185
5095
|
children: [
|
|
4186
|
-
/* @__PURE__ */ (0,
|
|
5096
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_react31.DotsSixVertical, { size: 16, "aria-hidden": true, className: "hidden shrink-0 group-hover:block" }),
|
|
4187
5097
|
children
|
|
4188
5098
|
]
|
|
4189
5099
|
}
|
|
4190
5100
|
);
|
|
4191
5101
|
}
|
|
4192
|
-
return /* @__PURE__ */ (0,
|
|
4193
|
-
type === "question" && /* @__PURE__ */ (0,
|
|
4194
|
-
type === "id" && /* @__PURE__ */ (0,
|
|
5102
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("span", { ref, className: classes, ...props, children: [
|
|
5103
|
+
type === "question" && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_react31.RadioButton, { size: 16, weight: "fill", "aria-hidden": true }),
|
|
5104
|
+
type === "id" && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "text-secondary-muted-foreground", children: "ID" }),
|
|
4195
5105
|
children
|
|
4196
5106
|
] });
|
|
4197
5107
|
}
|
|
4198
5108
|
);
|
|
4199
5109
|
Badge.displayName = "Badge";
|
|
4200
|
-
|
|
4201
|
-
// src/components/Utility/Pagination.tsx
|
|
4202
|
-
var React55 = __toESM(require("react"), 1);
|
|
4203
|
-
var import_react30 = require("@phosphor-icons/react");
|
|
4204
|
-
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
4205
|
-
function getPaginationItems(page, pageCount, siblings = 1) {
|
|
4206
|
-
const keep = /* @__PURE__ */ new Set([1, pageCount]);
|
|
4207
|
-
for (let p = page - siblings; p <= page + siblings; p++) if (p >= 1 && p <= pageCount) keep.add(p);
|
|
4208
|
-
const sorted = [...keep].sort((a, b) => a - b);
|
|
4209
|
-
const items = [];
|
|
4210
|
-
sorted.forEach((p, index) => {
|
|
4211
|
-
const previous = sorted[index - 1];
|
|
4212
|
-
if (previous !== void 0 && p - previous === 2) items.push(previous + 1);
|
|
4213
|
-
else if (previous !== void 0 && p - previous > 2) items.push("ellipsis");
|
|
4214
|
-
items.push(p);
|
|
4215
|
-
});
|
|
4216
|
-
return items;
|
|
4217
|
-
}
|
|
4218
|
-
var Pagination = React55.forwardRef(
|
|
4219
|
-
({ className, page, pageCount, onPageChange, variant = "full", siblings = 1, ...props }, ref) => {
|
|
4220
|
-
const go = (next2) => onPageChange(Math.min(pageCount, Math.max(1, next2)));
|
|
4221
|
-
const previous = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
4222
|
-
Button,
|
|
4223
|
-
{
|
|
4224
|
-
type: "button",
|
|
4225
|
-
variant: "outline",
|
|
4226
|
-
size: "icon-sm",
|
|
4227
|
-
"aria-label": "Previous page",
|
|
4228
|
-
disabled: page <= 1,
|
|
4229
|
-
onClick: () => go(page - 1),
|
|
4230
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_react30.ArrowLeft, { size: 16, "aria-hidden": true })
|
|
4231
|
-
}
|
|
4232
|
-
);
|
|
4233
|
-
const next = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
4234
|
-
Button,
|
|
4235
|
-
{
|
|
4236
|
-
type: "button",
|
|
4237
|
-
variant: "outline",
|
|
4238
|
-
size: "icon-sm",
|
|
4239
|
-
"aria-label": "Next page",
|
|
4240
|
-
disabled: page >= pageCount,
|
|
4241
|
-
onClick: () => go(page + 1),
|
|
4242
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_react30.ArrowRight, { size: 16, "aria-hidden": true })
|
|
4243
|
-
}
|
|
4244
|
-
);
|
|
4245
|
-
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
4246
|
-
"nav",
|
|
4247
|
-
{
|
|
4248
|
-
ref,
|
|
4249
|
-
"aria-label": "Pagination",
|
|
4250
|
-
className: cn("flex items-center", variant === "compact" ? "w-35 justify-between" : "gap-2", className),
|
|
4251
|
-
...props,
|
|
4252
|
-
children: [
|
|
4253
|
-
previous,
|
|
4254
|
-
variant === "compact" ? /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("span", { className: "text-body-small text-surface-foreground", "aria-live": "polite", children: [
|
|
4255
|
-
page,
|
|
4256
|
-
"/",
|
|
4257
|
-
pageCount
|
|
4258
|
-
] }) : /* @__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: [
|
|
4259
|
-
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_react30.DotsThree, { size: 16, "aria-hidden": true }),
|
|
4260
|
-
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "sr-only", children: "More pages" })
|
|
4261
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
4262
|
-
Button,
|
|
4263
|
-
{
|
|
4264
|
-
type: "button",
|
|
4265
|
-
variant: item === page ? "subtle" : "outline",
|
|
4266
|
-
size: "sm",
|
|
4267
|
-
"aria-label": `Page ${item}`,
|
|
4268
|
-
"aria-current": item === page ? "page" : void 0,
|
|
4269
|
-
onClick: () => go(item),
|
|
4270
|
-
children: item
|
|
4271
|
-
}
|
|
4272
|
-
) }, item === "ellipsis" ? `ellipsis-${index}` : item)) }),
|
|
4273
|
-
next
|
|
4274
|
-
]
|
|
4275
|
-
}
|
|
4276
|
-
);
|
|
4277
|
-
}
|
|
4278
|
-
);
|
|
4279
|
-
Pagination.displayName = "Pagination";
|
|
4280
5110
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4281
5111
|
0 && (module.exports = {
|
|
4282
5112
|
AIMiniAvatar,
|
|
@@ -4292,6 +5122,7 @@ Pagination.displayName = "Pagination";
|
|
|
4292
5122
|
ChatOption,
|
|
4293
5123
|
Checkbox,
|
|
4294
5124
|
CheckboxField,
|
|
5125
|
+
DataTable,
|
|
4295
5126
|
DatePicker,
|
|
4296
5127
|
DateTimePicker,
|
|
4297
5128
|
Dialog,
|
|
@@ -4372,6 +5203,7 @@ Pagination.displayName = "Pagination";
|
|
|
4372
5203
|
TableBody,
|
|
4373
5204
|
TableCell,
|
|
4374
5205
|
TableCellTwoLines,
|
|
5206
|
+
TableFooter,
|
|
4375
5207
|
TableHead,
|
|
4376
5208
|
TableHeader,
|
|
4377
5209
|
TableRow,
|