@mui/x-virtualizer 0.1.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +10645 -0
  2. package/README.md +3 -0
  3. package/esm/features/colspan.d.ts +28 -0
  4. package/esm/features/colspan.js +88 -0
  5. package/esm/features/dimensions.d.ts +41 -0
  6. package/esm/features/dimensions.js +465 -0
  7. package/esm/features/index.d.ts +5 -0
  8. package/esm/features/index.js +5 -0
  9. package/esm/features/keyboard.d.ts +16 -0
  10. package/esm/features/keyboard.js +35 -0
  11. package/esm/features/rowspan.d.ts +25 -0
  12. package/esm/features/rowspan.js +36 -0
  13. package/esm/features/virtualization.d.ts +103 -0
  14. package/esm/features/virtualization.js +844 -0
  15. package/esm/index.d.ts +2 -0
  16. package/esm/index.js +9 -0
  17. package/esm/models/colspan.d.ts +13 -0
  18. package/esm/models/colspan.js +1 -0
  19. package/esm/models/core.d.ts +72 -0
  20. package/esm/models/core.js +43 -0
  21. package/esm/models/dimensions.d.ts +132 -0
  22. package/esm/models/dimensions.js +1 -0
  23. package/esm/models/index.d.ts +4 -0
  24. package/esm/models/index.js +4 -0
  25. package/esm/models/rowspan.d.ts +17 -0
  26. package/esm/models/rowspan.js +1 -0
  27. package/esm/package.json +1 -0
  28. package/esm/useVirtualizer.d.ts +193 -0
  29. package/esm/useVirtualizer.js +26 -0
  30. package/features/colspan.d.ts +28 -0
  31. package/features/colspan.js +94 -0
  32. package/features/dimensions.d.ts +41 -0
  33. package/features/dimensions.js +472 -0
  34. package/features/index.d.ts +5 -0
  35. package/features/index.js +60 -0
  36. package/features/keyboard.d.ts +16 -0
  37. package/features/keyboard.js +40 -0
  38. package/features/rowspan.d.ts +25 -0
  39. package/features/rowspan.js +42 -0
  40. package/features/virtualization.d.ts +103 -0
  41. package/features/virtualization.js +853 -0
  42. package/index.d.ts +2 -0
  43. package/index.js +34 -0
  44. package/models/colspan.d.ts +13 -0
  45. package/models/colspan.js +5 -0
  46. package/models/core.d.ts +72 -0
  47. package/models/core.js +49 -0
  48. package/models/dimensions.d.ts +132 -0
  49. package/models/dimensions.js +5 -0
  50. package/models/index.d.ts +4 -0
  51. package/models/index.js +49 -0
  52. package/models/rowspan.d.ts +17 -0
  53. package/models/rowspan.js +5 -0
  54. package/package.json +67 -0
  55. package/useVirtualizer.d.ts +193 -0
  56. package/useVirtualizer.js +33 -0
@@ -0,0 +1,25 @@
1
+ import { Store } from '@mui/x-internals/store';
2
+ import type { BaseState, VirtualizerParams } from "../useVirtualizer.js";
3
+ import type { RowSpanningState } from "../models/rowspan.js";
4
+ import { Virtualization } from "./virtualization.js";
5
+ export declare const Rowspan: {
6
+ initialize: typeof initializeState;
7
+ use: typeof useRowspan;
8
+ selectors: {
9
+ state: (state: Rowspan.State) => RowSpanningState;
10
+ hiddenCells: (state: Rowspan.State) => Record<any, Record<number, boolean>>;
11
+ spannedCells: (state: Rowspan.State) => Record<any, Record<number, number>>;
12
+ hiddenCellsOriginMap: (state: Rowspan.State) => Record<number, Record<number, number>>;
13
+ };
14
+ };
15
+ export declare namespace Rowspan {
16
+ type State = {
17
+ rowSpanning: RowSpanningState;
18
+ };
19
+ type API = ReturnType<typeof useRowspan>;
20
+ }
21
+ declare function initializeState(params: VirtualizerParams): Rowspan.State;
22
+ declare function useRowspan(store: Store<BaseState & Rowspan.State>, _params: VirtualizerParams, _api: Virtualization.API): {
23
+ getHiddenCellsOrigin: () => Record<number, Record<number, number>>;
24
+ };
25
+ export {};
@@ -0,0 +1,36 @@
1
+ /* eslint-disable import/export, @typescript-eslint/no-redeclare */
2
+
3
+ const EMPTY_RANGE = {
4
+ firstRowIndex: 0,
5
+ lastRowIndex: 0
6
+ };
7
+ const EMPTY_CACHES = {
8
+ spannedCells: {},
9
+ hiddenCells: {},
10
+ hiddenCellOriginMap: {}
11
+ };
12
+ const selectors = {
13
+ state: state => state.rowSpanning,
14
+ hiddenCells: state => state.rowSpanning.caches.hiddenCells,
15
+ spannedCells: state => state.rowSpanning.caches.spannedCells,
16
+ hiddenCellsOriginMap: state => state.rowSpanning.caches.hiddenCellOriginMap
17
+ };
18
+ export const Rowspan = {
19
+ initialize: initializeState,
20
+ use: useRowspan,
21
+ selectors
22
+ };
23
+ function initializeState(params) {
24
+ return {
25
+ rowSpanning: params.initialState?.rowSpanning ?? {
26
+ caches: EMPTY_CACHES,
27
+ processedRange: EMPTY_RANGE
28
+ }
29
+ };
30
+ }
31
+ function useRowspan(store, _params, _api) {
32
+ const getHiddenCellsOrigin = () => selectors.hiddenCellsOriginMap(store.state);
33
+ return {
34
+ getHiddenCellsOrigin
35
+ };
36
+ }
@@ -0,0 +1,103 @@
1
+ import * as React from 'react';
2
+ import type { integer } from '@mui/x-internals/types';
3
+ import { Store } from '@mui/x-internals/store';
4
+ import type { CellColSpanInfo } from "../models/colspan.js";
5
+ import { Dimensions } from "./dimensions.js";
6
+ import type { BaseState, VirtualizerParams } from "../useVirtualizer.js";
7
+ import { PinnedRowPosition, RenderContext, ColumnsRenderContext, ColumnWithWidth, RowId, RowEntry } from "../models/index.js";
8
+ export type VirtualizationState = {
9
+ enabled: boolean;
10
+ enabledForRows: boolean;
11
+ enabledForColumns: boolean;
12
+ renderContext: RenderContext;
13
+ };
14
+ export declare const EMPTY_RENDER_CONTEXT: {
15
+ firstRowIndex: number;
16
+ lastRowIndex: number;
17
+ firstColumnIndex: number;
18
+ lastColumnIndex: number;
19
+ };
20
+ export declare const Virtualization: {
21
+ initialize: typeof initializeState;
22
+ use: typeof useVirtualization;
23
+ selectors: {
24
+ renderContext: (state: BaseState) => RenderContext;
25
+ enabledForRows: (state: BaseState) => boolean;
26
+ enabledForColumns: (state: BaseState) => boolean;
27
+ };
28
+ };
29
+ export declare namespace Virtualization {
30
+ type State = {
31
+ virtualization: VirtualizationState;
32
+ getters: ReturnType<typeof useVirtualization>['getters'];
33
+ };
34
+ type API = ReturnType<typeof useVirtualization>;
35
+ }
36
+ declare function initializeState(params: VirtualizerParams): Virtualization.State;
37
+ /** APIs to override for colspan/rowspan */
38
+ type AbstractAPI = {
39
+ getCellColSpanInfo: (rowId: RowId, columnIndex: integer) => CellColSpanInfo;
40
+ calculateColSpan: (rowId: RowId, minFirstColumn: integer, maxLastColumn: integer, columns: ColumnWithWidth[]) => void;
41
+ getHiddenCellsOrigin: () => Record<RowId, Record<number, number>>;
42
+ };
43
+ type RequiredAPI = Dimensions.API & AbstractAPI;
44
+ declare function useVirtualization(store: Store<BaseState>, params: VirtualizerParams, api: RequiredAPI): {
45
+ getters: {
46
+ setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
47
+ getRows: (rowParams: {
48
+ rows?: RowEntry[];
49
+ position?: PinnedRowPosition;
50
+ renderContext?: RenderContext;
51
+ } | undefined, unstable_rowTree: Record<RowId, any>) => React.ReactNode[];
52
+ getContainerProps: () => {
53
+ ref: React.RefObject<HTMLDivElement | null>;
54
+ };
55
+ getScrollerProps: () => {
56
+ ref: React.RefObject<HTMLDivElement | null>;
57
+ onScroll: () => void;
58
+ onWheel: ((event: React.WheelEvent) => void) | undefined;
59
+ onTouchMove: ((event: React.TouchEvent) => void) | undefined;
60
+ style: React.CSSProperties;
61
+ role: string;
62
+ tabIndex: number | undefined;
63
+ };
64
+ getContentProps: () => {
65
+ style: React.CSSProperties;
66
+ role: string;
67
+ ref: (node: HTMLDivElement | null) => void;
68
+ };
69
+ getRenderZoneProps: () => {
70
+ role: string;
71
+ };
72
+ getScrollbarVerticalProps: () => {
73
+ ref: React.RefObject<HTMLDivElement | null>;
74
+ scrollPosition: React.RefObject<{
75
+ top: number;
76
+ left: number;
77
+ }>;
78
+ };
79
+ getScrollbarHorizontalProps: () => {
80
+ ref: React.RefObject<HTMLDivElement | null>;
81
+ scrollPosition: React.RefObject<{
82
+ top: number;
83
+ left: number;
84
+ }>;
85
+ };
86
+ getScrollAreaProps: () => {
87
+ scrollPosition: React.RefObject<{
88
+ top: number;
89
+ left: number;
90
+ }>;
91
+ };
92
+ };
93
+ useVirtualization: () => BaseState;
94
+ setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
95
+ forceUpdateRenderContext: () => void;
96
+ getCellColSpanInfo: (rowId: RowId, columnIndex: integer) => CellColSpanInfo;
97
+ calculateColSpan: (rowId: RowId, minFirstColumn: integer, maxLastColumn: integer, columns: ColumnWithWidth[]) => void;
98
+ getHiddenCellsOrigin: () => Record<RowId, Record<number, number>>;
99
+ };
100
+ export declare function areRenderContextsEqual(context1: RenderContext, context2: RenderContext): boolean;
101
+ export declare function computeOffsetLeft(columnPositions: number[], renderContext: ColumnsRenderContext, pinnedLeftLength: number): number;
102
+ export declare function roundToDecimalPlaces(value: number, decimals: number): number;
103
+ export {};