@platned/ui 1.1.0 → 1.1.2
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 +1464 -1163
- package/dist/blocks.cjs.map +1 -1
- package/dist/blocks.d.cts +146 -12
- package/dist/blocks.d.ts +146 -12
- package/dist/blocks.js +1294 -988
- 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.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as ColumnMobileRole, f as ColumnPin, g as CreateSelectColumnOptions, D as DataTable, h as DataTableAlign, i as DataTableButtonFilter, j as DataTableColumnAlign, k as DataTableColumnDef, l as DataTableColumnHeader, m as DataTableColumnHeaderProps, n as DataTableExpand, o as DataTableFacetedFilter, p as DataTableFacetedFilterProps, q as DataTableField, r as DataTableFilterMeta, s as DataTableFilterOptions, t as DataTableGroupBy, u as DataTableManual, v as DataTablePagination, w as DataTablePaginationProps, x as DataTableProps, y as DataTableRowAction, z as DataTableRowLinkProps, A as DataTableRowTone, E as DataTableSearchOptions, G as DataTableState, H as DataTableTabsFilter, I as DataTableViewOptions, J as DataTableViewOptionsProps, R as ROW_ACTIONS_COLUMN_ID, Q as RowActionLink, S as SELECT_COLUMN_ID, T as TableCellBadge, U as TableCellBadgeProps, W as TableCellLeadText, X as TableCellLeadTextProps, Y as TableCellProgress, Z as TableCellProgressProps, _ as TableCellSize, $ as TableCellText, a0 as TableCellTextProps, a2 as createSelectColumn, a3 as fieldToColumn, aa as isFieldColumn } from './data-table-
|
|
1
|
+
export { C as ColumnMobileRole, f as ColumnPin, g as CreateSelectColumnOptions, D as DataTable, h as DataTableAlign, i as DataTableButtonFilter, j as DataTableColumnAlign, k as DataTableColumnDef, l as DataTableColumnHeader, m as DataTableColumnHeaderProps, n as DataTableExpand, o as DataTableFacetedFilter, p as DataTableFacetedFilterProps, q as DataTableField, r as DataTableFilterMeta, s as DataTableFilterOptions, t as DataTableGroupBy, u as DataTableManual, v as DataTablePagination, w as DataTablePaginationProps, x as DataTableProps, y as DataTableRowAction, z as DataTableRowLinkProps, A as DataTableRowTone, E as DataTableSearchOptions, G as DataTableState, H as DataTableTabsFilter, I as DataTableViewOptions, J as DataTableViewOptionsProps, R as ROW_ACTIONS_COLUMN_ID, Q as RowActionLink, S as SELECT_COLUMN_ID, T as TableCellBadge, U as TableCellBadgeProps, W as TableCellLeadText, X as TableCellLeadTextProps, Y as TableCellProgress, Z as TableCellProgressProps, _ as TableCellSize, $ as TableCellText, a0 as TableCellTextProps, a2 as createSelectColumn, a3 as fieldToColumn, aa as isFieldColumn } from './data-table-CcIINjPg.js';
|
|
2
2
|
export { CellContext, ColumnDef, ColumnFiltersState, Column as DataTableColumn, Table as DataTableInstance, HeaderContext, PaginationState, Row, RowSelectionState, SortingState, VisibilityState, createColumnHelper } from '@tanstack/react-table';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'radix-ui';
|
package/dist/data-table.js
CHANGED
|
@@ -119,6 +119,7 @@ import {
|
|
|
119
119
|
ChevronsLeftIcon,
|
|
120
120
|
ChevronsRightIcon,
|
|
121
121
|
ChevronsUpDownIcon,
|
|
122
|
+
EyeIcon,
|
|
122
123
|
EyeOffIcon,
|
|
123
124
|
PinIcon,
|
|
124
125
|
PinOffIcon,
|
|
@@ -229,28 +230,60 @@ function createSelectColumn(options = {}) {
|
|
|
229
230
|
meta: { width: "48px", interactive: true, mobile: "hidden", label: "Select" }
|
|
230
231
|
};
|
|
231
232
|
}
|
|
233
|
+
function hideableColumns(table) {
|
|
234
|
+
return table.getAllLeafColumns().filter((column) => typeof column.accessorFn !== "undefined" && column.getCanHide() && !column.id.startsWith("__"));
|
|
235
|
+
}
|
|
232
236
|
function DataTableViewOptions({ table, label = "View" }) {
|
|
233
|
-
const columns = table
|
|
237
|
+
const columns = hideableColumns(table);
|
|
234
238
|
if (columns.length === 0) return null;
|
|
239
|
+
const hidden = columns.filter((column) => !column.getIsVisible()).length;
|
|
235
240
|
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
236
|
-
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
242
|
+
Button,
|
|
243
|
+
{
|
|
244
|
+
variant: "outline",
|
|
245
|
+
size: "sm",
|
|
246
|
+
className: "ms-auto h-8",
|
|
247
|
+
"aria-label": hidden ? `${label}, ${hidden} ${hidden === 1 ? "column" : "columns"} hidden` : void 0,
|
|
248
|
+
children: [
|
|
249
|
+
/* @__PURE__ */ jsx(Settings2Icon, {}),
|
|
250
|
+
label,
|
|
251
|
+
hidden > 0 && /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "h-5 min-w-5 rounded-full px-1.5 font-normal tabular-nums", children: hidden })
|
|
252
|
+
]
|
|
253
|
+
}
|
|
254
|
+
) }),
|
|
255
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "min-w-[180px]", children: [
|
|
241
256
|
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: "Toggle columns" }),
|
|
242
257
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
243
258
|
columns.map((column) => /* @__PURE__ */ jsx(
|
|
244
259
|
DropdownMenuCheckboxItem,
|
|
245
260
|
{
|
|
246
|
-
className: "capitalize",
|
|
247
261
|
checked: column.getIsVisible(),
|
|
248
262
|
onCheckedChange: (visible) => column.toggleVisibility(visible),
|
|
249
263
|
onSelect: (event) => event.preventDefault(),
|
|
250
264
|
children: columnLabel(column)
|
|
251
265
|
},
|
|
252
266
|
column.id
|
|
253
|
-
))
|
|
267
|
+
)),
|
|
268
|
+
hidden > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
269
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
270
|
+
/* @__PURE__ */ jsxs(
|
|
271
|
+
DropdownMenuItem,
|
|
272
|
+
{
|
|
273
|
+
onClick: () => (
|
|
274
|
+
// One update: toggling the columns one by one would each start from the same state.
|
|
275
|
+
table.setColumnVisibility((visibility) => ({
|
|
276
|
+
...visibility,
|
|
277
|
+
...Object.fromEntries(columns.map((column) => [column.id, true]))
|
|
278
|
+
}))
|
|
279
|
+
),
|
|
280
|
+
children: [
|
|
281
|
+
/* @__PURE__ */ jsx(EyeIcon, {}),
|
|
282
|
+
"Show all columns"
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
)
|
|
286
|
+
] })
|
|
254
287
|
] })
|
|
255
288
|
] });
|
|
256
289
|
}
|
|
@@ -347,6 +380,7 @@ function DataTablePagination({
|
|
|
347
380
|
}
|
|
348
381
|
|
|
349
382
|
// src/components/lists/data-table-fields.tsx
|
|
383
|
+
import { createContext, useContext } from "react";
|
|
350
384
|
import { CheckIcon, MoreHorizontalIcon, PlusCircleIcon } from "lucide-react";
|
|
351
385
|
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
352
386
|
var ROW_ACTIONS_COLUMN_ID = "actions";
|
|
@@ -409,6 +443,7 @@ function fieldToColumn(field, format = {}) {
|
|
|
409
443
|
options: typeof field.filter === "object" ? field.filter.options : void 0,
|
|
410
444
|
variant: typeof field.filter === "object" && field.filter.variant || "menu",
|
|
411
445
|
allLabel: typeof field.filter === "object" && field.filter.allLabel || "All",
|
|
446
|
+
disabled: typeof field.filter === "object" ? field.filter.disabled : void 0,
|
|
412
447
|
describe: describeFor(field)
|
|
413
448
|
} : void 0;
|
|
414
449
|
const mobile = field.mobile ?? (field.type === "avatar" ? "title" : field.type === "status" ? "status" : void 0);
|
|
@@ -548,20 +583,31 @@ var DOT = {
|
|
|
548
583
|
slate: "bg-badge-dot-slate",
|
|
549
584
|
violet: "bg-badge-dot-violet"
|
|
550
585
|
};
|
|
551
|
-
|
|
586
|
+
var DataTableFacetsContext = createContext({ manual: false });
|
|
587
|
+
function useFacets(column) {
|
|
588
|
+
const server = useContext(DataTableFacetsContext);
|
|
552
589
|
const meta = column.columnDef.meta?.filter;
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
590
|
+
let counts;
|
|
591
|
+
let total;
|
|
592
|
+
if (server.manual) {
|
|
593
|
+
const own = server.counts?.[column.id];
|
|
594
|
+
counts = own ? new Map(Object.entries(own)) : null;
|
|
595
|
+
total = own ? Object.values(own).reduce((sum, n) => sum + n, 0) : void 0;
|
|
596
|
+
} else {
|
|
597
|
+
counts = /* @__PURE__ */ new Map();
|
|
598
|
+
for (const row of column.getFacetedRowModel().rows) {
|
|
599
|
+
if (row.getIsGrouped()) continue;
|
|
600
|
+
for (const value of filterValues(row.getValue(column.id))) counts.set(value, (counts.get(value) ?? 0) + 1);
|
|
601
|
+
}
|
|
602
|
+
total = column.getFacetedRowModel().rows.filter((row) => !row.getIsGrouped()).length;
|
|
557
603
|
}
|
|
558
|
-
const
|
|
604
|
+
const known = counts ? [...counts.keys()] : [...new Set(column.getFacetedRowModel().rows.flatMap((row) => filterValues(row.getValue(column.id))))];
|
|
605
|
+
const values = meta?.options ?? known.sort((a, b) => a.localeCompare(b, void 0, { numeric: true }));
|
|
559
606
|
const items = values.map((value) => ({
|
|
560
607
|
value,
|
|
561
608
|
...meta?.describe(value) ?? { label: value },
|
|
562
609
|
icon: void 0
|
|
563
610
|
}));
|
|
564
|
-
const total = column.getFacetedRowModel().rows.filter((row) => !row.getIsGrouped()).length;
|
|
565
611
|
return { counts, items, total };
|
|
566
612
|
}
|
|
567
613
|
function singleValue(column) {
|
|
@@ -573,10 +619,10 @@ function singleValue(column) {
|
|
|
573
619
|
}
|
|
574
620
|
function DataTableButtonFilter({ column, title }) {
|
|
575
621
|
const meta = column.columnDef.meta?.filter;
|
|
576
|
-
const { items } =
|
|
622
|
+
const { items } = useFacets(column);
|
|
577
623
|
const { value, set } = singleValue(column);
|
|
578
624
|
const heading = title ?? meta?.title ?? column.columnDef.meta?.label ?? column.id;
|
|
579
|
-
return /* @__PURE__ */ jsxs2(
|
|
625
|
+
return /* @__PURE__ */ jsx2(DisabledReason, { reason: meta?.disabled, children: /* @__PURE__ */ jsxs2(
|
|
580
626
|
ToggleGroup,
|
|
581
627
|
{
|
|
582
628
|
type: "single",
|
|
@@ -584,6 +630,7 @@ function DataTableButtonFilter({ column, title }) {
|
|
|
584
630
|
size: "sm",
|
|
585
631
|
spacing: 0,
|
|
586
632
|
"aria-label": heading,
|
|
633
|
+
disabled: Boolean(meta?.disabled),
|
|
587
634
|
value: value || "__all",
|
|
588
635
|
onValueChange: (next) => set(next === "__all" || !next ? "" : next),
|
|
589
636
|
children: [
|
|
@@ -594,28 +641,33 @@ function DataTableButtonFilter({ column, title }) {
|
|
|
594
641
|
] }, item.value))
|
|
595
642
|
]
|
|
596
643
|
}
|
|
597
|
-
);
|
|
644
|
+
) });
|
|
645
|
+
}
|
|
646
|
+
function DisabledReason({ reason, children }) {
|
|
647
|
+
if (typeof reason !== "string") return /* @__PURE__ */ jsx2(Fragment2, { children });
|
|
648
|
+
return /* @__PURE__ */ jsx2("span", { "data-slot": "data-table-disabled", title: reason, className: "inline-flex cursor-not-allowed", children });
|
|
598
649
|
}
|
|
599
650
|
function DataTableTabsFilter({ column, title }) {
|
|
600
651
|
const meta = column.columnDef.meta?.filter;
|
|
601
|
-
const { counts, items, total } =
|
|
652
|
+
const { counts, items, total } = useFacets(column);
|
|
602
653
|
const { value, set } = singleValue(column);
|
|
603
654
|
const heading = title ?? meta?.title ?? column.columnDef.meta?.label ?? column.id;
|
|
604
|
-
const count = (n) => /* @__PURE__ */ jsx2(Badge, { variant: "secondary", className: "ms-1 h-5 min-w-5 rounded-full px-1.5 font-normal tabular-nums", children: n ?? 0 });
|
|
605
|
-
|
|
606
|
-
|
|
655
|
+
const count = (n) => counts && /* @__PURE__ */ jsx2(Badge, { variant: "secondary", className: "ms-1 h-5 min-w-5 rounded-full px-1.5 font-normal tabular-nums", children: n ?? 0 });
|
|
656
|
+
const disabled = Boolean(meta?.disabled);
|
|
657
|
+
return /* @__PURE__ */ jsx2(DisabledReason, { reason: meta?.disabled, children: /* @__PURE__ */ jsx2(Tabs, { value: value || "__all", onValueChange: (next) => set(next === "__all" ? "" : next), children: /* @__PURE__ */ jsxs2(TabsList, { "aria-label": heading, children: [
|
|
658
|
+
/* @__PURE__ */ jsxs2(TabsTrigger, { value: "__all", disabled, children: [
|
|
607
659
|
meta?.allLabel ?? "All",
|
|
608
660
|
count(total)
|
|
609
661
|
] }),
|
|
610
|
-
items.map((item) => /* @__PURE__ */ jsxs2(TabsTrigger, { value: item.value, children: [
|
|
662
|
+
items.map((item) => /* @__PURE__ */ jsxs2(TabsTrigger, { value: item.value, disabled, children: [
|
|
611
663
|
item.label,
|
|
612
|
-
count(counts
|
|
664
|
+
count(counts?.get(item.value))
|
|
613
665
|
] }, item.value))
|
|
614
|
-
] }) });
|
|
666
|
+
] }) }) });
|
|
615
667
|
}
|
|
616
668
|
function DataTableFacetedFilter({ column, title, options }) {
|
|
617
669
|
const meta = column.columnDef.meta?.filter;
|
|
618
|
-
const { counts, items: facetItems } =
|
|
670
|
+
const { counts, items: facetItems } = useFacets(column);
|
|
619
671
|
const items = options ?? facetItems;
|
|
620
672
|
const selected = new Set(column.getFilterValue() ?? []);
|
|
621
673
|
const heading = title ?? meta?.title ?? column.columnDef.meta?.label ?? column.id;
|
|
@@ -625,8 +677,8 @@ function DataTableFacetedFilter({ column, title, options }) {
|
|
|
625
677
|
else next.add(value);
|
|
626
678
|
column.setFilterValue(next.size ? [...next] : void 0);
|
|
627
679
|
};
|
|
628
|
-
return /* @__PURE__ */ jsxs2(Popover, { children: [
|
|
629
|
-
/* @__PURE__ */ jsx2(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs2(Button, { variant: "outline", size: "sm", className: "h-8 border-dashed", children: [
|
|
680
|
+
return /* @__PURE__ */ jsx2(DisabledReason, { reason: meta?.disabled, children: /* @__PURE__ */ jsxs2(Popover, { children: [
|
|
681
|
+
/* @__PURE__ */ jsx2(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs2(Button, { variant: "outline", size: "sm", className: "h-8 border-dashed", disabled: Boolean(meta?.disabled), children: [
|
|
630
682
|
/* @__PURE__ */ jsx2(PlusCircleIcon, {}),
|
|
631
683
|
heading,
|
|
632
684
|
selected.size > 0 && /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
@@ -665,9 +717,9 @@ function DataTableFacetedFilter({ column, title, options }) {
|
|
|
665
717
|
item.color && /* @__PURE__ */ jsx2("span", { "aria-hidden": "true", className: cn("size-2 rounded-full", DOT[item.color]) }),
|
|
666
718
|
item.icon,
|
|
667
719
|
/* @__PURE__ */ jsx2("span", { children: item.label }),
|
|
668
|
-
counts
|
|
720
|
+
counts?.get(item.value) ? (
|
|
669
721
|
// A shortcut slot, so it takes the item's end (and the item's own check hides).
|
|
670
|
-
/* @__PURE__ */ jsx2(CommandShortcut, { className: "font-mono tracking-normal", children: counts
|
|
722
|
+
/* @__PURE__ */ jsx2(CommandShortcut, { className: "font-mono tracking-normal", children: counts?.get(item.value) })
|
|
671
723
|
) : null
|
|
672
724
|
]
|
|
673
725
|
},
|
|
@@ -680,11 +732,11 @@ function DataTableFacetedFilter({ column, title, options }) {
|
|
|
680
732
|
] })
|
|
681
733
|
] })
|
|
682
734
|
] }) })
|
|
683
|
-
] });
|
|
735
|
+
] }) });
|
|
684
736
|
}
|
|
685
737
|
|
|
686
738
|
// src/components/lists/data-table-features.tsx
|
|
687
|
-
import { createContext, useContext } from "react";
|
|
739
|
+
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
688
740
|
import { ChevronRightIcon as ChevronRightIcon2, GripVerticalIcon } from "lucide-react";
|
|
689
741
|
import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
690
742
|
var EXPAND_COLUMN_ID = "expand";
|
|
@@ -724,9 +776,9 @@ function expandColumn() {
|
|
|
724
776
|
};
|
|
725
777
|
}
|
|
726
778
|
var detailId = (rowId) => `data-table-detail-${rowId.replace(/[^\w-]/g, "_")}`;
|
|
727
|
-
var RowDragContext =
|
|
779
|
+
var RowDragContext = createContext2(null);
|
|
728
780
|
function DragHandle() {
|
|
729
|
-
const drag =
|
|
781
|
+
const drag = useContext2(RowDragContext);
|
|
730
782
|
if (!drag) return null;
|
|
731
783
|
return /* @__PURE__ */ jsx3(
|
|
732
784
|
Button,
|
|
@@ -1003,6 +1055,11 @@ function DataTable({
|
|
|
1003
1055
|
bordered = true,
|
|
1004
1056
|
className
|
|
1005
1057
|
}) {
|
|
1058
|
+
const fill = maxHeight === "fill";
|
|
1059
|
+
const facetCounts = useMemo(
|
|
1060
|
+
() => ({ manual: Boolean(manual.filtering), counts: manual.facets }),
|
|
1061
|
+
[manual.filtering, manual.facets]
|
|
1062
|
+
);
|
|
1006
1063
|
if (!label && !caption) {
|
|
1007
1064
|
devWarn('DataTable needs `label` or `caption`: an unnamed table is announced as just "table".');
|
|
1008
1065
|
}
|
|
@@ -1261,7 +1318,8 @@ function DataTable({
|
|
|
1261
1318
|
const filterColumns = table.getAllLeafColumns().filter((column) => column.columnDef.meta?.filter);
|
|
1262
1319
|
const tabsFilters = filterColumns.filter((column) => column.columnDef.meta?.filter?.variant === "tabs");
|
|
1263
1320
|
const isToolbarFilter = (id) => filterColumns.some((c) => c.id === id && c.columnDef.meta?.filter?.variant !== "tabs");
|
|
1264
|
-
const
|
|
1321
|
+
const viewMenu = showColumnMenu || hideableColumns(table).some((column) => !column.getIsVisible());
|
|
1322
|
+
const showToolbar = Boolean(search || toolbar || viewMenu || filterColumns.length > tabsFilters.length);
|
|
1265
1323
|
const reorderActive = reorderable && sorting.length === 0 && !filtering && !group;
|
|
1266
1324
|
const showPager = paginated && !error && table.getRowCount() > 0;
|
|
1267
1325
|
const view = {
|
|
@@ -1304,48 +1362,64 @@ function DataTable({
|
|
|
1304
1362
|
summary: (row) => groupSummary(row, group.summary ?? [], formatOf, format)
|
|
1305
1363
|
} : void 0
|
|
1306
1364
|
};
|
|
1307
|
-
return /* @__PURE__ */
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1365
|
+
return /* @__PURE__ */ jsx4(DataTableFacetsContext.Provider, { value: facetCounts, children: /* @__PURE__ */ jsxs4(
|
|
1366
|
+
"div",
|
|
1367
|
+
{
|
|
1368
|
+
"data-slot": "data-table",
|
|
1369
|
+
"data-fill": fill || void 0,
|
|
1370
|
+
className: cn("relative flex flex-col gap-4", fill && "h-full min-h-0 flex-1", className),
|
|
1371
|
+
children: [
|
|
1372
|
+
tabsFilters.length > 0 && /* @__PURE__ */ jsx4("div", { className: cn("flex shrink-0 flex-wrap items-center gap-2", !bordered && "px-4 pt-3"), children: tabsFilters.map((column) => /* @__PURE__ */ jsx4(DataTableTabsFilter, { column }, column.id)) }),
|
|
1373
|
+
showToolbar && /* @__PURE__ */ jsxs4("div", { className: cn("flex shrink-0 items-center justify-between gap-2", !bordered && "px-4 pt-3"), children: [
|
|
1374
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-1 flex-wrap items-center gap-2", children: [
|
|
1375
|
+
search && /* @__PURE__ */ jsx4(DisabledReason, { reason: search.disabled, children: /* @__PURE__ */ jsx4(
|
|
1376
|
+
Input,
|
|
1377
|
+
{
|
|
1378
|
+
type: "search",
|
|
1379
|
+
"aria-label": search.label ?? "Filter",
|
|
1380
|
+
placeholder: search.placeholder ?? "Filter...",
|
|
1381
|
+
value: searchValue,
|
|
1382
|
+
onChange: (event) => setSearchValue(event.target.value),
|
|
1383
|
+
disabled: Boolean(search.disabled),
|
|
1384
|
+
className: "h-8 w-[150px] lg:w-[250px]"
|
|
1385
|
+
}
|
|
1386
|
+
) }),
|
|
1387
|
+
filterColumns.map(
|
|
1388
|
+
(column) => column.columnDef.meta?.filter?.variant === "buttons" ? /* @__PURE__ */ jsx4(DataTableButtonFilter, { column }, column.id) : column.columnDef.meta?.filter?.variant === "tabs" ? null : /* @__PURE__ */ jsx4(DataTableFacetedFilter, { column }, column.id)
|
|
1389
|
+
),
|
|
1390
|
+
columnFilters.some((f) => isToolbarFilter(f.id)) && /* @__PURE__ */ jsxs4(
|
|
1391
|
+
Button,
|
|
1392
|
+
{
|
|
1393
|
+
variant: "ghost",
|
|
1394
|
+
size: "sm",
|
|
1395
|
+
onClick: () => table.setColumnFilters((current) => current.filter((f) => !isToolbarFilter(f.id))),
|
|
1396
|
+
children: [
|
|
1397
|
+
"Reset",
|
|
1398
|
+
/* @__PURE__ */ jsx4(XIcon2, {})
|
|
1399
|
+
]
|
|
1400
|
+
}
|
|
1401
|
+
),
|
|
1402
|
+
toolbar
|
|
1403
|
+
] }),
|
|
1404
|
+
viewMenu && /* @__PURE__ */ jsx4("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx4(DataTableViewOptions, { table }) })
|
|
1405
|
+
] }),
|
|
1406
|
+
/* @__PURE__ */ jsx4("p", { role: "status", "aria-live": "polite", className: "sr-only", children: filtering && !loading ? `${resultCount} ${resultCount === 1 ? "result" : "results"}` : "" }),
|
|
1407
|
+
/* @__PURE__ */ jsxs4(
|
|
1408
|
+
"div",
|
|
1327
1409
|
{
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
onClick: () => table.setColumnFilters((current) => current.filter((f) => !isToolbarFilter(f.id))),
|
|
1410
|
+
ref: wrapRef,
|
|
1411
|
+
className: cn("overflow-hidden bg-background", bordered && "rounded-md border", fill && "flex min-h-0 flex-1 flex-col"),
|
|
1331
1412
|
children: [
|
|
1332
|
-
"
|
|
1333
|
-
/* @__PURE__ */ jsx4(
|
|
1413
|
+
mode === "cards" && caption && /* @__PURE__ */ jsx4("div", { id: captionId, className: "shrink-0 px-4 pt-3 text-left text-sm text-muted-foreground", children: caption }),
|
|
1414
|
+
mode === "cards" ? maxHeight ? /* @__PURE__ */ jsx4(CardScroll, { label, maxHeight, children: /* @__PURE__ */ jsx4(CardList, { ...view }) }) : /* @__PURE__ */ jsx4(CardList, { ...view }) : /* @__PURE__ */ jsx4(TableView, { ...view }),
|
|
1415
|
+
footer && /* @__PURE__ */ jsx4("div", { className: "shrink-0 border-t p-2", children: footer })
|
|
1334
1416
|
]
|
|
1335
1417
|
}
|
|
1336
1418
|
),
|
|
1337
|
-
|
|
1338
|
-
]
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
/* @__PURE__ */ jsx4("p", { role: "status", "aria-live": "polite", className: "sr-only", children: filtering && !loading ? `${resultCount} ${resultCount === 1 ? "result" : "results"}` : "" }),
|
|
1342
|
-
/* @__PURE__ */ jsxs4("div", { ref: wrapRef, className: cn("overflow-hidden bg-background", bordered && "rounded-md border"), children: [
|
|
1343
|
-
mode === "cards" && caption && /* @__PURE__ */ jsx4("div", { id: captionId, className: "px-4 pt-3 text-left text-sm text-muted-foreground", children: caption }),
|
|
1344
|
-
mode === "cards" ? maxHeight ? /* @__PURE__ */ jsx4(CardScroll, { label, maxHeight, children: /* @__PURE__ */ jsx4(CardList, { ...view }) }) : /* @__PURE__ */ jsx4(CardList, { ...view }) : /* @__PURE__ */ jsx4(TableView, { ...view }),
|
|
1345
|
-
footer && /* @__PURE__ */ jsx4("div", { className: "border-t p-2", children: footer })
|
|
1346
|
-
] }),
|
|
1347
|
-
showPager && /* @__PURE__ */ jsx4("div", { className: cn(!bordered && "px-2 pb-3"), children: /* @__PURE__ */ jsx4(DataTablePagination, { table, pageSizeOptions }) })
|
|
1348
|
-
] });
|
|
1419
|
+
showPager && /* @__PURE__ */ jsx4("div", { className: cn("shrink-0", !bordered && "px-2 pb-3"), children: /* @__PURE__ */ jsx4(DataTablePagination, { table, pageSizeOptions }) })
|
|
1420
|
+
]
|
|
1421
|
+
}
|
|
1422
|
+
) });
|
|
1349
1423
|
}
|
|
1350
1424
|
var verticalOnly = ({ transform }) => ({ ...transform, x: 0 });
|
|
1351
1425
|
function titleColumnId(columns) {
|
|
@@ -1420,7 +1494,7 @@ function TableView({
|
|
|
1420
1494
|
const direction = scroll.overflowing && maxHeight && scroll.overflowingY ? "scrolls" : scroll.overflowing ? "scrolls horizontally" : "scrolls vertically";
|
|
1421
1495
|
const regionLabel = `${label ?? "Table"} (${direction})`;
|
|
1422
1496
|
const pinnedHeader = maxHeight ? clsx("sticky top-0 z-sticky bg-background", !scroll.atTop && "shadow-[inset_0_-1px_0_var(--border)]") : void 0;
|
|
1423
|
-
return /* @__PURE__ */ jsxs4("div", { className: "relative", children: [
|
|
1497
|
+
return /* @__PURE__ */ jsxs4("div", { className: cn("relative", maxHeight === "fill" && "flex min-h-0 flex-1 flex-col"), children: [
|
|
1424
1498
|
/* @__PURE__ */ jsx4(
|
|
1425
1499
|
"div",
|
|
1426
1500
|
{
|
|
@@ -1428,10 +1502,11 @@ function TableView({
|
|
|
1428
1502
|
onScroll: scroll.onScroll,
|
|
1429
1503
|
className: cn(
|
|
1430
1504
|
maxHeight ? "overflow-auto overscroll-contain" : "overflow-x-auto overscroll-x-contain",
|
|
1505
|
+
maxHeight === "fill" && "min-h-0 flex-1",
|
|
1431
1506
|
SCROLLBAR_CLASSES,
|
|
1432
1507
|
scrolls && FOCUS_RING_INSET
|
|
1433
1508
|
),
|
|
1434
|
-
style: maxHeight ? { maxHeight } : void 0,
|
|
1509
|
+
style: maxHeight && maxHeight !== "fill" ? { maxHeight } : void 0,
|
|
1435
1510
|
...scrolls ? { role: "region", tabIndex: 0, "aria-label": regionLabel } : {},
|
|
1436
1511
|
children: /* @__PURE__ */ jsx4(
|
|
1437
1512
|
DndWrapper,
|
|
@@ -1820,13 +1895,14 @@ function ResizeHandle({
|
|
|
1820
1895
|
}
|
|
1821
1896
|
function CardScroll({ label, maxHeight, children }) {
|
|
1822
1897
|
const scroll = useScrollEdges();
|
|
1898
|
+
const fill = maxHeight === "fill";
|
|
1823
1899
|
return /* @__PURE__ */ jsx4(
|
|
1824
1900
|
"div",
|
|
1825
1901
|
{
|
|
1826
1902
|
ref: scroll.ref,
|
|
1827
1903
|
onScroll: scroll.onScroll,
|
|
1828
|
-
style: { maxHeight },
|
|
1829
|
-
className: cn("overflow-y-auto overscroll-contain", SCROLLBAR_CLASSES, scroll.overflowingY && FOCUS_RING_INSET),
|
|
1904
|
+
style: fill ? void 0 : { maxHeight },
|
|
1905
|
+
className: cn("overflow-y-auto overscroll-contain", fill && "min-h-0 flex-1", SCROLLBAR_CLASSES, scroll.overflowingY && FOCUS_RING_INSET),
|
|
1830
1906
|
...scroll.overflowingY ? { role: "region", tabIndex: 0, "aria-label": `${label ?? "Table"} (scrolls vertically)` } : {},
|
|
1831
1907
|
children
|
|
1832
1908
|
}
|