You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

723 lines
24 KiB

7 months ago
  1. type _Arrayable<T> = T | T[];
  2. declare global {
  3. /**
  4. * z-paging返回数据
  5. *
  6. * @since 2.5.3
  7. */
  8. interface ZPagingReturnData<T> {
  9. /**
  10. *
  11. */
  12. totalList: T[];
  13. /**
  14. *
  15. */
  16. noMore: boolean;
  17. }
  18. /**
  19. * [list组件](https://uniapp.dcloud.net.cn/component/list.html)
  20. *
  21. * @since 2.0.4
  22. */
  23. interface ZPagingSetSpecialEffectsArgs {
  24. /**
  25. * list同时滚动的组件idscroller
  26. */
  27. id?: string;
  28. /**
  29. * header顶部距离scroller顶部的距离
  30. * - Android暂不支持
  31. *
  32. * @default 0
  33. */
  34. headerHeight?: number;
  35. }
  36. /**
  37. * z-paging组件实例
  38. */
  39. interface ZPagingInstance<T = any> {
  40. /**
  41. * pageNo恢复为默认值
  42. *
  43. * @param [animate=false]
  44. */
  45. reload: (animate?: boolean) => Promise<ZPagingReturnData<T>>;
  46. /**
  47. * pageNo和pageSize不会重置
  48. *
  49. * @since 2.0.4
  50. */
  51. refresh: () => Promise<ZPagingReturnData<T>>;
  52. /**
  53. *
  54. *
  55. * @since 2.5.9
  56. * @param page
  57. */
  58. refreshToPage: (page: number) => Promise<ZPagingReturnData<T>>;
  59. /**
  60. *
  61. * - complete传进去的数组长度小于pageSize时
  62. *
  63. * @param [data]
  64. * @param [success=true]
  65. */
  66. complete: (data?: T[] | false, success?: boolean) => Promise<ZPagingReturnData<T>>;
  67. /**
  68. *
  69. * - total判断是否有更多数据
  70. *
  71. * @since 2.0.6
  72. * @param data
  73. * @param total
  74. * @param [success=true]
  75. */
  76. completeByTotal: (data: T[], total: number, success?: boolean) => Promise<ZPagingReturnData<T>>;
  77. /**
  78. *
  79. * -
  80. *
  81. * @since 1.9.2
  82. * @param data
  83. * @param noMore
  84. * @param [success=true]
  85. */
  86. completeByNoMore: (data: T[], noMore: boolean, success?: boolean) => Promise<ZPagingReturnData<T>>;
  87. /**
  88. *
  89. * - z-paging展示
  90. *
  91. * @since 2.6.3
  92. * @param cause
  93. */
  94. completeByError: (cause: string) => Promise<ZPagingReturnData<T>>;
  95. /**
  96. *
  97. * -
  98. *
  99. * @since 1.6.4
  100. * @param data
  101. * @param key dataKey需与:data-key绑定的一致
  102. * @param [success=true]
  103. */
  104. completeByKey: (data: T[], key: string, success?: boolean) => Promise<ZPagingReturnData<T>>;
  105. /**
  106. * pageNo恢复为默认值
  107. *
  108. * @since 2.1.0
  109. */
  110. clear: () => void;
  111. /**
  112. * pageNo和pageSize
  113. *
  114. * @param data
  115. * @param [scrollToTop=true] true
  116. * @param [animate=true] 使
  117. */
  118. addDataFromTop: (data: _Arrayable<T>, scrollToTop?: boolean, animate?: boolean) => void;
  119. /**
  120. * pageNo和pageSize
  121. * - z-paging
  122. *
  123. * @param data
  124. */
  125. resetTotalData: (data: T[]) => void;
  126. /**
  127. *
  128. *
  129. * @since 2.1.0
  130. */
  131. endRefresh: () => void;
  132. /**
  133. * view高度
  134. * - 使slot="refresher"view高度未能正确计算导致异常时手动更新其高度
  135. *
  136. * @since 2.6.1
  137. */
  138. updateCustomRefresherHeight: () => void;
  139. /**
  140. *
  141. *
  142. * @since 2.7.7
  143. */
  144. closeF2: () => void;
  145. /**
  146. *
  147. * - 使z-paging未确定高度时scroll-view会无限增高z-paging无法得知是否滚动到底部onReachBottom中手动调用此方法触发上拉加载更多
  148. *
  149. * @param [source]
  150. */
  151. doLoadMore: (source?: "click" | "toBottom") => void;
  152. /**
  153. * 使onPageScroll中调用此方法z-paging当前的pageScrollTop
  154. * - mixins
  155. *
  156. * @param scrollTop page的onPageScroll中获取的scrollTop
  157. */
  158. updatePageScrollTop: (scrollTop: number) => void;
  159. /**
  160. * 使slot="top"使slot="top"view高度动态改变时
  161. */
  162. updatePageScrollTopHeight: () => void;
  163. /**
  164. * 使slot="bottom"使slot="bottom"view高度动态改变时
  165. */
  166. updatePageScrollBottomHeight: () => void;
  167. /**
  168. * slot="left"slot="right"slot="left"slot="right"
  169. *
  170. * @since 2.3.5
  171. */
  172. updateLeftAndRightWidth: () => void;
  173. /**
  174. * fixed模式下z-paging的布局onShow时候调用iOS+h5+tabbar+fixed+tabbar页面跳转到无tabbar页面后返回
  175. *
  176. * @since 2.6.5
  177. */
  178. updateFixedLayout: () => void;
  179. /**
  180. * 使item
  181. *
  182. * @since 2.5.9
  183. * @param item
  184. * @param index cell位置2item在原list的index=10
  185. */
  186. doInsertVirtualListItem: (item: T, index: number) => void;
  187. /**
  188. * 使cell的缓存高度
  189. * - cell高度在初始化之后再次改变时调用
  190. *
  191. * @since 2.4.0
  192. * @param index cell在列表中的位置0
  193. */
  194. didUpdateVirtualListCell: (index: number) => void;
  195. /**
  196. * 使item
  197. *
  198. * @since 2.4.0
  199. * @param index cell在列表中的位置0
  200. */
  201. didDeleteVirtualListCell: (index: number) => void;
  202. /**
  203. *
  204. *
  205. * @since 2.7.10
  206. */
  207. updateVirtualListRender: () => void;
  208. /**
  209. * ()z-paging作分页处理
  210. * - @query所绑定的事件
  211. *
  212. * @param data
  213. * @param [success=true]
  214. */
  215. setLocalPaging: (data: T[], success?: boolean) => Promise<ZPagingReturnData<T>>;
  216. /**
  217. *
  218. */
  219. doChatRecordLoadMore: () => void;
  220. /**
  221. * use-chat-record-mode为true时有效
  222. *
  223. * @param data
  224. * @param [scrollToBottom=true]
  225. * @param [animate=true] 使
  226. */
  227. addChatRecordData: (data: _Arrayable<T>, scrollToBottom?: boolean, animate?: boolean) => void;
  228. /**
  229. *
  230. *
  231. * @param [animate=true]
  232. */
  233. scrollToTop: (animate?: boolean) => void;
  234. /**
  235. *
  236. *
  237. * @param [animate=true]
  238. */
  239. scrollToBottom: (animate?: boolean) => void;
  240. /**
  241. * view
  242. * - vue中有效使scrollIntoViewByNodeTop
  243. *
  244. * @param id view的id值"#"
  245. * @param [offset=0] px
  246. * @param [animate=false]
  247. */
  248. scrollIntoViewById: (id: string, offset?: number, animate?: boolean) => void;
  249. /**
  250. * view
  251. * - vue中有效
  252. *
  253. * @since 1.7.4
  254. * @param top view的top值(uni.createSelectorQuery())
  255. * @param [offset=0] px
  256. * @param [animate=false]
  257. */
  258. scrollIntoViewByNodeTop: (top: number, offset?: number, animate?: boolean) => void;
  259. /**
  260. * view
  261. * - vue中有效
  262. * - scrollIntoViewByNodeTop的不同之处在于scrollToY传入的是view相对于屏幕的top值scrollIntoViewByNodeTop传入的top值并非是固定的uni.createSelectorQuery()top会因列表滚动而改变
  263. *
  264. * @param top view的top值px
  265. * @param [offset=0] px
  266. * @param [animate=false]
  267. */
  268. scrollToY: (top: number, offset?: number, animate?: boolean) => void;
  269. /**
  270. * view
  271. * - nvue或虚拟列表中有效
  272. * - 在nvue中的cell必须设置 :ref="`z-paging-${index}`"
  273. *
  274. * @param index view的index()
  275. * @param [offset=0] px
  276. * @param [animate=false]
  277. */
  278. scrollIntoViewByIndex: (index: number, offset?: number, animate?: boolean) => void;
  279. /**
  280. * view
  281. * - nvue中有效
  282. *
  283. * @param view view(this.$refs.xxx获取)
  284. * @param [offset=0] px
  285. * @param [animate=false]
  286. */
  287. scrollIntoViewByView: (view: any, offset?: number, animate?: boolean) => void;
  288. /**
  289. * nvue List的specialEffects
  290. *
  291. * @since 2.0.4
  292. * @param args https://uniapp.dcloud.io/component/list?id=listsetspecialeffects
  293. */
  294. setSpecialEffects: (args: ZPagingSetSpecialEffectsArgs) => void;
  295. /**
  296. * {@link setSpecialEffects}
  297. *
  298. * @since 2.0.4
  299. */
  300. setListSpecialEffects: (args: ZPagingSetSpecialEffectsArgs) => void;
  301. /**
  302. * v-model绑定的list中的前pageSize条覆盖缓存list数据更新到预期结果后再调用此方法
  303. *
  304. * @since 2.3.9
  305. */
  306. updateCache: () => void;
  307. /**
  308. *
  309. */
  310. getVersion: () => string;
  311. }
  312. /**
  313. * z-paging全局数据
  314. * - uni.$zp
  315. *
  316. * @since 2.6.5
  317. */
  318. interface ZPagingGlobal {
  319. /**
  320. *
  321. */
  322. config: Record<string, any>;
  323. }
  324. /**
  325. *
  326. *
  327. * @since 2.7.7
  328. */
  329. type ZPagingVirtualItem<T> = T & {
  330. /**
  331. *
  332. */
  333. zp_index: number;
  334. };
  335. namespace ZPagingEvent {
  336. /**
  337. * query的触发来源0. 1.reload触发 2.refresh触发 3.
  338. */
  339. type _QueryFrom = 0 | 1 | 2 | 3;
  340. /**
  341. *
  342. *
  343. * @param pageNo
  344. * @param pageSize
  345. * @param from query的触发来源0. 1.reload触发 2.refresh触发 3.
  346. */
  347. interface Query {
  348. (pageNo: number, pageSize: number, from: _QueryFrom): void;
  349. }
  350. /**
  351. *
  352. *
  353. * @param list
  354. */
  355. interface ListChange {
  356. (list: []): void;
  357. }
  358. /**
  359. * 0- 1. 2. 3.(:refresher-complete-delay="200")
  360. */
  361. type _RefresherStatus = 0 | 1 | 2 | 3;
  362. /**
  363. *
  364. * - use-custom-refresher为false时无效
  365. *
  366. * @param status 0- 1. 2. 3.(:refresher-complete-delay="200")
  367. */
  368. interface RefresherStatusChange {
  369. (status: _RefresherStatus): void;
  370. }
  371. /**
  372. *
  373. * - use-custom-refresher为false时无效nvue无效
  374. *
  375. * @param y y值(px)
  376. */
  377. interface RefresherTouchstart {
  378. (y: number): void;
  379. }
  380. /**
  381. * touchmove信息
  382. */
  383. interface _RefresherTouchmoveInfo {
  384. /** 下拉的距离 */
  385. pullingDistance: number;
  386. /** 前后两次回调滑动距离的差值 */
  387. dy: number;
  388. /** refresh组件高度 */
  389. viewHeight: number;
  390. /** pullingDistance/viewHeight的比值 */
  391. rate: number;
  392. }
  393. /**
  394. *
  395. * - use-custom-refresher为false时无效
  396. * - 使wxs的平台上wxs与js通信折损z-paging添加@refresherTouchmove时wxs才会实时将下拉拖动事件传给jsQQ小程序中$listeners无效所以必须设置:watch-refresher-touchmove="true"使
  397. *
  398. * @param info touchmove信息
  399. */
  400. interface RefresherTouchmove {
  401. (info: _RefresherTouchmoveInfo): void;
  402. }
  403. /**
  404. *
  405. * - use-custom-refresher为false时无效nvue无效
  406. *
  407. * @param y y值(px)
  408. */
  409. interface RefresherTouchend {
  410. (y: number): void;
  411. }
  412. /**
  413. * go- close-
  414. */
  415. type _RefresherF2ChangeStatus = 'go' | 'close';
  416. /**
  417. *
  418. *
  419. * @since 2.7.7
  420. * @param status go- close-
  421. */
  422. interface RefresherF2Change {
  423. (status: _RefresherF2ChangeStatus): void;
  424. }
  425. /**
  426. *
  427. */
  428. interface OnRefresh {
  429. (): void;
  430. }
  431. /**
  432. *
  433. */
  434. interface OnRestore {
  435. (): void;
  436. }
  437. /**
  438. * 0- 1. 2. 3.
  439. */
  440. type _LoadingStatus = 0 | 1 | 2 | 3;
  441. /**
  442. *
  443. *
  444. * @param status 0- 1. 2. 3.
  445. */
  446. interface LoadingStatusChange {
  447. (status: _LoadingStatus): void;
  448. }
  449. /**
  450. * reload操作reload事件handler(false)
  451. */
  452. type _EmptyViewReloadHandler = (value: boolean) => void;
  453. /**
  454. *
  455. *
  456. * @since 1.8.0
  457. * @param handler reload操作reload事件handler(false)
  458. */
  459. interface EmptyViewReload {
  460. (handler: _EmptyViewReloadHandler): void;
  461. }
  462. /**
  463. * view
  464. *
  465. * @since 2.3.3
  466. */
  467. interface EmptyViewClick {
  468. (): void;
  469. }
  470. /**
  471. *
  472. *
  473. * @since 2.5.0
  474. * @param isLoadFailed true代表是
  475. */
  476. interface IsLoadFailedChange {
  477. (isLoadFailed: boolean): void;
  478. }
  479. /**
  480. * handler(false)
  481. */
  482. type _BackToTopClickHandler = (value: boolean) => void;
  483. /**
  484. *
  485. *
  486. * @since 2.6.1
  487. * @param handler handler(false)
  488. */
  489. interface BackToTopClick {
  490. (handler: _BackToTopClickHandler): void;
  491. }
  492. /**
  493. * +
  494. * -nvue无效
  495. *
  496. * @since 2.2.7
  497. * @param list
  498. */
  499. interface VirtualListChange {
  500. (list: []): void;
  501. }
  502. /**
  503. * 使cell的信息
  504. */
  505. interface _InnerCellClickInfo<T> {
  506. /** 当前点击的item */
  507. item: T;
  508. /** 当前点击的index */
  509. index: number;
  510. }
  511. /**
  512. * 使cell
  513. * -nvue无效
  514. *
  515. * @since 2.4.0
  516. * @param info cell的信息
  517. */
  518. interface InnerCellClick {
  519. (info: _InnerCellClickInfo<any>): void;
  520. }
  521. /**
  522. *
  523. *
  524. * @since 2.3.6
  525. */
  526. interface HidedKeyboard {
  527. (): void;
  528. }
  529. /**
  530. *
  531. */
  532. interface _KeyboardHeightInfo {
  533. /** 键盘的高度 */
  534. height: number;
  535. }
  536. /**
  537. *
  538. * -uni.onKeyboardHeightChange监听z-paging内置的键盘高度改变监听失效ps:H5
  539. *
  540. * @since 2.7.1
  541. * @param info
  542. */
  543. interface KeyboardHeightChange {
  544. (info: _KeyboardHeightInfo): void;
  545. }
  546. /**
  547. * (vue)
  548. */
  549. interface _ScrollInfo {
  550. detail: {
  551. scrollLeft: number;
  552. scrollTop: number;
  553. scrollHeight: number;
  554. scrollWidth: number;
  555. deltaX: number;
  556. deltaY: number;
  557. }
  558. }
  559. /**
  560. * (nvue)
  561. */
  562. interface _ScrollInfoN {
  563. contentSize: {
  564. width: number;
  565. height: number;
  566. };
  567. contentOffset: {
  568. x: number;
  569. y: number;
  570. };
  571. isDragging: boolean;
  572. }
  573. /**
  574. *
  575. *
  576. * @param event vue使用_ScrollInfonvue使用_ScrollInfoN
  577. */
  578. interface Scroll {
  579. (event: _ScrollInfo | _ScrollInfoN): void;
  580. }
  581. /**
  582. * scrollTop改变时触发使scrollTop时可使用此事件
  583. *
  584. * @param scrollTop
  585. */
  586. interface ScrollTopChange {
  587. (scrollTop: number): void;
  588. }
  589. /**
  590. * scroll-view滚动底部时的来源(toBottom滚动到底部click点击了加载更多view)
  591. */
  592. type _ScrolltolowerFrom = 'toBottom' | 'click';
  593. /**
  594. * scroll-view滚动底部时触发
  595. *
  596. * @param from (toBottom滚动到底部click点击了加载更多view)
  597. */
  598. interface Scrolltolower {
  599. (from: _ScrolltolowerFrom): void;
  600. }
  601. /**
  602. * scroll-view滚动顶部时触发
  603. */
  604. interface Scrolltoupper {
  605. (): void;
  606. }
  607. /**
  608. *
  609. */
  610. interface _ScrollendEvent {
  611. contentSize: {
  612. width: number;
  613. height: number;
  614. };
  615. contentOffset: {
  616. x: number;
  617. y: number;
  618. };
  619. isDragging: boolean;
  620. }
  621. /**
  622. * list滚动结束时触发
  623. * -nvue有效
  624. *
  625. * @since 2.7.3
  626. * @param event
  627. */
  628. interface Scrollend {
  629. (event: _ScrollendEvent): void;
  630. }
  631. /**
  632. * z-paging中内容高度改变时触发
  633. *
  634. * @since 2.1.3
  635. * @param height
  636. */
  637. interface ContentHeightChanged {
  638. (height: number): void;
  639. }
  640. /**
  641. * top代表用户将列表向上移动(scrollTop不断减小)bottom代表用户将列表向下移动(scrollTop不断增大)
  642. */
  643. type _TouchDirection = 'top' | 'bottom';
  644. /**
  645. *
  646. *
  647. * @since 2.3.0
  648. * @param direction top代表用户将列表向上移动(scrollTop不断减小)bottom代表用户将列表向下移动(scrollTop不断增大)
  649. */
  650. interface TouchDirectionChange {
  651. (direction: _TouchDirection): void;
  652. }
  653. }
  654. }
  655. export {};