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