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