simple-table-core 2.6.3 → 2.6.6

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.
Files changed (45) hide show
  1. package/dist/Animate-98c6e3ff.js +2 -0
  2. package/dist/Animate-98c6e3ff.js.map +1 -0
  3. package/dist/{DatePicker-f7a6a949.js → DatePicker-775f504e.js} +2 -2
  4. package/dist/DatePicker-775f504e.js.map +1 -0
  5. package/dist/cjs/Animate-07698e17.js +2 -0
  6. package/dist/cjs/Animate-07698e17.js.map +1 -0
  7. package/dist/cjs/{DatePicker-8be26322.js → DatePicker-d48eb4c4.js} +2 -2
  8. package/dist/cjs/DatePicker-d48eb4c4.js.map +1 -0
  9. package/dist/cjs/components/simple-table/RenderCells.d.ts +3 -1
  10. package/dist/cjs/components/simple-table/TableCell.d.ts +1 -1
  11. package/dist/cjs/components/simple-table/TableRow.d.ts +3 -1
  12. package/dist/cjs/components/simple-table/TableSection.d.ts +3 -0
  13. package/dist/cjs/context/TableContext.d.ts +8 -2
  14. package/dist/cjs/hooks/useKeyboardNavigation.d.ts +3 -3
  15. package/dist/cjs/index-709627ca.js +2 -0
  16. package/dist/cjs/index-709627ca.js.map +1 -0
  17. package/dist/cjs/index.js +1 -1
  18. package/dist/cjs/types/TableCellProps.d.ts +6 -0
  19. package/dist/cjs/utils/cellScrollUtils.d.ts +0 -6
  20. package/dist/cjs/utils/columnUtils.d.ts +13 -0
  21. package/dist/cjs/utils/columnVirtualizationUtils.d.ts +86 -0
  22. package/dist/components/simple-table/RenderCells.d.ts +3 -1
  23. package/dist/components/simple-table/TableCell.d.ts +1 -1
  24. package/dist/components/simple-table/TableRow.d.ts +3 -1
  25. package/dist/components/simple-table/TableSection.d.ts +3 -0
  26. package/dist/context/TableContext.d.ts +8 -2
  27. package/dist/hooks/useKeyboardNavigation.d.ts +3 -3
  28. package/dist/index-586682e1.js +2 -0
  29. package/dist/index-586682e1.js.map +1 -0
  30. package/dist/index.es.js +1 -1
  31. package/dist/types/TableCellProps.d.ts +6 -0
  32. package/dist/utils/cellScrollUtils.d.ts +0 -6
  33. package/dist/utils/columnUtils.d.ts +13 -0
  34. package/dist/utils/columnVirtualizationUtils.d.ts +86 -0
  35. package/package.json +1 -1
  36. package/dist/Animate-60695947.js +0 -2
  37. package/dist/Animate-60695947.js.map +0 -1
  38. package/dist/DatePicker-f7a6a949.js.map +0 -1
  39. package/dist/cjs/Animate-5abc33cc.js +0 -2
  40. package/dist/cjs/Animate-5abc33cc.js.map +0 -1
  41. package/dist/cjs/DatePicker-8be26322.js.map +0 -1
  42. package/dist/cjs/index-1fd4e5b3.js +0 -2
  43. package/dist/cjs/index-1fd4e5b3.js.map +0 -1
  44. package/dist/index-b46195cc.js +0 -2
  45. package/dist/index-b46195cc.js.map +0 -1
@@ -0,0 +1,86 @@
1
+ import HeaderObject, { Accessor } from "../types/HeaderObject";
2
+ import { Pinned } from "../types/Pinned";
3
+ /**
4
+ * Column virtualization for the horizontally-scrollable (main) section.
5
+ *
6
+ * This mirrors the row virtualization approach (cumulative position map + binary
7
+ * search + asymmetric overscan) but for columns. The algorithm is ported from the
8
+ * `main` branch's `columnVirtualizationUtils.ts`; the integration differs: instead of
9
+ * recomputing CSS grid offsets, v2 keeps the full `grid-template-columns` track list
10
+ * and places each rendered cell into its real track via `grid-column`, so the leaf
11
+ * order here must match the grid produced by `createGridTemplateColumns`. That is
12
+ * guaranteed by deriving the leaf list from the shared `flattenColumnsForGrid`.
13
+ */
14
+ /**
15
+ * Precomputed cumulative width data for O(1) column position lookups and
16
+ * O(log n) viewport calculations (analogous to CumulativeHeightMap for rows).
17
+ */
18
+ export interface CumulativeWidthMap {
19
+ /** Left pixel position of each leaf column (index i -> left of column i) */
20
+ columnLeftPositions: number[];
21
+ /** Total nominal width of all leaf columns combined */
22
+ totalWidth: number;
23
+ /** Ordered leaf headers, 1:1 with the section's grid tracks */
24
+ leafHeaders: HeaderObject[];
25
+ }
26
+ /**
27
+ * Resolve a header's column width to pixels for position math.
28
+ *
29
+ * Only fixed widths (number or "Npx") are exact. fr/%/minmax/auto layouts can't be
30
+ * resolved without measuring the DOM, so we fall back to the column's numeric
31
+ * minWidth or a sensible default. This only affects which columns are *selected* for
32
+ * the window (mitigated by overscan); placement stays correct because cells are
33
+ * positioned by their real grid track via `grid-column`.
34
+ */
35
+ export declare const getColumnWidthInPixels: (header: HeaderObject) => number;
36
+ /**
37
+ * Build a cumulative width map for a section's headers. The leaf order matches the
38
+ * grid tracks created by `createGridTemplateColumns` (both use `flattenColumnsForGrid`).
39
+ */
40
+ export declare const buildCumulativeWidthMap: ({ headers, collapsedHeaders, }: {
41
+ headers: HeaderObject[];
42
+ collapsedHeaders?: Set<string> | undefined;
43
+ }) => CumulativeWidthMap;
44
+ /**
45
+ * Find the leaf column index at a given horizontal scroll position using binary
46
+ * search. Returns the index of the column that contains (or is closest to) the
47
+ * position. Analogous to `findRowAtScrollPosition` for rows.
48
+ */
49
+ export declare const findColumnAtScrollPosition: (scrollLeft: number, widthMap: CumulativeWidthMap) => number;
50
+ /**
51
+ * Calculate the visible leaf columns for the viewport, with an overscan buffer.
52
+ * Returns the [startIndex, endIndex) range into the section's leaf array plus the
53
+ * leaf header objects in that range. Analogous to `getViewportCalculations` for rows.
54
+ */
55
+ export declare const getVisibleColumns: ({ scrollLeft, viewportWidth, bufferColumnCount, scrollDirection, widthMap, }: {
56
+ scrollLeft: number;
57
+ viewportWidth: number;
58
+ bufferColumnCount: number;
59
+ scrollDirection?: "left" | "right" | "none" | undefined;
60
+ widthMap: CumulativeWidthMap;
61
+ }) => {
62
+ startIndex: number;
63
+ endIndex: number;
64
+ columns: HeaderObject[];
65
+ };
66
+ /**
67
+ * Build the set of leaf accessors that should render for the current horizontal
68
+ * viewport, plus a map from accessor to its grid track index (0-based) so cells can
69
+ * be placed with `grid-column: <index + 1>`. Pinned sections never virtualize, so
70
+ * callers pass `null` to disable windowing.
71
+ */
72
+ export interface ColumnWindow {
73
+ /** Leaf accessors currently within the viewport (+overscan) */
74
+ visibleAccessors: Set<Accessor>;
75
+ /** Leaf accessor -> 0-based grid track index within the section */
76
+ trackIndexByAccessor: Map<Accessor, number>;
77
+ }
78
+ export declare const buildColumnWindow: ({ headers, collapsedHeaders, scrollLeft, viewportWidth, bufferColumnCount, scrollDirection, pinned, }: {
79
+ headers: HeaderObject[];
80
+ collapsedHeaders?: Set<string> | undefined;
81
+ scrollLeft: number;
82
+ viewportWidth: number;
83
+ bufferColumnCount: number;
84
+ scrollDirection?: "left" | "right" | "none" | undefined;
85
+ pinned?: Pinned | undefined;
86
+ }) => ColumnWindow | null;
@@ -4,9 +4,11 @@ import type TableRowType from "../../types/TableRow";
4
4
  import { Pinned } from "../../types/Pinned";
5
5
  import RowIndices from "../../types/RowIndices";
6
6
  import ColumnIndices from "../../types/ColumnIndices";
7
+ import { ColumnWindow } from "../../utils/columnVirtualizationUtils";
7
8
  interface RenderCellsProps {
8
9
  columnIndexStart?: number;
9
10
  columnIndices: ColumnIndices;
11
+ columnWindow?: ColumnWindow | null;
10
12
  headers: HeaderObject[];
11
13
  pinned?: Pinned;
12
14
  rowIndex: number;
@@ -14,5 +16,5 @@ interface RenderCellsProps {
14
16
  rowIndices: RowIndices;
15
17
  tableRow: TableRowType;
16
18
  }
17
- declare const _default: React.MemoExoticComponent<({ columnIndexStart, columnIndices, headers, pinned, rowIndex, displayRowNumber, rowIndices, tableRow, }: RenderCellsProps) => import("react/jsx-runtime").JSX.Element>;
19
+ declare const _default: React.MemoExoticComponent<({ columnIndexStart, columnIndices, columnWindow, headers, pinned, rowIndex, displayRowNumber, rowIndices, tableRow, }: RenderCellsProps) => import("react/jsx-runtime").JSX.Element>;
18
20
  export default _default;
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import TableCellProps from "../../types/TableCellProps";
3
- declare const _default: React.MemoExoticComponent<({ borderClass, colIndex, displayRowNumber, header, isHighlighted, isInitialFocused, nestedIndex, parentHeader, rowIndex, tableRow, }: TableCellProps) => import("react/jsx-runtime").JSX.Element>;
3
+ declare const _default: React.MemoExoticComponent<({ borderClass, colIndex, displayRowNumber, gridColumnStart, header, isHighlighted, isInitialFocused, nestedIndex, parentHeader, rowIndex, tableRow, }: TableCellProps) => import("react/jsx-runtime").JSX.Element>;
4
4
  export default _default;
@@ -4,9 +4,11 @@ import { Pinned } from "../../types/Pinned";
4
4
  import HeaderObject from "../../types/HeaderObject";
5
5
  import ColumnIndices from "../../types/ColumnIndices";
6
6
  import RowIndices from "../../types/RowIndices";
7
+ import { ColumnWindow } from "../../utils/columnVirtualizationUtils";
7
8
  interface TableRowProps {
8
9
  columnIndexStart?: number;
9
10
  columnIndices: ColumnIndices;
11
+ columnWindow?: ColumnWindow | null;
10
12
  gridTemplateColumns: string;
11
13
  headers: HeaderObject[];
12
14
  index: number;
@@ -20,5 +22,5 @@ interface TableRowProps {
20
22
  stickyOffset?: number;
21
23
  stickyZIndex?: number;
22
24
  }
23
- declare const _default: React.MemoExoticComponent<({ columnIndices, columnIndexStart, gridTemplateColumns, headers, index, pinned, rowHeight, rowIndices, setHoveredIndex, tableRow, isSticky, stickyIndex, stickyOffset, stickyZIndex, }: TableRowProps) => import("react/jsx-runtime").JSX.Element>;
25
+ declare const _default: React.MemoExoticComponent<({ columnIndices, columnIndexStart, columnWindow, gridTemplateColumns, headers, index, pinned, rowHeight, rowIndices, setHoveredIndex, tableRow, isSticky, stickyIndex, stickyOffset, stickyZIndex, }: TableRowProps) => import("react/jsx-runtime").JSX.Element>;
24
26
  export default _default;
@@ -4,9 +4,12 @@ import { Pinned } from "../../types/Pinned";
4
4
  import HeaderObject from "../../types/HeaderObject";
5
5
  import ColumnIndices from "../../types/ColumnIndices";
6
6
  import RowIndices from "../../types/RowIndices";
7
+ import { ColumnWindow } from "../../utils/columnVirtualizationUtils";
7
8
  interface TableSectionProps {
8
9
  columnIndexStart?: number;
9
10
  columnIndices: ColumnIndices;
11
+ /** Visible-column window for this section, or null/undefined to render all columns (pinned sections). */
12
+ columnWindow?: ColumnWindow | null;
10
13
  headers: HeaderObject[];
11
14
  pinned?: Pinned;
12
15
  regularRows: TableRowType[];
@@ -79,7 +79,6 @@ interface TableContextType {
79
79
  isLoading?: boolean;
80
80
  isResizing: boolean;
81
81
  isRowSelected?: (rowId: string) => boolean;
82
- isScrolling: boolean;
83
82
  isSelected: (cell: Cell) => boolean;
84
83
  isWarningFlashing: (cell: Cell) => boolean;
85
84
  mainBodyRef: RefObject<HTMLDivElement | null>;
@@ -115,7 +114,6 @@ interface TableContextType {
115
114
  setHeaders: Dispatch<SetStateAction<HeaderObject[]>>;
116
115
  setInitialFocusedCell: Dispatch<SetStateAction<Cell | null>>;
117
116
  setIsResizing: Dispatch<SetStateAction<boolean>>;
118
- setIsScrolling: Dispatch<SetStateAction<boolean>>;
119
117
  setSelectedCells: Dispatch<SetStateAction<Set<string>>>;
120
118
  setSelectedColumns: Dispatch<SetStateAction<Set<number>>>;
121
119
  setSelectedRows?: Dispatch<SetStateAction<Set<string>>>;
@@ -140,4 +138,12 @@ export declare const TableProvider: ({ children, value, }: {
140
138
  value: TableContextType;
141
139
  }) => import("react/jsx-runtime").JSX.Element;
142
140
  export declare const useTableContext: () => TableContextType;
141
+ interface ScrollStateContextType {
142
+ isScrolling: boolean;
143
+ setIsScrolling: Dispatch<SetStateAction<boolean>>;
144
+ }
145
+ export declare const ScrollStateProvider: ({ children }: {
146
+ children: ReactNode;
147
+ }) => import("react/jsx-runtime").JSX.Element;
148
+ export declare const useScrollState: () => ScrollStateContextType;
143
149
  export {};
@@ -4,7 +4,8 @@ import HeaderObject from "../types/HeaderObject";
4
4
  import type TableRowType from "../types/TableRow";
5
5
  interface UseKeyboardNavigationProps {
6
6
  selectableCells: boolean;
7
- initialFocusedCell: Cell | null;
7
+ initialFocusedCellRef: React.MutableRefObject<Cell | null>;
8
+ selectedCellsRef: React.MutableRefObject<Set<string>>;
8
9
  tableRows: TableRowType[];
9
10
  leafHeaders: HeaderObject[];
10
11
  selectSingleCell: (cell: Cell) => void;
@@ -17,10 +18,9 @@ interface UseKeyboardNavigationProps {
17
18
  deleteSelectedCells: () => void;
18
19
  startCell: React.MutableRefObject<Cell | null>;
19
20
  enableRowSelection?: boolean;
20
- selectedCells: Set<string>;
21
21
  }
22
22
  /**
23
23
  * Hook that handles keyboard navigation for cell selection
24
24
  */
25
- export declare const useKeyboardNavigation: ({ copyToClipboard, deleteSelectedCells, enableRowSelection, initialFocusedCell, leafHeaders, pasteFromClipboard, selectCellRange, selectSingleCell, selectableCells, selectedCells, setLastSelectedColumnIndex, setSelectedCells, setSelectedColumns, startCell, tableRows, }: UseKeyboardNavigationProps) => void;
25
+ export declare const useKeyboardNavigation: ({ copyToClipboard, deleteSelectedCells, enableRowSelection, initialFocusedCellRef, leafHeaders, pasteFromClipboard, selectCellRange, selectSingleCell, selectableCells, selectedCellsRef, setLastSelectedColumnIndex, setSelectedCells, setSelectedColumns, startCell, tableRows, }: UseKeyboardNavigationProps) => void;
26
26
  export {};