• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * Declare scroll status
18 * @since 7
19 */
20/**
21 * Declare scroll status
22 * @form
23 * @since 9
24 */
25declare enum ScrollState {
26  /**
27   * Not activated.
28   * @since 7
29   */
30  /**
31   * Not activated.
32   * @form
33   * @since 9
34   */
35  Idle,
36
37  /**
38   * Scrolling status.
39   * @since 7
40   */
41  /**
42   * Scrolling status.
43   * @form
44   * @since 9
45   */
46  Scroll,
47
48  /**
49   * Drag status.
50   * @since 7
51   */
52  /**
53   * Drag status.
54   * @form
55   * @since 9
56   */
57  Fling,
58}
59
60/**
61 * Declare list item alignment status
62 * @form
63 * @since 9
64 */
65declare enum ListItemAlign {
66  /**
67   * Start position in the direction of cross axis.
68   * @form
69   * @since 9
70   */
71  Start,
72
73  /**
74   * Center position in the direction of cross axis.
75   * @form
76   * @since 9
77   */
78  Center,
79
80  /**
81   * End position in the direction of cross axis
82   * @form
83   * @since 9
84   */
85  End,
86}
87
88/**
89 * Declare item group sticky style.
90 * @form
91 * @since 9
92 */
93declare enum StickyStyle {
94  /**
95   * The header and footer of each item group will not be pinned.
96   * @form
97   * @since 9
98   */
99  None = 0,
100
101  /**
102   * The header of each item group will be pinned.
103   * @form
104   * @since 9
105   */
106  Header = 1,
107
108  /**
109   * The footer of each item group will be pinned.
110   * @form
111   * @since 9
112   */
113  Footer = 2,
114}
115
116/**
117 * The list interface is extended.
118 * @since 7
119 */
120/**
121 * The list interface is extended.
122 * @form
123 * @since 9
124 */
125interface ListInterface {
126  /**
127   * Called when interface data is called.
128   * @since 7
129   */
130  /**
131   * Called when interface data is called.
132   * @form
133   * @since 9
134   */
135  (value?: { initialIndex?: number; space?: number | string; scroller?: Scroller }): ListAttribute;
136}
137
138/**
139 * @since 7
140 */
141/**
142 * @form
143 * @since 9
144 */
145declare class ListAttribute extends CommonMethod<ListAttribute> {
146  /**
147   * Called when need to decide how much lanes the list will show.
148   * @form
149   * @since 9
150   */
151  lanes(value: number | LengthConstrain): ListAttribute;
152
153  /**
154   * Called when need to decide how to align lanes in the direction of the cross axis.
155   * @form
156   * @since 9
157   */
158  alignListItem(value: ListItemAlign): ListAttribute;
159
160  /**
161   * Called when the arrangement direction of the list component is set.
162   * @since 7
163   */
164  /**
165   * Called when the arrangement direction of the list component is set.
166   * @form
167   * @since 9
168   */
169  listDirection(value: Axis): ListAttribute;
170
171  /**
172   * Called when the display mode of the side slider is set.
173   * @since 7
174   */
175  /**
176   * Called when the display mode of the side slider is set.
177   * @form
178   * @since 9
179   */
180  scrollBar(value: BarState): ListAttribute;
181
182  /**
183   * Called when the sliding effect is set.
184   * @since 7
185   */
186  /**
187   * Called when the sliding effect is set.
188   * @form
189   * @since 9
190   */
191  edgeEffect(value: EdgeEffect): ListAttribute;
192
193  /**
194   * Called when the ListItem split line style is set.
195   * @since 7
196   */
197  /**
198   * Called when the ListItem split line style is set.
199   * @form
200   * @since 9
201   */
202  divider(
203    value: {
204      strokeWidth: Length;
205      color?: ResourceColor;
206      startMargin?: Length;
207      endMargin?: Length;
208    } | null,
209  ): ListAttribute;
210
211  /**
212   * Called when judging whether it is in editable mode.
213   * @since 7
214   * @deprecated since 9
215   */
216  editMode(value: boolean): ListAttribute;
217
218  /**
219   * Called when judging whether it is multiSelectable.
220   * @since 8
221   */
222  /**
223   * Called when judging whether it is multiSelectable.
224   * @form
225   * @since 9
226   */
227  multiSelectable(value: boolean): ListAttribute;
228
229  /**
230   * Called when the minimum number of list item caches is set for long list deferred loading.
231   * @since 7
232   */
233  /**
234   * Called when the minimum number of list item caches is set for long list deferred loading.
235   * @form
236   * @since 9
237   */
238  cachedCount(value: number): ListAttribute;
239
240  /**
241   * Called when setting whether to enable chain linkage dynamic effect.
242   * @since 7
243   */
244  /**
245   * Called when setting whether to enable chain linkage dynamic effect.
246   * @form
247   * @since 9
248   */
249  chainAnimation(value: boolean): ListAttribute;
250
251  /**
252   * Called when header or footer of item group will be pinned.
253   * @form
254   * @since 9
255   */
256  sticky(value: StickyStyle): ListAttribute;
257
258  /**
259   * Called when the offset and status callback of the slide are set.
260   * @since 7
261   */
262  /**
263   * Called when the offset and status callback of the slide are set.
264   * @form
265   * @since 9
266   */
267  onScroll(event: (scrollOffset: number, scrollState: ScrollState) => void): ListAttribute;
268
269  /**
270   * Called when the start and end positions of the display change.
271   * @since 7
272   */
273  /**
274   * Called when the start and end positions of the display change.
275   * @form
276   * @since 9
277   */
278  onScrollIndex(event: (start: number, end: number) => void): ListAttribute;
279
280  /**
281   * Called when the list begins to arrive.
282   * @since 7
283   */
284  /**
285   * Called when the list begins to arrive.
286   * @form
287   * @since 9
288   */
289  onReachStart(event: () => void): ListAttribute;
290
291  /**
292   * Called when the list reaches the end.
293   * @since 7
294   */
295  /**
296   * Called when the list reaches the end.
297   * @form
298   * @since 9
299   */
300  onReachEnd(event: () => void): ListAttribute;
301
302  /**
303   * Called when the slider start.
304   * @form
305   * @since 9
306   */
307  onScrollStart(event: () => void): ListAttribute;
308
309  /**
310   * Called when the slider stops.
311   * @since 7
312   */
313  /**
314   * Called when the slider stops.
315   * @form
316   * @since 9
317   */
318  onScrollStop(event: () => void): ListAttribute;
319
320  /**
321   * Called when a list item is deleted.
322   * @since 7
323   * @deprecated since 9
324   */
325  onItemDelete(event: (index: number) => boolean): ListAttribute;
326
327  /**
328   * Called when a list item is moved.
329   * @since 7
330   */
331  onItemMove(event: (from: number, to: number) => boolean): ListAttribute;
332
333  /**
334   * After a listener is bound, the component can be dragged. After the drag occurs, a callback is triggered.
335   * (To be triggered, press and hold for 170 milliseconds (ms))
336   * @since 8
337   */
338  onItemDragStart(event: (event: ItemDragInfo, itemIndex: number) => ((() => any) | void)): ListAttribute;
339
340  /**
341   * After binding, a callback is triggered when the component is dragged to the range of the component.
342   * @since 8
343   */
344  onItemDragEnter(event: (event: ItemDragInfo) => void): ListAttribute;
345
346  /**
347   * After binding, a callback is triggered when the drag moves within the range of a placeable component.
348   * @since 8
349   */
350  onItemDragMove(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number) => void): ListAttribute;
351
352  /**
353   * After binding, a callback is triggered when the component is dragged out of the component range.
354   * @since 8
355   */
356  onItemDragLeave(event: (event: ItemDragInfo, itemIndex: number) => void): ListAttribute;
357
358  /**
359   * The component bound to this event can be used as the drag release target.
360   * This callback is triggered when the drag behavior is stopped within the scope of the component.
361   * @since 8
362   */
363  onItemDrop(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void): ListAttribute;
364
365  /**
366   * Called when scrolling begin each frame.
367   * @form
368   * @since 9
369   */
370  onScrollFrameBegin(event: (offset: number, state: ScrollState) => { offsetRemain: number }): ListAttribute;
371}
372
373/**
374 * Defines List Component.
375 * @since 7
376 */
377/**
378 * Defines List Component.
379 * @form
380 * @since 9
381 */
382declare const List: ListInterface;
383
384/**
385 * Defines List Component instance.
386 * @since 7
387 */
388/**
389 * Defines List Component instance.
390 * @form
391 * @since 9
392 */
393declare const ListInstance: ListAttribute;
394