@coldsmirk/ledger-mantine 0.1.0 → 0.2.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
  /**
@@ -987,6 +987,12 @@ interface DataTableBaseProps<TData extends RowData$1> extends BoxProps, StylesAp
987
987
  withColumnBorders?: boolean;
988
988
  withRowBorders?: boolean;
989
989
  borderColor?: MantineColor;
990
+ /**
991
+ * Corner radius of the table box — header, body, and footer as one rounded, clipping box;
992
+ * the `withTableBorder` frame follows it, so a framed table can be its own card (host
993
+ * vocabulary: `Paper.radius`).
994
+ */
995
+ radius?: MantineRadius;
990
996
  verticalSpacing?: MantineSpacing;
991
997
  horizontalSpacing?: MantineSpacing;
992
998
  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
  /**
@@ -987,6 +987,12 @@ interface DataTableBaseProps<TData extends RowData$1> extends BoxProps, StylesAp
987
987
  withColumnBorders?: boolean;
988
988
  withRowBorders?: boolean;
989
989
  borderColor?: MantineColor;
990
+ /**
991
+ * Corner radius of the table box — header, body, and footer as one rounded, clipping box;
992
+ * the `withTableBorder` frame follows it, so a framed table can be its own card (host
993
+ * vocabulary: `Paper.radius`).
994
+ */
995
+ radius?: MantineRadius;
990
996
  verticalSpacing?: MantineSpacing;
991
997
  horizontalSpacing?: MantineSpacing;
992
998
  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";
@@ -123,9 +123,10 @@ const dateRange = (row, columnId, filterValue) => {
123
123
  };
124
124
  dateRange.autoRemove = (value) => !value || !value[0] && !value[1];
125
125
  /**
126
- * Strict set membership for the multi-select variant. TanStack's `arrIncludesSome` expects an
127
- * array row value and degrades to substring matching on scalars ("active" would match
128
- * "inactive") — the variant's semantics are exact membership for scalar and array cells.
126
+ * Strict set membership for the multi-select variant. No TanStack built-in covers both cell
127
+ * shapes exactly: `arrIncludesSome` rejects non-array row values outright, `arrHas` rejects
128
+ * array cells, and `arrIncludes` substring-matches strings ("active" would match "inactive") —
129
+ * the variant's semantics are exact membership for scalar and array cells.
129
130
  */
130
131
  const oneOf = (row, columnId, filterValue) => {
131
132
  const raw = row.getValue(columnId);
@@ -493,10 +494,12 @@ function RowReorderOverlay({ session }) {
493
494
  function RowDragCell({ row, table }) {
494
495
  const { labels, icons, rowReorderKeyboard } = useDataTableContext();
495
496
  const orderable = table.options.meta?.ledger?.rowOrdering.orderable === true;
497
+ const pinned = table.options.enableRowPinning === true && row.getIsPinned() !== false;
496
498
  const { ref, isDragSource } = useDraggable({
497
499
  id: row.id,
498
- disabled: !orderable
500
+ disabled: !orderable || pinned
499
501
  });
502
+ if (pinned) return null;
500
503
  const lifted = rowReorderKeyboard?.active(row.id) === true;
501
504
  const handleKeyDown = (event) => {
502
505
  const keyboard = rowReorderKeyboard;
@@ -2844,8 +2847,9 @@ function TableBody({ table, virtualization, columnWindow, viewportRef, loading,
2844
2847
  //#endregion
2845
2848
  //#region src/table-footer.tsx
2846
2849
  /**
2847
- * Column footers (totals row). Rendered only when at least one leaf column declares a `footer`;
2848
- * pinned columns keep their sticky offsets so the totals track their columns.
2850
+ * Column footers (totals row). Rendered only when at least one column — leaf or group —
2851
+ * declares a `footer`; pinned columns keep their sticky offsets so the totals track their
2852
+ * columns.
2849
2853
  */
2850
2854
  /**
2851
2855
  * The footer rows that actually render. `getFooterGroups()` mirrors *every* header level, so a
@@ -3700,10 +3704,14 @@ function useColumnWidths(table, columns, viewport, tableMinWidth) {
3700
3704
  * object so `typeof ledgerFeatures` (`LedgerFeatures`) can pre-bind the `TFeatures` generic of
3701
3705
  * every re-exported type — consumers keep writing v8-shaped `ColumnDef<TData>` code.
3702
3706
  *
3703
- * - Every stock feature is registered EXCEPT `columnResizingFeature`: ledger owns the resize
3704
- * interaction end to end (`use-column-resize.ts`), so TanStack's drag machinery — and with it
3705
- * the `columnResizing` state slice, `getIsResizing()`, and `getResizeHandler()` — is not
3706
- * registered at all. Feature-gated APIs cannot lie about a pipeline that never runs.
3707
+ * - Every stock feature is registered EXCEPT the two below.
3708
+ * - `columnResizingFeature`: ledger owns the resize interaction end to end
3709
+ * (`use-column-resize.ts`), so TanStack's drag machinery — and with it the `columnResizing`
3710
+ * state slice, `getIsResizing()`, and `getResizeHandler()` — is not registered at all.
3711
+ * Feature-gated APIs cannot lie about a pipeline that never runs.
3712
+ * - `cellSelectionFeature`: cell selection is deferred until its own design round
3713
+ * (docs/DESIGN.md), so the `cellSelection` state slice, `enableCellSelection`, and
3714
+ * `cell.getIsSelected()` are likewise absent by the same rule.
3707
3715
  * - Row model factories are registered statically; the `manualX` translations decide at runtime
3708
3716
  * whether a model actually processes rows (client mode) or passes through (server mode).
3709
3717
  * - Every built-in fn ships registered under its conventional name. v9 resolves string ids —
@@ -6029,6 +6037,18 @@ function useDataTable(options) {
6029
6037
  enableRowSelection,
6030
6038
  withExpander
6031
6039
  ]);
6040
+ const setPublicColumnPinning = useCallback((updater) => {
6041
+ setColumnPinning((old) => {
6042
+ const next = functionalUpdate(updater, old);
6043
+ const start = next.start.filter((id) => !isInternalColumn(id));
6044
+ const end = next.end.filter((id) => !isInternalColumn(id));
6045
+ if (start.length === next.start.length && end.length === next.end.length) return next;
6046
+ return start.length === old.start.length && end.length === old.end.length && start.every((id, index) => id === old.start[index]) && end.every((id, index) => id === old.end[index]) ? old : {
6047
+ end,
6048
+ start
6049
+ };
6050
+ });
6051
+ }, [setColumnPinning]);
6032
6052
  if (isDev && (enableRowSelection || withExpander) && !getRowId) warnOnce("missing-get-row-id", "Row selection/expansion is enabled without getRowId — index-based row ids corrupt state across refetches.");
6033
6053
  const churn = useRef({
6034
6054
  renders: 0,
@@ -6126,7 +6146,7 @@ function useDataTable(options) {
6126
6146
  onRowSelectionChange: setRowSelection,
6127
6147
  onExpandedChange: setExpanded,
6128
6148
  onColumnVisibilityChange: setColumnVisibility,
6129
- onColumnPinningChange: setColumnPinning,
6149
+ onColumnPinningChange: setPublicColumnPinning,
6130
6150
  onColumnOrderChange: setColumnOrder,
6131
6151
  onColumnSizingChange: setColumnSizing,
6132
6152
  onGroupingChange: setGrouping,
@@ -6361,11 +6381,12 @@ const defaultProps = {
6361
6381
  function leafCol(column) {
6362
6382
  return /* @__PURE__ */ jsx("col", { style: { width: `var(${columnWidthVar(column.id)})` } }, column.id);
6363
6383
  }
6364
- const varsResolver = createVarsResolver((theme, { stripedColor, highlightOnHoverColor, borderColor }) => {
6384
+ const varsResolver = createVarsResolver((theme, { stripedColor, highlightOnHoverColor, borderColor, radius }) => {
6365
6385
  return { root: {
6366
6386
  "--ledger-striped-color": stripedColor ? getThemeColor(stripedColor, theme) : void 0,
6367
6387
  "--ledger-hover-color": highlightOnHoverColor ? getThemeColor(highlightOnHoverColor, theme) : void 0,
6368
- "--ledger-border-color": borderColor ? getThemeColor(borderColor, theme) : void 0
6388
+ "--ledger-border-color": borderColor ? getThemeColor(borderColor, theme) : void 0,
6389
+ "--ledger-radius": radius === void 0 ? void 0 : getRadius(radius)
6369
6390
  } };
6370
6391
  });
6371
6392
  const OPTION_KEY_SET = /* @__PURE__ */ new Set([
@@ -6486,7 +6507,7 @@ function DataTableFromOptions({ props }) {
6486
6507
  });
6487
6508
  }
6488
6509
  function DataTableCore({ presentation, stylesProps, table }) {
6489
- 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;
6510
+ const { striped, stripedColor: _stripedColor, highlightOnHover, highlightOnHoverColor: _highlightOnHoverColor, withTableBorder, withColumnBorders, withRowBorders, 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;
6490
6511
  const getStyles = useStyles({
6491
6512
  name: "DataTable",
6492
6513
  classes,