@platned/ui 1.1.0 → 1.1.1
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/blocks.cjs +8 -4
- package/dist/blocks.cjs.map +1 -1
- package/dist/blocks.d.cts +29 -3
- package/dist/blocks.d.ts +29 -3
- package/dist/blocks.js +8 -4
- package/dist/blocks.js.map +1 -1
- package/dist/{data-table-Dec6t8NO.d.ts → data-table-CcIINjPg.d.ts} +30 -3
- package/dist/data-table.cjs +199 -124
- package/dist/data-table.cjs.map +1 -1
- package/dist/data-table.d.ts +1 -1
- package/dist/data-table.js +152 -76
- package/dist/data-table.js.map +1 -1
- package/dist/index.cjs +257 -165
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +26 -9
- package/dist/index.js.map +1 -1
- package/dist/map.d.cts +2 -0
- package/dist/map.d.ts +2 -0
- package/package.json +1 -1
package/dist/data-table.cjs
CHANGED
|
@@ -52,7 +52,7 @@ __export(data_table_exports, {
|
|
|
52
52
|
module.exports = __toCommonJS(data_table_exports);
|
|
53
53
|
|
|
54
54
|
// src/components/lists/data-table.tsx
|
|
55
|
-
var
|
|
55
|
+
var import_react32 = require("react");
|
|
56
56
|
var import_clsx5 = __toESM(require("clsx"), 1);
|
|
57
57
|
var import_react_table = require("@tanstack/react-table");
|
|
58
58
|
var import_lucide_react12 = require("lucide-react");
|
|
@@ -1561,28 +1561,60 @@ function createSelectColumn(options = {}) {
|
|
|
1561
1561
|
meta: { width: "48px", interactive: true, mobile: "hidden", label: "Select" }
|
|
1562
1562
|
};
|
|
1563
1563
|
}
|
|
1564
|
+
function hideableColumns(table) {
|
|
1565
|
+
return table.getAllLeafColumns().filter((column) => typeof column.accessorFn !== "undefined" && column.getCanHide() && !column.id.startsWith("__"));
|
|
1566
|
+
}
|
|
1564
1567
|
function DataTableViewOptions({ table, label = "View" }) {
|
|
1565
|
-
const columns = table
|
|
1568
|
+
const columns = hideableColumns(table);
|
|
1566
1569
|
if (columns.length === 0) return null;
|
|
1570
|
+
const hidden = columns.filter((column) => !column.getIsVisible()).length;
|
|
1567
1571
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(DropdownMenu, { children: [
|
|
1568
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1572
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
1573
|
+
Button,
|
|
1574
|
+
{
|
|
1575
|
+
variant: "outline",
|
|
1576
|
+
size: "sm",
|
|
1577
|
+
className: "ms-auto h-8",
|
|
1578
|
+
"aria-label": hidden ? `${label}, ${hidden} ${hidden === 1 ? "column" : "columns"} hidden` : void 0,
|
|
1579
|
+
children: [
|
|
1580
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react6.Settings2Icon, {}),
|
|
1581
|
+
label,
|
|
1582
|
+
hidden > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Badge, { variant: "secondary", className: "h-5 min-w-5 rounded-full px-1.5 font-normal tabular-nums", children: hidden })
|
|
1583
|
+
]
|
|
1584
|
+
}
|
|
1585
|
+
) }),
|
|
1586
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(DropdownMenuContent, { align: "end", className: "min-w-[180px]", children: [
|
|
1573
1587
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DropdownMenuLabel, { children: "Toggle columns" }),
|
|
1574
1588
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DropdownMenuSeparator, {}),
|
|
1575
1589
|
columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1576
1590
|
DropdownMenuCheckboxItem,
|
|
1577
1591
|
{
|
|
1578
|
-
className: "capitalize",
|
|
1579
1592
|
checked: column.getIsVisible(),
|
|
1580
1593
|
onCheckedChange: (visible) => column.toggleVisibility(visible),
|
|
1581
1594
|
onSelect: (event) => event.preventDefault(),
|
|
1582
1595
|
children: columnLabel(column)
|
|
1583
1596
|
},
|
|
1584
1597
|
column.id
|
|
1585
|
-
))
|
|
1598
|
+
)),
|
|
1599
|
+
hidden > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
1600
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DropdownMenuSeparator, {}),
|
|
1601
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
1602
|
+
DropdownMenuItem,
|
|
1603
|
+
{
|
|
1604
|
+
onClick: () => (
|
|
1605
|
+
// One update: toggling the columns one by one would each start from the same state.
|
|
1606
|
+
table.setColumnVisibility((visibility) => ({
|
|
1607
|
+
...visibility,
|
|
1608
|
+
...Object.fromEntries(columns.map((column) => [column.id, true]))
|
|
1609
|
+
}))
|
|
1610
|
+
),
|
|
1611
|
+
children: [
|
|
1612
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react6.EyeIcon, {}),
|
|
1613
|
+
"Show all columns"
|
|
1614
|
+
]
|
|
1615
|
+
}
|
|
1616
|
+
)
|
|
1617
|
+
] })
|
|
1586
1618
|
] })
|
|
1587
1619
|
] });
|
|
1588
1620
|
}
|
|
@@ -1679,6 +1711,7 @@ function DataTablePagination({
|
|
|
1679
1711
|
}
|
|
1680
1712
|
|
|
1681
1713
|
// src/components/lists/data-table-fields.tsx
|
|
1714
|
+
var import_react28 = require("react");
|
|
1682
1715
|
var import_lucide_react10 = require("lucide-react");
|
|
1683
1716
|
|
|
1684
1717
|
// src/lib/format.tsx
|
|
@@ -2804,6 +2837,7 @@ function fieldToColumn(field, format = {}) {
|
|
|
2804
2837
|
options: typeof field.filter === "object" ? field.filter.options : void 0,
|
|
2805
2838
|
variant: typeof field.filter === "object" && field.filter.variant || "menu",
|
|
2806
2839
|
allLabel: typeof field.filter === "object" && field.filter.allLabel || "All",
|
|
2840
|
+
disabled: typeof field.filter === "object" ? field.filter.disabled : void 0,
|
|
2807
2841
|
describe: describeFor(field)
|
|
2808
2842
|
} : void 0;
|
|
2809
2843
|
const mobile = field.mobile ?? (field.type === "avatar" ? "title" : field.type === "status" ? "status" : void 0);
|
|
@@ -2943,20 +2977,31 @@ var DOT = {
|
|
|
2943
2977
|
slate: "bg-badge-dot-slate",
|
|
2944
2978
|
violet: "bg-badge-dot-violet"
|
|
2945
2979
|
};
|
|
2946
|
-
|
|
2980
|
+
var DataTableFacetsContext = (0, import_react28.createContext)({ manual: false });
|
|
2981
|
+
function useFacets(column) {
|
|
2982
|
+
const server = (0, import_react28.useContext)(DataTableFacetsContext);
|
|
2947
2983
|
const meta = column.columnDef.meta?.filter;
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2984
|
+
let counts;
|
|
2985
|
+
let total;
|
|
2986
|
+
if (server.manual) {
|
|
2987
|
+
const own = server.counts?.[column.id];
|
|
2988
|
+
counts = own ? new Map(Object.entries(own)) : null;
|
|
2989
|
+
total = own ? Object.values(own).reduce((sum, n) => sum + n, 0) : void 0;
|
|
2990
|
+
} else {
|
|
2991
|
+
counts = /* @__PURE__ */ new Map();
|
|
2992
|
+
for (const row of column.getFacetedRowModel().rows) {
|
|
2993
|
+
if (row.getIsGrouped()) continue;
|
|
2994
|
+
for (const value of filterValues(row.getValue(column.id))) counts.set(value, (counts.get(value) ?? 0) + 1);
|
|
2995
|
+
}
|
|
2996
|
+
total = column.getFacetedRowModel().rows.filter((row) => !row.getIsGrouped()).length;
|
|
2952
2997
|
}
|
|
2953
|
-
const
|
|
2998
|
+
const known = counts ? [...counts.keys()] : [...new Set(column.getFacetedRowModel().rows.flatMap((row) => filterValues(row.getValue(column.id))))];
|
|
2999
|
+
const values = meta?.options ?? known.sort((a, b) => a.localeCompare(b, void 0, { numeric: true }));
|
|
2954
3000
|
const items = values.map((value) => ({
|
|
2955
3001
|
value,
|
|
2956
3002
|
...meta?.describe(value) ?? { label: value },
|
|
2957
3003
|
icon: void 0
|
|
2958
3004
|
}));
|
|
2959
|
-
const total = column.getFacetedRowModel().rows.filter((row) => !row.getIsGrouped()).length;
|
|
2960
3005
|
return { counts, items, total };
|
|
2961
3006
|
}
|
|
2962
3007
|
function singleValue(column) {
|
|
@@ -2968,10 +3013,10 @@ function singleValue(column) {
|
|
|
2968
3013
|
}
|
|
2969
3014
|
function DataTableButtonFilter({ column, title }) {
|
|
2970
3015
|
const meta = column.columnDef.meta?.filter;
|
|
2971
|
-
const { items } =
|
|
3016
|
+
const { items } = useFacets(column);
|
|
2972
3017
|
const { value, set } = singleValue(column);
|
|
2973
3018
|
const heading = title ?? meta?.title ?? column.columnDef.meta?.label ?? column.id;
|
|
2974
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3019
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DisabledReason, { reason: meta?.disabled, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
2975
3020
|
ToggleGroup,
|
|
2976
3021
|
{
|
|
2977
3022
|
type: "single",
|
|
@@ -2979,6 +3024,7 @@ function DataTableButtonFilter({ column, title }) {
|
|
|
2979
3024
|
size: "sm",
|
|
2980
3025
|
spacing: 0,
|
|
2981
3026
|
"aria-label": heading,
|
|
3027
|
+
disabled: Boolean(meta?.disabled),
|
|
2982
3028
|
value: value || "__all",
|
|
2983
3029
|
onValueChange: (next) => set(next === "__all" || !next ? "" : next),
|
|
2984
3030
|
children: [
|
|
@@ -2989,28 +3035,33 @@ function DataTableButtonFilter({ column, title }) {
|
|
|
2989
3035
|
] }, item.value))
|
|
2990
3036
|
]
|
|
2991
3037
|
}
|
|
2992
|
-
);
|
|
3038
|
+
) });
|
|
3039
|
+
}
|
|
3040
|
+
function DisabledReason({ reason, children }) {
|
|
3041
|
+
if (typeof reason !== "string") return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children });
|
|
3042
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { "data-slot": "data-table-disabled", title: reason, className: "inline-flex cursor-not-allowed", children });
|
|
2993
3043
|
}
|
|
2994
3044
|
function DataTableTabsFilter({ column, title }) {
|
|
2995
3045
|
const meta = column.columnDef.meta?.filter;
|
|
2996
|
-
const { counts, items, total } =
|
|
3046
|
+
const { counts, items, total } = useFacets(column);
|
|
2997
3047
|
const { value, set } = singleValue(column);
|
|
2998
3048
|
const heading = title ?? meta?.title ?? column.columnDef.meta?.label ?? column.id;
|
|
2999
|
-
const count = (n) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Badge, { variant: "secondary", className: "ms-1 h-5 min-w-5 rounded-full px-1.5 font-normal tabular-nums", children: n ?? 0 });
|
|
3000
|
-
|
|
3001
|
-
|
|
3049
|
+
const count = (n) => counts && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Badge, { variant: "secondary", className: "ms-1 h-5 min-w-5 rounded-full px-1.5 font-normal tabular-nums", children: n ?? 0 });
|
|
3050
|
+
const disabled = Boolean(meta?.disabled);
|
|
3051
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DisabledReason, { reason: meta?.disabled, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Tabs, { value: value || "__all", onValueChange: (next) => set(next === "__all" ? "" : next), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(TabsList, { "aria-label": heading, children: [
|
|
3052
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(TabsTrigger, { value: "__all", disabled, children: [
|
|
3002
3053
|
meta?.allLabel ?? "All",
|
|
3003
3054
|
count(total)
|
|
3004
3055
|
] }),
|
|
3005
|
-
items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(TabsTrigger, { value: item.value, children: [
|
|
3056
|
+
items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(TabsTrigger, { value: item.value, disabled, children: [
|
|
3006
3057
|
item.label,
|
|
3007
|
-
count(counts
|
|
3058
|
+
count(counts?.get(item.value))
|
|
3008
3059
|
] }, item.value))
|
|
3009
|
-
] }) });
|
|
3060
|
+
] }) }) });
|
|
3010
3061
|
}
|
|
3011
3062
|
function DataTableFacetedFilter({ column, title, options }) {
|
|
3012
3063
|
const meta = column.columnDef.meta?.filter;
|
|
3013
|
-
const { counts, items: facetItems } =
|
|
3064
|
+
const { counts, items: facetItems } = useFacets(column);
|
|
3014
3065
|
const items = options ?? facetItems;
|
|
3015
3066
|
const selected = new Set(column.getFilterValue() ?? []);
|
|
3016
3067
|
const heading = title ?? meta?.title ?? column.columnDef.meta?.label ?? column.id;
|
|
@@ -3020,8 +3071,8 @@ function DataTableFacetedFilter({ column, title, options }) {
|
|
|
3020
3071
|
else next.add(value);
|
|
3021
3072
|
column.setFilterValue(next.size ? [...next] : void 0);
|
|
3022
3073
|
};
|
|
3023
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(Popover, { children: [
|
|
3024
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(Button, { variant: "outline", size: "sm", className: "h-8 border-dashed", children: [
|
|
3074
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DisabledReason, { reason: meta?.disabled, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(Popover, { children: [
|
|
3075
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(Button, { variant: "outline", size: "sm", className: "h-8 border-dashed", disabled: Boolean(meta?.disabled), children: [
|
|
3025
3076
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_lucide_react10.PlusCircleIcon, {}),
|
|
3026
3077
|
heading,
|
|
3027
3078
|
selected.size > 0 && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
@@ -3060,9 +3111,9 @@ function DataTableFacetedFilter({ column, title, options }) {
|
|
|
3060
3111
|
item.color && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { "aria-hidden": "true", className: cn("size-2 rounded-full", DOT[item.color]) }),
|
|
3061
3112
|
item.icon,
|
|
3062
3113
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { children: item.label }),
|
|
3063
|
-
counts
|
|
3114
|
+
counts?.get(item.value) ? (
|
|
3064
3115
|
// A shortcut slot, so it takes the item's end (and the item's own check hides).
|
|
3065
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CommandShortcut, { className: "font-mono tracking-normal", children: counts
|
|
3116
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CommandShortcut, { className: "font-mono tracking-normal", children: counts?.get(item.value) })
|
|
3066
3117
|
) : null
|
|
3067
3118
|
]
|
|
3068
3119
|
},
|
|
@@ -3075,11 +3126,11 @@ function DataTableFacetedFilter({ column, title, options }) {
|
|
|
3075
3126
|
] })
|
|
3076
3127
|
] })
|
|
3077
3128
|
] }) })
|
|
3078
|
-
] });
|
|
3129
|
+
] }) });
|
|
3079
3130
|
}
|
|
3080
3131
|
|
|
3081
3132
|
// src/components/lists/data-table-features.tsx
|
|
3082
|
-
var
|
|
3133
|
+
var import_react29 = require("react");
|
|
3083
3134
|
var import_lucide_react11 = require("lucide-react");
|
|
3084
3135
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3085
3136
|
var EXPAND_COLUMN_ID = "expand";
|
|
@@ -3119,9 +3170,9 @@ function expandColumn() {
|
|
|
3119
3170
|
};
|
|
3120
3171
|
}
|
|
3121
3172
|
var detailId = (rowId) => `data-table-detail-${rowId.replace(/[^\w-]/g, "_")}`;
|
|
3122
|
-
var RowDragContext = (0,
|
|
3173
|
+
var RowDragContext = (0, import_react29.createContext)(null);
|
|
3123
3174
|
function DragHandle() {
|
|
3124
|
-
const drag = (0,
|
|
3175
|
+
const drag = (0, import_react29.useContext)(RowDragContext);
|
|
3125
3176
|
if (!drag) return null;
|
|
3126
3177
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3127
3178
|
Button,
|
|
@@ -3215,7 +3266,7 @@ var import_sortable = require("@dnd-kit/sortable");
|
|
|
3215
3266
|
var import_utilities = require("@dnd-kit/utilities");
|
|
3216
3267
|
|
|
3217
3268
|
// src/components/lists/table.tsx
|
|
3218
|
-
var
|
|
3269
|
+
var import_react30 = require("react");
|
|
3219
3270
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3220
3271
|
function renderShorthand({
|
|
3221
3272
|
columns,
|
|
@@ -3232,16 +3283,16 @@ function renderShorthand({
|
|
|
3232
3283
|
footer && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TableFooter, { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TableRow, { children: cols.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TableCell, { className: column.className, children: footer[index] }, column.key)) }) })
|
|
3233
3284
|
] });
|
|
3234
3285
|
}
|
|
3235
|
-
var TableRoot = (0,
|
|
3286
|
+
var TableRoot = (0, import_react30.forwardRef)(function Table({ className, columns, rows, getRowKey, caption, footer, children, ...props }, ref) {
|
|
3236
3287
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { "data-slot": "table-container", className: "relative w-full scrollbar-thin overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("table", { ref, "data-slot": "table", className: cn("w-full caption-bottom text-sm", className), ...props, children: columns ? renderShorthand({ columns, rows, getRowKey, caption, footer }) : children }) });
|
|
3237
3288
|
});
|
|
3238
|
-
var TableHeader = (0,
|
|
3289
|
+
var TableHeader = (0, import_react30.forwardRef)(function TableHeader2({ className, ...props }, ref) {
|
|
3239
3290
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("thead", { ref, "data-slot": "table-header", className: cn("[&_tr]:border-b", className), ...props });
|
|
3240
3291
|
});
|
|
3241
|
-
var TableBody = (0,
|
|
3292
|
+
var TableBody = (0, import_react30.forwardRef)(function TableBody2({ className, ...props }, ref) {
|
|
3242
3293
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("tbody", { ref, "data-slot": "table-body", className: cn("[&_tr:last-child]:border-0", className), ...props });
|
|
3243
3294
|
});
|
|
3244
|
-
var TableFooter = (0,
|
|
3295
|
+
var TableFooter = (0, import_react30.forwardRef)(function TableFooter2({ className, ...props }, ref) {
|
|
3245
3296
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3246
3297
|
"tfoot",
|
|
3247
3298
|
{
|
|
@@ -3252,7 +3303,7 @@ var TableFooter = (0, import_react29.forwardRef)(function TableFooter2({ classNa
|
|
|
3252
3303
|
}
|
|
3253
3304
|
);
|
|
3254
3305
|
});
|
|
3255
|
-
var TableRow = (0,
|
|
3306
|
+
var TableRow = (0, import_react30.forwardRef)(function TableRow2({ className, ...props }, ref) {
|
|
3256
3307
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3257
3308
|
"tr",
|
|
3258
3309
|
{
|
|
@@ -3266,7 +3317,7 @@ var TableRow = (0, import_react29.forwardRef)(function TableRow2({ className, ..
|
|
|
3266
3317
|
}
|
|
3267
3318
|
);
|
|
3268
3319
|
});
|
|
3269
|
-
var TableHead = (0,
|
|
3320
|
+
var TableHead = (0, import_react30.forwardRef)(function TableHead2({ className, ...props }, ref) {
|
|
3270
3321
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3271
3322
|
"th",
|
|
3272
3323
|
{
|
|
@@ -3280,7 +3331,7 @@ var TableHead = (0, import_react29.forwardRef)(function TableHead2({ className,
|
|
|
3280
3331
|
}
|
|
3281
3332
|
);
|
|
3282
3333
|
});
|
|
3283
|
-
var TableCell = (0,
|
|
3334
|
+
var TableCell = (0, import_react30.forwardRef)(function TableCell2({ className, ...props }, ref) {
|
|
3284
3335
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3285
3336
|
"td",
|
|
3286
3337
|
{
|
|
@@ -3291,7 +3342,7 @@ var TableCell = (0, import_react29.forwardRef)(function TableCell2({ className,
|
|
|
3291
3342
|
}
|
|
3292
3343
|
);
|
|
3293
3344
|
});
|
|
3294
|
-
var TableCaption = (0,
|
|
3345
|
+
var TableCaption = (0, import_react30.forwardRef)(function TableCaption2({ className, ...props }, ref) {
|
|
3295
3346
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("caption", { ref, "data-slot": "table-caption", className: cn("text-muted-foreground mt-4 text-sm", className), ...props });
|
|
3296
3347
|
});
|
|
3297
3348
|
|
|
@@ -3299,7 +3350,7 @@ var TableCaption = (0, import_react29.forwardRef)(function TableCaption2({ class
|
|
|
3299
3350
|
var import_clsx4 = __toESM(require("clsx"), 1);
|
|
3300
3351
|
|
|
3301
3352
|
// src/components/feedback/progress.tsx
|
|
3302
|
-
var
|
|
3353
|
+
var import_react31 = require("react");
|
|
3303
3354
|
var import_radix_ui9 = require("radix-ui");
|
|
3304
3355
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3305
3356
|
var FILL2 = {
|
|
@@ -3309,7 +3360,7 @@ var FILL2 = {
|
|
|
3309
3360
|
danger: "bg-destructive",
|
|
3310
3361
|
neutral: "bg-muted-foreground"
|
|
3311
3362
|
};
|
|
3312
|
-
var Progress = (0,
|
|
3363
|
+
var Progress = (0, import_react31.forwardRef)(function Progress2({ className, value, max = 100, tone = "brand", ...props }, ref) {
|
|
3313
3364
|
const clamped = value == null ? value : Math.min(max, Math.max(0, value));
|
|
3314
3365
|
const percent = clamped == null ? 0 : clamped / max * 100;
|
|
3315
3366
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
@@ -3464,14 +3515,14 @@ function resolve(updater, previous) {
|
|
|
3464
3515
|
return typeof updater === "function" ? updater(previous) : updater;
|
|
3465
3516
|
}
|
|
3466
3517
|
function useTableState(controlled, initial, onChange) {
|
|
3467
|
-
const [inner, setInner] = (0,
|
|
3518
|
+
const [inner, setInner] = (0, import_react32.useState)(initial);
|
|
3468
3519
|
const value = controlled ?? inner;
|
|
3469
|
-
const latest = (0,
|
|
3520
|
+
const latest = (0, import_react32.useRef)(value);
|
|
3470
3521
|
latest.current = value;
|
|
3471
3522
|
const isControlled = controlled !== void 0;
|
|
3472
|
-
const onChangeRef = (0,
|
|
3523
|
+
const onChangeRef = (0, import_react32.useRef)(onChange);
|
|
3473
3524
|
onChangeRef.current = onChange;
|
|
3474
|
-
const set = (0,
|
|
3525
|
+
const set = (0, import_react32.useCallback)(
|
|
3475
3526
|
(updater) => {
|
|
3476
3527
|
const next = resolve(updater, latest.current);
|
|
3477
3528
|
if (!isControlled) setInner(next);
|
|
@@ -3495,9 +3546,9 @@ function CellInteractionGuard({ children }) {
|
|
|
3495
3546
|
}
|
|
3496
3547
|
var HEADER_PADDING_PX = 16;
|
|
3497
3548
|
function useHeaderWidths(padding, deps) {
|
|
3498
|
-
const nodes = (0,
|
|
3499
|
-
const [widths, setWidths] = (0,
|
|
3500
|
-
const measure = (0,
|
|
3549
|
+
const nodes = (0, import_react32.useRef)(/* @__PURE__ */ new Map());
|
|
3550
|
+
const [widths, setWidths] = (0, import_react32.useState)({});
|
|
3551
|
+
const measure = (0, import_react32.useCallback)(() => {
|
|
3501
3552
|
const next = {};
|
|
3502
3553
|
nodes.current.forEach((node, id) => {
|
|
3503
3554
|
next[id] = Math.ceil(node.getBoundingClientRect().width) + padding;
|
|
@@ -3508,15 +3559,15 @@ function useHeaderWidths(padding, deps) {
|
|
|
3508
3559
|
return same ? previous : next;
|
|
3509
3560
|
});
|
|
3510
3561
|
}, [padding]);
|
|
3511
|
-
(0,
|
|
3512
|
-
(0,
|
|
3562
|
+
(0, import_react32.useLayoutEffect)(measure, [measure, deps]);
|
|
3563
|
+
(0, import_react32.useLayoutEffect)(() => {
|
|
3513
3564
|
let live = true;
|
|
3514
3565
|
void document.fonts?.ready.then(() => live && measure());
|
|
3515
3566
|
return () => {
|
|
3516
3567
|
live = false;
|
|
3517
3568
|
};
|
|
3518
3569
|
}, [measure]);
|
|
3519
|
-
const register = (0,
|
|
3570
|
+
const register = (0, import_react32.useCallback)(
|
|
3520
3571
|
(id) => (node) => {
|
|
3521
3572
|
if (node) nodes.current.set(id, node);
|
|
3522
3573
|
else nodes.current.delete(id);
|
|
@@ -3526,9 +3577,9 @@ function useHeaderWidths(padding, deps) {
|
|
|
3526
3577
|
return { widths, register };
|
|
3527
3578
|
}
|
|
3528
3579
|
function useScrollEdges() {
|
|
3529
|
-
const [node, setNode] = (0,
|
|
3530
|
-
const [edges, setEdges] = (0,
|
|
3531
|
-
const measure = (0,
|
|
3580
|
+
const [node, setNode] = (0, import_react32.useState)(null);
|
|
3581
|
+
const [edges, setEdges] = (0, import_react32.useState)({ overflowing: false, atStart: true, atEnd: true, overflowingY: false, atTop: true });
|
|
3582
|
+
const measure = (0, import_react32.useCallback)(() => {
|
|
3532
3583
|
if (!node) return;
|
|
3533
3584
|
const { scrollLeft, scrollWidth, clientWidth, scrollTop, scrollHeight, clientHeight } = node;
|
|
3534
3585
|
const next = {
|
|
@@ -3542,7 +3593,7 @@ function useScrollEdges() {
|
|
|
3542
3593
|
(previous) => previous.overflowing === next.overflowing && previous.atStart === next.atStart && previous.atEnd === next.atEnd && previous.overflowingY === next.overflowingY && previous.atTop === next.atTop ? previous : next
|
|
3543
3594
|
);
|
|
3544
3595
|
}, [node]);
|
|
3545
|
-
(0,
|
|
3596
|
+
(0, import_react32.useLayoutEffect)(() => {
|
|
3546
3597
|
if (!node) return;
|
|
3547
3598
|
measure();
|
|
3548
3599
|
if (typeof ResizeObserver === "undefined") return;
|
|
@@ -3608,6 +3659,11 @@ function DataTable({
|
|
|
3608
3659
|
bordered = true,
|
|
3609
3660
|
className
|
|
3610
3661
|
}) {
|
|
3662
|
+
const fill = maxHeight === "fill";
|
|
3663
|
+
const facetCounts = (0, import_react32.useMemo)(
|
|
3664
|
+
() => ({ manual: Boolean(manual.filtering), counts: manual.facets }),
|
|
3665
|
+
[manual.filtering, manual.facets]
|
|
3666
|
+
);
|
|
3611
3667
|
if (!label && !caption) {
|
|
3612
3668
|
devWarn('DataTable needs `label` or `caption`: an unnamed table is announced as just "table".');
|
|
3613
3669
|
}
|
|
@@ -3622,8 +3678,8 @@ function DataTable({
|
|
|
3622
3678
|
})),
|
|
3623
3679
|
onSortingChange
|
|
3624
3680
|
);
|
|
3625
|
-
const [ownOrder, setOwnOrder] = (0,
|
|
3626
|
-
(0,
|
|
3681
|
+
const [ownOrder, setOwnOrder] = (0, import_react32.useState)(null);
|
|
3682
|
+
(0, import_react32.useEffect)(() => setOwnOrder(null), [data]);
|
|
3627
3683
|
const tableData = ownOrder ?? data;
|
|
3628
3684
|
const moveRow = (from, to) => {
|
|
3629
3685
|
const next = (0, import_sortable.arrayMove)(tableData, from, to);
|
|
@@ -3631,10 +3687,10 @@ function DataTable({
|
|
|
3631
3687
|
else setOwnOrder(next);
|
|
3632
3688
|
};
|
|
3633
3689
|
const group = typeof groupBy === "string" ? { key: groupBy } : groupBy;
|
|
3634
|
-
const [groupsExpanded, setGroupsExpanded] = (0,
|
|
3635
|
-
const [openRows, setOpenRows] = (0,
|
|
3636
|
-
const [pinOverrides, setPinOverrides] = (0,
|
|
3637
|
-
const [widthOverrides, setWidthOverrides] = (0,
|
|
3690
|
+
const [groupsExpanded, setGroupsExpanded] = (0, import_react32.useState)(group?.defaultCollapsed ? {} : true);
|
|
3691
|
+
const [openRows, setOpenRows] = (0, import_react32.useState)(() => new Set(expand?.defaultExpanded ?? []));
|
|
3692
|
+
const [pinOverrides, setPinOverrides] = (0, import_react32.useState)({});
|
|
3693
|
+
const [widthOverrides, setWidthOverrides] = (0, import_react32.useState)({});
|
|
3638
3694
|
const getRowHref = getRowHrefProp ?? (rowHref ? (row) => fillTemplate(rowHref, row) : void 0);
|
|
3639
3695
|
const format = useFormat();
|
|
3640
3696
|
const [globalFilter, setGlobalFilter] = useTableState(state.globalFilter, "", onGlobalFilterChange);
|
|
@@ -3651,7 +3707,7 @@ function DataTable({
|
|
|
3651
3707
|
);
|
|
3652
3708
|
const [rowSelection, setRowSelection] = useTableState(state.rowSelection, {}, onRowSelectionChange);
|
|
3653
3709
|
const hasExpand = Boolean(expand);
|
|
3654
|
-
const allColumns = (0,
|
|
3710
|
+
const allColumns = (0, import_react32.useMemo)(() => {
|
|
3655
3711
|
let cols = columns.map(
|
|
3656
3712
|
(column) => isFieldColumn(column) ? fieldToColumn(column, format) : column
|
|
3657
3713
|
);
|
|
@@ -3702,7 +3758,7 @@ function DataTable({
|
|
|
3702
3758
|
group?.by,
|
|
3703
3759
|
reorderable
|
|
3704
3760
|
]);
|
|
3705
|
-
const fieldsByKey = (0,
|
|
3761
|
+
const fieldsByKey = (0, import_react32.useMemo)(() => {
|
|
3706
3762
|
const map = /* @__PURE__ */ new Map();
|
|
3707
3763
|
for (const column of columns) if (isFieldColumn(column)) map.set(column.key, column);
|
|
3708
3764
|
return map;
|
|
@@ -3726,16 +3782,16 @@ function DataTable({
|
|
|
3726
3782
|
...columnIds.filter((id) => !isUtility(id) && !pinOf(id)),
|
|
3727
3783
|
...columnIds.filter((id) => !isUtility(id) && pinOf(id) === "end")
|
|
3728
3784
|
].join("\0");
|
|
3729
|
-
const columnOrder = (0,
|
|
3785
|
+
const columnOrder = (0, import_react32.useMemo)(() => orderKey.split("\0"), [orderKey]);
|
|
3730
3786
|
const anyStartPin = columnIds.some((id) => !isUtility(id) && pinOf(id) === "start");
|
|
3731
3787
|
const effectivePin = (id) => isUtility(id) ? anyStartPin ? "start" : void 0 : pinOf(id);
|
|
3732
3788
|
const grouped = Boolean(group);
|
|
3733
3789
|
const groupDesc = group?.order === "desc";
|
|
3734
|
-
const effectiveSorting = (0,
|
|
3790
|
+
const effectiveSorting = (0, import_react32.useMemo)(
|
|
3735
3791
|
() => grouped ? [{ id: GROUP_COLUMN_ID, desc: groupDesc }, ...sorting.filter((sort) => sort.id !== GROUP_COLUMN_ID)] : sorting,
|
|
3736
3792
|
[grouped, groupDesc, sorting]
|
|
3737
3793
|
);
|
|
3738
|
-
const effectiveVisibility = (0,
|
|
3794
|
+
const effectiveVisibility = (0, import_react32.useMemo)(
|
|
3739
3795
|
() => grouped ? { ...columnVisibility, [GROUP_COLUMN_ID]: false } : columnVisibility,
|
|
3740
3796
|
[grouped, columnVisibility]
|
|
3741
3797
|
);
|
|
@@ -3759,7 +3815,7 @@ function DataTable({
|
|
|
3759
3815
|
}
|
|
3760
3816
|
) : expand.fields ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DetailFields, { row, fields: expand.fields }) : null
|
|
3761
3817
|
} : void 0;
|
|
3762
|
-
const searchTextById = (0,
|
|
3818
|
+
const searchTextById = (0, import_react32.useMemo)(() => {
|
|
3763
3819
|
const map = /* @__PURE__ */ new Map();
|
|
3764
3820
|
for (const column of allColumns) {
|
|
3765
3821
|
const text = column.meta?.searchText;
|
|
@@ -3827,8 +3883,8 @@ function DataTable({
|
|
|
3827
3883
|
enableSortingRemoval: false,
|
|
3828
3884
|
...tableOptions
|
|
3829
3885
|
});
|
|
3830
|
-
const selectionReported = (0,
|
|
3831
|
-
(0,
|
|
3886
|
+
const selectionReported = (0, import_react32.useRef)(false);
|
|
3887
|
+
(0, import_react32.useEffect)(() => {
|
|
3832
3888
|
if (!onSelectionChange) return;
|
|
3833
3889
|
if (!selectionReported.current) {
|
|
3834
3890
|
selectionReported.current = true;
|
|
@@ -3837,9 +3893,9 @@ function DataTable({
|
|
|
3837
3893
|
onSelectionChange(table.getSelectedRowModel().rows.map((row) => row.original));
|
|
3838
3894
|
}, [rowSelection]);
|
|
3839
3895
|
const [wrapRef, containerWidth] = useElementWidth();
|
|
3840
|
-
const captionId = (0,
|
|
3896
|
+
const captionId = (0, import_react32.useId)();
|
|
3841
3897
|
const breakpoint = responsive === false ? 0 : typeof responsive === "object" ? responsive.breakpoint ?? DEFAULT_CARD_BREAKPOINT_PX : DEFAULT_CARD_BREAKPOINT_PX;
|
|
3842
|
-
const modeRef = (0,
|
|
3898
|
+
const modeRef = (0, import_react32.useRef)("table");
|
|
3843
3899
|
const mode = nextLayoutMode(modeRef.current, containerWidth, breakpoint);
|
|
3844
3900
|
modeRef.current = mode;
|
|
3845
3901
|
const search = searchable === true ? {} : searchable || void 0;
|
|
@@ -3866,7 +3922,8 @@ function DataTable({
|
|
|
3866
3922
|
const filterColumns = table.getAllLeafColumns().filter((column) => column.columnDef.meta?.filter);
|
|
3867
3923
|
const tabsFilters = filterColumns.filter((column) => column.columnDef.meta?.filter?.variant === "tabs");
|
|
3868
3924
|
const isToolbarFilter = (id) => filterColumns.some((c) => c.id === id && c.columnDef.meta?.filter?.variant !== "tabs");
|
|
3869
|
-
const
|
|
3925
|
+
const viewMenu = showColumnMenu || hideableColumns(table).some((column) => !column.getIsVisible());
|
|
3926
|
+
const showToolbar = Boolean(search || toolbar || viewMenu || filterColumns.length > tabsFilters.length);
|
|
3870
3927
|
const reorderActive = reorderable && sorting.length === 0 && !filtering && !group;
|
|
3871
3928
|
const showPager = paginated && !error && table.getRowCount() > 0;
|
|
3872
3929
|
const view = {
|
|
@@ -3909,48 +3966,64 @@ function DataTable({
|
|
|
3909
3966
|
summary: (row) => groupSummary(row, group.summary ?? [], formatOf, format)
|
|
3910
3967
|
} : void 0
|
|
3911
3968
|
};
|
|
3912
|
-
return /* @__PURE__ */ (0, import_jsx_runtime31.
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3969
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DataTableFacetsContext.Provider, { value: facetCounts, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
3970
|
+
"div",
|
|
3971
|
+
{
|
|
3972
|
+
"data-slot": "data-table",
|
|
3973
|
+
"data-fill": fill || void 0,
|
|
3974
|
+
className: cn("relative flex flex-col gap-4", fill && "h-full min-h-0 flex-1", className),
|
|
3975
|
+
children: [
|
|
3976
|
+
tabsFilters.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: cn("flex shrink-0 flex-wrap items-center gap-2", !bordered && "px-4 pt-3"), children: tabsFilters.map((column) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DataTableTabsFilter, { column }, column.id)) }),
|
|
3977
|
+
showToolbar && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: cn("flex shrink-0 items-center justify-between gap-2", !bordered && "px-4 pt-3"), children: [
|
|
3978
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-1 flex-wrap items-center gap-2", children: [
|
|
3979
|
+
search && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DisabledReason, { reason: search.disabled, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3980
|
+
Input,
|
|
3981
|
+
{
|
|
3982
|
+
type: "search",
|
|
3983
|
+
"aria-label": search.label ?? "Filter",
|
|
3984
|
+
placeholder: search.placeholder ?? "Filter...",
|
|
3985
|
+
value: searchValue,
|
|
3986
|
+
onChange: (event) => setSearchValue(event.target.value),
|
|
3987
|
+
disabled: Boolean(search.disabled),
|
|
3988
|
+
className: "h-8 w-[150px] lg:w-[250px]"
|
|
3989
|
+
}
|
|
3990
|
+
) }),
|
|
3991
|
+
filterColumns.map(
|
|
3992
|
+
(column) => column.columnDef.meta?.filter?.variant === "buttons" ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DataTableButtonFilter, { column }, column.id) : column.columnDef.meta?.filter?.variant === "tabs" ? null : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DataTableFacetedFilter, { column }, column.id)
|
|
3993
|
+
),
|
|
3994
|
+
columnFilters.some((f) => isToolbarFilter(f.id)) && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
3995
|
+
Button,
|
|
3996
|
+
{
|
|
3997
|
+
variant: "ghost",
|
|
3998
|
+
size: "sm",
|
|
3999
|
+
onClick: () => table.setColumnFilters((current) => current.filter((f) => !isToolbarFilter(f.id))),
|
|
4000
|
+
children: [
|
|
4001
|
+
"Reset",
|
|
4002
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react12.XIcon, {})
|
|
4003
|
+
]
|
|
4004
|
+
}
|
|
4005
|
+
),
|
|
4006
|
+
toolbar
|
|
4007
|
+
] }),
|
|
4008
|
+
viewMenu && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DataTableViewOptions, { table }) })
|
|
4009
|
+
] }),
|
|
4010
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { role: "status", "aria-live": "polite", className: "sr-only", children: filtering && !loading ? `${resultCount} ${resultCount === 1 ? "result" : "results"}` : "" }),
|
|
4011
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
4012
|
+
"div",
|
|
3932
4013
|
{
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
onClick: () => table.setColumnFilters((current) => current.filter((f) => !isToolbarFilter(f.id))),
|
|
4014
|
+
ref: wrapRef,
|
|
4015
|
+
className: cn("overflow-hidden bg-background", bordered && "rounded-md border", fill && "flex min-h-0 flex-1 flex-col"),
|
|
3936
4016
|
children: [
|
|
3937
|
-
"
|
|
3938
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4017
|
+
mode === "cards" && caption && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { id: captionId, className: "shrink-0 px-4 pt-3 text-left text-sm text-muted-foreground", children: caption }),
|
|
4018
|
+
mode === "cards" ? maxHeight ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CardScroll, { label, maxHeight, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CardList, { ...view }) }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CardList, { ...view }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(TableView, { ...view }),
|
|
4019
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "shrink-0 border-t p-2", children: footer })
|
|
3939
4020
|
]
|
|
3940
4021
|
}
|
|
3941
4022
|
),
|
|
3942
|
-
|
|
3943
|
-
]
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { role: "status", "aria-live": "polite", className: "sr-only", children: filtering && !loading ? `${resultCount} ${resultCount === 1 ? "result" : "results"}` : "" }),
|
|
3947
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { ref: wrapRef, className: cn("overflow-hidden bg-background", bordered && "rounded-md border"), children: [
|
|
3948
|
-
mode === "cards" && caption && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { id: captionId, className: "px-4 pt-3 text-left text-sm text-muted-foreground", children: caption }),
|
|
3949
|
-
mode === "cards" ? maxHeight ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CardScroll, { label, maxHeight, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CardList, { ...view }) }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CardList, { ...view }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(TableView, { ...view }),
|
|
3950
|
-
footer && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "border-t p-2", children: footer })
|
|
3951
|
-
] }),
|
|
3952
|
-
showPager && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: cn(!bordered && "px-2 pb-3"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DataTablePagination, { table, pageSizeOptions }) })
|
|
3953
|
-
] });
|
|
4023
|
+
showPager && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: cn("shrink-0", !bordered && "px-2 pb-3"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DataTablePagination, { table, pageSizeOptions }) })
|
|
4024
|
+
]
|
|
4025
|
+
}
|
|
4026
|
+
) });
|
|
3954
4027
|
}
|
|
3955
4028
|
var verticalOnly = ({ transform }) => ({ ...transform, x: 0 });
|
|
3956
4029
|
function titleColumnId(columns) {
|
|
@@ -4025,7 +4098,7 @@ function TableView({
|
|
|
4025
4098
|
const direction = scroll.overflowing && maxHeight && scroll.overflowingY ? "scrolls" : scroll.overflowing ? "scrolls horizontally" : "scrolls vertically";
|
|
4026
4099
|
const regionLabel = `${label ?? "Table"} (${direction})`;
|
|
4027
4100
|
const pinnedHeader = maxHeight ? (0, import_clsx5.default)("sticky top-0 z-sticky bg-background", !scroll.atTop && "shadow-[inset_0_-1px_0_var(--border)]") : void 0;
|
|
4028
|
-
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "relative", children: [
|
|
4101
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: cn("relative", maxHeight === "fill" && "flex min-h-0 flex-1 flex-col"), children: [
|
|
4029
4102
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4030
4103
|
"div",
|
|
4031
4104
|
{
|
|
@@ -4033,10 +4106,11 @@ function TableView({
|
|
|
4033
4106
|
onScroll: scroll.onScroll,
|
|
4034
4107
|
className: cn(
|
|
4035
4108
|
maxHeight ? "overflow-auto overscroll-contain" : "overflow-x-auto overscroll-x-contain",
|
|
4109
|
+
maxHeight === "fill" && "min-h-0 flex-1",
|
|
4036
4110
|
SCROLLBAR_CLASSES,
|
|
4037
4111
|
scrolls && FOCUS_RING_INSET
|
|
4038
4112
|
),
|
|
4039
|
-
style: maxHeight ? { maxHeight } : void 0,
|
|
4113
|
+
style: maxHeight && maxHeight !== "fill" ? { maxHeight } : void 0,
|
|
4040
4114
|
...scrolls ? { role: "region", tabIndex: 0, "aria-label": regionLabel } : {},
|
|
4041
4115
|
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4042
4116
|
DndWrapper,
|
|
@@ -4127,7 +4201,7 @@ function TableView({
|
|
|
4127
4201
|
getRowTone,
|
|
4128
4202
|
getRowDimmed
|
|
4129
4203
|
};
|
|
4130
|
-
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
4204
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react32.Fragment, { children: [
|
|
4131
4205
|
reorder ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4132
4206
|
SortableBodyRow,
|
|
4133
4207
|
{
|
|
@@ -4330,12 +4404,12 @@ function GroupRow({
|
|
|
4330
4404
|
) }) });
|
|
4331
4405
|
}
|
|
4332
4406
|
function usePinOffsets(key) {
|
|
4333
|
-
const nodes = (0,
|
|
4334
|
-
const [offsets, setOffsets] = (0,
|
|
4407
|
+
const nodes = (0, import_react32.useRef)(/* @__PURE__ */ new Map());
|
|
4408
|
+
const [offsets, setOffsets] = (0, import_react32.useState)({
|
|
4335
4409
|
start: {},
|
|
4336
4410
|
end: {}
|
|
4337
4411
|
});
|
|
4338
|
-
(0,
|
|
4412
|
+
(0, import_react32.useLayoutEffect)(() => {
|
|
4339
4413
|
const cells = [...nodes.current.entries()].filter(([, node]) => node.isConnected);
|
|
4340
4414
|
cells.sort(([, a], [, b]) => a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
|
|
4341
4415
|
const start = {};
|
|
@@ -4354,7 +4428,7 @@ function usePinOffsets(key) {
|
|
|
4354
4428
|
(current) => JSON.stringify(current) === JSON.stringify({ start, end }) ? current : { start, end }
|
|
4355
4429
|
);
|
|
4356
4430
|
}, [key]);
|
|
4357
|
-
const register = (0,
|
|
4431
|
+
const register = (0, import_react32.useCallback)(
|
|
4358
4432
|
(id) => (node) => {
|
|
4359
4433
|
if (node) nodes.current.set(id, node);
|
|
4360
4434
|
else nodes.current.delete(id);
|
|
@@ -4370,7 +4444,7 @@ function ResizeHandle({
|
|
|
4370
4444
|
width,
|
|
4371
4445
|
onResize
|
|
4372
4446
|
}) {
|
|
4373
|
-
const [now, setNow] = (0,
|
|
4447
|
+
const [now, setNow] = (0, import_react32.useState)();
|
|
4374
4448
|
const set = (next) => {
|
|
4375
4449
|
const clamped = next === void 0 ? void 0 : Math.max(floor, Math.round(next));
|
|
4376
4450
|
setNow(clamped);
|
|
@@ -4425,13 +4499,14 @@ function ResizeHandle({
|
|
|
4425
4499
|
}
|
|
4426
4500
|
function CardScroll({ label, maxHeight, children }) {
|
|
4427
4501
|
const scroll = useScrollEdges();
|
|
4502
|
+
const fill = maxHeight === "fill";
|
|
4428
4503
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4429
4504
|
"div",
|
|
4430
4505
|
{
|
|
4431
4506
|
ref: scroll.ref,
|
|
4432
4507
|
onScroll: scroll.onScroll,
|
|
4433
|
-
style: { maxHeight },
|
|
4434
|
-
className: cn("overflow-y-auto overscroll-contain", SCROLLBAR_CLASSES, scroll.overflowingY && FOCUS_RING_INSET),
|
|
4508
|
+
style: fill ? void 0 : { maxHeight },
|
|
4509
|
+
className: cn("overflow-y-auto overscroll-contain", fill && "min-h-0 flex-1", SCROLLBAR_CLASSES, scroll.overflowingY && FOCUS_RING_INSET),
|
|
4435
4510
|
...scroll.overflowingY ? { role: "region", tabIndex: 0, "aria-label": `${label ?? "Table"} (scrolls vertically)` } : {},
|
|
4436
4511
|
children
|
|
4437
4512
|
}
|