1 | import { RenderFunction, SetupContext, ComponentPublicInstance, Ref } from 'vue'
|
2 | import { VXEComponent, VxeComponentBase, VxeEvent, SizeType, ValueOf } from './component'
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | export const VxeList: VXEComponent<VxeListProps, VxeListEventProps, VxeListSlots>
|
11 |
|
12 |
|
13 |
|
14 | export const List: typeof VxeList
|
15 |
|
16 | export type VxeListInstance = ComponentPublicInstance<VxeListProps, VxeListConstructor>
|
17 |
|
18 | export interface VxeListConstructor extends VxeComponentBase, VxeListMethods {
|
19 | props: VxeListProps
|
20 | context: SetupContext<VxeListEmits>
|
21 | reactData: ListReactData
|
22 | internalData: ListInternalData
|
23 | getRefMaps(): ListPrivateRef
|
24 | renderVN: RenderFunction
|
25 | }
|
26 |
|
27 | export interface ListPrivateRef {
|
28 | refElem: Ref<HTMLDivElement>
|
29 | }
|
30 | export interface VxeListPrivateRef extends ListPrivateRef { }
|
31 |
|
32 | export interface ListReactData {
|
33 | scrollYLoad: boolean
|
34 | bodyHeight: number
|
35 | rowHeight: number
|
36 | topSpaceHeight: number
|
37 | items: any[]
|
38 | }
|
39 |
|
40 | export interface ListInternalData {
|
41 | fullData: any[]
|
42 | lastScrollLeft: number
|
43 | lastScrollTop: number
|
44 | scrollYStore: {
|
45 | startIndex: number
|
46 | endIndex: number
|
47 | visibleSize: number
|
48 | offsetSize: number
|
49 | rowHeight: number
|
50 | }
|
51 | }
|
52 |
|
53 | export interface ListMethods {
|
54 | dispatchEvent(type: ValueOf<VxeListEmits>, params: any, evnt: Event): void
|
55 | |
56 |
|
57 |
|
58 |
|
59 | loadData(data: any[]): Promise<any>
|
60 |
|
61 | |
62 |
|
63 |
|
64 |
|
65 | reloadData(data: any[]): Promise<any>
|
66 |
|
67 | |
68 |
|
69 |
|
70 | recalculate(): Promise<void>
|
71 |
|
72 | |
73 |
|
74 |
|
75 |
|
76 |
|
77 | scrollTo(scrollLeft: number | null, scrollTop?: number | null): Promise<void>
|
78 |
|
79 | |
80 |
|
81 |
|
82 | refreshScroll(): Promise<void>
|
83 |
|
84 | |
85 |
|
86 |
|
87 | clearScroll(): Promise<void>
|
88 | }
|
89 | export interface VxeListMethods extends ListMethods { }
|
90 |
|
91 | export interface ListPrivateMethods { }
|
92 | export interface VxeListPrivateMethods extends ListPrivateMethods { }
|
93 |
|
94 | export namespace VxeListPropTypes {
|
95 | export type Size = SizeType
|
96 | export type Data = any[]
|
97 | export type Height = number | string
|
98 | export type MaxHeight = number | string
|
99 | export type Loading = boolean
|
100 | export type AutoResize = boolean
|
101 | export type ClassName = string | ((params: { $list: VxeListConstructor }) => string)
|
102 | export type SyncResize = boolean | string | number
|
103 | export interface ScrollY {
|
104 | /**
|
105 | * 指定大于指定行时自动启动纵向虚拟滚动,如果为 0 则总是启用,如果为 -1 则关闭
|
106 | */
|
107 | gt?: number
|
108 | /**
|
109 | * 指定每次渲染的数据偏移量,偏移量越大渲染次数就越少,但每次渲染耗时就越久
|
110 | */
|
111 | oSize?: number
|
112 | /**
|
113 | * 指定列表项的 className
|
114 | */
|
115 | sItem?: string
|
116 | /**
|
117 | * 是否启用
|
118 | */
|
119 | enabled?: boolean
|
120 | }
|
121 | }
|
122 |
|
123 | export type VxeListProps<D = any> = {
|
124 | size?: VxeListPropTypes.Size
|
125 | data?: D[]
|
126 | height?: VxeListPropTypes.Height
|
127 | maxHeight?: VxeListPropTypes.MaxHeight
|
128 | loading?: VxeListPropTypes.Loading
|
129 | autoResize?: VxeListPropTypes.AutoResize
|
130 | syncResize?: VxeListPropTypes.SyncResize
|
131 | className?: VxeListPropTypes.ClassName
|
132 | scrollY?: VxeListPropTypes.ScrollY
|
133 | }
|
134 |
|
135 | export type VxeListEmits = [
|
136 | 'scroll'
|
137 | ]
|
138 |
|
139 | export namespace VxeListDefines {
|
140 | interface ListEventParams extends VxeEvent {
|
141 | $list: VxeListConstructor
|
142 | }
|
143 |
|
144 | export interface ScrollParams { }
|
145 | export interface ScrollEventParams extends ListEventParams, ScrollParams { }
|
146 | }
|
147 |
|
148 | export type VxeListEventProps = {
|
149 | onScroll?: VxeListEvents.Scroll
|
150 | }
|
151 |
|
152 | export interface VxeListListeners {
|
153 | scroll?: VxeListEvents.Scroll
|
154 | }
|
155 |
|
156 | export namespace VxeListEvents {
|
157 | export type Scroll = (params: VxeListDefines.ScrollEventParams) => void
|
158 | }
|
159 |
|
160 | export interface VxeListSlots {
|
161 | |
162 |
|
163 |
|
164 | [key: string]: ((params: {
|
165 | [key: string]: any
|
166 | }) => any) | undefined
|
167 | }
|