@v-c/virtual-list 0.0.1 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/Filler.cjs +51 -1
  2. package/dist/Filler.js +47 -56
  3. package/dist/Item.cjs +26 -1
  4. package/dist/Item.js +23 -26
  5. package/dist/List.cjs +412 -1
  6. package/dist/List.d.ts +45 -9
  7. package/dist/List.js +407 -274
  8. package/dist/ScrollBar.cjs +259 -1
  9. package/dist/ScrollBar.d.ts +3 -97
  10. package/dist/ScrollBar.js +254 -191
  11. package/dist/_virtual/rolldown_runtime.cjs +21 -0
  12. package/dist/hooks/useDiffItem.cjs +19 -1
  13. package/dist/hooks/useDiffItem.js +16 -20
  14. package/dist/hooks/useFrameWheel.cjs +63 -1
  15. package/dist/hooks/useFrameWheel.js +60 -51
  16. package/dist/hooks/useGetSize.cjs +29 -1
  17. package/dist/hooks/useGetSize.d.ts +2 -2
  18. package/dist/hooks/useGetSize.js +27 -23
  19. package/dist/hooks/useHeights.cjs +66 -1
  20. package/dist/hooks/useHeights.d.ts +1 -1
  21. package/dist/hooks/useHeights.js +62 -41
  22. package/dist/hooks/useMobileTouchMove.cjs +82 -1
  23. package/dist/hooks/useMobileTouchMove.js +79 -43
  24. package/dist/hooks/useOriginScroll.cjs +23 -1
  25. package/dist/hooks/useOriginScroll.js +20 -16
  26. package/dist/hooks/useScrollDrag.cjs +83 -1
  27. package/dist/hooks/useScrollDrag.js +77 -48
  28. package/dist/hooks/useScrollTo.cjs +97 -0
  29. package/dist/hooks/useScrollTo.d.ts +19 -0
  30. package/dist/hooks/useScrollTo.js +94 -0
  31. package/dist/index.cjs +4 -1
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +3 -4
  34. package/dist/interface.cjs +0 -1
  35. package/dist/interface.d.ts +1 -1
  36. package/dist/interface.js +0 -1
  37. package/dist/utils/CacheMap.cjs +25 -1
  38. package/dist/utils/CacheMap.d.ts +1 -1
  39. package/dist/utils/CacheMap.js +23 -28
  40. package/dist/utils/isFirefox.cjs +4 -1
  41. package/dist/utils/isFirefox.js +2 -4
  42. package/dist/utils/scrollbarUtil.cjs +8 -1
  43. package/dist/utils/scrollbarUtil.js +7 -6
  44. package/package.json +19 -13
  45. package/docs/basic.vue +0 -175
  46. package/docs/height.vue +0 -48
  47. package/docs/nest.vue +0 -60
  48. package/docs/no-virtual.vue +0 -127
  49. package/docs/switch.vue +0 -101
  50. package/docs/virtual-list.stories.vue +0 -31
  51. package/src/Filler.tsx +0 -72
  52. package/src/Item.tsx +0 -34
  53. package/src/List.tsx +0 -577
  54. package/src/ScrollBar.tsx +0 -298
  55. package/src/__tests__/List.test.ts +0 -59
  56. package/src/hooks/useDiffItem.ts +0 -27
  57. package/src/hooks/useFrameWheel.ts +0 -141
  58. package/src/hooks/useGetSize.ts +0 -44
  59. package/src/hooks/useHeights.ts +0 -106
  60. package/src/hooks/useMobileTouchMove.ts +0 -131
  61. package/src/hooks/useOriginScroll.ts +0 -47
  62. package/src/hooks/useScrollDrag.ts +0 -123
  63. package/src/index.ts +0 -5
  64. package/src/interface.ts +0 -32
  65. package/src/utils/CacheMap.ts +0 -42
  66. package/src/utils/isFirefox.ts +0 -3
  67. package/src/utils/scrollbarUtil.ts +0 -10
  68. package/vite.config.ts +0 -18
  69. package/vitest.config.ts +0 -11
package/dist/List.d.ts CHANGED
@@ -1,14 +1,16 @@
1
- import { Key } from '../../util/src/type';
2
- import { ExtraRenderInfo } from './interface';
3
- import { PropType, VNode } from 'vue';
1
+ import { Key } from '@v-c/util/dist/type';
2
+ import { CSSProperties, PropType, VNode } from 'vue';
4
3
  import { InnerProps } from './Filler';
4
+ import { ExtraRenderInfo } from './interface';
5
+ import { ScrollBarDirectionType } from './ScrollBar';
5
6
  export interface ScrollInfo {
6
7
  x: number;
7
8
  y: number;
8
9
  }
10
+ export type ScrollTo = (arg?: number | ScrollConfig | null) => void;
9
11
  export interface ListRef {
10
12
  nativeElement?: HTMLDivElement;
11
- scrollTo: (arg?: number | ScrollConfig) => void;
13
+ scrollTo: ScrollTo;
12
14
  getScrollInfo: () => ScrollInfo;
13
15
  }
14
16
  export interface ScrollPos {
@@ -22,18 +24,33 @@ export interface ScrollTarget {
22
24
  offset?: number;
23
25
  }
24
26
  export type ScrollConfig = ScrollTarget | ScrollPos;
25
- export interface ListProps<T = any> {
27
+ export interface ListProps {
26
28
  prefixCls?: string;
27
- data?: T[];
29
+ data?: any[];
28
30
  height?: number;
29
31
  itemHeight?: number;
30
32
  fullHeight?: boolean;
31
- itemKey: Key | ((item: T) => Key);
33
+ itemKey: Key | ((item: any) => Key);
32
34
  component?: string;
33
35
  virtual?: boolean;
36
+ direction?: ScrollBarDirectionType;
37
+ /**
38
+ * By default `scrollWidth` is same as container.
39
+ * When set this, it will show the horizontal scrollbar and
40
+ * `scrollWidth` will be used as the real width instead of container width.
41
+ * When set, `virtual` will always be enabled.
42
+ */
43
+ scrollWidth?: number;
44
+ styles?: {
45
+ horizontalScrollBar?: CSSProperties;
46
+ horizontalScrollBarThumb?: CSSProperties;
47
+ verticalScrollBar?: CSSProperties;
48
+ verticalScrollBarThumb?: CSSProperties;
49
+ };
50
+ showScrollBar?: boolean | 'optional';
34
51
  onScroll?: (e: Event) => void;
35
52
  onVirtualScroll?: (info: ScrollInfo) => void;
36
- onVisibleChange?: (visibleList: T[], fullList: T[]) => void;
53
+ onVisibleChange?: (visibleList: any[], fullList: any[]) => void;
37
54
  innerProps?: InnerProps;
38
55
  extraRender?: (info: ExtraRenderInfo) => VNode;
39
56
  }
@@ -59,6 +76,15 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
59
76
  type: StringConstructor;
60
77
  default: string;
61
78
  };
79
+ direction: {
80
+ type: PropType<ScrollBarDirectionType>;
81
+ };
82
+ scrollWidth: NumberConstructor;
83
+ styles: ObjectConstructor;
84
+ showScrollBar: {
85
+ type: PropType<boolean | "optional">;
86
+ default: string;
87
+ };
62
88
  virtual: {
63
89
  type: BooleanConstructor;
64
90
  default: boolean;
@@ -90,6 +116,15 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
90
116
  type: StringConstructor;
91
117
  default: string;
92
118
  };
119
+ direction: {
120
+ type: PropType<ScrollBarDirectionType>;
121
+ };
122
+ scrollWidth: NumberConstructor;
123
+ styles: ObjectConstructor;
124
+ showScrollBar: {
125
+ type: PropType<boolean | "optional">;
126
+ default: string;
127
+ };
93
128
  virtual: {
94
129
  type: BooleanConstructor;
95
130
  default: boolean;
@@ -101,8 +136,9 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
101
136
  extraRender: PropType<(info: ExtraRenderInfo) => VNode>;
102
137
  }>> & Readonly<{}>, {
103
138
  prefixCls: string;
104
- component: string;
139
+ showScrollBar: boolean | "optional";
105
140
  fullHeight: boolean;
141
+ component: string;
106
142
  virtual: boolean;
107
143
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
108
144
  export default _default;