@coldsmirk/ledger-mantine 0.3.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +265 -122
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -46
- package/dist/index.d.ts +66 -46
- package/dist/index.js +266 -123
- package/dist/index.js.map +1 -1
- package/dist/{labels-ChBqD1II.d.ts → labels-D-6FCakH.d.cts} +16 -2
- package/dist/{labels-ChBqD1II.d.cts → labels-D-6FCakH.d.ts} +16 -2
- package/dist/locales.cjs +10 -0
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.d.cts +2 -3
- package/dist/locales.d.ts +2 -3
- package/dist/locales.js +10 -0
- package/dist/locales.js.map +1 -1
- package/dist/styles.css +26 -6
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { move } from "@dnd-kit/helpers";
|
|
3
3
|
import { DragDropProvider, PointerSensor, useDraggable } from "@dnd-kit/react";
|
|
4
4
|
import { useSortable } from "@dnd-kit/react/sortable";
|
|
5
|
-
import { ActionIcon, Box, Button, Center, Checkbox, CloseButton, EmptyState, Group, Loader, LoadingOverlay, MultiSelect, NumberInput, Pagination, Popover, Portal, Radio, ScrollArea, SegmentedControl, Select, Skeleton, Stack, Table, Text, TextInput, Tooltip, VisuallyHidden, createSafeContext, createVarsResolver, genericFactory, getRadius, getThemeColor, useMantineClassNamesPrefix, useMantineIsHeadless, useMantineStylesTransform, useMantineTheme, useMantineWithStaticClasses, useProps, useStyles } from "@mantine/core";
|
|
5
|
+
import { ActionIcon, Box, Button, Center, Checkbox, CloseButton, EmptyState, Group, Loader, LoadingOverlay, MultiSelect, NumberInput, Pagination, Popover, Portal, Radio, ScrollArea, SegmentedControl, Select, Skeleton, Stack, Table, Text, TextInput, Tooltip, VisuallyHidden, createSafeContext, createVarsResolver, genericFactory, getFontSize, getRadius, getThemeColor, useMantineClassNamesPrefix, useMantineIsHeadless, useMantineStylesTransform, useMantineTheme, useMantineWithStaticClasses, useProps, useStyles } from "@mantine/core";
|
|
6
6
|
import clsx from "clsx";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { AutoScroller, Cursor, PointerActivationConstraints, PreventSelection } from "@dnd-kit/dom";
|
|
@@ -28,30 +28,74 @@ import { DatePicker } from "@mantine/dates";
|
|
|
28
28
|
*/
|
|
29
29
|
const [DataTableProvider, useDataTableContext] = createSafeContext("DataTable parts must be rendered inside <DataTable>");
|
|
30
30
|
//#endregion
|
|
31
|
+
//#region src/size.ts
|
|
32
|
+
const SIZES = {
|
|
33
|
+
xs: {
|
|
34
|
+
verticalSpacing: 5,
|
|
35
|
+
horizontalSpacing: 8,
|
|
36
|
+
rowHeight: 31,
|
|
37
|
+
control: "xs",
|
|
38
|
+
glyph: 12,
|
|
39
|
+
injectedWidth: 36
|
|
40
|
+
},
|
|
41
|
+
sm: {
|
|
42
|
+
verticalSpacing: 7,
|
|
43
|
+
horizontalSpacing: 10,
|
|
44
|
+
rowHeight: 37,
|
|
45
|
+
control: "xs",
|
|
46
|
+
glyph: 14,
|
|
47
|
+
injectedWidth: 40
|
|
48
|
+
},
|
|
49
|
+
md: {
|
|
50
|
+
verticalSpacing: 8,
|
|
51
|
+
horizontalSpacing: 12,
|
|
52
|
+
rowHeight: 43,
|
|
53
|
+
control: "sm",
|
|
54
|
+
glyph: 16,
|
|
55
|
+
injectedWidth: 48
|
|
56
|
+
},
|
|
57
|
+
lg: {
|
|
58
|
+
verticalSpacing: 10,
|
|
59
|
+
horizontalSpacing: 16,
|
|
60
|
+
rowHeight: 51,
|
|
61
|
+
control: "md",
|
|
62
|
+
glyph: 18,
|
|
63
|
+
injectedWidth: 62
|
|
64
|
+
},
|
|
65
|
+
xl: {
|
|
66
|
+
verticalSpacing: 14,
|
|
67
|
+
horizontalSpacing: 20,
|
|
68
|
+
rowHeight: 61,
|
|
69
|
+
control: "lg",
|
|
70
|
+
glyph: 20,
|
|
71
|
+
injectedWidth: 76
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
//#endregion
|
|
31
75
|
//#region src/expander.tsx
|
|
32
76
|
/**
|
|
33
77
|
* The injected expander column: a per-row chevron (detail panels and sub-row trees share it)
|
|
34
78
|
* and an expand-all header affordance for trees. Clicks never reach `onRowClick`.
|
|
35
79
|
*/
|
|
36
80
|
function ExpanderHeaderCell({ table }) {
|
|
37
|
-
const { labels, icons, expansion } = useDataTableContext();
|
|
81
|
+
const { labels, icons, expansion, size } = useDataTableContext();
|
|
38
82
|
if (!table.options.getSubRows) return null;
|
|
39
83
|
const allExpanded = table.getIsAllRowsExpanded();
|
|
40
84
|
const canSomeExpand = table.getCanSomeRowsExpand();
|
|
41
85
|
return /* @__PURE__ */ jsx(ActionIcon, {
|
|
42
86
|
"aria-label": allExpanded ? labels.collapseAll : labels.expandAll,
|
|
43
87
|
"data-expanded": allExpanded || void 0,
|
|
44
|
-
size:
|
|
88
|
+
size: SIZES[size].control,
|
|
45
89
|
variant: "subtle",
|
|
46
90
|
onClick: (event) => {
|
|
47
91
|
event.stopPropagation();
|
|
48
92
|
expansion?.toggleAll(!allExpanded, canSomeExpand);
|
|
49
93
|
},
|
|
50
|
-
children: /* @__PURE__ */ jsx(icons.expandRow, {})
|
|
94
|
+
children: /* @__PURE__ */ jsx(icons.expandRow, { size: SIZES[size].glyph })
|
|
51
95
|
});
|
|
52
96
|
}
|
|
53
97
|
function ExpanderCell({ row }) {
|
|
54
|
-
const { labels, icons, expansion } = useDataTableContext();
|
|
98
|
+
const { labels, icons, expansion, size } = useDataTableContext();
|
|
55
99
|
const canExpand = row.getCanExpand();
|
|
56
100
|
if (!canExpand) return null;
|
|
57
101
|
const expanded = row.getIsExpanded();
|
|
@@ -59,13 +103,13 @@ function ExpanderCell({ row }) {
|
|
|
59
103
|
"aria-expanded": expanded,
|
|
60
104
|
"aria-label": expanded ? labels.collapseRow : labels.expandRow,
|
|
61
105
|
"data-expanded": expanded || void 0,
|
|
62
|
-
size:
|
|
106
|
+
size: SIZES[size].control,
|
|
63
107
|
variant: "subtle",
|
|
64
108
|
onClick: (event) => {
|
|
65
109
|
event.stopPropagation();
|
|
66
110
|
expansion?.toggle(row.id, expanded, canExpand);
|
|
67
111
|
},
|
|
68
|
-
children: /* @__PURE__ */ jsx(icons.expandRow, {})
|
|
112
|
+
children: /* @__PURE__ */ jsx(icons.expandRow, { size: SIZES[size].glyph })
|
|
69
113
|
});
|
|
70
114
|
}
|
|
71
115
|
//#endregion
|
|
@@ -492,7 +536,7 @@ function RowReorderOverlay({ session }) {
|
|
|
492
536
|
* why (docs/rows.md#row-ordering).
|
|
493
537
|
*/
|
|
494
538
|
function RowDragCell({ row, table }) {
|
|
495
|
-
const { labels, icons, rowReorderKeyboard } = useDataTableContext();
|
|
539
|
+
const { labels, icons, rowReorderKeyboard, size } = useDataTableContext();
|
|
496
540
|
const orderable = table.options.meta?.ledger?.rowOrdering.orderable === true;
|
|
497
541
|
const pinned = table.options.enableRowPinning === true && row.getIsPinned() !== false;
|
|
498
542
|
const { ref, isDragSource } = useDraggable({
|
|
@@ -550,13 +594,13 @@ function RowDragCell({ row, table }) {
|
|
|
550
594
|
"aria-label": labels.reorderRow,
|
|
551
595
|
"aria-pressed": lifted || void 0,
|
|
552
596
|
color: "gray",
|
|
553
|
-
size:
|
|
597
|
+
size: SIZES[size].control,
|
|
554
598
|
variant: "subtle",
|
|
555
599
|
onBlur: () => {
|
|
556
600
|
if (lifted) rowReorderKeyboard?.cancel();
|
|
557
601
|
},
|
|
558
602
|
onKeyDown: handleKeyDown,
|
|
559
|
-
children: /* @__PURE__ */ jsx(icons.reorderRow, { size:
|
|
603
|
+
children: /* @__PURE__ */ jsx(icons.reorderRow, { size: SIZES[size].glyph })
|
|
560
604
|
})
|
|
561
605
|
});
|
|
562
606
|
}
|
|
@@ -573,7 +617,7 @@ function RowDragCell({ row, table }) {
|
|
|
573
617
|
*/
|
|
574
618
|
function noop() {}
|
|
575
619
|
function SelectionHeaderCell({ table }) {
|
|
576
|
-
const { labels, selection } = useDataTableContext();
|
|
620
|
+
const { labels, selection, size } = useDataTableContext();
|
|
577
621
|
if (table.options.enableMultiRowSelection === false) return null;
|
|
578
622
|
const scope = table.options.meta?.ledger?.selectAllScope ?? "all";
|
|
579
623
|
const allSelected = scope === "page" ? table.getIsAllPageRowsSelected() : table.getIsAllRowsSelected();
|
|
@@ -582,7 +626,7 @@ function SelectionHeaderCell({ table }) {
|
|
|
582
626
|
"aria-label": labels.selectAllRows,
|
|
583
627
|
checked: allSelected,
|
|
584
628
|
indeterminate: !allSelected && someSelected,
|
|
585
|
-
size:
|
|
629
|
+
size: SIZES[size].control,
|
|
586
630
|
onChange: noop,
|
|
587
631
|
onClick: (event) => {
|
|
588
632
|
event.stopPropagation();
|
|
@@ -591,7 +635,7 @@ function SelectionHeaderCell({ table }) {
|
|
|
591
635
|
});
|
|
592
636
|
}
|
|
593
637
|
function SelectionCell({ row }) {
|
|
594
|
-
const { labels, instanceId, selection } = useDataTableContext();
|
|
638
|
+
const { labels, instanceId, selection, size } = useDataTableContext();
|
|
595
639
|
const selected = row.getIsSelected();
|
|
596
640
|
const select = (event) => {
|
|
597
641
|
event.stopPropagation();
|
|
@@ -602,7 +646,7 @@ function SelectionCell({ row }) {
|
|
|
602
646
|
checked: selected,
|
|
603
647
|
disabled: !row.getCanSelect(),
|
|
604
648
|
name: `${instanceId}-selection`,
|
|
605
|
-
size:
|
|
649
|
+
size: SIZES[size].control,
|
|
606
650
|
onChange: noop,
|
|
607
651
|
onClick: select
|
|
608
652
|
});
|
|
@@ -611,7 +655,7 @@ function SelectionCell({ row }) {
|
|
|
611
655
|
checked: selected,
|
|
612
656
|
disabled: !row.getCanSelect(),
|
|
613
657
|
indeterminate: !selected && row.getIsSomeSelected(),
|
|
614
|
-
size:
|
|
658
|
+
size: SIZES[size].control,
|
|
615
659
|
onChange: noop,
|
|
616
660
|
onClick: select
|
|
617
661
|
});
|
|
@@ -663,9 +707,6 @@ function buildColumns({ columns, withRowDrag, withSelection, withExpander, rowDr
|
|
|
663
707
|
const result = [];
|
|
664
708
|
if (withRowDrag) result.push(injectedColumn({
|
|
665
709
|
id: ROW_DRAG_COLUMN_ID,
|
|
666
|
-
size: 36,
|
|
667
|
-
minSize: 36,
|
|
668
|
-
maxSize: 36,
|
|
669
710
|
enableSorting: false,
|
|
670
711
|
enableHiding: false,
|
|
671
712
|
enableResizing: false,
|
|
@@ -680,9 +721,6 @@ function buildColumns({ columns, withRowDrag, withSelection, withExpander, rowDr
|
|
|
680
721
|
}, rowDragColumn));
|
|
681
722
|
if (withSelection) result.push(injectedColumn({
|
|
682
723
|
id: SELECTION_COLUMN_ID,
|
|
683
|
-
size: 40,
|
|
684
|
-
minSize: 40,
|
|
685
|
-
maxSize: 40,
|
|
686
724
|
enableSorting: false,
|
|
687
725
|
enableHiding: false,
|
|
688
726
|
enableResizing: false,
|
|
@@ -694,9 +732,6 @@ function buildColumns({ columns, withRowDrag, withSelection, withExpander, rowDr
|
|
|
694
732
|
}, selectionColumn));
|
|
695
733
|
if (withExpander) result.push(injectedColumn({
|
|
696
734
|
id: EXPANDER_COLUMN_ID,
|
|
697
|
-
size: 36,
|
|
698
|
-
minSize: 36,
|
|
699
|
-
maxSize: 36,
|
|
700
735
|
enableSorting: false,
|
|
701
736
|
enableHiding: false,
|
|
702
737
|
enableResizing: false,
|
|
@@ -1028,6 +1063,10 @@ function resolveIcons(icons) {
|
|
|
1028
1063
|
const defaultLabels = {
|
|
1029
1064
|
paginationSummary: (from, to, total) => `${from}–${to} of ${total}`,
|
|
1030
1065
|
rowsPerPage: "Rows per page",
|
|
1066
|
+
firstPage: "First page",
|
|
1067
|
+
previousPage: "Previous page",
|
|
1068
|
+
nextPage: "Next page",
|
|
1069
|
+
lastPage: "Last page",
|
|
1031
1070
|
selectAllRows: "Select all rows",
|
|
1032
1071
|
selectRow: "Select row",
|
|
1033
1072
|
selectedCount: (count) => `${count} selected`,
|
|
@@ -1056,6 +1095,12 @@ const defaultLabels = {
|
|
|
1056
1095
|
filterPlaceholder: "Filter…",
|
|
1057
1096
|
filterRangeMin: "Min",
|
|
1058
1097
|
filterRangeMax: "Max",
|
|
1098
|
+
previousMonth: "Previous month",
|
|
1099
|
+
nextMonth: "Next month",
|
|
1100
|
+
previousYear: "Previous year",
|
|
1101
|
+
nextYear: "Next year",
|
|
1102
|
+
previousDecade: "Previous decade",
|
|
1103
|
+
nextDecade: "Next decade",
|
|
1059
1104
|
searchPlaceholder: "Search…",
|
|
1060
1105
|
loading: "Loading",
|
|
1061
1106
|
empty: "No data",
|
|
@@ -1541,7 +1586,13 @@ const DEFAULT_PAGE_SIZE_OPTIONS = [
|
|
|
1541
1586
|
50,
|
|
1542
1587
|
100
|
|
1543
1588
|
];
|
|
1544
|
-
|
|
1589
|
+
const CONTROL_LABELS = {
|
|
1590
|
+
first: "firstPage",
|
|
1591
|
+
previous: "previousPage",
|
|
1592
|
+
next: "nextPage",
|
|
1593
|
+
last: "lastPage"
|
|
1594
|
+
};
|
|
1595
|
+
function PaginationBarCore({ table, labels, pageSizeOptions, size, className, style }) {
|
|
1545
1596
|
const pageSizeLabelId = useId();
|
|
1546
1597
|
const { pageIndex, pageSize } = table.atoms.pagination.get();
|
|
1547
1598
|
const total = table.getRowCount();
|
|
@@ -1556,8 +1607,8 @@ function PaginationBarCore({ table, labels, pageSizeOptions, className, style })
|
|
|
1556
1607
|
style,
|
|
1557
1608
|
wrap: "wrap",
|
|
1558
1609
|
children: [/* @__PURE__ */ jsx(Text, {
|
|
1559
|
-
c: "dimmed",
|
|
1560
|
-
size
|
|
1610
|
+
c: "var(--ledger-color-dimmed)",
|
|
1611
|
+
size,
|
|
1561
1612
|
children: labels.paginationSummary(from, to, total)
|
|
1562
1613
|
}), /* @__PURE__ */ jsxs(Group, {
|
|
1563
1614
|
gap: "md",
|
|
@@ -1566,21 +1617,24 @@ function PaginationBarCore({ table, labels, pageSizeOptions, className, style })
|
|
|
1566
1617
|
gap: "xs",
|
|
1567
1618
|
wrap: "nowrap",
|
|
1568
1619
|
children: [/* @__PURE__ */ jsx(Text, {
|
|
1569
|
-
c: "dimmed",
|
|
1620
|
+
c: "var(--ledger-color-dimmed)",
|
|
1570
1621
|
id: pageSizeLabelId,
|
|
1571
|
-
size
|
|
1622
|
+
size,
|
|
1572
1623
|
children: labels.rowsPerPage
|
|
1573
1624
|
}, "label"), /* @__PURE__ */ jsx(Select, {
|
|
1574
1625
|
allowDeselect: false,
|
|
1575
1626
|
"aria-labelledby": pageSizeLabelId,
|
|
1576
1627
|
data: sizeOptions.map(String),
|
|
1577
|
-
size:
|
|
1628
|
+
size: SIZES[size].control,
|
|
1578
1629
|
value: String(pageSize),
|
|
1579
1630
|
w: 84,
|
|
1580
1631
|
onChange: (value) => value !== null && table.setPageSize(Number(value))
|
|
1581
1632
|
})]
|
|
1582
1633
|
}), /* @__PURE__ */ jsx(Pagination, {
|
|
1583
|
-
|
|
1634
|
+
getControlProps: (control) => {
|
|
1635
|
+
return { "aria-label": labels[CONTROL_LABELS[control]] };
|
|
1636
|
+
},
|
|
1637
|
+
size: SIZES[size].control,
|
|
1584
1638
|
total: pageCount,
|
|
1585
1639
|
value: pageIndex + 1,
|
|
1586
1640
|
onChange: (page) => table.setPageIndex(page - 1)
|
|
@@ -1592,26 +1646,28 @@ function PaginationBarCore({ table, labels, pageSizeOptions, className, style })
|
|
|
1592
1646
|
* The built-in bar rendered by <DataTable> (context-styled).
|
|
1593
1647
|
*/
|
|
1594
1648
|
function PaginationBar({ table, pageSizeOptions }) {
|
|
1595
|
-
const { labels, getStyles } = useDataTableContext();
|
|
1649
|
+
const { labels, getStyles, size } = useDataTableContext();
|
|
1596
1650
|
const { className, style } = getStyles("paginationBar");
|
|
1597
1651
|
return /* @__PURE__ */ jsx(PaginationBarCore, {
|
|
1598
1652
|
className,
|
|
1599
1653
|
labels,
|
|
1600
1654
|
pageSizeOptions,
|
|
1655
|
+
size,
|
|
1601
1656
|
style,
|
|
1602
1657
|
table
|
|
1603
1658
|
});
|
|
1604
1659
|
}
|
|
1605
|
-
const paginationDefaultProps = {};
|
|
1660
|
+
const paginationDefaultProps = { size: "sm" };
|
|
1606
1661
|
/**
|
|
1607
1662
|
* Standalone compound (`DataTable.Pagination`) — place it anywhere, theme it via defaultProps.
|
|
1608
1663
|
*/
|
|
1609
1664
|
function DataTablePagination(props) {
|
|
1610
|
-
const { table, pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS, labels, className, style } = useProps("DataTablePagination", paginationDefaultProps, props);
|
|
1665
|
+
const { table, pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS, labels, size, className, style } = useProps("DataTablePagination", paginationDefaultProps, props);
|
|
1611
1666
|
return /* @__PURE__ */ jsx(PaginationBarCore, {
|
|
1612
1667
|
className: clsx("ledger-pagination-bar", className),
|
|
1613
1668
|
labels: resolveLabels(labels),
|
|
1614
1669
|
pageSizeOptions,
|
|
1670
|
+
size,
|
|
1615
1671
|
style,
|
|
1616
1672
|
table
|
|
1617
1673
|
});
|
|
@@ -1769,7 +1825,7 @@ function canEditCell(cell, row) {
|
|
|
1769
1825
|
* commit, and the pending presentation around it.
|
|
1770
1826
|
*/
|
|
1771
1827
|
function CellEditor({ cell }) {
|
|
1772
|
-
const { labels, getStyles } = useDataTableContext();
|
|
1828
|
+
const { labels, getStyles, size } = useDataTableContext();
|
|
1773
1829
|
const { table } = cell.getContext();
|
|
1774
1830
|
const editing = table.options.meta?.ledger?.editing;
|
|
1775
1831
|
const normalized = normalizeEdit(cell.column.columnDef.meta?.edit);
|
|
@@ -1818,7 +1874,8 @@ function CellEditor({ cell }) {
|
|
|
1818
1874
|
pending,
|
|
1819
1875
|
mode: "cell",
|
|
1820
1876
|
autoFocus: true,
|
|
1821
|
-
label: labels.editColumn(columnHeaderText(cell.column))
|
|
1877
|
+
label: labels.editColumn(columnHeaderText(cell.column)),
|
|
1878
|
+
size: SIZES[size].control
|
|
1822
1879
|
});
|
|
1823
1880
|
return /* @__PURE__ */ jsxs("div", {
|
|
1824
1881
|
"aria-busy": pending || void 0,
|
|
@@ -1840,7 +1897,7 @@ function CellEditor({ cell }) {
|
|
|
1840
1897
|
* a virtualized unmount), blur never commits, and Enter/Escape commit or cancel the whole row.
|
|
1841
1898
|
*/
|
|
1842
1899
|
function RowCellEditor({ cell }) {
|
|
1843
|
-
const { labels, getStyles } = useDataTableContext();
|
|
1900
|
+
const { labels, getStyles, size } = useDataTableContext();
|
|
1844
1901
|
const { table } = cell.getContext();
|
|
1845
1902
|
const editing = table.options.meta?.ledger?.editing;
|
|
1846
1903
|
const rowApi = editing?.row;
|
|
@@ -1898,7 +1955,8 @@ function RowCellEditor({ cell }) {
|
|
|
1898
1955
|
},
|
|
1899
1956
|
error: editError,
|
|
1900
1957
|
pending,
|
|
1901
|
-
label
|
|
1958
|
+
label,
|
|
1959
|
+
size: SIZES[size].control
|
|
1902
1960
|
}) : normalized.render({
|
|
1903
1961
|
row: cell.row,
|
|
1904
1962
|
column: cell.column,
|
|
@@ -1910,7 +1968,8 @@ function RowCellEditor({ cell }) {
|
|
|
1910
1968
|
pending,
|
|
1911
1969
|
mode: "row",
|
|
1912
1970
|
autoFocus,
|
|
1913
|
-
label
|
|
1971
|
+
label,
|
|
1972
|
+
size: SIZES[size].control
|
|
1914
1973
|
});
|
|
1915
1974
|
return /* @__PURE__ */ jsxs("div", {
|
|
1916
1975
|
ref: containerRef,
|
|
@@ -2303,7 +2362,7 @@ function usePinnedRowOffsets(topCount, bottomCount) {
|
|
|
2303
2362
|
* variables).
|
|
2304
2363
|
*/
|
|
2305
2364
|
const TREE_INDENT_PX = 20;
|
|
2306
|
-
const DEFAULT_ESTIMATED_ROW_HEIGHT =
|
|
2365
|
+
const DEFAULT_ESTIMATED_ROW_HEIGHT = SIZES.sm.rowHeight;
|
|
2307
2366
|
const DEFAULT_OVERSCAN = 8;
|
|
2308
2367
|
/**
|
|
2309
2368
|
* Whether any leaf definition declares a merge — the gate that keeps span-index reads (and the
|
|
@@ -2351,7 +2410,7 @@ function countDisplayRows(rows, withDetailPanels) {
|
|
|
2351
2410
|
* Grouped cell: expander, the grouped value, and the group size.
|
|
2352
2411
|
*/
|
|
2353
2412
|
function GroupCell({ cell }) {
|
|
2354
|
-
const { labels, icons, expansion } = useDataTableContext();
|
|
2413
|
+
const { labels, icons, expansion, size } = useDataTableContext();
|
|
2355
2414
|
const { row } = cell;
|
|
2356
2415
|
const expandedGroup = row.getIsExpanded();
|
|
2357
2416
|
const canExpandGroup = row.getCanExpand();
|
|
@@ -2362,13 +2421,13 @@ function GroupCell({ cell }) {
|
|
|
2362
2421
|
"aria-expanded": expandedGroup,
|
|
2363
2422
|
"aria-label": expandedGroup ? labels.collapseRow : labels.expandRow,
|
|
2364
2423
|
"data-expanded": expandedGroup || void 0,
|
|
2365
|
-
size:
|
|
2424
|
+
size: SIZES[size].control,
|
|
2366
2425
|
variant: "subtle",
|
|
2367
2426
|
onClick: (event) => {
|
|
2368
2427
|
event.stopPropagation();
|
|
2369
2428
|
expansion?.toggle(row.id, expandedGroup, canExpandGroup);
|
|
2370
2429
|
},
|
|
2371
|
-
children: /* @__PURE__ */ jsx(icons.expandRow, { size:
|
|
2430
|
+
children: /* @__PURE__ */ jsx(icons.expandRow, { size: SIZES[size].glyph })
|
|
2372
2431
|
}),
|
|
2373
2432
|
flexRender$1(cell.column.columnDef.cell, cell.getContext()),
|
|
2374
2433
|
/* @__PURE__ */ jsxs("span", {
|
|
@@ -2392,7 +2451,7 @@ function GroupCell({ cell }) {
|
|
|
2392
2451
|
* `onRowClick` out.
|
|
2393
2452
|
*/
|
|
2394
2453
|
function InstantCell({ cell, render }) {
|
|
2395
|
-
const { labels, getStyles } = useDataTableContext();
|
|
2454
|
+
const { labels, getStyles, size } = useDataTableContext();
|
|
2396
2455
|
const { table } = cell.getContext();
|
|
2397
2456
|
const instant = table.options.meta?.ledger?.editing.instant;
|
|
2398
2457
|
const rowId = cell.row.id;
|
|
@@ -2424,7 +2483,8 @@ function InstantCell({ cell, render }) {
|
|
|
2424
2483
|
commit: (next) => instant.commit(rowId, columnId, next),
|
|
2425
2484
|
pending,
|
|
2426
2485
|
error,
|
|
2427
|
-
label: labels.editColumn(columnHeaderText(cell.column))
|
|
2486
|
+
label: labels.editColumn(columnHeaderText(cell.column)),
|
|
2487
|
+
size: SIZES[size].control
|
|
2428
2488
|
}),
|
|
2429
2489
|
pending && /* @__PURE__ */ jsx(Loader, {
|
|
2430
2490
|
"aria-label": labels.editPending,
|
|
@@ -2995,8 +3055,16 @@ function autosizeColumn(setColumnSizing, { columnId, minSize, maxSize, hasFilter
|
|
|
2995
3055
|
* a black box that may ship no clear of its own — keeps the popover-level fallback.
|
|
2996
3056
|
*/
|
|
2997
3057
|
const FACETED_OPTIONS_CAP = 100;
|
|
3058
|
+
/**
|
|
3059
|
+
* The smallest pointer target WCAG 2.2 AA accepts without spacing around it, in px.
|
|
3060
|
+
*/
|
|
3061
|
+
const MIN_TARGET_SIZE = 24;
|
|
3062
|
+
/**
|
|
3063
|
+
* The calendar's weekend color, as the variable Mantine's day rule reads (see DateRangeFilter).
|
|
3064
|
+
*/
|
|
3065
|
+
const WEEKEND_COLOR = { "--mantine-color-red-6": "color-mix(in srgb, var(--mantine-color-red-text), var(--mantine-color-text) 30%)" };
|
|
2998
3066
|
function FilterPopover({ column }) {
|
|
2999
|
-
const { labels, icons, getStyles, filterMode } = useDataTableContext();
|
|
3067
|
+
const { labels, icons, getStyles, filterMode, size } = useDataTableContext();
|
|
3000
3068
|
const filter = column.columnDef.meta?.filter;
|
|
3001
3069
|
if (!filter || !column.getCanFilter()) return null;
|
|
3002
3070
|
const active = column.getFilterValue() !== void 0;
|
|
@@ -3008,7 +3076,9 @@ function FilterPopover({ column }) {
|
|
|
3008
3076
|
children: [/* @__PURE__ */ jsx(Popover.Target, { children: /* @__PURE__ */ jsx(ActionIcon, {
|
|
3009
3077
|
"aria-label": name,
|
|
3010
3078
|
"data-active": active || void 0,
|
|
3011
|
-
|
|
3079
|
+
mih: MIN_TARGET_SIZE,
|
|
3080
|
+
miw: MIN_TARGET_SIZE,
|
|
3081
|
+
size: SIZES[size].control,
|
|
3012
3082
|
variant: active ? "light" : "subtle",
|
|
3013
3083
|
onClick: (event) => event.stopPropagation(),
|
|
3014
3084
|
children: /* @__PURE__ */ jsx(icons.filterColumn, {})
|
|
@@ -3189,11 +3259,21 @@ function DateRangeFilter({ column, name }) {
|
|
|
3189
3259
|
const filterValue = column.getFilterValue();
|
|
3190
3260
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(DatePicker, {
|
|
3191
3261
|
allowSingleDateInRange: true,
|
|
3262
|
+
hideOutsideDates: true,
|
|
3192
3263
|
highlightToday: true,
|
|
3193
3264
|
"aria-label": name,
|
|
3194
3265
|
size: "xs",
|
|
3266
|
+
style: WEEKEND_COLOR,
|
|
3195
3267
|
type: "range",
|
|
3196
3268
|
value: filterValue ?? [null, null],
|
|
3269
|
+
ariaLabels: {
|
|
3270
|
+
previousMonth: labels.previousMonth,
|
|
3271
|
+
nextMonth: labels.nextMonth,
|
|
3272
|
+
previousYear: labels.previousYear,
|
|
3273
|
+
nextYear: labels.nextYear,
|
|
3274
|
+
previousDecade: labels.previousDecade,
|
|
3275
|
+
nextDecade: labels.nextDecade
|
|
3276
|
+
},
|
|
3197
3277
|
onChange: (next) => column.setFilterValue(!next[0] && !next[1] ? void 0 : next)
|
|
3198
3278
|
}), filterValue !== void 0 && /* @__PURE__ */ jsx(Group, {
|
|
3199
3279
|
justify: "flex-end",
|
|
@@ -3450,8 +3530,9 @@ function TableHeader({ table, columnWidths, columnSizing, columnWindow }) {
|
|
|
3450
3530
|
});
|
|
3451
3531
|
}
|
|
3452
3532
|
function HeaderCell({ header, table, reorder, resize, columnWidths, columnSizing, colSpan, ariaColIndex }) {
|
|
3453
|
-
const { getStyles, labels, icons } = useDataTableContext();
|
|
3533
|
+
const { getStyles, labels, icons, size } = useDataTableContext();
|
|
3454
3534
|
const { column } = header;
|
|
3535
|
+
const { glyph } = SIZES[size];
|
|
3455
3536
|
const { meta } = column.columnDef;
|
|
3456
3537
|
const internal = isInternalColumn(column.id);
|
|
3457
3538
|
const canSort = column.getCanSort();
|
|
@@ -3527,9 +3608,9 @@ function HeaderCell({ header, table, reorder, resize, columnWidths, columnSizing
|
|
|
3527
3608
|
...getStyles("sortIndicator"),
|
|
3528
3609
|
"data-sorted": sorted || void 0,
|
|
3529
3610
|
children: [
|
|
3530
|
-
sorted === "asc" && /* @__PURE__ */ jsx(icons.sortAsc, { size:
|
|
3531
|
-
sorted === "desc" && /* @__PURE__ */ jsx(icons.sortDesc, { size:
|
|
3532
|
-
sorted === false && /* @__PURE__ */ jsx(icons.sortable, { size:
|
|
3611
|
+
sorted === "asc" && /* @__PURE__ */ jsx(icons.sortAsc, { size: glyph }),
|
|
3612
|
+
sorted === "desc" && /* @__PURE__ */ jsx(icons.sortDesc, { size: glyph }),
|
|
3613
|
+
sorted === false && /* @__PURE__ */ jsx(icons.sortable, { size: glyph }),
|
|
3533
3614
|
sorted !== false && sortCount > 1 && sortIndex >= 0 && /* @__PURE__ */ jsx("sup", { children: sortIndex + 1 })
|
|
3534
3615
|
]
|
|
3535
3616
|
})]
|
|
@@ -3682,7 +3763,7 @@ function minWidthPx(tableMinWidth, viewport) {
|
|
|
3682
3763
|
if (!tableElement) return Number.parseFloat(tableMinWidth) || 0;
|
|
3683
3764
|
return Number.parseFloat(getComputedStyle(tableElement).minWidth) || 0;
|
|
3684
3765
|
}
|
|
3685
|
-
function useColumnWidths(table, columns, viewport, tableMinWidth) {
|
|
3766
|
+
function useColumnWidths(table, columns, viewport, tableMinWidth, injectedWidth) {
|
|
3686
3767
|
const [availableWidth, setAvailableWidth] = useState(0);
|
|
3687
3768
|
const measure = useCallback(() => {
|
|
3688
3769
|
if (!viewport) return;
|
|
@@ -3701,6 +3782,12 @@ function useColumnWidths(table, columns, viewport, tableMinWidth) {
|
|
|
3701
3782
|
const resolved = useMemo(() => {
|
|
3702
3783
|
return resolveColumnWidths(columns.map((column) => {
|
|
3703
3784
|
const raw = rawColumnSizing(column.columnDef);
|
|
3785
|
+
if (isInternalColumn(column.id)) return {
|
|
3786
|
+
id: column.id,
|
|
3787
|
+
size: raw?.size ?? injectedWidth,
|
|
3788
|
+
minSize: raw?.minSize ?? injectedWidth,
|
|
3789
|
+
maxSize: raw?.maxSize ?? injectedWidth
|
|
3790
|
+
};
|
|
3704
3791
|
return {
|
|
3705
3792
|
id: column.id,
|
|
3706
3793
|
size: raw ? raw.size ?? defaultColumn?.size : column.columnDef.size,
|
|
@@ -3712,7 +3799,8 @@ function useColumnWidths(table, columns, viewport, tableMinWidth) {
|
|
|
3712
3799
|
columns,
|
|
3713
3800
|
columnSizing,
|
|
3714
3801
|
availableWidth,
|
|
3715
|
-
defaultColumn
|
|
3802
|
+
defaultColumn,
|
|
3803
|
+
injectedWidth
|
|
3716
3804
|
]);
|
|
3717
3805
|
const signature = JSON.stringify([resolved.total, Object.entries(resolved.byId)]);
|
|
3718
3806
|
return useMemo(() => resolved, [signature]);
|
|
@@ -3763,6 +3851,24 @@ const builtInFilterFns = {
|
|
|
3763
3851
|
startsWith: filterFn_startsWith,
|
|
3764
3852
|
weakEquals: filterFn_weakEquals
|
|
3765
3853
|
};
|
|
3854
|
+
/**
|
|
3855
|
+
* Typed through the exported definitions on purpose: since 9.2 several of their value types
|
|
3856
|
+
* name an alias TanStack does not export, and an inferred registry would carry that alias into
|
|
3857
|
+
* ledger's declaration files, where no consumer can resolve it.
|
|
3858
|
+
*/
|
|
3859
|
+
const builtInAggregationFns = {
|
|
3860
|
+
count: aggregationFn_count,
|
|
3861
|
+
extent: aggregationFn_extent,
|
|
3862
|
+
first: aggregationFn_first,
|
|
3863
|
+
last: aggregationFn_last,
|
|
3864
|
+
max: aggregationFn_max,
|
|
3865
|
+
mean: aggregationFn_mean,
|
|
3866
|
+
median: aggregationFn_median,
|
|
3867
|
+
min: aggregationFn_min,
|
|
3868
|
+
sum: aggregationFn_sum,
|
|
3869
|
+
unique: aggregationFn_unique,
|
|
3870
|
+
uniqueCount: aggregationFn_uniqueCount
|
|
3871
|
+
};
|
|
3766
3872
|
const ledgerFeatures = tableFeatures({
|
|
3767
3873
|
cellSpanningFeature,
|
|
3768
3874
|
columnFacetingFeature,
|
|
@@ -3787,19 +3893,7 @@ const ledgerFeatures = tableFeatures({
|
|
|
3787
3893
|
groupedRowModel: createGroupedRowModel(),
|
|
3788
3894
|
paginatedRowModel: createPaginatedRowModel(),
|
|
3789
3895
|
sortedRowModel: createSortedRowModel(),
|
|
3790
|
-
aggregationFns:
|
|
3791
|
-
count: aggregationFn_count,
|
|
3792
|
-
extent: aggregationFn_extent,
|
|
3793
|
-
first: aggregationFn_first,
|
|
3794
|
-
last: aggregationFn_last,
|
|
3795
|
-
max: aggregationFn_max,
|
|
3796
|
-
mean: aggregationFn_mean,
|
|
3797
|
-
median: aggregationFn_median,
|
|
3798
|
-
min: aggregationFn_min,
|
|
3799
|
-
sum: aggregationFn_sum,
|
|
3800
|
-
unique: aggregationFn_unique,
|
|
3801
|
-
uniqueCount: aggregationFn_uniqueCount
|
|
3802
|
-
},
|
|
3896
|
+
aggregationFns: builtInAggregationFns,
|
|
3803
3897
|
filterFns: {
|
|
3804
3898
|
...builtInFilterFns,
|
|
3805
3899
|
...ledgerFilterFns
|
|
@@ -6320,6 +6414,33 @@ function useStylesRevision(getStyles, selectors) {
|
|
|
6320
6414
|
return revision;
|
|
6321
6415
|
}
|
|
6322
6416
|
//#endregion
|
|
6417
|
+
//#region src/use-viewport-overflow.ts
|
|
6418
|
+
/**
|
|
6419
|
+
* Whether the body viewport scrolls on either axis. A scroll container has to be reachable by
|
|
6420
|
+
* keyboard to be scrolled by it (WCAG 2.1.1), while a focus stop over content that fits is a
|
|
6421
|
+
* Tab press spent on nothing — so the viewport's focus stop follows this.
|
|
6422
|
+
*
|
|
6423
|
+
* Measured whenever the viewport or its content resizes: rows arriving, columns widening, or
|
|
6424
|
+
* the host resizing the table each change the answer without a scroll event. A 1px tolerance
|
|
6425
|
+
* absorbs fractional layout rounding, which would otherwise flicker the stop on and off.
|
|
6426
|
+
*/
|
|
6427
|
+
function useViewportOverflow(viewport) {
|
|
6428
|
+
const [overflowing, setOverflowing] = useState(false);
|
|
6429
|
+
useLayoutEffect(() => {
|
|
6430
|
+
if (!viewport) return;
|
|
6431
|
+
const measure = () => {
|
|
6432
|
+
const next = viewport.scrollHeight - viewport.clientHeight > 1 || viewport.scrollWidth - viewport.clientWidth > 1;
|
|
6433
|
+
setOverflowing(next);
|
|
6434
|
+
};
|
|
6435
|
+
measure();
|
|
6436
|
+
const observer = new ResizeObserver(measure);
|
|
6437
|
+
observer.observe(viewport);
|
|
6438
|
+
if (viewport.firstElementChild) observer.observe(viewport.firstElementChild);
|
|
6439
|
+
return () => observer.disconnect();
|
|
6440
|
+
}, [viewport]);
|
|
6441
|
+
return overflowing;
|
|
6442
|
+
}
|
|
6443
|
+
//#endregion
|
|
6323
6444
|
//#region src/data-table.tsx
|
|
6324
6445
|
/**
|
|
6325
6446
|
* The root component (docs/api.md): a generic Mantine factory with full Styles API,
|
|
@@ -6377,7 +6498,7 @@ const STYLE_SELECTORS = Object.keys(classes);
|
|
|
6377
6498
|
*/
|
|
6378
6499
|
const NO_ARIA_ROWS = [];
|
|
6379
6500
|
const EMPTY_STATE_STYLES = { title: {
|
|
6380
|
-
color: "var(--
|
|
6501
|
+
color: "var(--ledger-color-dimmed)",
|
|
6381
6502
|
fontWeight: 500
|
|
6382
6503
|
} };
|
|
6383
6504
|
const defaultProps = {
|
|
@@ -6387,8 +6508,7 @@ const defaultProps = {
|
|
|
6387
6508
|
withColumnBorders: false,
|
|
6388
6509
|
withRowBorders: true,
|
|
6389
6510
|
withBottomBorder: false,
|
|
6390
|
-
|
|
6391
|
-
horizontalSpacing: "xs",
|
|
6511
|
+
size: "sm",
|
|
6392
6512
|
tabularNums: false,
|
|
6393
6513
|
virtualizedRows: false,
|
|
6394
6514
|
virtualizedColumns: false,
|
|
@@ -6402,12 +6522,13 @@ const defaultProps = {
|
|
|
6402
6522
|
function leafCol(column) {
|
|
6403
6523
|
return /* @__PURE__ */ jsx("col", { style: { width: `var(${columnWidthVar(column.id)})` } }, column.id);
|
|
6404
6524
|
}
|
|
6405
|
-
const varsResolver = createVarsResolver((theme, { stripedColor, highlightOnHoverColor, borderColor, radius }) => {
|
|
6525
|
+
const varsResolver = createVarsResolver((theme, { stripedColor, highlightOnHoverColor, borderColor, radius, size }) => {
|
|
6406
6526
|
return { root: {
|
|
6407
6527
|
"--ledger-striped-color": stripedColor ? getThemeColor(stripedColor, theme) : void 0,
|
|
6408
6528
|
"--ledger-hover-color": highlightOnHoverColor ? getThemeColor(highlightOnHoverColor, theme) : void 0,
|
|
6409
6529
|
"--ledger-border-color": borderColor ? getThemeColor(borderColor, theme) : void 0,
|
|
6410
|
-
"--ledger-radius": radius === void 0 ? void 0 : getRadius(radius)
|
|
6530
|
+
"--ledger-radius": radius === void 0 ? void 0 : getRadius(radius),
|
|
6531
|
+
"--ledger-font-size": getFontSize(size)
|
|
6411
6532
|
} };
|
|
6412
6533
|
});
|
|
6413
6534
|
const OPTION_KEY_SET = /* @__PURE__ */ new Set([
|
|
@@ -6528,7 +6649,7 @@ function DataTableFromOptions({ props }) {
|
|
|
6528
6649
|
});
|
|
6529
6650
|
}
|
|
6530
6651
|
function DataTableCore({ presentation, stylesProps, table }) {
|
|
6531
|
-
const { striped, stripedColor: _stripedColor, highlightOnHover, highlightOnHoverColor: _highlightOnHoverColor, withTableBorder, withColumnBorders, withRowBorders, withBottomBorder, borderColor: _borderColor, radius: _radius, verticalSpacing, horizontalSpacing, tabularNums, tableMinWidth, virtualizedRows, virtualizedColumns, onEndReached, endReachedOffset, loadingMore, loadMoreError, loading, emptyState, error, onRetry, withColumnHeaders, withPaginationBar, pageSizeOptions, onRowClick, onRowActivate, onRowDoubleClick, onRowContextMenu, rowProps, headerRowProps, footerRowProps, viewportProps, labels: labelsProp, icons: iconsProp, handleRef, ref: rootRef, classNames, styles, unstyled, vars, className, style, attributes, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...others } = presentation;
|
|
6652
|
+
const { striped, stripedColor: _stripedColor, highlightOnHover, highlightOnHoverColor: _highlightOnHoverColor, withTableBorder, withColumnBorders, withRowBorders, withBottomBorder, borderColor: _borderColor, radius: _radius, size: sizeProp, verticalSpacing, horizontalSpacing, tabularNums, tableMinWidth, virtualizedRows, virtualizedColumns, onEndReached, endReachedOffset, loadingMore, loadMoreError, loading, emptyState, error, onRetry, withColumnHeaders, withPaginationBar, pageSizeOptions, onRowClick, onRowActivate, onRowDoubleClick, onRowContextMenu, rowProps, headerRowProps, footerRowProps, viewportProps, labels: labelsProp, icons: iconsProp, handleRef, ref: rootRef, classNames, styles, unstyled, vars, className, style, attributes, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...others } = presentation;
|
|
6532
6653
|
const getStyles = useStyles({
|
|
6533
6654
|
name: "DataTable",
|
|
6534
6655
|
classes,
|
|
@@ -6569,6 +6690,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
6569
6690
|
viewportRef.current = element;
|
|
6570
6691
|
setViewport(element);
|
|
6571
6692
|
}, []);
|
|
6693
|
+
const viewportOverflows = useViewportOverflow(viewport);
|
|
6572
6694
|
const startLeafColumns = table.getStartVisibleLeafColumns();
|
|
6573
6695
|
const endLeafColumns = table.getEndVisibleLeafColumns();
|
|
6574
6696
|
const displayColumns = [
|
|
@@ -6581,9 +6703,11 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
6581
6703
|
const displayOrderSignature = JSON.stringify(displayColumns.map((column) => column.id));
|
|
6582
6704
|
const ledgerColumns = table.options.meta?.ledger?.columns;
|
|
6583
6705
|
const visibleLeafColumns = useMemo(() => displayColumns, [displayOrderSignature, ledgerColumns]);
|
|
6584
|
-
const
|
|
6706
|
+
const size = sizeProp ?? "sm";
|
|
6707
|
+
const scale = SIZES[size];
|
|
6708
|
+
const columnWidths = useColumnWidths(table, visibleLeafColumns, viewport, tableMinWidth, scale.injectedWidth);
|
|
6585
6709
|
const virtualization = virtualizedRows ? {
|
|
6586
|
-
estimateHeight: typeof virtualizedRows === "object" && virtualizedRows.estimateHeight !== void 0 ? virtualizedRows.estimateHeight :
|
|
6710
|
+
estimateHeight: typeof virtualizedRows === "object" && virtualizedRows.estimateHeight !== void 0 ? virtualizedRows.estimateHeight : scale.rowHeight,
|
|
6587
6711
|
overscan: typeof virtualizedRows === "object" && virtualizedRows.overscan !== void 0 ? virtualizedRows.overscan : 8
|
|
6588
6712
|
} : null;
|
|
6589
6713
|
const virtualEnabled = virtualization !== null;
|
|
@@ -6782,7 +6906,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
6782
6906
|
rowPinningActive,
|
|
6783
6907
|
withDetailPanels
|
|
6784
6908
|
]);
|
|
6785
|
-
const bodyAriaRowCount = loading && logicalDisplayRowCount === 0 ? skeletonRowCount : logicalDisplayRowCount + (loadMoreError || loadingMore ? 1 : 0);
|
|
6909
|
+
const bodyAriaRowCount = loading && logicalDisplayRowCount === 0 ? skeletonRowCount : logicalDisplayRowCount + (loadMoreError || loadingMore ? 1 : 0) + (isEmpty || errorActive ? 1 : 0);
|
|
6786
6910
|
const footerRowCount = visibleFooterGroups(table).length;
|
|
6787
6911
|
const ariaRowCount = headerRowCount + bodyAriaRowCount + footerRowCount;
|
|
6788
6912
|
const footerAriaRowIndexStart = headerRowCount + bodyAriaRowCount + 1;
|
|
@@ -7013,11 +7137,11 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
7013
7137
|
]);
|
|
7014
7138
|
const stripedMode = striped === true ? "odd" : striped || void 0;
|
|
7015
7139
|
const sharedTableProps = {
|
|
7016
|
-
horizontalSpacing,
|
|
7140
|
+
horizontalSpacing: horizontalSpacing ?? scale.horizontalSpacing,
|
|
7017
7141
|
layout: "fixed",
|
|
7018
7142
|
role: "presentation",
|
|
7019
7143
|
tabularNums,
|
|
7020
|
-
verticalSpacing
|
|
7144
|
+
verticalSpacing: verticalSpacing ?? scale.verticalSpacing
|
|
7021
7145
|
};
|
|
7022
7146
|
const tableStyleProps = () => getStyles("table", { style: {
|
|
7023
7147
|
width: columnWidths.total > 0 ? columnWidths.total : void 0,
|
|
@@ -7053,6 +7177,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
7053
7177
|
getStyles: stylesRevision,
|
|
7054
7178
|
labels,
|
|
7055
7179
|
icons,
|
|
7180
|
+
size,
|
|
7056
7181
|
filterMode,
|
|
7057
7182
|
virtualizedRows: virtualEnabled,
|
|
7058
7183
|
withColumnHeaders: columnHeadersVisible,
|
|
@@ -7076,6 +7201,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
7076
7201
|
stylesRevision,
|
|
7077
7202
|
labels,
|
|
7078
7203
|
icons,
|
|
7204
|
+
size,
|
|
7079
7205
|
filterMode,
|
|
7080
7206
|
virtualEnabled,
|
|
7081
7207
|
columnHeadersVisible,
|
|
@@ -7099,6 +7225,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
7099
7225
|
"data-loading": loading || void 0,
|
|
7100
7226
|
"data-scrolled-end": scrollEdges.end || void 0,
|
|
7101
7227
|
"data-scrolled-start": scrollEdges.start || void 0,
|
|
7228
|
+
"data-size": size,
|
|
7102
7229
|
"data-striped": stripedMode,
|
|
7103
7230
|
"data-virtualized-columns": columnWindow !== null || void 0,
|
|
7104
7231
|
"data-virtualized-rows": virtualEnabled || void 0,
|
|
@@ -7153,11 +7280,10 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
7153
7280
|
},
|
|
7154
7281
|
viewportProps: mergeElementProps(viewportProps, {
|
|
7155
7282
|
style: { overscrollBehavior: "none" },
|
|
7283
|
+
role: "rowgroup",
|
|
7156
7284
|
"aria-describedby": viewportDescribedBy,
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
onKeyDown: handleActiveRowKeyDown
|
|
7160
|
-
}
|
|
7285
|
+
tabIndex: activeRowEnabled || viewportOverflows ? 0 : void 0,
|
|
7286
|
+
...activeRowEnabled && { onKeyDown: handleActiveRowKeyDown }
|
|
7161
7287
|
}),
|
|
7162
7288
|
onScrollPositionChange: handleScrollPositionChange,
|
|
7163
7289
|
children: [
|
|
@@ -7180,43 +7306,59 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
7180
7306
|
})]
|
|
7181
7307
|
}),
|
|
7182
7308
|
isEmpty && /* @__PURE__ */ jsx("div", {
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
7309
|
+
"aria-rowindex": virtualEnabled ? headerRowCount + bodyAriaRowCount : void 0,
|
|
7310
|
+
role: "row",
|
|
7311
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
7312
|
+
...getStyles("empty"),
|
|
7313
|
+
"aria-colspan": visibleLeafColumns.length,
|
|
7314
|
+
"data-variant": filtersActive ? "no-results" : "no-data",
|
|
7315
|
+
role: "cell",
|
|
7316
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
7317
|
+
role: "status",
|
|
7318
|
+
children: emptyState ?? /* @__PURE__ */ jsx(EmptyState, {
|
|
7319
|
+
withIndicatorBackground: true,
|
|
7320
|
+
size: "sm",
|
|
7321
|
+
styles: EMPTY_STATE_STYLES,
|
|
7322
|
+
title: filtersActive ? labels.noResults : labels.empty,
|
|
7323
|
+
icon: filtersActive ? /* @__PURE__ */ jsx(icons.noResults, {
|
|
7324
|
+
size: 40,
|
|
7325
|
+
strokeWidth: 1.5
|
|
7326
|
+
}) : /* @__PURE__ */ jsx(icons.empty, {
|
|
7327
|
+
size: 40,
|
|
7328
|
+
strokeWidth: 1.5
|
|
7329
|
+
})
|
|
7330
|
+
})
|
|
7197
7331
|
})
|
|
7198
7332
|
})
|
|
7199
7333
|
}),
|
|
7200
7334
|
errorActive && /* @__PURE__ */ jsx("div", {
|
|
7201
|
-
|
|
7202
|
-
"
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7335
|
+
"aria-rowindex": virtualEnabled ? headerRowCount + bodyAriaRowCount : void 0,
|
|
7336
|
+
role: "row",
|
|
7337
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
7338
|
+
...getStyles("empty"),
|
|
7339
|
+
"aria-colspan": visibleLeafColumns.length,
|
|
7340
|
+
"data-over-rows": rowsLength > 0 || void 0,
|
|
7341
|
+
"data-variant": "error",
|
|
7342
|
+
role: "cell",
|
|
7343
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
7344
|
+
role: "alert",
|
|
7345
|
+
children: /* @__PURE__ */ jsx(EmptyState, {
|
|
7346
|
+
withIndicatorBackground: true,
|
|
7347
|
+
icon: /* @__PURE__ */ jsx(icons.error, {
|
|
7348
|
+
size: 40,
|
|
7349
|
+
strokeWidth: 1.5
|
|
7350
|
+
}),
|
|
7351
|
+
size: "sm",
|
|
7352
|
+
styles: EMPTY_STATE_STYLES,
|
|
7353
|
+
title: error === true ? labels.error : error,
|
|
7354
|
+
children: onRetry && /* @__PURE__ */ jsx(Button, {
|
|
7355
|
+
leftSection: /* @__PURE__ */ jsx(icons.retry, { size: 14 }),
|
|
7356
|
+
size: "xs",
|
|
7357
|
+
variant: "light",
|
|
7358
|
+
onClick: onRetry,
|
|
7359
|
+
children: labels.retry
|
|
7360
|
+
})
|
|
7361
|
+
})
|
|
7220
7362
|
})
|
|
7221
7363
|
})
|
|
7222
7364
|
})
|
|
@@ -7263,14 +7405,15 @@ DataTable.SelectionBar = DataTableSelectionBar;
|
|
|
7263
7405
|
* The shipped editor renderers — conveniences, never the mechanism. Each is an ordinary
|
|
7264
7406
|
* renderer over the public editing contexts (docs/editing.md#editors), which is the proof the
|
|
7265
7407
|
* contexts suffice: anything these do, an application's own renderer can do the same way.
|
|
7266
|
-
* All are default-variant Mantine inputs — the border marks the cell as an
|
|
7408
|
+
* All are default-variant Mantine inputs at the context's `size` — the border marks the cell as an
|
|
7409
|
+
* open editor, and the size keeps it inside the row.
|
|
7267
7410
|
*/
|
|
7268
|
-
const renderTextEditor = ({ value, setValue, error, pending, autoFocus, label }) => /* @__PURE__ */ jsx(TextInput, {
|
|
7411
|
+
const renderTextEditor = ({ value, setValue, error, pending, autoFocus, label, size }) => /* @__PURE__ */ jsx(TextInput, {
|
|
7269
7412
|
"aria-label": label,
|
|
7270
7413
|
autoFocus,
|
|
7271
7414
|
disabled: pending,
|
|
7272
7415
|
error,
|
|
7273
|
-
size
|
|
7416
|
+
size,
|
|
7274
7417
|
value: value === null || value === void 0 ? "" : String(value),
|
|
7275
7418
|
onChange: (event) => setValue(event.currentTarget.value)
|
|
7276
7419
|
});
|
|
@@ -7280,13 +7423,13 @@ const renderTextEditor = ({ value, setValue, error, pending, autoFocus, label })
|
|
|
7280
7423
|
function textEditor() {
|
|
7281
7424
|
return renderTextEditor;
|
|
7282
7425
|
}
|
|
7283
|
-
const renderNumberEditor = ({ value, setValue, error, pending, autoFocus, label }) => /* @__PURE__ */ jsx(NumberInput, {
|
|
7426
|
+
const renderNumberEditor = ({ value, setValue, error, pending, autoFocus, label, size }) => /* @__PURE__ */ jsx(NumberInput, {
|
|
7284
7427
|
hideControls: true,
|
|
7285
7428
|
"aria-label": label,
|
|
7286
7429
|
autoFocus,
|
|
7287
7430
|
disabled: pending,
|
|
7288
7431
|
error,
|
|
7289
|
-
size
|
|
7432
|
+
size,
|
|
7290
7433
|
value: typeof value === "number" || typeof value === "string" ? value : "",
|
|
7291
7434
|
onChange: (next) => setValue(next === "" ? null : next)
|
|
7292
7435
|
});
|
|
@@ -7302,7 +7445,7 @@ function numberEditor() {
|
|
|
7302
7445
|
* draft-bound field among the row's others, and the row's own commit decides.
|
|
7303
7446
|
*/
|
|
7304
7447
|
function selectEditor(options) {
|
|
7305
|
-
return ({ value, setValue, commit, error, pending, mode, autoFocus, label }) => /* @__PURE__ */ jsx(Select, {
|
|
7448
|
+
return ({ value, setValue, commit, error, pending, mode, autoFocus, label, size }) => /* @__PURE__ */ jsx(Select, {
|
|
7306
7449
|
"aria-label": label,
|
|
7307
7450
|
autoFocus,
|
|
7308
7451
|
comboboxProps: { withinPortal: true },
|
|
@@ -7310,7 +7453,7 @@ function selectEditor(options) {
|
|
|
7310
7453
|
defaultDropdownOpened: mode === "cell",
|
|
7311
7454
|
disabled: pending,
|
|
7312
7455
|
error,
|
|
7313
|
-
size
|
|
7456
|
+
size,
|
|
7314
7457
|
value: value === null || value === void 0 ? null : String(value),
|
|
7315
7458
|
onChange: (next) => {
|
|
7316
7459
|
setValue(next);
|
|
@@ -7318,12 +7461,12 @@ function selectEditor(options) {
|
|
|
7318
7461
|
}
|
|
7319
7462
|
});
|
|
7320
7463
|
}
|
|
7321
|
-
const renderCheckboxEditor = ({ value, commit, pending, error, label }) => /* @__PURE__ */ jsx(Checkbox, {
|
|
7464
|
+
const renderCheckboxEditor = ({ value, commit, pending, error, label, size }) => /* @__PURE__ */ jsx(Checkbox, {
|
|
7322
7465
|
"aria-label": label,
|
|
7323
7466
|
checked: Boolean(value),
|
|
7324
7467
|
disabled: pending,
|
|
7325
7468
|
error: Boolean(error),
|
|
7326
|
-
size
|
|
7469
|
+
size,
|
|
7327
7470
|
onChange: (event) => void commit(event.currentTarget.checked)
|
|
7328
7471
|
});
|
|
7329
7472
|
/**
|