@platned/ui 1.0.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/README.md +30 -7
- package/dist/blocks-charts.cjs +1 -0
- package/dist/blocks-charts.cjs.map +1 -1
- package/dist/blocks-charts.js +2 -0
- package/dist/blocks-charts.js.map +1 -1
- package/dist/blocks.cjs +282 -186
- package/dist/blocks.cjs.map +1 -1
- package/dist/blocks.d.cts +85 -5
- package/dist/blocks.d.ts +85 -5
- package/dist/blocks.js +280 -169
- package/dist/blocks.js.map +1 -1
- package/dist/chart.cjs +1 -0
- package/dist/chart.cjs.map +1 -1
- package/dist/chart.d.ts +1 -1
- package/dist/chart.js +2 -1
- package/dist/chart.js.map +1 -1
- package/dist/{chunk-327NSKZW.js → chunk-6BJ3OMUZ.js} +4 -3
- package/dist/{chunk-327NSKZW.js.map → chunk-6BJ3OMUZ.js.map} +1 -1
- package/dist/{chunk-GJJWRZ4B.js → chunk-7RXFHQL5.js} +4 -3
- package/dist/{chunk-GJJWRZ4B.js.map → chunk-7RXFHQL5.js.map} +1 -1
- package/dist/{chunk-2L5XAYNK.js → chunk-MJC4A7I4.js} +3 -1
- package/dist/{chunk-2L5XAYNK.js.map → chunk-MJC4A7I4.js.map} +1 -1
- package/dist/{chunk-WGCAQEZ4.js → chunk-QYFD7KIK.js} +3 -2
- package/dist/{chunk-WGCAQEZ4.js.map → chunk-QYFD7KIK.js.map} +1 -1
- package/dist/code-block-highlight.cjs +1 -0
- package/dist/code-block-highlight.cjs.map +1 -1
- package/dist/code-block-highlight.js +4 -3
- package/dist/code-block-highlight.js.map +1 -1
- package/dist/{data-table-Dec6t8NO.d.ts → data-table-CcIINjPg.d.ts} +30 -3
- package/dist/data-table.cjs +200 -124
- package/dist/data-table.cjs.map +1 -1
- package/dist/data-table.d.ts +1 -1
- package/dist/data-table.js +156 -79
- package/dist/data-table.js.map +1 -1
- package/dist/index.cjs +10632 -7124
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +204 -8
- package/dist/index.js +5933 -2507
- package/dist/index.js.map +1 -1
- package/dist/map.cjs +1 -0
- package/dist/map.cjs.map +1 -1
- package/dist/map.d.cts +2 -0
- package/dist/map.d.ts +2 -0
- package/dist/map.js +6 -0
- package/dist/map.js.map +1 -1
- package/package.json +2 -7
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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import {
|
|
2
3
|
Badge,
|
|
3
4
|
Checkbox,
|
|
@@ -47,13 +48,13 @@ import {
|
|
|
47
48
|
useElementWidth,
|
|
48
49
|
useFormat,
|
|
49
50
|
valueLabel
|
|
50
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-6BJ3OMUZ.js";
|
|
51
52
|
import {
|
|
52
53
|
Button
|
|
53
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-QYFD7KIK.js";
|
|
54
55
|
import {
|
|
55
56
|
cn
|
|
56
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-MJC4A7I4.js";
|
|
57
58
|
|
|
58
59
|
// src/components/lists/data-table.tsx
|
|
59
60
|
import {
|
|
@@ -118,6 +119,7 @@ import {
|
|
|
118
119
|
ChevronsLeftIcon,
|
|
119
120
|
ChevronsRightIcon,
|
|
120
121
|
ChevronsUpDownIcon,
|
|
122
|
+
EyeIcon,
|
|
121
123
|
EyeOffIcon,
|
|
122
124
|
PinIcon,
|
|
123
125
|
PinOffIcon,
|
|
@@ -228,28 +230,60 @@ function createSelectColumn(options = {}) {
|
|
|
228
230
|
meta: { width: "48px", interactive: true, mobile: "hidden", label: "Select" }
|
|
229
231
|
};
|
|
230
232
|
}
|
|
233
|
+
function hideableColumns(table) {
|
|
234
|
+
return table.getAllLeafColumns().filter((column) => typeof column.accessorFn !== "undefined" && column.getCanHide() && !column.id.startsWith("__"));
|
|
235
|
+
}
|
|
231
236
|
function DataTableViewOptions({ table, label = "View" }) {
|
|
232
|
-
const columns = table
|
|
237
|
+
const columns = hideableColumns(table);
|
|
233
238
|
if (columns.length === 0) return null;
|
|
239
|
+
const hidden = columns.filter((column) => !column.getIsVisible()).length;
|
|
234
240
|
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
235
|
-
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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: [
|
|
240
256
|
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: "Toggle columns" }),
|
|
241
257
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
242
258
|
columns.map((column) => /* @__PURE__ */ jsx(
|
|
243
259
|
DropdownMenuCheckboxItem,
|
|
244
260
|
{
|
|
245
|
-
className: "capitalize",
|
|
246
261
|
checked: column.getIsVisible(),
|
|
247
262
|
onCheckedChange: (visible) => column.toggleVisibility(visible),
|
|
248
263
|
onSelect: (event) => event.preventDefault(),
|
|
249
264
|
children: columnLabel(column)
|
|
250
265
|
},
|
|
251
266
|
column.id
|
|
252
|
-
))
|
|
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
|
+
] })
|
|
253
287
|
] })
|
|
254
288
|
] });
|
|
255
289
|
}
|
|
@@ -346,6 +380,7 @@ function DataTablePagination({
|
|
|
346
380
|
}
|
|
347
381
|
|
|
348
382
|
// src/components/lists/data-table-fields.tsx
|
|
383
|
+
import { createContext, useContext } from "react";
|
|
349
384
|
import { CheckIcon, MoreHorizontalIcon, PlusCircleIcon } from "lucide-react";
|
|
350
385
|
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
351
386
|
var ROW_ACTIONS_COLUMN_ID = "actions";
|
|
@@ -408,6 +443,7 @@ function fieldToColumn(field, format = {}) {
|
|
|
408
443
|
options: typeof field.filter === "object" ? field.filter.options : void 0,
|
|
409
444
|
variant: typeof field.filter === "object" && field.filter.variant || "menu",
|
|
410
445
|
allLabel: typeof field.filter === "object" && field.filter.allLabel || "All",
|
|
446
|
+
disabled: typeof field.filter === "object" ? field.filter.disabled : void 0,
|
|
411
447
|
describe: describeFor(field)
|
|
412
448
|
} : void 0;
|
|
413
449
|
const mobile = field.mobile ?? (field.type === "avatar" ? "title" : field.type === "status" ? "status" : void 0);
|
|
@@ -547,20 +583,31 @@ var DOT = {
|
|
|
547
583
|
slate: "bg-badge-dot-slate",
|
|
548
584
|
violet: "bg-badge-dot-violet"
|
|
549
585
|
};
|
|
550
|
-
|
|
586
|
+
var DataTableFacetsContext = createContext({ manual: false });
|
|
587
|
+
function useFacets(column) {
|
|
588
|
+
const server = useContext(DataTableFacetsContext);
|
|
551
589
|
const meta = column.columnDef.meta?.filter;
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
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;
|
|
556
603
|
}
|
|
557
|
-
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 }));
|
|
558
606
|
const items = values.map((value) => ({
|
|
559
607
|
value,
|
|
560
608
|
...meta?.describe(value) ?? { label: value },
|
|
561
609
|
icon: void 0
|
|
562
610
|
}));
|
|
563
|
-
const total = column.getFacetedRowModel().rows.filter((row) => !row.getIsGrouped()).length;
|
|
564
611
|
return { counts, items, total };
|
|
565
612
|
}
|
|
566
613
|
function singleValue(column) {
|
|
@@ -572,10 +619,10 @@ function singleValue(column) {
|
|
|
572
619
|
}
|
|
573
620
|
function DataTableButtonFilter({ column, title }) {
|
|
574
621
|
const meta = column.columnDef.meta?.filter;
|
|
575
|
-
const { items } =
|
|
622
|
+
const { items } = useFacets(column);
|
|
576
623
|
const { value, set } = singleValue(column);
|
|
577
624
|
const heading = title ?? meta?.title ?? column.columnDef.meta?.label ?? column.id;
|
|
578
|
-
return /* @__PURE__ */ jsxs2(
|
|
625
|
+
return /* @__PURE__ */ jsx2(DisabledReason, { reason: meta?.disabled, children: /* @__PURE__ */ jsxs2(
|
|
579
626
|
ToggleGroup,
|
|
580
627
|
{
|
|
581
628
|
type: "single",
|
|
@@ -583,6 +630,7 @@ function DataTableButtonFilter({ column, title }) {
|
|
|
583
630
|
size: "sm",
|
|
584
631
|
spacing: 0,
|
|
585
632
|
"aria-label": heading,
|
|
633
|
+
disabled: Boolean(meta?.disabled),
|
|
586
634
|
value: value || "__all",
|
|
587
635
|
onValueChange: (next) => set(next === "__all" || !next ? "" : next),
|
|
588
636
|
children: [
|
|
@@ -593,28 +641,33 @@ function DataTableButtonFilter({ column, title }) {
|
|
|
593
641
|
] }, item.value))
|
|
594
642
|
]
|
|
595
643
|
}
|
|
596
|
-
);
|
|
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 });
|
|
597
649
|
}
|
|
598
650
|
function DataTableTabsFilter({ column, title }) {
|
|
599
651
|
const meta = column.columnDef.meta?.filter;
|
|
600
|
-
const { counts, items, total } =
|
|
652
|
+
const { counts, items, total } = useFacets(column);
|
|
601
653
|
const { value, set } = singleValue(column);
|
|
602
654
|
const heading = title ?? meta?.title ?? column.columnDef.meta?.label ?? column.id;
|
|
603
|
-
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 });
|
|
604
|
-
|
|
605
|
-
|
|
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: [
|
|
606
659
|
meta?.allLabel ?? "All",
|
|
607
660
|
count(total)
|
|
608
661
|
] }),
|
|
609
|
-
items.map((item) => /* @__PURE__ */ jsxs2(TabsTrigger, { value: item.value, children: [
|
|
662
|
+
items.map((item) => /* @__PURE__ */ jsxs2(TabsTrigger, { value: item.value, disabled, children: [
|
|
610
663
|
item.label,
|
|
611
|
-
count(counts
|
|
664
|
+
count(counts?.get(item.value))
|
|
612
665
|
] }, item.value))
|
|
613
|
-
] }) });
|
|
666
|
+
] }) }) });
|
|
614
667
|
}
|
|
615
668
|
function DataTableFacetedFilter({ column, title, options }) {
|
|
616
669
|
const meta = column.columnDef.meta?.filter;
|
|
617
|
-
const { counts, items: facetItems } =
|
|
670
|
+
const { counts, items: facetItems } = useFacets(column);
|
|
618
671
|
const items = options ?? facetItems;
|
|
619
672
|
const selected = new Set(column.getFilterValue() ?? []);
|
|
620
673
|
const heading = title ?? meta?.title ?? column.columnDef.meta?.label ?? column.id;
|
|
@@ -624,8 +677,8 @@ function DataTableFacetedFilter({ column, title, options }) {
|
|
|
624
677
|
else next.add(value);
|
|
625
678
|
column.setFilterValue(next.size ? [...next] : void 0);
|
|
626
679
|
};
|
|
627
|
-
return /* @__PURE__ */ jsxs2(Popover, { children: [
|
|
628
|
-
/* @__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: [
|
|
629
682
|
/* @__PURE__ */ jsx2(PlusCircleIcon, {}),
|
|
630
683
|
heading,
|
|
631
684
|
selected.size > 0 && /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
@@ -664,9 +717,9 @@ function DataTableFacetedFilter({ column, title, options }) {
|
|
|
664
717
|
item.color && /* @__PURE__ */ jsx2("span", { "aria-hidden": "true", className: cn("size-2 rounded-full", DOT[item.color]) }),
|
|
665
718
|
item.icon,
|
|
666
719
|
/* @__PURE__ */ jsx2("span", { children: item.label }),
|
|
667
|
-
counts
|
|
720
|
+
counts?.get(item.value) ? (
|
|
668
721
|
// A shortcut slot, so it takes the item's end (and the item's own check hides).
|
|
669
|
-
/* @__PURE__ */ jsx2(CommandShortcut, { className: "font-mono tracking-normal", children: counts
|
|
722
|
+
/* @__PURE__ */ jsx2(CommandShortcut, { className: "font-mono tracking-normal", children: counts?.get(item.value) })
|
|
670
723
|
) : null
|
|
671
724
|
]
|
|
672
725
|
},
|
|
@@ -679,11 +732,11 @@ function DataTableFacetedFilter({ column, title, options }) {
|
|
|
679
732
|
] })
|
|
680
733
|
] })
|
|
681
734
|
] }) })
|
|
682
|
-
] });
|
|
735
|
+
] }) });
|
|
683
736
|
}
|
|
684
737
|
|
|
685
738
|
// src/components/lists/data-table-features.tsx
|
|
686
|
-
import { createContext, useContext } from "react";
|
|
739
|
+
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
687
740
|
import { ChevronRightIcon as ChevronRightIcon2, GripVerticalIcon } from "lucide-react";
|
|
688
741
|
import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
689
742
|
var EXPAND_COLUMN_ID = "expand";
|
|
@@ -723,9 +776,9 @@ function expandColumn() {
|
|
|
723
776
|
};
|
|
724
777
|
}
|
|
725
778
|
var detailId = (rowId) => `data-table-detail-${rowId.replace(/[^\w-]/g, "_")}`;
|
|
726
|
-
var RowDragContext =
|
|
779
|
+
var RowDragContext = createContext2(null);
|
|
727
780
|
function DragHandle() {
|
|
728
|
-
const drag =
|
|
781
|
+
const drag = useContext2(RowDragContext);
|
|
729
782
|
if (!drag) return null;
|
|
730
783
|
return /* @__PURE__ */ jsx3(
|
|
731
784
|
Button,
|
|
@@ -1002,6 +1055,11 @@ function DataTable({
|
|
|
1002
1055
|
bordered = true,
|
|
1003
1056
|
className
|
|
1004
1057
|
}) {
|
|
1058
|
+
const fill = maxHeight === "fill";
|
|
1059
|
+
const facetCounts = useMemo(
|
|
1060
|
+
() => ({ manual: Boolean(manual.filtering), counts: manual.facets }),
|
|
1061
|
+
[manual.filtering, manual.facets]
|
|
1062
|
+
);
|
|
1005
1063
|
if (!label && !caption) {
|
|
1006
1064
|
devWarn('DataTable needs `label` or `caption`: an unnamed table is announced as just "table".');
|
|
1007
1065
|
}
|
|
@@ -1260,7 +1318,8 @@ function DataTable({
|
|
|
1260
1318
|
const filterColumns = table.getAllLeafColumns().filter((column) => column.columnDef.meta?.filter);
|
|
1261
1319
|
const tabsFilters = filterColumns.filter((column) => column.columnDef.meta?.filter?.variant === "tabs");
|
|
1262
1320
|
const isToolbarFilter = (id) => filterColumns.some((c) => c.id === id && c.columnDef.meta?.filter?.variant !== "tabs");
|
|
1263
|
-
const
|
|
1321
|
+
const viewMenu = showColumnMenu || hideableColumns(table).some((column) => !column.getIsVisible());
|
|
1322
|
+
const showToolbar = Boolean(search || toolbar || viewMenu || filterColumns.length > tabsFilters.length);
|
|
1264
1323
|
const reorderActive = reorderable && sorting.length === 0 && !filtering && !group;
|
|
1265
1324
|
const showPager = paginated && !error && table.getRowCount() > 0;
|
|
1266
1325
|
const view = {
|
|
@@ -1303,48 +1362,64 @@ function DataTable({
|
|
|
1303
1362
|
summary: (row) => groupSummary(row, group.summary ?? [], formatOf, format)
|
|
1304
1363
|
} : void 0
|
|
1305
1364
|
};
|
|
1306
|
-
return /* @__PURE__ */
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
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",
|
|
1326
1409
|
{
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
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"),
|
|
1330
1412
|
children: [
|
|
1331
|
-
"
|
|
1332
|
-
/* @__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 })
|
|
1333
1416
|
]
|
|
1334
1417
|
}
|
|
1335
1418
|
),
|
|
1336
|
-
|
|
1337
|
-
]
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
/* @__PURE__ */ jsx4("p", { role: "status", "aria-live": "polite", className: "sr-only", children: filtering && !loading ? `${resultCount} ${resultCount === 1 ? "result" : "results"}` : "" }),
|
|
1341
|
-
/* @__PURE__ */ jsxs4("div", { ref: wrapRef, className: cn("overflow-hidden bg-background", bordered && "rounded-md border"), children: [
|
|
1342
|
-
mode === "cards" && caption && /* @__PURE__ */ jsx4("div", { id: captionId, className: "px-4 pt-3 text-left text-sm text-muted-foreground", children: caption }),
|
|
1343
|
-
mode === "cards" ? maxHeight ? /* @__PURE__ */ jsx4(CardScroll, { label, maxHeight, children: /* @__PURE__ */ jsx4(CardList, { ...view }) }) : /* @__PURE__ */ jsx4(CardList, { ...view }) : /* @__PURE__ */ jsx4(TableView, { ...view }),
|
|
1344
|
-
footer && /* @__PURE__ */ jsx4("div", { className: "border-t p-2", children: footer })
|
|
1345
|
-
] }),
|
|
1346
|
-
showPager && /* @__PURE__ */ jsx4("div", { className: cn(!bordered && "px-2 pb-3"), children: /* @__PURE__ */ jsx4(DataTablePagination, { table, pageSizeOptions }) })
|
|
1347
|
-
] });
|
|
1419
|
+
showPager && /* @__PURE__ */ jsx4("div", { className: cn("shrink-0", !bordered && "px-2 pb-3"), children: /* @__PURE__ */ jsx4(DataTablePagination, { table, pageSizeOptions }) })
|
|
1420
|
+
]
|
|
1421
|
+
}
|
|
1422
|
+
) });
|
|
1348
1423
|
}
|
|
1349
1424
|
var verticalOnly = ({ transform }) => ({ ...transform, x: 0 });
|
|
1350
1425
|
function titleColumnId(columns) {
|
|
@@ -1419,7 +1494,7 @@ function TableView({
|
|
|
1419
1494
|
const direction = scroll.overflowing && maxHeight && scroll.overflowingY ? "scrolls" : scroll.overflowing ? "scrolls horizontally" : "scrolls vertically";
|
|
1420
1495
|
const regionLabel = `${label ?? "Table"} (${direction})`;
|
|
1421
1496
|
const pinnedHeader = maxHeight ? clsx("sticky top-0 z-sticky bg-background", !scroll.atTop && "shadow-[inset_0_-1px_0_var(--border)]") : void 0;
|
|
1422
|
-
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: [
|
|
1423
1498
|
/* @__PURE__ */ jsx4(
|
|
1424
1499
|
"div",
|
|
1425
1500
|
{
|
|
@@ -1427,10 +1502,11 @@ function TableView({
|
|
|
1427
1502
|
onScroll: scroll.onScroll,
|
|
1428
1503
|
className: cn(
|
|
1429
1504
|
maxHeight ? "overflow-auto overscroll-contain" : "overflow-x-auto overscroll-x-contain",
|
|
1505
|
+
maxHeight === "fill" && "min-h-0 flex-1",
|
|
1430
1506
|
SCROLLBAR_CLASSES,
|
|
1431
1507
|
scrolls && FOCUS_RING_INSET
|
|
1432
1508
|
),
|
|
1433
|
-
style: maxHeight ? { maxHeight } : void 0,
|
|
1509
|
+
style: maxHeight && maxHeight !== "fill" ? { maxHeight } : void 0,
|
|
1434
1510
|
...scrolls ? { role: "region", tabIndex: 0, "aria-label": regionLabel } : {},
|
|
1435
1511
|
children: /* @__PURE__ */ jsx4(
|
|
1436
1512
|
DndWrapper,
|
|
@@ -1819,13 +1895,14 @@ function ResizeHandle({
|
|
|
1819
1895
|
}
|
|
1820
1896
|
function CardScroll({ label, maxHeight, children }) {
|
|
1821
1897
|
const scroll = useScrollEdges();
|
|
1898
|
+
const fill = maxHeight === "fill";
|
|
1822
1899
|
return /* @__PURE__ */ jsx4(
|
|
1823
1900
|
"div",
|
|
1824
1901
|
{
|
|
1825
1902
|
ref: scroll.ref,
|
|
1826
1903
|
onScroll: scroll.onScroll,
|
|
1827
|
-
style: { maxHeight },
|
|
1828
|
-
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),
|
|
1829
1906
|
...scroll.overflowingY ? { role: "region", tabIndex: 0, "aria-label": `${label ?? "Table"} (scrolls vertically)` } : {},
|
|
1830
1907
|
children
|
|
1831
1908
|
}
|