@v-c/virtual-list 0.0.1 → 1.0.0

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 (66) hide show
  1. package/bump.config.ts +6 -0
  2. package/dist/Filler.cjs +51 -1
  3. package/dist/Filler.js +47 -56
  4. package/dist/Item.cjs +26 -1
  5. package/dist/Item.js +23 -26
  6. package/dist/List.cjs +408 -1
  7. package/dist/List.d.ts +45 -9
  8. package/dist/List.js +403 -274
  9. package/dist/ScrollBar.cjs +259 -1
  10. package/dist/ScrollBar.d.ts +3 -97
  11. package/dist/ScrollBar.js +254 -191
  12. package/dist/_virtual/rolldown_runtime.cjs +21 -0
  13. package/dist/hooks/useDiffItem.cjs +19 -1
  14. package/dist/hooks/useDiffItem.js +16 -20
  15. package/dist/hooks/useFrameWheel.cjs +63 -1
  16. package/dist/hooks/useFrameWheel.js +60 -51
  17. package/dist/hooks/useGetSize.cjs +29 -1
  18. package/dist/hooks/useGetSize.d.ts +2 -2
  19. package/dist/hooks/useGetSize.js +27 -23
  20. package/dist/hooks/useHeights.cjs +66 -1
  21. package/dist/hooks/useHeights.d.ts +1 -1
  22. package/dist/hooks/useHeights.js +62 -41
  23. package/dist/hooks/useMobileTouchMove.cjs +82 -1
  24. package/dist/hooks/useMobileTouchMove.js +79 -43
  25. package/dist/hooks/useOriginScroll.cjs +23 -1
  26. package/dist/hooks/useOriginScroll.js +20 -16
  27. package/dist/hooks/useScrollDrag.cjs +83 -1
  28. package/dist/hooks/useScrollDrag.js +77 -48
  29. package/dist/hooks/useScrollTo.cjs +97 -0
  30. package/dist/hooks/useScrollTo.d.ts +19 -0
  31. package/dist/hooks/useScrollTo.js +94 -0
  32. package/dist/index.cjs +4 -1
  33. package/dist/index.d.ts +1 -1
  34. package/dist/index.js +3 -4
  35. package/dist/interface.cjs +0 -1
  36. package/dist/interface.d.ts +1 -1
  37. package/dist/interface.js +0 -1
  38. package/dist/utils/CacheMap.cjs +25 -1
  39. package/dist/utils/CacheMap.d.ts +1 -1
  40. package/dist/utils/CacheMap.js +23 -28
  41. package/dist/utils/isFirefox.cjs +4 -1
  42. package/dist/utils/isFirefox.js +2 -4
  43. package/dist/utils/scrollbarUtil.cjs +8 -1
  44. package/dist/utils/scrollbarUtil.js +7 -6
  45. package/docs/animate.less +31 -0
  46. package/docs/animate.vue +159 -0
  47. package/docs/basic.vue +2 -1
  48. package/docs/nest.vue +1 -1
  49. package/docs/switch.vue +2 -1
  50. package/docs/virtual-list.stories.vue +4 -0
  51. package/package.json +16 -14
  52. package/src/Filler.tsx +2 -1
  53. package/src/Item.tsx +2 -1
  54. package/src/List.tsx +189 -124
  55. package/src/ScrollBar.tsx +33 -44
  56. package/src/hooks/useDiffItem.ts +3 -2
  57. package/src/hooks/useFrameWheel.ts +2 -1
  58. package/src/hooks/useGetSize.ts +5 -4
  59. package/src/hooks/useHeights.ts +7 -6
  60. package/src/hooks/useMobileTouchMove.ts +2 -1
  61. package/src/hooks/useOriginScroll.ts +2 -1
  62. package/src/hooks/useScrollDrag.ts +2 -1
  63. package/src/hooks/useScrollTo.tsx +184 -0
  64. package/src/index.ts +1 -1
  65. package/tsconfig.json +7 -0
  66. package/vitest.config.ts +1 -1
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;