@coldsmirk/ledger-mantine 0.1.1 → 0.3.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.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { n as defaultLabels, t as DataTableLabels } from "./labels-ChBqD1II.cjs";
3
- import { BoxProps, ComboboxData, ElementProps, Factory, MantineBreakpoint, MantineColor, MantineSpacing, PopoverProps, StylesApiProps, TableTdProps, TableThProps, TableTrProps, TextInputProps } from "@mantine/core";
3
+ import { BoxProps, ComboboxData, ElementProps, Factory, MantineBreakpoint, MantineColor, MantineRadius, MantineSpacing, PopoverProps, StylesApiProps, TableTdProps, TableThProps, TableTrProps, TextInputProps } from "@mantine/core";
4
4
  import { Cell as Cell$1, CellData, Column as Column$1, ColumnDef as ColumnDef$1, ColumnFiltersState, ColumnFiltersState as ColumnFiltersState$1, ColumnOrderState, ColumnOrderState as ColumnOrderState$1, ColumnPinningState, ColumnPinningState as ColumnPinningState$1, ColumnSizingState, ColumnSizingState as ColumnSizingState$1, ColumnVisibilityState, ColumnVisibilityState as ColumnVisibilityState$1, ExpandedState, ExpandedState as ExpandedState$1, FilterFn, FilterFnOption, GroupingState, GroupingState as GroupingState$1, Header as Header$1, HeaderGroup as HeaderGroup$1, PaginationState, PaginationState as PaginationState$1, ReactTable, Row as Row$1, RowData, RowData as RowData$1, RowPinningState, RowPinningState as RowPinningState$1, RowSelectionState, RowSelectionState as RowSelectionState$1, SortingState, SortingState as SortingState$1, TableFeatures, TableOptions, flexRender } from "@tanstack/react-table";
5
5
  import { CSSProperties, ComponentProps, ComponentType, JSX, KeyboardEvent, MouseEvent, ReactElement, ReactNode, Ref } from "react";
6
6
  //#region src/icons.d.ts
@@ -972,7 +972,7 @@ declare function DataTableSelectionBar<TData extends RowData$1>(props: DataTable
972
972
  //#region src/data-table.d.ts
973
973
  type DataTableStylesNames = "root" | "main" | "header" | "scroller" | "footer" | "table" | "thead" | "tbody" | "tfoot" | "headerRow" | "headerCell" | "headerLabel" | "headerActions" | "sortIndicator" | "resizer" | "filterPopover" | "row" | "cell" | "selectionCell" | "expanderCell" | "detailPanel" | "cellEditor" | "instantCell" | "instantSpinner" | "rowDragCell" | "rowDragOverlay" | "footerRow" | "footerCell" | "empty" | "loaderRow" | "loaderRowContent" | "paginationBar";
974
974
  interface DataTableCssVariables {
975
- root: "--ledger-striped-color" | "--ledger-hover-color" | "--ledger-border-color";
975
+ root: "--ledger-striped-color" | "--ledger-hover-color" | "--ledger-border-color" | "--ledger-radius";
976
976
  }
977
977
  interface DataTableBaseProps<TData extends RowData$1> extends BoxProps, StylesApiProps<DataTableFactory>, ElementProps<"div"> {
978
978
  /**
@@ -986,7 +986,19 @@ interface DataTableBaseProps<TData extends RowData$1> extends BoxProps, StylesAp
986
986
  withTableBorder?: boolean;
987
987
  withColumnBorders?: boolean;
988
988
  withRowBorders?: boolean;
989
+ /**
990
+ * The closing line under the last row — and under a footer — for a table that stands alone
991
+ * without a frame. Mantine's `Table` leaves the last row open, so this is off by default; the
992
+ * `withTableBorder` frame closes the table itself and ignores it (docs/styling.md#borders).
993
+ */
994
+ withBottomBorder?: boolean;
989
995
  borderColor?: MantineColor;
996
+ /**
997
+ * Corner radius of the table box — header, body, and footer as one rounded, clipping box;
998
+ * the `withTableBorder` frame follows it, so a framed table can be its own card (host
999
+ * vocabulary: `Paper.radius`).
1000
+ */
1001
+ radius?: MantineRadius;
990
1002
  verticalSpacing?: MantineSpacing;
991
1003
  horizontalSpacing?: MantineSpacing;
992
1004
  tabularNums?: boolean;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { n as defaultLabels, t as DataTableLabels } from "./labels-ChBqD1II.js";
3
- import { BoxProps, ComboboxData, ElementProps, Factory, MantineBreakpoint, MantineColor, MantineSpacing, PopoverProps, StylesApiProps, TableTdProps, TableThProps, TableTrProps, TextInputProps } from "@mantine/core";
3
+ import { BoxProps, ComboboxData, ElementProps, Factory, MantineBreakpoint, MantineColor, MantineRadius, MantineSpacing, PopoverProps, StylesApiProps, TableTdProps, TableThProps, TableTrProps, TextInputProps } from "@mantine/core";
4
4
  import { CSSProperties, ComponentProps, ComponentType, JSX, KeyboardEvent, MouseEvent, ReactElement, ReactNode, Ref } from "react";
5
5
  import { Cell as Cell$1, CellData, Column as Column$1, ColumnDef as ColumnDef$1, ColumnFiltersState, ColumnFiltersState as ColumnFiltersState$1, ColumnOrderState, ColumnOrderState as ColumnOrderState$1, ColumnPinningState, ColumnPinningState as ColumnPinningState$1, ColumnSizingState, ColumnSizingState as ColumnSizingState$1, ColumnVisibilityState, ColumnVisibilityState as ColumnVisibilityState$1, ExpandedState, ExpandedState as ExpandedState$1, FilterFn, FilterFnOption, GroupingState, GroupingState as GroupingState$1, Header as Header$1, HeaderGroup as HeaderGroup$1, PaginationState, PaginationState as PaginationState$1, ReactTable, Row as Row$1, RowData, RowData as RowData$1, RowPinningState, RowPinningState as RowPinningState$1, RowSelectionState, RowSelectionState as RowSelectionState$1, SortingState, SortingState as SortingState$1, TableFeatures, TableOptions, flexRender } from "@tanstack/react-table";
6
6
  //#region src/icons.d.ts
@@ -972,7 +972,7 @@ declare function DataTableSelectionBar<TData extends RowData$1>(props: DataTable
972
972
  //#region src/data-table.d.ts
973
973
  type DataTableStylesNames = "root" | "main" | "header" | "scroller" | "footer" | "table" | "thead" | "tbody" | "tfoot" | "headerRow" | "headerCell" | "headerLabel" | "headerActions" | "sortIndicator" | "resizer" | "filterPopover" | "row" | "cell" | "selectionCell" | "expanderCell" | "detailPanel" | "cellEditor" | "instantCell" | "instantSpinner" | "rowDragCell" | "rowDragOverlay" | "footerRow" | "footerCell" | "empty" | "loaderRow" | "loaderRowContent" | "paginationBar";
974
974
  interface DataTableCssVariables {
975
- root: "--ledger-striped-color" | "--ledger-hover-color" | "--ledger-border-color";
975
+ root: "--ledger-striped-color" | "--ledger-hover-color" | "--ledger-border-color" | "--ledger-radius";
976
976
  }
977
977
  interface DataTableBaseProps<TData extends RowData$1> extends BoxProps, StylesApiProps<DataTableFactory>, ElementProps<"div"> {
978
978
  /**
@@ -986,7 +986,19 @@ interface DataTableBaseProps<TData extends RowData$1> extends BoxProps, StylesAp
986
986
  withTableBorder?: boolean;
987
987
  withColumnBorders?: boolean;
988
988
  withRowBorders?: boolean;
989
+ /**
990
+ * The closing line under the last row — and under a footer — for a table that stands alone
991
+ * without a frame. Mantine's `Table` leaves the last row open, so this is off by default; the
992
+ * `withTableBorder` frame closes the table itself and ignores it (docs/styling.md#borders).
993
+ */
994
+ withBottomBorder?: boolean;
989
995
  borderColor?: MantineColor;
996
+ /**
997
+ * Corner radius of the table box — header, body, and footer as one rounded, clipping box;
998
+ * the `withTableBorder` frame follows it, so a framed table can be its own card (host
999
+ * vocabulary: `Paper.radius`).
1000
+ */
1001
+ radius?: MantineRadius;
990
1002
  verticalSpacing?: MantineSpacing;
991
1003
  horizontalSpacing?: MantineSpacing;
992
1004
  tabularNums?: boolean;
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, 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, 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";
@@ -2438,7 +2438,7 @@ function InstantCell({ cell, render }) {
2438
2438
  ]
2439
2439
  });
2440
2440
  }
2441
- function DataCell({ cell, editing, rowEditing, isFirstDataCell, depth, rowSpan, colSpan, ariaColIndex }) {
2441
+ function DataCell({ cell, editing, rowEditing, isFirstDataCell, depth, rowSpan, colSpan, ariaColIndex, last }) {
2442
2442
  const { getStyles } = useDataTableContext();
2443
2443
  const { column, row } = cell;
2444
2444
  const { table } = cell.getContext();
@@ -2494,6 +2494,7 @@ function DataCell({ cell, editing, rowEditing, isFirstDataCell, depth, rowSpan,
2494
2494
  "data-align": meta?.align,
2495
2495
  "data-editable": editable || void 0,
2496
2496
  "data-editing": cellEditorActive || rowEditorActive || void 0,
2497
+ "data-last": last || void 0,
2497
2498
  "data-leading": column.getIsFirstColumn() || void 0,
2498
2499
  "data-ledger-column-id": column.id,
2499
2500
  "data-pinned": column.getIsPinned() || void 0,
@@ -2508,7 +2509,7 @@ function DataCell({ cell, editing, rowEditing, isFirstDataCell, depth, rowSpan,
2508
2509
  children: content
2509
2510
  });
2510
2511
  }
2511
- function DataRowImpl({ row, dataIndex, editingColumnId, editingRow, dragging, dropSide, selected, active, expanded, depth, spanning, columnWindow, pinnedPosition, pinnedOffset, virtualIndex, measureRef, ariaRowIndex }) {
2512
+ function DataRowImpl({ row, dataIndex, last, rowsBelow, editingColumnId, editingRow, dragging, dropSide, selected, active, expanded, depth, spanning, columnWindow, pinnedPosition, pinnedOffset, virtualIndex, measureRef, ariaRowIndex }) {
2512
2513
  const { getStyles, onRowClick, onRowActivate, onRowDoubleClick, onRowContextMenu, rowProps, activeRowEnabled, setActiveRow } = useDataTableContext();
2513
2514
  const cells = row.getVisibleCells();
2514
2515
  const firstDataCellIndex = cells.findIndex((cell) => !isInternalColumn(cell.column.id));
@@ -2532,6 +2533,7 @@ function DataRowImpl({ row, dataIndex, editingColumnId, editingRow, dragging, dr
2532
2533
  "data-editing-row": editingRow || void 0,
2533
2534
  "data-expanded": expanded || void 0,
2534
2535
  "data-index": virtualIndex,
2536
+ "data-last": last || void 0,
2535
2537
  "data-parity": dataIndex >= 0 ? dataIndex % 2 === 0 ? "odd" : "even" : void 0,
2536
2538
  "data-pinned-row": pinnedPosition,
2537
2539
  "data-row-id": row.id,
@@ -2554,6 +2556,7 @@ function DataRowImpl({ row, dataIndex, editingColumnId, editingRow, dragging, dr
2554
2556
  depth,
2555
2557
  editing: editingColumnId === cell.column.id,
2556
2558
  isFirstDataCell: displayIndex === firstDataCellIndex,
2559
+ last: rowsBelow === void 0 ? last : cell.getRowSpan() - 1 === rowsBelow,
2557
2560
  rowEditing: editingRow,
2558
2561
  rowSpan: spanning ? cell.getRowSpan() : 1
2559
2562
  }, cell.id);
@@ -2578,7 +2581,7 @@ function DataRowImpl({ row, dataIndex, editingColumnId, editingRow, dragging, dr
2578
2581
  }
2579
2582
  }
2580
2583
  const DataRow = memo(DataRowImpl);
2581
- function DetailRow({ row, renderDetailPanel, colSpan, dragging, dropSide, pinnedPosition, pinnedOffset, virtualIndex, measureRef, ariaRowIndex }) {
2584
+ function DetailRow({ row, renderDetailPanel, colSpan, dragging, dropSide, last, pinnedPosition, pinnedOffset, virtualIndex, measureRef, ariaRowIndex }) {
2582
2585
  const { getStyles } = useDataTableContext();
2583
2586
  const pinnedStyle = pinnedPosition === "top" ? { top: `${pinnedOffset ?? 0}px` } : pinnedPosition === "bottom" ? { bottom: `${pinnedOffset ?? 0}px` } : void 0;
2584
2587
  return /* @__PURE__ */ jsx(Table.Tr, {
@@ -2588,6 +2591,7 @@ function DetailRow({ row, renderDetailPanel, colSpan, dragging, dropSide, pinned
2588
2591
  "data-dragging": dragging || void 0,
2589
2592
  "data-drop-side": dropSide ?? void 0,
2590
2593
  "data-index": virtualIndex,
2594
+ "data-last": last || void 0,
2591
2595
  "data-pinned-row": pinnedPosition,
2592
2596
  role: "row",
2593
2597
  ...getStyles("row", { style: pinnedStyle }),
@@ -2603,6 +2607,7 @@ function SkeletonRows({ rowCount, columnCount, ariaRowIndexStart }) {
2603
2607
  const { getStyles } = useDataTableContext();
2604
2608
  return /* @__PURE__ */ jsx(Fragment, { children: Array.from({ length: rowCount }, (_, rowIndex) => /* @__PURE__ */ jsx(Table.Tr, {
2605
2609
  "aria-rowindex": ariaRowIndexStart === void 0 ? void 0 : ariaRowIndexStart + rowIndex,
2610
+ "data-last": rowIndex === rowCount - 1 || void 0,
2606
2611
  role: "row",
2607
2612
  ...getStyles("row"),
2608
2613
  children: Array.from({ length: columnCount }, (_, columnIndex) => /* @__PURE__ */ jsx(Table.Td, {
@@ -2746,13 +2751,26 @@ function TableBody({ table, virtualization, columnWindow, viewportRef, loading,
2746
2751
  const editingCell = ledger?.editing.cell ?? null;
2747
2752
  const editingRowId = ledger?.editing.mode === "row" ? ledger.editing.row.id : null;
2748
2753
  const activeRowId = ledger?.activeRow.enabled ? ledger.activeRow.id : null;
2754
+ const trailingRowCount = loadMoreError || loadingMore ? 1 : 0;
2755
+ const zoneRows = {
2756
+ top: topDisplayRows,
2757
+ center: centerDisplayRows,
2758
+ bottom: bottomDisplayRows
2759
+ };
2760
+ const rowsBelowOf = (zone, displayIndex) => {
2761
+ const laterZones = zone === "top" ? centerDisplayRows.length + bottomDisplayRows.length : zone === "center" ? bottomDisplayRows.length : 0;
2762
+ return zoneRows[zone].length - 1 - displayIndex + laterZones + trailingRowCount;
2763
+ };
2749
2764
  const renderDisplayRow = (displayRow, options) => {
2750
2765
  const zoneStart = options.pinnedPosition === "top" ? headerRowCount : options.pinnedPosition === "bottom" ? headerRowCount + topDisplayRows.length + centerDisplayRows.length : headerRowCount + topDisplayRows.length;
2751
2766
  const ariaRowIndex = virtualEnabled ? zoneStart + options.displayIndex + 1 : void 0;
2767
+ const rowsBelow = rowsBelowOf(options.pinnedPosition ?? "center", options.displayIndex);
2768
+ const last = rowsBelow === 0;
2752
2769
  if (displayRow.kind === "detail") return /* @__PURE__ */ jsx(DetailRow, {
2753
2770
  ariaRowIndex,
2754
2771
  colSpan: fullWidthColSpan,
2755
2772
  dragging: reorderSourceId === displayRow.row.id,
2773
+ last,
2756
2774
  measureRef: options.measureRef,
2757
2775
  pinnedOffset: options.pinnedOffset,
2758
2776
  pinnedPosition: options.pinnedPosition,
@@ -2775,12 +2793,14 @@ function TableBody({ table, virtualization, columnWindow, viewportRef, loading,
2775
2793
  dropSide,
2776
2794
  editingRow: editingRowId === row.id && (ledger?.editing.row.active(row.id) ?? false),
2777
2795
  expanded: row.getIsExpanded(),
2796
+ last,
2778
2797
  measureRef: options.measureRef,
2779
2798
  pinKey,
2780
2799
  pinnedOffset: options.pinnedOffset,
2781
2800
  pinnedPosition: options.pinnedPosition,
2782
2801
  renderVersion,
2783
2802
  row,
2803
+ rowsBelow: spanningActive ? rowsBelow : void 0,
2784
2804
  selected: row.getIsSelected(),
2785
2805
  spanKey,
2786
2806
  spanning: spanningActive,
@@ -6366,6 +6386,7 @@ const defaultProps = {
6366
6386
  withTableBorder: false,
6367
6387
  withColumnBorders: false,
6368
6388
  withRowBorders: true,
6389
+ withBottomBorder: false,
6369
6390
  verticalSpacing: "xs",
6370
6391
  horizontalSpacing: "xs",
6371
6392
  tabularNums: false,
@@ -6381,11 +6402,12 @@ const defaultProps = {
6381
6402
  function leafCol(column) {
6382
6403
  return /* @__PURE__ */ jsx("col", { style: { width: `var(${columnWidthVar(column.id)})` } }, column.id);
6383
6404
  }
6384
- const varsResolver = createVarsResolver((theme, { stripedColor, highlightOnHoverColor, borderColor }) => {
6405
+ const varsResolver = createVarsResolver((theme, { stripedColor, highlightOnHoverColor, borderColor, radius }) => {
6385
6406
  return { root: {
6386
6407
  "--ledger-striped-color": stripedColor ? getThemeColor(stripedColor, theme) : void 0,
6387
6408
  "--ledger-hover-color": highlightOnHoverColor ? getThemeColor(highlightOnHoverColor, theme) : void 0,
6388
- "--ledger-border-color": borderColor ? getThemeColor(borderColor, theme) : void 0
6409
+ "--ledger-border-color": borderColor ? getThemeColor(borderColor, theme) : void 0,
6410
+ "--ledger-radius": radius === void 0 ? void 0 : getRadius(radius)
6389
6411
  } };
6390
6412
  });
6391
6413
  const OPTION_KEY_SET = /* @__PURE__ */ new Set([
@@ -6506,7 +6528,7 @@ function DataTableFromOptions({ props }) {
6506
6528
  });
6507
6529
  }
6508
6530
  function DataTableCore({ presentation, stylesProps, table }) {
6509
- const { striped, stripedColor: _stripedColor, highlightOnHover, highlightOnHoverColor: _highlightOnHoverColor, withTableBorder, withColumnBorders, withRowBorders, borderColor: _borderColor, 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;
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;
6510
6532
  const getStyles = useStyles({
6511
6533
  name: "DataTable",
6512
6534
  classes,
@@ -7080,7 +7102,9 @@ function DataTableCore({ presentation, stylesProps, table }) {
7080
7102
  "data-striped": stripedMode,
7081
7103
  "data-virtualized-columns": columnWindow !== null || void 0,
7082
7104
  "data-virtualized-rows": virtualEnabled || void 0,
7105
+ "data-with-bottom-border": withBottomBorder || void 0,
7083
7106
  "data-with-column-borders": withColumnBorders || void 0,
7107
+ "data-with-footer": hasFooter || void 0,
7084
7108
  "data-with-row-borders": withRowBorders || void 0,
7085
7109
  "data-with-table-border": withTableBorder || void 0,
7086
7110
  ...getStyles("root", { style: columnVars }),