List.d.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import * as React from 'react';
  2. import type { InnerProps } from './Filler';
  3. import type { ScrollPos, ScrollTarget } from './hooks/useScrollTo';
  4. import type { ExtraRenderInfo, RenderFunc } from './interface';
  5. import type { ScrollBarDirectionType } from './ScrollBar';
  6. export interface ScrollInfo {
  7. x: number;
  8. y: number;
  9. }
  10. export type ScrollConfig = ScrollTarget | ScrollPos;
  11. export type ScrollTo = (arg?: number | ScrollConfig | null) => void;
  12. export type ListRef = {
  13. nativeElement: HTMLDivElement;
  14. scrollTo: ScrollTo;
  15. getScrollInfo: () => ScrollInfo;
  16. };
  17. export interface ListProps<T> extends Omit<React.HTMLAttributes<any>, 'children'> {
  18. prefixCls?: string;
  19. children: RenderFunc<T>;
  20. data: T[];
  21. height?: number;
  22. itemHeight?: number;
  23. /** If not match virtual scroll condition, Set List still use height of container. */
  24. fullHeight?: boolean;
  25. itemKey: React.Key | ((item: T) => React.Key);
  26. component?: string | React.FC<any> | React.ComponentClass<any>;
  27. /** Set `false` will always use real scroll instead of virtual one */
  28. virtual?: boolean;
  29. direction?: ScrollBarDirectionType;
  30. /**
  31. * By default `scrollWidth` is same as container.
  32. * When set this, it will show the horizontal scrollbar and
  33. * `scrollWidth` will be used as the real width instead of container width.
  34. * When set, `virtual` will always be enabled.
  35. */
  36. scrollWidth?: number;
  37. styles?: {
  38. horizontalScrollBar?: React.CSSProperties;
  39. horizontalScrollBarThumb?: React.CSSProperties;
  40. verticalScrollBar?: React.CSSProperties;
  41. verticalScrollBarThumb?: React.CSSProperties;
  42. };
  43. showScrollBar?: boolean | 'optional';
  44. onScroll?: React.UIEventHandler<HTMLElement>;
  45. /**
  46. * Given the virtual offset value.
  47. * It's the logic offset from start position.
  48. */
  49. onVirtualScroll?: (info: ScrollInfo) => void;
  50. /** Trigger when render list item changed */
  51. onVisibleChange?: (visibleList: T[], fullList: T[]) => void;
  52. /** Inject to inner container props. Only use when you need pass aria related data */
  53. innerProps?: InnerProps;
  54. /** Render extra content into Filler */
  55. extraRender?: (info: ExtraRenderInfo) => React.ReactNode;
  56. }
  57. export declare function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>): React.JSX.Element;
  58. declare const _default: <Item = any>(props: ListProps<Item> & {
  59. ref?: React.Ref<ListRef>;
  60. }) => React.ReactElement;
  61. export default _default;