@coldsmirk/ledger-mantine 0.3.1 → 0.4.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 +123 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +124 -69
- package/dist/index.js.map +1 -1
- package/dist/styles.css +9 -1
- package/package.json +1 -1
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,
|
|
@@ -1541,7 +1576,7 @@ const DEFAULT_PAGE_SIZE_OPTIONS = [
|
|
|
1541
1576
|
50,
|
|
1542
1577
|
100
|
|
1543
1578
|
];
|
|
1544
|
-
function PaginationBarCore({ table, labels, pageSizeOptions, className, style }) {
|
|
1579
|
+
function PaginationBarCore({ table, labels, pageSizeOptions, size, className, style }) {
|
|
1545
1580
|
const pageSizeLabelId = useId();
|
|
1546
1581
|
const { pageIndex, pageSize } = table.atoms.pagination.get();
|
|
1547
1582
|
const total = table.getRowCount();
|
|
@@ -1557,7 +1592,7 @@ function PaginationBarCore({ table, labels, pageSizeOptions, className, style })
|
|
|
1557
1592
|
wrap: "wrap",
|
|
1558
1593
|
children: [/* @__PURE__ */ jsx(Text, {
|
|
1559
1594
|
c: "dimmed",
|
|
1560
|
-
size
|
|
1595
|
+
size,
|
|
1561
1596
|
children: labels.paginationSummary(from, to, total)
|
|
1562
1597
|
}), /* @__PURE__ */ jsxs(Group, {
|
|
1563
1598
|
gap: "md",
|
|
@@ -1568,19 +1603,19 @@ function PaginationBarCore({ table, labels, pageSizeOptions, className, style })
|
|
|
1568
1603
|
children: [/* @__PURE__ */ jsx(Text, {
|
|
1569
1604
|
c: "dimmed",
|
|
1570
1605
|
id: pageSizeLabelId,
|
|
1571
|
-
size
|
|
1606
|
+
size,
|
|
1572
1607
|
children: labels.rowsPerPage
|
|
1573
1608
|
}, "label"), /* @__PURE__ */ jsx(Select, {
|
|
1574
1609
|
allowDeselect: false,
|
|
1575
1610
|
"aria-labelledby": pageSizeLabelId,
|
|
1576
1611
|
data: sizeOptions.map(String),
|
|
1577
|
-
size:
|
|
1612
|
+
size: SIZES[size].control,
|
|
1578
1613
|
value: String(pageSize),
|
|
1579
1614
|
w: 84,
|
|
1580
1615
|
onChange: (value) => value !== null && table.setPageSize(Number(value))
|
|
1581
1616
|
})]
|
|
1582
1617
|
}), /* @__PURE__ */ jsx(Pagination, {
|
|
1583
|
-
size:
|
|
1618
|
+
size: SIZES[size].control,
|
|
1584
1619
|
total: pageCount,
|
|
1585
1620
|
value: pageIndex + 1,
|
|
1586
1621
|
onChange: (page) => table.setPageIndex(page - 1)
|
|
@@ -1592,26 +1627,28 @@ function PaginationBarCore({ table, labels, pageSizeOptions, className, style })
|
|
|
1592
1627
|
* The built-in bar rendered by <DataTable> (context-styled).
|
|
1593
1628
|
*/
|
|
1594
1629
|
function PaginationBar({ table, pageSizeOptions }) {
|
|
1595
|
-
const { labels, getStyles } = useDataTableContext();
|
|
1630
|
+
const { labels, getStyles, size } = useDataTableContext();
|
|
1596
1631
|
const { className, style } = getStyles("paginationBar");
|
|
1597
1632
|
return /* @__PURE__ */ jsx(PaginationBarCore, {
|
|
1598
1633
|
className,
|
|
1599
1634
|
labels,
|
|
1600
1635
|
pageSizeOptions,
|
|
1636
|
+
size,
|
|
1601
1637
|
style,
|
|
1602
1638
|
table
|
|
1603
1639
|
});
|
|
1604
1640
|
}
|
|
1605
|
-
const paginationDefaultProps = {};
|
|
1641
|
+
const paginationDefaultProps = { size: "sm" };
|
|
1606
1642
|
/**
|
|
1607
1643
|
* Standalone compound (`DataTable.Pagination`) — place it anywhere, theme it via defaultProps.
|
|
1608
1644
|
*/
|
|
1609
1645
|
function DataTablePagination(props) {
|
|
1610
|
-
const { table, pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS, labels, className, style } = useProps("DataTablePagination", paginationDefaultProps, props);
|
|
1646
|
+
const { table, pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS, labels, size, className, style } = useProps("DataTablePagination", paginationDefaultProps, props);
|
|
1611
1647
|
return /* @__PURE__ */ jsx(PaginationBarCore, {
|
|
1612
1648
|
className: clsx("ledger-pagination-bar", className),
|
|
1613
1649
|
labels: resolveLabels(labels),
|
|
1614
1650
|
pageSizeOptions,
|
|
1651
|
+
size,
|
|
1615
1652
|
style,
|
|
1616
1653
|
table
|
|
1617
1654
|
});
|
|
@@ -1769,7 +1806,7 @@ function canEditCell(cell, row) {
|
|
|
1769
1806
|
* commit, and the pending presentation around it.
|
|
1770
1807
|
*/
|
|
1771
1808
|
function CellEditor({ cell }) {
|
|
1772
|
-
const { labels, getStyles } = useDataTableContext();
|
|
1809
|
+
const { labels, getStyles, size } = useDataTableContext();
|
|
1773
1810
|
const { table } = cell.getContext();
|
|
1774
1811
|
const editing = table.options.meta?.ledger?.editing;
|
|
1775
1812
|
const normalized = normalizeEdit(cell.column.columnDef.meta?.edit);
|
|
@@ -1818,7 +1855,8 @@ function CellEditor({ cell }) {
|
|
|
1818
1855
|
pending,
|
|
1819
1856
|
mode: "cell",
|
|
1820
1857
|
autoFocus: true,
|
|
1821
|
-
label: labels.editColumn(columnHeaderText(cell.column))
|
|
1858
|
+
label: labels.editColumn(columnHeaderText(cell.column)),
|
|
1859
|
+
size: SIZES[size].control
|
|
1822
1860
|
});
|
|
1823
1861
|
return /* @__PURE__ */ jsxs("div", {
|
|
1824
1862
|
"aria-busy": pending || void 0,
|
|
@@ -1840,7 +1878,7 @@ function CellEditor({ cell }) {
|
|
|
1840
1878
|
* a virtualized unmount), blur never commits, and Enter/Escape commit or cancel the whole row.
|
|
1841
1879
|
*/
|
|
1842
1880
|
function RowCellEditor({ cell }) {
|
|
1843
|
-
const { labels, getStyles } = useDataTableContext();
|
|
1881
|
+
const { labels, getStyles, size } = useDataTableContext();
|
|
1844
1882
|
const { table } = cell.getContext();
|
|
1845
1883
|
const editing = table.options.meta?.ledger?.editing;
|
|
1846
1884
|
const rowApi = editing?.row;
|
|
@@ -1898,7 +1936,8 @@ function RowCellEditor({ cell }) {
|
|
|
1898
1936
|
},
|
|
1899
1937
|
error: editError,
|
|
1900
1938
|
pending,
|
|
1901
|
-
label
|
|
1939
|
+
label,
|
|
1940
|
+
size: SIZES[size].control
|
|
1902
1941
|
}) : normalized.render({
|
|
1903
1942
|
row: cell.row,
|
|
1904
1943
|
column: cell.column,
|
|
@@ -1910,7 +1949,8 @@ function RowCellEditor({ cell }) {
|
|
|
1910
1949
|
pending,
|
|
1911
1950
|
mode: "row",
|
|
1912
1951
|
autoFocus,
|
|
1913
|
-
label
|
|
1952
|
+
label,
|
|
1953
|
+
size: SIZES[size].control
|
|
1914
1954
|
});
|
|
1915
1955
|
return /* @__PURE__ */ jsxs("div", {
|
|
1916
1956
|
ref: containerRef,
|
|
@@ -2303,7 +2343,7 @@ function usePinnedRowOffsets(topCount, bottomCount) {
|
|
|
2303
2343
|
* variables).
|
|
2304
2344
|
*/
|
|
2305
2345
|
const TREE_INDENT_PX = 20;
|
|
2306
|
-
const DEFAULT_ESTIMATED_ROW_HEIGHT =
|
|
2346
|
+
const DEFAULT_ESTIMATED_ROW_HEIGHT = SIZES.sm.rowHeight;
|
|
2307
2347
|
const DEFAULT_OVERSCAN = 8;
|
|
2308
2348
|
/**
|
|
2309
2349
|
* Whether any leaf definition declares a merge — the gate that keeps span-index reads (and the
|
|
@@ -2351,7 +2391,7 @@ function countDisplayRows(rows, withDetailPanels) {
|
|
|
2351
2391
|
* Grouped cell: expander, the grouped value, and the group size.
|
|
2352
2392
|
*/
|
|
2353
2393
|
function GroupCell({ cell }) {
|
|
2354
|
-
const { labels, icons, expansion } = useDataTableContext();
|
|
2394
|
+
const { labels, icons, expansion, size } = useDataTableContext();
|
|
2355
2395
|
const { row } = cell;
|
|
2356
2396
|
const expandedGroup = row.getIsExpanded();
|
|
2357
2397
|
const canExpandGroup = row.getCanExpand();
|
|
@@ -2362,13 +2402,13 @@ function GroupCell({ cell }) {
|
|
|
2362
2402
|
"aria-expanded": expandedGroup,
|
|
2363
2403
|
"aria-label": expandedGroup ? labels.collapseRow : labels.expandRow,
|
|
2364
2404
|
"data-expanded": expandedGroup || void 0,
|
|
2365
|
-
size:
|
|
2405
|
+
size: SIZES[size].control,
|
|
2366
2406
|
variant: "subtle",
|
|
2367
2407
|
onClick: (event) => {
|
|
2368
2408
|
event.stopPropagation();
|
|
2369
2409
|
expansion?.toggle(row.id, expandedGroup, canExpandGroup);
|
|
2370
2410
|
},
|
|
2371
|
-
children: /* @__PURE__ */ jsx(icons.expandRow, { size:
|
|
2411
|
+
children: /* @__PURE__ */ jsx(icons.expandRow, { size: SIZES[size].glyph })
|
|
2372
2412
|
}),
|
|
2373
2413
|
flexRender$1(cell.column.columnDef.cell, cell.getContext()),
|
|
2374
2414
|
/* @__PURE__ */ jsxs("span", {
|
|
@@ -2392,7 +2432,7 @@ function GroupCell({ cell }) {
|
|
|
2392
2432
|
* `onRowClick` out.
|
|
2393
2433
|
*/
|
|
2394
2434
|
function InstantCell({ cell, render }) {
|
|
2395
|
-
const { labels, getStyles } = useDataTableContext();
|
|
2435
|
+
const { labels, getStyles, size } = useDataTableContext();
|
|
2396
2436
|
const { table } = cell.getContext();
|
|
2397
2437
|
const instant = table.options.meta?.ledger?.editing.instant;
|
|
2398
2438
|
const rowId = cell.row.id;
|
|
@@ -2424,7 +2464,8 @@ function InstantCell({ cell, render }) {
|
|
|
2424
2464
|
commit: (next) => instant.commit(rowId, columnId, next),
|
|
2425
2465
|
pending,
|
|
2426
2466
|
error,
|
|
2427
|
-
label: labels.editColumn(columnHeaderText(cell.column))
|
|
2467
|
+
label: labels.editColumn(columnHeaderText(cell.column)),
|
|
2468
|
+
size: SIZES[size].control
|
|
2428
2469
|
}),
|
|
2429
2470
|
pending && /* @__PURE__ */ jsx(Loader, {
|
|
2430
2471
|
"aria-label": labels.editPending,
|
|
@@ -2996,7 +3037,7 @@ function autosizeColumn(setColumnSizing, { columnId, minSize, maxSize, hasFilter
|
|
|
2996
3037
|
*/
|
|
2997
3038
|
const FACETED_OPTIONS_CAP = 100;
|
|
2998
3039
|
function FilterPopover({ column }) {
|
|
2999
|
-
const { labels, icons, getStyles, filterMode } = useDataTableContext();
|
|
3040
|
+
const { labels, icons, getStyles, filterMode, size } = useDataTableContext();
|
|
3000
3041
|
const filter = column.columnDef.meta?.filter;
|
|
3001
3042
|
if (!filter || !column.getCanFilter()) return null;
|
|
3002
3043
|
const active = column.getFilterValue() !== void 0;
|
|
@@ -3008,7 +3049,7 @@ function FilterPopover({ column }) {
|
|
|
3008
3049
|
children: [/* @__PURE__ */ jsx(Popover.Target, { children: /* @__PURE__ */ jsx(ActionIcon, {
|
|
3009
3050
|
"aria-label": name,
|
|
3010
3051
|
"data-active": active || void 0,
|
|
3011
|
-
size:
|
|
3052
|
+
size: SIZES[size].control,
|
|
3012
3053
|
variant: active ? "light" : "subtle",
|
|
3013
3054
|
onClick: (event) => event.stopPropagation(),
|
|
3014
3055
|
children: /* @__PURE__ */ jsx(icons.filterColumn, {})
|
|
@@ -3450,8 +3491,9 @@ function TableHeader({ table, columnWidths, columnSizing, columnWindow }) {
|
|
|
3450
3491
|
});
|
|
3451
3492
|
}
|
|
3452
3493
|
function HeaderCell({ header, table, reorder, resize, columnWidths, columnSizing, colSpan, ariaColIndex }) {
|
|
3453
|
-
const { getStyles, labels, icons } = useDataTableContext();
|
|
3494
|
+
const { getStyles, labels, icons, size } = useDataTableContext();
|
|
3454
3495
|
const { column } = header;
|
|
3496
|
+
const { glyph } = SIZES[size];
|
|
3455
3497
|
const { meta } = column.columnDef;
|
|
3456
3498
|
const internal = isInternalColumn(column.id);
|
|
3457
3499
|
const canSort = column.getCanSort();
|
|
@@ -3527,9 +3569,9 @@ function HeaderCell({ header, table, reorder, resize, columnWidths, columnSizing
|
|
|
3527
3569
|
...getStyles("sortIndicator"),
|
|
3528
3570
|
"data-sorted": sorted || void 0,
|
|
3529
3571
|
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:
|
|
3572
|
+
sorted === "asc" && /* @__PURE__ */ jsx(icons.sortAsc, { size: glyph }),
|
|
3573
|
+
sorted === "desc" && /* @__PURE__ */ jsx(icons.sortDesc, { size: glyph }),
|
|
3574
|
+
sorted === false && /* @__PURE__ */ jsx(icons.sortable, { size: glyph }),
|
|
3533
3575
|
sorted !== false && sortCount > 1 && sortIndex >= 0 && /* @__PURE__ */ jsx("sup", { children: sortIndex + 1 })
|
|
3534
3576
|
]
|
|
3535
3577
|
})]
|
|
@@ -3682,7 +3724,7 @@ function minWidthPx(tableMinWidth, viewport) {
|
|
|
3682
3724
|
if (!tableElement) return Number.parseFloat(tableMinWidth) || 0;
|
|
3683
3725
|
return Number.parseFloat(getComputedStyle(tableElement).minWidth) || 0;
|
|
3684
3726
|
}
|
|
3685
|
-
function useColumnWidths(table, columns, viewport, tableMinWidth) {
|
|
3727
|
+
function useColumnWidths(table, columns, viewport, tableMinWidth, injectedWidth) {
|
|
3686
3728
|
const [availableWidth, setAvailableWidth] = useState(0);
|
|
3687
3729
|
const measure = useCallback(() => {
|
|
3688
3730
|
if (!viewport) return;
|
|
@@ -3701,6 +3743,12 @@ function useColumnWidths(table, columns, viewport, tableMinWidth) {
|
|
|
3701
3743
|
const resolved = useMemo(() => {
|
|
3702
3744
|
return resolveColumnWidths(columns.map((column) => {
|
|
3703
3745
|
const raw = rawColumnSizing(column.columnDef);
|
|
3746
|
+
if (isInternalColumn(column.id)) return {
|
|
3747
|
+
id: column.id,
|
|
3748
|
+
size: raw?.size ?? injectedWidth,
|
|
3749
|
+
minSize: raw?.minSize ?? injectedWidth,
|
|
3750
|
+
maxSize: raw?.maxSize ?? injectedWidth
|
|
3751
|
+
};
|
|
3704
3752
|
return {
|
|
3705
3753
|
id: column.id,
|
|
3706
3754
|
size: raw ? raw.size ?? defaultColumn?.size : column.columnDef.size,
|
|
@@ -3712,7 +3760,8 @@ function useColumnWidths(table, columns, viewport, tableMinWidth) {
|
|
|
3712
3760
|
columns,
|
|
3713
3761
|
columnSizing,
|
|
3714
3762
|
availableWidth,
|
|
3715
|
-
defaultColumn
|
|
3763
|
+
defaultColumn,
|
|
3764
|
+
injectedWidth
|
|
3716
3765
|
]);
|
|
3717
3766
|
const signature = JSON.stringify([resolved.total, Object.entries(resolved.byId)]);
|
|
3718
3767
|
return useMemo(() => resolved, [signature]);
|
|
@@ -6387,8 +6436,7 @@ const defaultProps = {
|
|
|
6387
6436
|
withColumnBorders: false,
|
|
6388
6437
|
withRowBorders: true,
|
|
6389
6438
|
withBottomBorder: false,
|
|
6390
|
-
|
|
6391
|
-
horizontalSpacing: "xs",
|
|
6439
|
+
size: "sm",
|
|
6392
6440
|
tabularNums: false,
|
|
6393
6441
|
virtualizedRows: false,
|
|
6394
6442
|
virtualizedColumns: false,
|
|
@@ -6402,12 +6450,13 @@ const defaultProps = {
|
|
|
6402
6450
|
function leafCol(column) {
|
|
6403
6451
|
return /* @__PURE__ */ jsx("col", { style: { width: `var(${columnWidthVar(column.id)})` } }, column.id);
|
|
6404
6452
|
}
|
|
6405
|
-
const varsResolver = createVarsResolver((theme, { stripedColor, highlightOnHoverColor, borderColor, radius }) => {
|
|
6453
|
+
const varsResolver = createVarsResolver((theme, { stripedColor, highlightOnHoverColor, borderColor, radius, size }) => {
|
|
6406
6454
|
return { root: {
|
|
6407
6455
|
"--ledger-striped-color": stripedColor ? getThemeColor(stripedColor, theme) : void 0,
|
|
6408
6456
|
"--ledger-hover-color": highlightOnHoverColor ? getThemeColor(highlightOnHoverColor, theme) : void 0,
|
|
6409
6457
|
"--ledger-border-color": borderColor ? getThemeColor(borderColor, theme) : void 0,
|
|
6410
|
-
"--ledger-radius": radius === void 0 ? void 0 : getRadius(radius)
|
|
6458
|
+
"--ledger-radius": radius === void 0 ? void 0 : getRadius(radius),
|
|
6459
|
+
"--ledger-font-size": getFontSize(size)
|
|
6411
6460
|
} };
|
|
6412
6461
|
});
|
|
6413
6462
|
const OPTION_KEY_SET = /* @__PURE__ */ new Set([
|
|
@@ -6528,7 +6577,7 @@ function DataTableFromOptions({ props }) {
|
|
|
6528
6577
|
});
|
|
6529
6578
|
}
|
|
6530
6579
|
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;
|
|
6580
|
+
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
6581
|
const getStyles = useStyles({
|
|
6533
6582
|
name: "DataTable",
|
|
6534
6583
|
classes,
|
|
@@ -6581,9 +6630,11 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
6581
6630
|
const displayOrderSignature = JSON.stringify(displayColumns.map((column) => column.id));
|
|
6582
6631
|
const ledgerColumns = table.options.meta?.ledger?.columns;
|
|
6583
6632
|
const visibleLeafColumns = useMemo(() => displayColumns, [displayOrderSignature, ledgerColumns]);
|
|
6584
|
-
const
|
|
6633
|
+
const size = sizeProp ?? "sm";
|
|
6634
|
+
const scale = SIZES[size];
|
|
6635
|
+
const columnWidths = useColumnWidths(table, visibleLeafColumns, viewport, tableMinWidth, scale.injectedWidth);
|
|
6585
6636
|
const virtualization = virtualizedRows ? {
|
|
6586
|
-
estimateHeight: typeof virtualizedRows === "object" && virtualizedRows.estimateHeight !== void 0 ? virtualizedRows.estimateHeight :
|
|
6637
|
+
estimateHeight: typeof virtualizedRows === "object" && virtualizedRows.estimateHeight !== void 0 ? virtualizedRows.estimateHeight : scale.rowHeight,
|
|
6587
6638
|
overscan: typeof virtualizedRows === "object" && virtualizedRows.overscan !== void 0 ? virtualizedRows.overscan : 8
|
|
6588
6639
|
} : null;
|
|
6589
6640
|
const virtualEnabled = virtualization !== null;
|
|
@@ -7013,11 +7064,11 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
7013
7064
|
]);
|
|
7014
7065
|
const stripedMode = striped === true ? "odd" : striped || void 0;
|
|
7015
7066
|
const sharedTableProps = {
|
|
7016
|
-
horizontalSpacing,
|
|
7067
|
+
horizontalSpacing: horizontalSpacing ?? scale.horizontalSpacing,
|
|
7017
7068
|
layout: "fixed",
|
|
7018
7069
|
role: "presentation",
|
|
7019
7070
|
tabularNums,
|
|
7020
|
-
verticalSpacing
|
|
7071
|
+
verticalSpacing: verticalSpacing ?? scale.verticalSpacing
|
|
7021
7072
|
};
|
|
7022
7073
|
const tableStyleProps = () => getStyles("table", { style: {
|
|
7023
7074
|
width: columnWidths.total > 0 ? columnWidths.total : void 0,
|
|
@@ -7053,6 +7104,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
7053
7104
|
getStyles: stylesRevision,
|
|
7054
7105
|
labels,
|
|
7055
7106
|
icons,
|
|
7107
|
+
size,
|
|
7056
7108
|
filterMode,
|
|
7057
7109
|
virtualizedRows: virtualEnabled,
|
|
7058
7110
|
withColumnHeaders: columnHeadersVisible,
|
|
@@ -7076,6 +7128,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
7076
7128
|
stylesRevision,
|
|
7077
7129
|
labels,
|
|
7078
7130
|
icons,
|
|
7131
|
+
size,
|
|
7079
7132
|
filterMode,
|
|
7080
7133
|
virtualEnabled,
|
|
7081
7134
|
columnHeadersVisible,
|
|
@@ -7099,6 +7152,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
7099
7152
|
"data-loading": loading || void 0,
|
|
7100
7153
|
"data-scrolled-end": scrollEdges.end || void 0,
|
|
7101
7154
|
"data-scrolled-start": scrollEdges.start || void 0,
|
|
7155
|
+
"data-size": size,
|
|
7102
7156
|
"data-striped": stripedMode,
|
|
7103
7157
|
"data-virtualized-columns": columnWindow !== null || void 0,
|
|
7104
7158
|
"data-virtualized-rows": virtualEnabled || void 0,
|
|
@@ -7263,14 +7317,15 @@ DataTable.SelectionBar = DataTableSelectionBar;
|
|
|
7263
7317
|
* The shipped editor renderers — conveniences, never the mechanism. Each is an ordinary
|
|
7264
7318
|
* renderer over the public editing contexts (docs/editing.md#editors), which is the proof the
|
|
7265
7319
|
* 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
|
|
7320
|
+
* All are default-variant Mantine inputs at the context's `size` — the border marks the cell as an
|
|
7321
|
+
* open editor, and the size keeps it inside the row.
|
|
7267
7322
|
*/
|
|
7268
|
-
const renderTextEditor = ({ value, setValue, error, pending, autoFocus, label }) => /* @__PURE__ */ jsx(TextInput, {
|
|
7323
|
+
const renderTextEditor = ({ value, setValue, error, pending, autoFocus, label, size }) => /* @__PURE__ */ jsx(TextInput, {
|
|
7269
7324
|
"aria-label": label,
|
|
7270
7325
|
autoFocus,
|
|
7271
7326
|
disabled: pending,
|
|
7272
7327
|
error,
|
|
7273
|
-
size
|
|
7328
|
+
size,
|
|
7274
7329
|
value: value === null || value === void 0 ? "" : String(value),
|
|
7275
7330
|
onChange: (event) => setValue(event.currentTarget.value)
|
|
7276
7331
|
});
|
|
@@ -7280,13 +7335,13 @@ const renderTextEditor = ({ value, setValue, error, pending, autoFocus, label })
|
|
|
7280
7335
|
function textEditor() {
|
|
7281
7336
|
return renderTextEditor;
|
|
7282
7337
|
}
|
|
7283
|
-
const renderNumberEditor = ({ value, setValue, error, pending, autoFocus, label }) => /* @__PURE__ */ jsx(NumberInput, {
|
|
7338
|
+
const renderNumberEditor = ({ value, setValue, error, pending, autoFocus, label, size }) => /* @__PURE__ */ jsx(NumberInput, {
|
|
7284
7339
|
hideControls: true,
|
|
7285
7340
|
"aria-label": label,
|
|
7286
7341
|
autoFocus,
|
|
7287
7342
|
disabled: pending,
|
|
7288
7343
|
error,
|
|
7289
|
-
size
|
|
7344
|
+
size,
|
|
7290
7345
|
value: typeof value === "number" || typeof value === "string" ? value : "",
|
|
7291
7346
|
onChange: (next) => setValue(next === "" ? null : next)
|
|
7292
7347
|
});
|
|
@@ -7302,7 +7357,7 @@ function numberEditor() {
|
|
|
7302
7357
|
* draft-bound field among the row's others, and the row's own commit decides.
|
|
7303
7358
|
*/
|
|
7304
7359
|
function selectEditor(options) {
|
|
7305
|
-
return ({ value, setValue, commit, error, pending, mode, autoFocus, label }) => /* @__PURE__ */ jsx(Select, {
|
|
7360
|
+
return ({ value, setValue, commit, error, pending, mode, autoFocus, label, size }) => /* @__PURE__ */ jsx(Select, {
|
|
7306
7361
|
"aria-label": label,
|
|
7307
7362
|
autoFocus,
|
|
7308
7363
|
comboboxProps: { withinPortal: true },
|
|
@@ -7310,7 +7365,7 @@ function selectEditor(options) {
|
|
|
7310
7365
|
defaultDropdownOpened: mode === "cell",
|
|
7311
7366
|
disabled: pending,
|
|
7312
7367
|
error,
|
|
7313
|
-
size
|
|
7368
|
+
size,
|
|
7314
7369
|
value: value === null || value === void 0 ? null : String(value),
|
|
7315
7370
|
onChange: (next) => {
|
|
7316
7371
|
setValue(next);
|
|
@@ -7318,12 +7373,12 @@ function selectEditor(options) {
|
|
|
7318
7373
|
}
|
|
7319
7374
|
});
|
|
7320
7375
|
}
|
|
7321
|
-
const renderCheckboxEditor = ({ value, commit, pending, error, label }) => /* @__PURE__ */ jsx(Checkbox, {
|
|
7376
|
+
const renderCheckboxEditor = ({ value, commit, pending, error, label, size }) => /* @__PURE__ */ jsx(Checkbox, {
|
|
7322
7377
|
"aria-label": label,
|
|
7323
7378
|
checked: Boolean(value),
|
|
7324
7379
|
disabled: pending,
|
|
7325
7380
|
error: Boolean(error),
|
|
7326
|
-
size
|
|
7381
|
+
size,
|
|
7327
7382
|
onChange: (event) => void commit(event.currentTarget.checked)
|
|
7328
7383
|
});
|
|
7329
7384
|
/**
|