UNPKG

5.37 kBTypeScriptView Raw
1import Grid, { GridFunction, GridItem, GridOptions, GridOutlines, Properties, PROPERTY_TYPE, RenderOptions } from "@egjs/grid";
2import { GROUP_TYPE, STATUS_TYPE } from "./consts";
3import { InfiniteGridItem, InfiniteGridItemStatus } from "./InfiniteGridItem";
4import { InfiniteGridGroup, InfiniteGridItemInfo } from "./types";
5export interface InfiniteGridGroupStatus {
6 type: GROUP_TYPE;
7 groupKey: string | number;
8 items: InfiniteGridItemStatus[];
9 outlines: GridOutlines;
10}
11export interface GroupManagerOptions extends GridOptions {
12 appliedItemChecker?: (item: InfiniteGridItem, grid: Grid) => boolean;
13 gridConstructor: GridFunction | null;
14 gridOptions: Record<string, any>;
15}
16export interface GroupManagerStatus {
17 cursors: [number, number];
18 orgCursors: [number, number];
19 itemCursors: [number, number];
20 startGroupKey: number | string;
21 endGroupKey: number | string;
22 groups: InfiniteGridGroupStatus[];
23 outlines: GridOutlines;
24}
25export declare class GroupManager extends Grid<GroupManagerOptions> {
26 static defaultOptions: Required<GroupManagerOptions>;
27 static propertyTypes: {
28 readonly gridConstructor: PROPERTY_TYPE.PROPERTY;
29 readonly gridOptions: PROPERTY_TYPE.PROPERTY;
30 readonly gap: PROPERTY_TYPE;
31 readonly defaultDirection: PROPERTY_TYPE;
32 readonly renderOnPropertyChange: PROPERTY_TYPE;
33 readonly preserveUIOnDestroy: PROPERTY_TYPE;
34 readonly useFit: PROPERTY_TYPE;
35 readonly outlineSize: PROPERTY_TYPE;
36 readonly outlineLength: PROPERTY_TYPE;
37 };
38 protected items: InfiniteGridItem[];
39 protected groupItems: InfiniteGridItem[];
40 protected groups: InfiniteGridGroup[];
41 protected itemKeys: Record<string | number, InfiniteGridItem>;
42 protected groupKeys: Record<string | number, InfiniteGridGroup>;
43 protected startCursor: number;
44 protected endCursor: number;
45 private _placeholder;
46 private _loadingGrid;
47 private _mainGrid;
48 constructor(container: HTMLElement, options: GroupManagerOptions);
49 set gridOptions(options: Record<string, any>);
50 getItemByKey(key: string | number): InfiniteGridItem | null;
51 getGroupItems(includePlaceholders?: boolean): InfiniteGridItem[];
52 getVisibleItems(includePlaceholders?: boolean): InfiniteGridItem[];
53 getRenderingItems(): InfiniteGridItem[];
54 getGroups(includePlaceholders?: boolean): InfiniteGridGroup[];
55 hasVisibleVirtualGroups(): boolean;
56 hasPlaceholder(): boolean;
57 hasLoadingItem(): boolean;
58 updateItems(items?: InfiniteGridItem[], options?: RenderOptions): this;
59 setPlaceholder(placeholder: Partial<InfiniteGridItemStatus> | null): void;
60 getLoadingType(): "" | "start" | "end";
61 startLoading(type: "start" | "end"): boolean;
62 endLoading(): boolean;
63 setLoading(loading: Partial<InfiniteGridItemStatus> | null): void;
64 getVisibleGroups(includePlaceholders?: boolean): InfiniteGridGroup[];
65 getComputedOutlineLength(items?: InfiniteGridItem[]): number;
66 getComputedOutlineSize(items?: InfiniteGridItem[]): number;
67 applyGrid(items: InfiniteGridItem[], direction: "end" | "start", outline: number[]): GridOutlines;
68 syncItems(nextItemInfos: InfiniteGridItemInfo[]): void;
69 renderItems(options?: RenderOptions): this;
70 setCursors(startCursor: number, endCursor: number): void;
71 getStartCursor(): number;
72 getEndCursor(): number;
73 getGroupStatus(type?: STATUS_TYPE, includePlaceholders?: boolean): GroupManagerStatus;
74 protected fitOutlines(useFit?: boolean): void;
75 setGroupStatus(status: GroupManagerStatus): void;
76 appendPlaceholders(items: number | InfiniteGridItemStatus[], groupKey?: string | number): {
77 group: {
78 type: GROUP_TYPE;
79 groupKey: string | number;
80 grid: Grid<GridOptions>;
81 items: InfiniteGridItem[];
82 renderItems: InfiniteGridItem[];
83 };
84 items: InfiniteGridItem[];
85 };
86 prependPlaceholders(items: number | InfiniteGridItemStatus[], groupKey?: string | number): {
87 group: {
88 type: GROUP_TYPE;
89 groupKey: string | number;
90 grid: Grid<GridOptions>;
91 items: InfiniteGridItem[];
92 renderItems: InfiniteGridItem[];
93 };
94 items: InfiniteGridItem[];
95 };
96 removePlaceholders(type: "start" | "end" | {
97 groupKey: string | number;
98 }): void;
99 insertPlaceholders(direction: "start" | "end", items: number | InfiniteGridItemStatus[], groupKey?: string | number): {
100 group: {
101 type: GROUP_TYPE;
102 groupKey: string | number;
103 grid: Grid<GridOptions>;
104 items: InfiniteGridItem[];
105 renderItems: InfiniteGridItem[];
106 };
107 items: InfiniteGridItem[];
108 };
109 shouldRerenderItems(): boolean;
110 protected _updateItems(items: GridItem[]): void;
111 private _getGroupItems;
112 private _getRenderingItems;
113 private _checkShouldRender;
114 private _applyVirtualGrid;
115 private _syncItemInfos;
116 private _registerGroups;
117 private _splitVirtualGroups;
118 private _mergeVirtualGroups;
119 private _updatePlaceholder;
120 private _makeGrid;
121 private _getLoadingGroup;
122 private _getLoadingItem;
123}
124export interface GroupManager extends Properties<typeof GroupManager> {
125 getItems(): InfiniteGridItem[];
126}