UNPKG

9.9 kBTypeScriptView Raw
1import Grid, { GridOptions, GridFunction, GridItem, ContainerManagerStatus, ItemRendererStatus, Methods } from "@egjs/grid";
2import { GROUP_TYPE, INFINITEGRID_METHODS, ITEM_TYPE } from "./consts";
3import { GroupManagerStatus } from "./GroupManager";
4import InfiniteGrid from "./InfiniteGrid";
5import { InfiniteGridItem } from "./InfiniteGridItem";
6import { Renderer } from "./Renderer/Renderer";
7import { ScrollManagerStatus } from "./ScrollManager";
8/**
9 * @typedef
10 */
11export interface InfiniteGridStatus {
12 itemRenderer: ItemRendererStatus;
13 containerManager: ContainerManagerStatus;
14 groupManager: GroupManagerStatus;
15 scrollManager: ScrollManagerStatus;
16}
17export interface InfiniteGridGroup {
18 type: GROUP_TYPE;
19 groupKey: string | number;
20 grid: Grid;
21 items: InfiniteGridItem[];
22 renderItems: InfiniteGridItem[];
23}
24export interface CategorizedGroup<Item extends InfiniteGridItemInfo = InfiniteGridItem> {
25 groupKey: number | string;
26 items: Item[];
27}
28/**
29 * @typedef
30 */
31export interface InfiniteGridItemInfo {
32 type?: ITEM_TYPE;
33 groupKey?: string | number;
34 key?: string | number;
35 element?: HTMLElement | null;
36 html?: string;
37 data?: Record<string, any>;
38}
39/**
40 * @typedef
41 * @extends Grid.GridOptions
42 * @property - The target to which the container is applied. If false, create itself, if true, create container. A string or HTMLElement specifies the target directly. (default: false) <ko>container를 적용할 대상. false면 자기 자신, true면 container를 생성. string 또는 HTMLElement는 직접 대상을 지정. (default: false)</ko>
43 * @property - If you create a container, you can set the container's tag. (default: "div") <ko>container를 생성한다면 container의 tag를 정할 수 있다. (default: "div")</ko>
44 * @property - The size of the scrollable area for adding the next group of items. (default: 100) <ko>다음 아이템 그룹을 추가하기 위한 스크롤 영역의 크기. (default: 100)</ko>
45 * @property - Whether to show only the DOM of the visible area. (default: true) <ko>보이는 영역의 DOM만 보여줄지 여부. (default: true)</ko>
46 * @property - Grid class to apply Infinite function. <ko>Infinite 기능을 적용할 Grid 클래스.</ko>
47 * @property - class that renders the DOM. <ko> DOM을 렌더하는 클래스. </ko>
48 */
49export interface InfiniteGridOptions extends GridOptions {
50 container?: boolean | string | HTMLElement;
51 containerTag?: string;
52 threshold?: number;
53 useRecycle?: boolean;
54 gridConstructor?: GridFunction;
55 renderer?: Renderer | null;
56}
57/**
58 * @typedef
59 * @property - Groups corresponding to placeholders <ko>placholder에 해당하는 그룹</ko>
60 * @property - Items corresponding to placeholders <ko>placholder에 해당하는 아이템들</ko>
61 * @property - Remove the inserted placeholders. <ko>추가한 placeholder들을 삭제한다.</ko>
62 */
63export interface InsertedPlaceholdersResult {
64 group: InfiniteGridGroup;
65 items: InfiniteGridItem[];
66 remove(): void;
67}
68/**
69 * @typedef
70 * @property - An InfiniteGrid instance that triggered this event. <ko>이 이벤트를 트리거한 InfiniteGrid의 인스턴스</ko>
71 * @property - Last group key. <ko>마지막 그룹의 키.</ko>
72 * @property - The key of the next group that should replace Virtual Item(placeholder)s. <ko>Virtual Item(placeholder)들을 대체해야 할 다음 그룹의 키.</ko>
73 * @property - Array of the following group keys that need to be replaced with Virtual Item(placeholder)s. <ko>Virtual Item(placeholder)들을 대체해야 할 다음 그룹키 배열.</ko>
74 * @property - Whether to request virtual groups corresponding to Virtual Item(placeholder)s. <ko>Virtual Item(placeholder)들에 해당하는 가상의 그룹을 요청하는지 여부</ko>
75 * @property - Set to standby to request data. <ko>데이터를 요청하기 위해 대기 상태로 설정한다.</ko>
76 * @property - When the data request is complete, it is set to ready state. <ko>데이터 요청이 끝났다면 준비 상태로 설정한다.</ko>
77 */
78export interface OnRequestAppend {
79 currentTarget: InfiniteGrid;
80 groupKey: string | number | undefined;
81 nextGroupKey?: string | number | undefined;
82 nextGroupKeys: Array<string | number>;
83 isVirtual: boolean;
84 wait(): void;
85 ready(): void;
86}
87/**
88 * @typedef
89 * @property - An InfiniteGrid instance that triggered this event. <ko>이 이벤트를 트리거한 InfiniteGrid의 인스턴스</ko>
90 * @property - First group key. <ko>첫번째 그룹의 키.</ko>
91 * @property - The key of the next group that should replace Virtual Item(placeholder)s. <ko>Virtual Item(placeholder)들을 대체해야 할 다음 그룹의 키.</ko>
92 * @property - Array of the following group keys that need to be replaced with Virtual Item(placeholder)s. <ko>Virtual Item(placeholder)들을 대체해야 할 다음 그룹키 배열.</ko>
93 * @property - Whether to request virtual groups corresponding to Virtual Item(placeholder)s. <ko>Virtual Item(placeholder)들에 해당하는 가상의 그룹을 요청하는지 여부</ko>
94 * @property - Set to standby to request data. <ko>데이터를 요청하기 위해 대기 상태로 설정한다.</ko>
95 * @property - When the data request is complete, it is set to ready state. <ko>데이터 요청이 끝났다면 준비 상태로 설정한다.</ko>
96 */
97export interface OnRequestPrepend {
98 currentTarget: InfiniteGrid;
99 groupKey: string | number | undefined;
100 nextGroupKey?: string | number | undefined;
101 nextGroupKeys: Array<string | number>;
102 isVirtual: boolean;
103 wait(): void;
104 ready(): void;
105}
106/**
107 * @typedef
108 * @property - An InfiniteGrid instance that triggered this event. <ko>이 이벤트를 트리거한 InfiniteGrid의 인스턴스</ko>
109 * @property - The items rendered for the first time. <ko>처음 렌더링한 아이템들.</ko>
110 * @property - The items updated in size. <ko>사이즈 업데이트한 아이템들.</ko>
111 * @property - The direction InfiniteGrid was rendered. <ko>InfiniteGrid가 렌더링된 방향.</ko>
112 * @property - Whether rendering was done using the resize event or the useResize option. <ko>resize 이벤트 또는 useResize 옵션을 사용하여 렌더링를 했는지 여부.</ko>
113 * @property - The key of the first group that has been rendered. <ko>렌더링이 완료된 첫번째 그룹의 키.</ko>
114 * @property - The key of the last group that has been rendered. <ko>렌더링이 완료된 마지막 그룹의 키.</ko>
115 * @property - Items that have been rendered. <ko>렌더링이 완료된 아이템들.</ko>
116 * @property - Groups that have been rendered. <ko>렌더링이 완료된 그룹들.</ko>
117 */
118export interface OnRenderComplete {
119 currentTarget: InfiniteGrid;
120 mounted: InfiniteGridItem[];
121 updated: InfiniteGridItem[];
122 direction: "start" | "end";
123 isResize: boolean;
124 startCursor: number;
125 endCursor: number;
126 items: InfiniteGridItem[];
127 groups: InfiniteGridGroup[];
128}
129/**
130 * @typedef
131 * @property - An InfiniteGrid instance that triggered this event. <ko>이 이벤트를 트리거한 InfiniteGrid의 인스턴스</ko>
132 * @property - The item's element.<ko>아이템의 엘리먼트.</ko>
133 * @property - The content element with error.<ko>에러난 발생한 콘텐츠 엘리먼트.</ko>
134 * @property - The item with error content.<ko>에러난 콘텐츠를 가지고 있는 아이템</ko>
135 * @property - If you have fixed the error and want to recheck it, call update(). If you remove an element, call the syncElements() method.<ko>에러를 해결했고 재검사하고 싶으면 update()를 호출해라. 만약 엘리먼트를 삭제한 경우 syncElements() 메서드를 호출해라.</ko>
136 * @property - If you want to remove the item corresponding to the error, call remove(). <ko>에러에 해당하는 아이템을 제거하고 싶으면 remove()를 호출해라.</ko>
137 */
138export interface OnContentError {
139 currentTarget: InfiniteGrid;
140 element: HTMLElement;
141 target: HTMLElement;
142 item: InfiniteGridItem;
143 update(): void;
144 remove(): void;
145}
146/**
147 * @typedef
148 * @property - An InfiniteGrid instance that triggered this event. <ko>이 이벤트를 트리거한 InfiniteGrid의 인스턴스</ko>
149 * @property - The scroll direction. <ko>스크롤 방향.</ko>
150 * @property - The scroll position. <ko>스크롤 포지션.</ko>
151 * @property - The scroll position relative to container. <ko>컨테이너 기준의 스크롤 포지션.</ko>
152 */
153export interface OnChangeScroll {
154 currentTarget: InfiniteGrid;
155 direction: "start" | "end";
156 scrollPos: number;
157 relativeScrollPos: number;
158}
159export interface InfiniteGridEvents {
160 changeScroll: OnChangeScroll;
161 requestAppend: OnRequestAppend;
162 requestPrepend: OnRequestPrepend;
163 renderComplete: OnRenderComplete;
164 contentError: OnContentError;
165}
166export interface OnPickedRenderComplete {
167 mounted: GridItem[];
168 updated: GridItem[];
169 isResize: boolean;
170 direction: "start" | "end";
171}
172export interface OnRequestInsert {
173 key: string | number | undefined;
174 nextKey: string | number | undefined;
175 isVirtual: boolean;
176}
177export interface RenderingOptions {
178 grid: InfiniteGrid<any> | null | undefined;
179 status: InfiniteGridStatus | null | undefined;
180 useFirstRender: boolean | null | undefined;
181 usePlaceholder: boolean | null | undefined;
182 useLoading: boolean | null | undefined;
183 horizontal: boolean | null | undefined;
184}
185export declare type InfiniteGridInsertedItems = string | Array<string | InfiniteGridItemInfo | HTMLElement>;
186export declare type InfiniteGridMethods<Component> = Methods<Component, InfiniteGrid, typeof INFINITEGRID_METHODS>;
187export declare type InfiniteGridFunction = (new (container: HTMLElement, options: Partial<GridOptions>) => InfiniteGrid) & {
188 propertyTypes: any;
189 defaultOptions: any;
190};
191
\No newline at end of file