virtua 0.19.2 → 0.20.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.
@@ -1,6 +1,6 @@
1
1
  import { CSSProperties, ReactNode } from "react";
2
2
  /**
3
- * Props of customized item component for {@link VList}.
3
+ * Props of customized item component for {@link Virtualizer} or {@link WindowVirtualizer}.
4
4
  */
5
5
  export interface CustomItemComponentProps {
6
6
  style: CSSProperties;
@@ -1,5 +1,32 @@
1
1
  import { CSSProperties, ReactNode } from "react";
2
- import { CustomViewportComponent, ViewportComponentAttributes } from "./Viewport";
2
+ import { ViewportComponentAttributes } from "./types";
3
+ /**
4
+ * Props of customized scrollable component.
5
+ */
6
+ interface CustomViewportComponentProps {
7
+ /**
8
+ * Renderable item elements.
9
+ */
10
+ children: ReactNode;
11
+ /**
12
+ * Attributes that should be passed to the scrollable element.
13
+ */
14
+ attrs: ViewportComponentAttributes;
15
+ /**
16
+ * Total height of items. It's undefined if component is not vertically scrollable.
17
+ */
18
+ height: number | undefined;
19
+ /**
20
+ * Total width of items. It's undefined if component is not horizontally scrollable.
21
+ */
22
+ width: number | undefined;
23
+ /**
24
+ * Currently component is scrolling or not.
25
+ */
26
+ scrolling: boolean;
27
+ }
28
+ declare const DefaultViewport: import("react").ForwardRefExoticComponent<CustomViewportComponentProps & import("react").RefAttributes<any>>;
29
+ export type CustomViewportComponent = typeof DefaultViewport;
3
30
  /**
4
31
  * Props of customized cell component for {@link VGrid}.
5
32
  */
@@ -8,7 +35,6 @@ export interface CustomCellComponentProps {
8
35
  children: ReactNode;
9
36
  }
10
37
  export type CustomCellComponent = React.ForwardRefExoticComponent<React.PropsWithoutRef<CustomCellComponentProps> & React.RefAttributes<any>>;
11
- type CustomCellComponentOrElement = keyof JSX.IntrinsicElements | CustomCellComponent;
12
38
  /**
13
39
  * Methods of {@link VGrid}.
14
40
  */
@@ -105,7 +131,7 @@ export interface VGridProps extends ViewportComponentAttributes {
105
131
  * Component or element type for cell element. This component will get {@link CustomCellComponentProps} as props.
106
132
  * @defaultValue "div"
107
133
  */
108
- Cell?: CustomCellComponentOrElement;
134
+ Cell?: keyof JSX.IntrinsicElements | CustomCellComponent;
109
135
  };
110
136
  }
111
137
  /**
@@ -1,130 +1,17 @@
1
- import { ReactElement, ReactNode } from "react";
2
- import { CustomViewportComponent, ViewportComponentAttributes } from "./Viewport";
3
- import { CustomItemComponent } from "./ListItem";
4
- import { CacheSnapshot, ScrollToIndexOpts } from "../core/types";
5
- type CustomItemComponentOrElement = keyof JSX.IntrinsicElements | CustomItemComponent;
1
+ /// <reference types="react" />
2
+ import { ViewportComponentAttributes } from "./types";
3
+ import { VirtualizerHandle, VirtualizerProps } from "./Virtualizer";
6
4
  /**
7
5
  * Methods of {@link VList}.
8
6
  */
9
- export interface VListHandle {
10
- /**
11
- * Get current {@link CacheSnapshot}.
12
- */
13
- readonly cache: CacheSnapshot;
14
- /**
15
- * Get current scrollTop or scrollLeft.
16
- */
17
- readonly scrollOffset: number;
18
- /**
19
- * Get current scrollHeight or scrollWidth.
20
- */
21
- readonly scrollSize: number;
22
- /**
23
- * Get current offsetHeight or offsetWidth.
24
- */
25
- readonly viewportSize: number;
26
- /**
27
- * Scroll to the item specified by index.
28
- * @param index index of item
29
- * @param opts options
30
- */
31
- scrollToIndex(index: number, opts?: ScrollToIndexOpts): void;
32
- /**
33
- * Scroll to the given offset.
34
- * @param offset offset from start
35
- */
36
- scrollTo(offset: number): void;
37
- /**
38
- * Scroll by the given offset.
39
- * @param offset offset from current position
40
- */
41
- scrollBy(offset: number): void;
7
+ export interface VListHandle extends VirtualizerHandle {
42
8
  }
43
9
  /**
44
10
  * Props of {@link VList}.
45
11
  */
46
- export interface VListProps extends ViewportComponentAttributes {
47
- /**
48
- * Elements rendered by this component.
49
- *
50
- * You can also pass a function and set {@link VListProps.count} to create elements lazily.
51
- */
52
- children: ReactNode | ((index: number) => ReactElement);
53
- /**
54
- * If you set a function to {@link VListProps.children}, you have to set total number of items to this prop.
55
- */
56
- count?: number;
57
- /**
58
- * Number of items to render above/below the visible bounds of the list. Lower value will give better performance but you can increase to avoid showing blank items in fast scrolling.
59
- * @defaultValue 4
60
- */
61
- overscan?: number;
62
- /**
63
- * Item size hint for unmeasured items. It will help to reduce scroll jump when items are measured if used properly.
64
- *
65
- * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.
66
- * - If set, you can opt out estimation and use the value as initial item size.
67
- */
68
- initialItemSize?: number;
69
- /**
70
- * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.
71
- */
72
- shift?: boolean;
73
- /**
74
- * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.
75
- */
76
- horizontal?: boolean;
77
- /**
78
- * If true, items are aligned to the end of the list when total size of items are smaller than viewport size. It's useful for chat like app.
79
- */
80
- reverse?: boolean;
81
- /**
82
- * You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link VListHandle.cache}.
83
- */
84
- cache?: CacheSnapshot;
85
- /**
86
- * A prop for SSR. If set, the specified amount of items will be mounted in the initial rendering regardless of the container size until hydrated.
87
- */
88
- ssrCount?: number;
89
- /**
90
- * Customized components for advanced usage.
91
- */
92
- components?: {
93
- /**
94
- * Component for scrollable element. This component will get {@link CustomViewportComponentProps} as props.
95
- * @defaultValue {@link DefaultViewport}
96
- */
97
- Root?: CustomViewportComponent;
98
- /**
99
- * Component or element type for item element. This component will get {@link CustomItemComponentProps} as props.
100
- * @defaultValue "div"
101
- */
102
- Item?: CustomItemComponentOrElement;
103
- };
104
- /**
105
- * Callback invoked whenever scroll offset changes.
106
- * @param offset Current scrollTop or scrollLeft.
107
- */
108
- onScroll?: (offset: number) => void;
109
- /**
110
- * Callback invoked when scrolling stops.
111
- */
112
- onScrollStop?: () => void;
113
- /**
114
- * Callback invoked when visible items range changes.
115
- */
116
- onRangeChange?: (
117
- /**
118
- * The start index of viewable items.
119
- */
120
- startIndex: number,
121
- /**
122
- * The end index of viewable items.
123
- */
124
- endIndex: number) => void;
12
+ export interface VListProps extends Pick<VirtualizerProps, "children" | "count" | "overscan" | "itemSize" | "shift" | "horizontal" | "reverse" | "cache" | "ssrCount" | "item" | "onScroll" | "onScrollEnd" | "onRangeChange">, ViewportComponentAttributes {
125
13
  }
126
14
  /**
127
15
  * Virtualized list component. See {@link VListProps} and {@link VListHandle}.
128
16
  */
129
17
  export declare const VList: import("react").ForwardRefExoticComponent<VListProps & import("react").RefAttributes<VListHandle>>;
130
- export {};
@@ -0,0 +1,135 @@
1
+ import { ReactElement, ReactNode, RefObject } from "react";
2
+ import { CustomItemComponent } from "./ListItem";
3
+ import { CacheSnapshot, ScrollToIndexOpts } from "../core/types";
4
+ import { CustomContainerComponent } from "./types";
5
+ /**
6
+ * Methods of {@link Virtualizer}.
7
+ */
8
+ export interface VirtualizerHandle {
9
+ /**
10
+ * Get current {@link CacheSnapshot}.
11
+ */
12
+ readonly cache: CacheSnapshot;
13
+ /**
14
+ * Get current scrollTop or scrollLeft.
15
+ */
16
+ readonly scrollOffset: number;
17
+ /**
18
+ * Get current scrollHeight or scrollWidth.
19
+ */
20
+ readonly scrollSize: number;
21
+ /**
22
+ * Get current offsetHeight or offsetWidth.
23
+ */
24
+ readonly viewportSize: number;
25
+ /**
26
+ * Scroll to the item specified by index.
27
+ * @param index index of item
28
+ * @param opts options
29
+ */
30
+ scrollToIndex(index: number, opts?: ScrollToIndexOpts): void;
31
+ /**
32
+ * Scroll to the given offset.
33
+ * @param offset offset from start
34
+ */
35
+ scrollTo(offset: number): void;
36
+ /**
37
+ * Scroll by the given offset.
38
+ * @param offset offset from current position
39
+ */
40
+ scrollBy(offset: number): void;
41
+ }
42
+ /**
43
+ * Props of {@link Virtualizer}.
44
+ */
45
+ export interface VirtualizerProps {
46
+ /**
47
+ * Elements rendered by this component.
48
+ *
49
+ * You can also pass a function and set {@link VirtualizerProps.count} to create elements lazily.
50
+ */
51
+ children: ReactNode | ((index: number) => ReactElement);
52
+ /**
53
+ * If you set a function to {@link VirtualizerProps.children}, you have to set total number of items to this prop.
54
+ */
55
+ count?: number;
56
+ /**
57
+ * Number of items to render above/below the visible bounds of the list. Lower value will give better performance but you can increase to avoid showing blank items in fast scrolling.
58
+ * @defaultValue 4
59
+ */
60
+ overscan?: number;
61
+ /**
62
+ * Item size hint for unmeasured items. It will help to reduce scroll jump when items are measured if used properly.
63
+ *
64
+ * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.
65
+ * - If set, you can opt out estimation and use the value as initial item size.
66
+ */
67
+ itemSize?: number;
68
+ /**
69
+ * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.
70
+ */
71
+ shift?: boolean;
72
+ /**
73
+ * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.
74
+ */
75
+ horizontal?: boolean;
76
+ /**
77
+ * If true, items are aligned to the end of the list when total size of items are smaller than viewport size. It's useful for chat like app.
78
+ */
79
+ reverse?: boolean;
80
+ /**
81
+ * You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link VirtualizerHandle.cache}.
82
+ */
83
+ cache?: CacheSnapshot;
84
+ /**
85
+ * If you put an element before virtualizer, you have to define its height with this prop.
86
+ */
87
+ startMargin?: number;
88
+ /**
89
+ * If you put an element after virtualizer, you have to define its height with this prop.
90
+ */
91
+ endMargin?: number;
92
+ /**
93
+ * A prop for SSR. If set, the specified amount of items will be mounted in the initial rendering regardless of the container size until hydrated.
94
+ */
95
+ ssrCount?: number;
96
+ /**
97
+ * Component or element type for container element.
98
+ * @defaultValue "div"
99
+ */
100
+ as?: keyof JSX.IntrinsicElements | CustomContainerComponent;
101
+ /**
102
+ * Component or element type for item element. This component will get {@link CustomItemComponentProps} as props.
103
+ * @defaultValue "div"
104
+ */
105
+ item?: keyof JSX.IntrinsicElements | CustomItemComponent;
106
+ /**
107
+ * Reference to the scrollable element. The default will get the parent element of virtualizer.
108
+ */
109
+ scrollRef?: RefObject<HTMLElement>;
110
+ /**
111
+ * Callback invoked whenever scroll offset changes.
112
+ * @param offset Current scrollTop or scrollLeft.
113
+ */
114
+ onScroll?: (offset: number) => void;
115
+ /**
116
+ * Callback invoked when scrolling stops.
117
+ */
118
+ onScrollEnd?: () => void;
119
+ /**
120
+ * Callback invoked when visible items range changes.
121
+ */
122
+ onRangeChange?: (
123
+ /**
124
+ * The start index of viewable items.
125
+ */
126
+ startIndex: number,
127
+ /**
128
+ * The end index of viewable items.
129
+ */
130
+ endIndex: number) => void;
131
+ }
132
+ /**
133
+ * Customizable list virtualizer for advanced usage. See {@link VirtualizerProps} and {@link VirtualizerHandle}.
134
+ */
135
+ export declare const Virtualizer: import("react").ForwardRefExoticComponent<VirtualizerProps & import("react").RefAttributes<VirtualizerHandle>>;
@@ -1,29 +1,28 @@
1
1
  import { ReactElement, ReactNode } from "react";
2
2
  import { CacheSnapshot } from "../core/types";
3
- import { CustomViewportComponent, ViewportComponentAttributes } from "./Viewport";
3
+ import { CustomContainerComponent } from "./types";
4
4
  import { CustomItemComponent } from "./ListItem";
5
- type CustomItemComponentOrElement = keyof JSX.IntrinsicElements | CustomItemComponent;
6
5
  /**
7
- * Methods of {@link WVList}.
6
+ * Methods of {@link WindowVirtualizer}.
8
7
  */
9
- export interface WVListHandle {
8
+ export interface WindowVirtualizerHandle {
10
9
  /**
11
10
  * Get current {@link CacheSnapshot}.
12
11
  */
13
12
  readonly cache: CacheSnapshot;
14
13
  }
15
14
  /**
16
- * Props of {@link WVList}.
15
+ * Props of {@link WindowVirtualizer}.
17
16
  */
18
- export interface WVListProps extends ViewportComponentAttributes {
17
+ export interface WindowVirtualizerProps {
19
18
  /**
20
19
  * Elements rendered by this component.
21
20
  *
22
- * You can also pass a function and set {@link WVListProps.count} to create elements lazily.
21
+ * You can also pass a function and set {@link WindowVirtualizerProps.count} to create elements lazily.
23
22
  */
24
23
  children: ReactNode | ((index: number) => ReactElement);
25
24
  /**
26
- * If you set a function to {@link WVListProps.children}, you have to set total number of items to this prop.
25
+ * If you set a function to {@link WindowVirtualizerProps.children}, you have to set total number of items to this prop.
27
26
  */
28
27
  count?: number;
29
28
  /**
@@ -37,7 +36,7 @@ export interface WVListProps extends ViewportComponentAttributes {
37
36
  * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.
38
37
  * - If set, you can opt out estimation and use the value as initial item size.
39
38
  */
40
- initialItemSize?: number;
39
+ itemSize?: number;
41
40
  /**
42
41
  * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.
43
42
  */
@@ -47,7 +46,7 @@ export interface WVListProps extends ViewportComponentAttributes {
47
46
  */
48
47
  horizontal?: boolean;
49
48
  /**
50
- * You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link WVListHandle.cache}.
49
+ * You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link WindowVirtualizerHandle.cache}.
51
50
  */
52
51
  cache?: CacheSnapshot;
53
52
  /**
@@ -55,24 +54,19 @@ export interface WVListProps extends ViewportComponentAttributes {
55
54
  */
56
55
  ssrCount?: number;
57
56
  /**
58
- * Customized components for advanced usage.
57
+ * Component or element type for container element.
58
+ * @defaultValue "div"
59
59
  */
60
- components?: {
61
- /**
62
- * Component for scrollable element. This component will get {@link CustomViewportComponentProps} as props.
63
- * @defaultValue {@link DefaultViewport}
64
- */
65
- Root?: CustomViewportComponent;
66
- /**
67
- * Component or element type for item element. This component will get {@link CustomItemComponentProps} as props.
68
- * @defaultValue "div"
69
- */
70
- Item?: CustomItemComponentOrElement;
71
- };
60
+ as?: keyof JSX.IntrinsicElements | CustomContainerComponent;
61
+ /**
62
+ * Component or element type for item element. This component will get {@link CustomItemComponentProps} as props.
63
+ * @defaultValue "div"
64
+ */
65
+ item?: keyof JSX.IntrinsicElements | CustomItemComponent;
72
66
  /**
73
67
  * Callback invoked when scrolling stops.
74
68
  */
75
- onScrollStop?: () => void;
69
+ onScrollEnd?: () => void;
76
70
  /**
77
71
  * Callback invoked when visible items range changes.
78
72
  */
@@ -87,7 +81,6 @@ export interface WVListProps extends ViewportComponentAttributes {
87
81
  endIndex: number) => void;
88
82
  }
89
83
  /**
90
- * Virtualized list component controlled by the window scrolling. See {@link WVListProps} and {@link WVListHandle}.
84
+ * {@link Virtualizer} controlled by the window scrolling. See {@link WindowVirtualizerProps} and {@link WindowVirtualizer}.
91
85
  */
92
- export declare const WVList: import("react").ForwardRefExoticComponent<WVListProps & import("react").RefAttributes<WVListHandle>>;
93
- export {};
86
+ export declare const WindowVirtualizer: import("react").ForwardRefExoticComponent<WindowVirtualizerProps & import("react").RefAttributes<WindowVirtualizerHandle>>;
@@ -1,8 +1,10 @@
1
1
  export { VList } from "./VList";
2
2
  export type { VListProps, VListHandle } from "./VList";
3
- export { WVList } from "./WVList";
4
- export type { WVListProps, WVListHandle } from "./WVList";
3
+ export { Virtualizer } from "./Virtualizer";
4
+ export type { VirtualizerProps, VirtualizerHandle } from "./Virtualizer";
5
+ export { WindowVirtualizer } from "./WindowVirtualizer";
6
+ export type { WindowVirtualizerProps, WindowVirtualizerHandle, } from "./WindowVirtualizer";
5
7
  export { VGrid as experimental_VGrid } from "./VGrid";
6
8
  export type { VGridProps, VGridHandle, CustomCellComponent, CustomCellComponentProps, } from "./VGrid";
7
- export type { ViewportComponentAttributes, CustomViewportComponent, CustomViewportComponentProps, } from "./Viewport";
9
+ export type * from "./types";
8
10
  export type { CustomItemComponent, CustomItemComponentProps } from "./ListItem";
@@ -0,0 +1,7 @@
1
+ import { CSSProperties, ReactNode } from "react";
2
+ export type ViewportComponentAttributes = Pick<React.HTMLAttributes<HTMLElement>, "className" | "style" | "id" | "role" | "tabIndex" | "onKeyDown"> & React.AriaAttributes;
3
+ export interface CustomContainerComponentProps {
4
+ style: CSSProperties;
5
+ children: ReactNode;
6
+ }
7
+ export type CustomContainerComponent = React.ForwardRefExoticComponent<React.PropsWithoutRef<CustomContainerComponentProps> & React.RefAttributes<any>>;
@@ -53,7 +53,7 @@ export declare const VList: import("vue").DefineComponent<{
53
53
  * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.
54
54
  * - If set, you can opt out estimation and use the value as initial item size.
55
55
  */
56
- initialItemSize: NumberConstructor;
56
+ itemSize: NumberConstructor;
57
57
  /**
58
58
  * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.
59
59
  */
@@ -71,7 +71,7 @@ export declare const VList: import("vue").DefineComponent<{
71
71
  /**
72
72
  * Callback invoked when scrolling stops.
73
73
  */
74
- scrollStop: () => void;
74
+ scrollEnd: () => void;
75
75
  /**
76
76
  * Callback invoked when visible items range changes.
77
77
  */
@@ -98,7 +98,7 @@ export declare const VList: import("vue").DefineComponent<{
98
98
  * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.
99
99
  * - If set, you can opt out estimation and use the value as initial item size.
100
100
  */
101
- initialItemSize: NumberConstructor;
101
+ itemSize: NumberConstructor;
102
102
  /**
103
103
  * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.
104
104
  */
@@ -108,9 +108,9 @@ export declare const VList: import("vue").DefineComponent<{
108
108
  */
109
109
  horizontal: BooleanConstructor;
110
110
  }>> & {
111
- onScroll?: (offset: number) => any;
112
- onScrollStop?: () => any;
113
- onRangeChange?: (startIndex: number, endIndex: number) => any;
111
+ onScroll?: ((offset: number) => any) | undefined;
112
+ onScrollEnd?: (() => any) | undefined;
113
+ onRangeChange?: ((startIndex: number, endIndex: number) => any) | undefined;
114
114
  }, {
115
115
  shift: boolean;
116
116
  overscan: number;
package/lib/vue/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var e=require("vue/jsx-runtime"),t=require("vue");const r=Math.min,o=Math.max,n=Math.abs,s=Date.now,l=setTimeout,i=(e,t,n)=>r(n,o(t,e)),c=e=>null!=e,a=e=>{let t,r;return(...o)=>(t||(t=!0,r=e(...o)),r)},u=e=>getComputedStyle(e),f=-1,d=(e,t,r)=>{const o=r?"unshift":"push";for(let r=0;r<t;r++)e[o](f);return e},h=(e,t)=>{const r=e.t[t];return r===f?e.o:r},p=(e,t)=>{if(!e.l)return 0;if(e.i>=t)return e.u[t];e.i<0&&(e.u[0]=0,e.i=0);let r=e.i,o=e.u[r];for(;r<t;)o+=h(e,r),e.u[++r]=o;return e.i=t,o},_=(e,t,r)=>{let o=p(e,r);for(;r>=0&&r<e.l;)if(o<=t){const n=h(e,r);if(o+n>t)break;o+=n,r++}else o-=h(e,--r);return i(r,0,e.l-1)},g=(e,t,o,n)=>{const s=_(e,t,r(o,e.l-1));return[s,_(e,t+n,s)]},v=(e,t,o)=>{const n=t-e.l,s=n>0;let l;return s?(l=e.o*n,d(e.t,n,o),d(e.u,n)):(l=(o?e.t.splice(0,-n):e.t.splice(n)).reduce(((t,r)=>t+(r===f?e.o:r)),0),e.u.splice(n)),e.i=o?-1:r(t-1,e.i),e.l=t,[l,s]},m="undefined"!=typeof window,b=()=>document.documentElement,y=/*#__PURE__*/a((e=>{const t="scrollLeft",r=e[t];e[t]=1;const o=e[t]<1;return e[t]=r,o})),S=/*#__PURE__*/a((()=>!!m&&"rtl"===u(b()).direction)),w=/*#__PURE__*/a((()=>/iP(hone|od|ad)/.test(navigator.userAgent))),z=/*#__PURE__*/a((()=>"scrollBehavior"in b().style)),x=(e,t,r)=>t.reduce(((t,[o,n])=>{const s=n-h(e,o);return(!r||s>0)&&(t+=s),t}),0),k={box:"border-box"},I=/*#__PURE__*/t.defineComponent({props:{h:{type:Object,required:!0},p:{type:Object,required:!0},_:{type:Number,required:!0},v:{type:Number,required:!0},m:{type:Boolean},S:{type:Boolean},k:{type:String,required:!0}},setup(r){const o=t.ref();return t.watch((()=>o.value&&r._),((e,t,n)=>{n(r.p(o.value,r._))}),{flush:"post"}),()=>{const{h:t,v:n,m:s,k:l,S:i}=r,c={margin:0,padding:0,position:"absolute",[i?"height":"width"]:"100%",[i?"top":"left"]:"0px",[i?S()?"right":"left":"top"]:n+"px",visibility:s?"hidden":"visible"};return i&&(c.display="flex"),e.jsx(l,{ref:o,style:c,children:t})}}}),O={data:{type:Array,required:!0},overscan:{type:Number,default:4},initialItemSize:Number,shift:Boolean,horizontal:Boolean},q=/*#__PURE__*/t.defineComponent({props:O,emits:["scroll","scrollStop","rangeChange"],setup(_,{emit:m,expose:b,slots:O}){var q;const T=_.horizontal,B=t.ref(),N=((e,t=40,s=0,l=((e,t)=>({o:t,l:e,i:-1,t:d([],e),u:d([],e)}))(e,t),c)=>{let a=!!s,u=[],_=0,m=0,b=0,y=0,S=0,z=0,k=0,I=0,O=0,q=0,T=a?[0,o(s-1,0)]:null,B=[0,0];const N=new Set,C=()=>(e=>e.l?p(e,e.l-1)+h(e,e.l-1):0)(l),J=()=>_-m-b,M=()=>o(0,C()-J()),R=e=>{w()&&0!==O?k+=e:(z+=e,S++)};return{I:()=>u,O:()=>JSON.parse(JSON.stringify(l)),q:()=>T?[r(B[0],T[0]),o(B[1],T[1])]:I?B:B=g(l,y+k+z,B[0],_),T:e=>l.t[e]===f,B:()=>!!T&&l.t.slice(o(0,T[0]-1),r(l.l-1,T[1]+1)+1).includes(f),N:e=>p(l,e)-k,C:e=>h(l,e),J:()=>l.l,M:()=>y,R:M,j:()=>O,H:()=>_,L:()=>m,A:()=>o(C(),J()),D:C,F:()=>S,P:()=>J()>C()?z=0:(I=z,z=0,I),U(e,t){const r=[e,t];return N.add(r),()=>{N.delete(r)}},V(e,t){let o,s,d=0;switch(e){case 1:{const e=t.filter((([e,t])=>l.t[e]!==t));if(!e.length)break;let o=0;if(0===y);else if(y>M()-1.5)o=x(l,e,!0);else if(2===q)o=x(l,e);else{const[t]=B;o=x(l,e.filter((([e])=>e<t)))}o&&R(o);let n=!1;e.forEach((([e,t])=>{((e,t,o)=>{const n=e.t[t]===f;return e.t[t]=o,e.i=r(t,e.i),n})(l,e,t)&&(n=!0)})),c&&n&&!y&&(e=>{const t=e.t.filter((e=>e!==f)),r=t[0];e.o=t.every((e=>e===r))?r:(e=>{const t=[...e].sort(((e,t)=>e-t)),r=e.length/2|0;return t.length%2==0?(t[r-1]+t[r])/2:t[r]})(t)})(l),d=2,s=!0;break}case 2:{const e=t[0]+t[1]+t[2];_!==e&&(_=e,m=t[1],b=t[2],d=2);break}case 3:if(t[1]){const e=M()-y,[o,n]=v(l,t[0],!0);R(n?o:-r(o,e)),n&&(q=2),d=1}else v(l,t[0]);break;case 4:{const e=i(t,0,M()),r=I;if(I=0,e===y)break;const o=e-y,l=n(o);r&&l<n(r)+1||0!==q||(O=o<0?2:1),a&&(T=null,a=!1),s=l>_,y=e,d=5;break}case 5:d=8,0!==O&&(o=!0,d+=1),O=0,q=0,T=null;break;case 6:q=1;break;case 7:T=g(l,t,B[0],_),d=1}d&&(u=[],o&&k&&(z+=k,k=0,S++),N.forEach((([e,t])=>{d&e&&t(s)})))}}})(_.data.length,null!==(q=_.initialItemSize)&&void 0!==q?q:40,void 0,void 0,!_.initialItemSize),C=((e,t)=>{let r;const o=t?"width":"height",n=new WeakMap,s=a((()=>new ResizeObserver((s=>{const l=[];for(const{target:a,contentRect:f}of s)if(a.offsetParent)if(a===r)e.V(2,[f[o],f[t?"left":"top"],(i=u(r)[t?"paddingRight":"paddingBottom"],i?parseFloat(i):0)]);else{const e=n.get(a);c(e)&&l.push([e,f[o]])}var i;l.length&&e.V(1,l)}))));return{X(e){r=e;const t=s();return t.observe(e,k),()=>{t.disconnect()}},Y:(e,t)=>{const r=s();return n.set(e,t),r.observe(e),()=>{n.delete(e),r.unobserve(e)}}}})(N,T),J=((e,t)=>{let r,o,n=!1;const a=t?"scrollLeft":"scrollTop",u=t?"overflowX":"overflowY",f=(o,n)=>t&&S()?((e,t,r,o)=>y(e)||o?-r:t.R()-r)(r,e,o,n):o,d=async(n,s)=>{if(!r)return;o&&o();const c=()=>i(n(),0,e.R()),u=()=>{let t;return[new Promise(((e,r)=>{t=e,l(o=r,150)})),e.U(2,(()=>{t&&t()}))]};if(s&&z()){for(;e.V(7,c()),e.B();){const[e,t]=u();try{await e}catch(e){return}finally{t()}}r.scrollTo({[t?"left":"top"]:f(c()),behavior:"smooth"})}else for(;;){const[t,o]=u();try{r[a]=f(c()),e.V(6),await t}catch(e){return}finally{o()}}};return{W(o){r=o;let i=!1,u=!1;const d=(()=>{let t;const r=()=>{c(t)&&clearTimeout(t)},o=()=>{r(),t=l((()=>{t=null,i?d():(u=!1,e.V(5))}),150)};return o.G=r,o})(),h=()=>{u&&(n=!0),e.V(4,f(o[a])),d()},p=((e,t,r)=>(()=>{let o=s()-50;return(...n)=>{const l=s();o+50<l&&(o=l,(o=>{if(0!==e.j()&&!o.ctrlKey&&(t?o.deltaX:o.deltaY)){const t=e.M();t>0&&t<e.R()&&r()}})(...n))}})())(e,t,d),_=()=>{i=!0,u=n=!1},g=()=>{i=!1,w()&&(u=!0)};return o.addEventListener("scroll",h),o.addEventListener("wheel",p,{passive:!0}),o.addEventListener("touchstart",_,{passive:!0}),o.addEventListener("touchend",g,{passive:!0}),()=>{o.removeEventListener("scroll",h),o.removeEventListener("wheel",p),o.removeEventListener("touchstart",_),o.removeEventListener("touchend",g),d.G()}},K(e){d((()=>e))},Z(t){t+=e.M(),d((()=>t))},$(t,{align:r,smooth:o}={}){if(t=i(t,0,e.J()-1),"nearest"===r){const o=e.N(t),n=e.M();if(o<n)r="start";else{if(!(o+e.C(t)>n+e.H()))return;r="end"}}d((()=>e.L()+("end"===r?e.N(t)+e.C(t)-e.H():"center"===r?e.N(t)+(e.C(t)-e.H())/2:e.N(t))),o)},ee:e=>{if(r){if(n){n=!1;const e=r.style,t=e[u];e[u]="hidden",l((()=>{e[u]=t}))}r[a]+=f(e,!0)}}}})(N,T),M=t.ref(N.I()),R=N.U(3,(()=>{M.value=N.I()})),j=N.U(4,(()=>{m("scroll",N.M())})),H=N.U(8,(()=>{m("scrollStop")}));let L,A;return t.onMounted((()=>{const e=B.value;e&&(L=C.X(e),A=J.W(e))})),t.onUnmounted((()=>{R(),j(),H(),L&&L(),A&&A()})),t.watch((()=>_.data.length),(e=>{N.V(3,[e,_.shift])})),t.watch([M,N.F],(([,e],[,t])=>{if(e===t)return;const r=N.P();r&&J.ee(r)}),{flush:"post"}),t.watch([M,N.q],(([,[e,t]],[,[r,o]])=>{r===e&&o===t||m("rangeChange",e,t)}),{flush:"post"}),b({get scrollOffset(){return N.M()},get scrollSize(){return N.A()},get viewportSize(){return N.H()},scrollToIndex:J.$,scrollTo:J.K,scrollBy:J.Z}),()=>{M.value;const t=_.data.length,[n,s]=N.q(),l=N.j(),i=N.A(),a=((e,t,r)=>o(e-(1===r?1:o(1,t)),0))(n,_.overscan,l),u=((e,t,n,s)=>r(e+(2===n?1:o(1,t)),s-1))(s,_.overscan,l,t),f=[];for(let t=a;t<=u;t++){const r=O.default(_.data[t])[0],o=r.key;f.push(e.jsx(I,{p:C.Y,_:t,v:N.N(t),m:N.T(t),k:"div",h:r,S:T},c(o)?o:"_"+t))}return e.jsx("div",{ref:B,style:{display:T?"inline-block":"block",[T?"overflowX":"overflowY"]:"auto",overflowAnchor:"none",contain:"strict",width:"100%",height:"100%"},children:e.jsx("div",{style:{contain:"content",position:"relative",visibility:"hidden",width:T?i+"px":"100%",height:T?"100%":i+"px",pointerEvents:0!==l?"none":"auto"},children:f})})}}});exports.VList=q;
1
+ var e=require("vue/jsx-runtime"),t=require("vue");const r=Math.min,o=Math.max,n=Math.abs,s=Date.now,i=setTimeout,l=(e,t,n)=>r(n,o(t,e)),c=e=>null!=e,a=e=>{let t,r;return(...o)=>(t||(t=!0,r=e(...o)),r)},u=-1,f=(e,t,r)=>{const o=r?"unshift":"push";for(let r=0;r<t;r++)e[o](u);return e},d=(e,t)=>{const r=e.t[t];return r===u?e.o:r},h=(e,t)=>{if(!e.i)return 0;if(e.l>=t)return e.u[t];e.l<0&&(e.u[0]=0,e.l=0);let r=e.l,o=e.u[r];for(;r<t;)o+=d(e,r),e.u[++r]=o;return e.l=t,o},_=(e,t,r)=>{let o=h(e,r);for(;r>=0&&r<e.i;)if(o<=t){const n=d(e,r);if(o+n>t)break;o+=n,r++}else o-=d(e,--r);return l(r,0,e.i-1)},p=(e,t,o,n)=>{const s=_(e,t,r(o,e.i-1));return[s,_(e,t+n,s)]},g=(e,t,o)=>{const n=t-e.i,s=n>0;let i;return s?(i=e.o*n,f(e.t,n,o),f(e.u,n)):(i=(o?e.t.splice(0,-n):e.t.splice(n)).reduce(((t,r)=>t+(r===u?e.o:r)),0),e.u.splice(n)),e.l=o?-1:r(t-1,e.l),e.i=t,[i,s]},m="undefined"!=typeof window,v=()=>document.documentElement,b=/*#__PURE__*/a((e=>{const t="scrollLeft",r=e[t];e[t]=1;const o=e[t]<1;return e[t]=r,o})),y=/*#__PURE__*/a((()=>{return!!m&&"rtl"===(e=v(),getComputedStyle(e)).direction;var e})),w=/*#__PURE__*/a((()=>/iP(hone|od|ad)/.test(navigator.userAgent))),S=/*#__PURE__*/a((()=>"scrollBehavior"in v().style)),z=(e,t,r)=>t.reduce(((t,[o,n])=>{const s=n-d(e,o);return(!r||s>0)&&(t+=s),t}),0),x=/*#__PURE__*/t.defineComponent({props:{h:{type:Object,required:!0},_:{type:Object,required:!0},p:{type:Number,required:!0},m:{type:Number,required:!0},v:{type:Boolean},S:{type:Boolean},k:{type:String,required:!0}},setup(r){const o=t.ref();return t.watch((()=>o.value&&r.p),((e,t,n)=>{n(r._(o.value,r.p))}),{flush:"post"}),()=>{const{h:t,m:n,v:s,k:i,S:l}=r,c={margin:0,padding:0,position:"absolute",[l?"height":"width"]:"100%",[l?"top":"left"]:"0px",[l?y()?"right":"left":"top"]:n+"px",visibility:s?"hidden":"visible"};return l&&(c.display="flex"),e.jsx(i,{ref:o,style:c,children:t})}}}),k={data:{type:Array,required:!0},overscan:{type:Number,default:4},itemSize:Number,shift:Boolean,horizontal:Boolean},I=/*#__PURE__*/t.defineComponent({props:k,emits:["scroll","scrollEnd","rangeChange"],setup(_,{emit:m,expose:v,slots:k}){var I;const O=_.horizontal,q=t.ref(),T=((e,t=40,s=0,i=((e,t)=>({o:t,i:e,l:-1,t:f([],e),u:f([],e)}))(e,t),c,a=0,_=0)=>{let m=!!s,v=[],b=0,y=0,S=0,x=0,k=0,I=0,O=0,q=0,T=m?[0,o(s-1,0)]:null,B=[0,0];const N=new Set,C=()=>(e=>e.i?h(e,e.i-1)+d(e,e.i-1):0)(i),J=()=>C()+a+_,M=()=>o(0,J()-b),R=e=>{w()&&0!==O?k+=e:(x+=e,S++)};return{I:()=>v,O:()=>JSON.parse(JSON.stringify(i)),q:()=>T?[r(B[0],T[0]),o(B[1],T[1])]:I?B:B=p(i,y-a+k+x,B[0],b),T:e=>i.t[e]===u,B:()=>!!T&&i.t.slice(o(0,T[0]-1),r(i.i-1,T[1]+1)+1).includes(u),N:e=>h(i,e)-k,C:e=>d(i,e),J:()=>i.i,M:()=>y,R:M,H:()=>O,j:()=>b,A:()=>a,L:()=>_,D:C,P:()=>S,U:()=>b>J()?x=0:(I=x,x=0,I),V(e,t){const r=[e,t];return N.add(r),()=>{N.delete(r)}},W(e,t){let o,s,a=0;switch(e){case 1:{const e=t.filter((([e,t])=>i.t[e]!==t));if(!e.length)break;let o=0;if(0===y);else if(y>M()-1.5)o=z(i,e,!0);else if(2===q)o=z(i,e);else{const[t]=B;o=z(i,e.filter((([e])=>e<t)))}o&&R(o);let n=!1;e.forEach((([e,t])=>{((e,t,o)=>{const n=e.t[t]===u;return e.t[t]=o,e.l=r(t,e.l),n})(i,e,t)&&(n=!0)})),c&&n&&!y&&(e=>{const t=e.t.filter((e=>e!==u)),r=t[0];e.o=t.every((e=>e===r))?r:(e=>{const t=[...e].sort(((e,t)=>e-t)),r=e.length/2|0;return t.length%2==0?(t[r-1]+t[r])/2:t[r]})(t)})(i),a=2,s=!0;break}case 2:b!==t&&(b=t,a=2);break;case 3:if(t[1]){const e=M()-y,[o,n]=g(i,t[0],!0);R(n?o:-r(o,e)),n&&(q=2),a=1}else g(i,t[0]);break;case 4:{const e=l(t,0,M()),r=I;if(I=0,e===y)break;const o=e-y,i=n(o);r&&i<n(r)+1||0!==q||(O=o<0?2:1),m&&(T=null,m=!1),s=i>b,y=e,a=5;break}case 5:a=8,0!==O&&(o=!0,a+=1),O=0,q=0,T=null;break;case 6:q=1;break;case 7:T=p(i,t,B[0],b),a=1}a&&(v=[],o&&k&&(x+=k,k=0,S++),N.forEach((([e,t])=>{a&e&&t(s)})))}}})(_.data.length,null!==(I=_.itemSize)&&void 0!==I?I:40,void 0,void 0,!_.itemSize),B=((e,t)=>{let r;const o=t?"width":"height",n=new WeakMap,s=a((()=>new ResizeObserver((t=>{const s=[];for(const{target:i,contentRect:l}of t)if(i.offsetParent)if(i===r)e.W(2,l[o]);else{const e=n.get(i);c(e)&&s.push([e,l[o]])}s.length&&e.W(1,s)}))));return{X(e){s().observe(r=e)},Y:(e,t)=>{const r=s();return n.set(e,t),r.observe(e),()=>{n.delete(e),r.unobserve(e)}},F(){s().disconnect()}}})(T,O),N=((e,t)=>{let r,o,n,a=!1;const u=t?"scrollLeft":"scrollTop",f=t?"overflowX":"overflowY",d=(o,n)=>t&&y()?((e,t,r,o)=>b(e)||o?-r:t.R()-r)(r,e,o,n):o,h=async(o,s)=>{if(!r)return;n&&n();const c=()=>l(o(),0,e.R()),a=()=>{let t;return[new Promise(((e,r)=>{t=e,i(n=r,150)})),e.V(2,(()=>{t&&t()}))]};if(s&&S()){for(;e.W(7,c()),e.B();){const[e,t]=a();try{await e}catch(e){return}finally{t()}}r.scrollTo({[t?"left":"top"]:d(c()),behavior:"smooth"})}else for(;;){const[t,o]=a();try{r[u]=d(c()),e.W(6),await t}catch(e){return}finally{o()}}};return{G(n){r=n;let l=!1,f=!1;const h=(()=>{let t;const r=()=>{c(t)&&clearTimeout(t)},o=()=>{r(),t=i((()=>{t=null,l?h():(f=!1,e.W(5))}),150)};return o.K=r,o})(),_=()=>{f&&(a=!0),e.W(4,d(n[u])),h()},p=((e,t,r)=>(()=>{let o=s()-50;return(...n)=>{const i=s();o+50<i&&(o=i,(o=>{if(0!==e.H()&&!o.ctrlKey&&(t?o.deltaX:o.deltaY)){const t=e.M();t>0&&t<e.R()&&r()}})(...n))}})())(e,t,h),g=()=>{l=!0,f=a=!1},m=()=>{l=!1,w()&&(f=!0)};n.addEventListener("scroll",_),n.addEventListener("wheel",p,{passive:!0}),n.addEventListener("touchstart",g,{passive:!0}),n.addEventListener("touchend",m,{passive:!0}),o=()=>{n.removeEventListener("scroll",_),n.removeEventListener("wheel",p),n.removeEventListener("touchstart",g),n.removeEventListener("touchend",m),h.K()}},F(){o&&o()},Z(e){h((()=>e))},$(t){t+=e.M(),h((()=>t))},ee(t,{align:r,smooth:o}={}){if(t=l(t,0,e.J()-1),"nearest"===r){const o=e.N(t),n=e.M();if(o<n)r="start";else{if(!(o+e.C(t)>n+e.j()))return;r="end"}}h((()=>e.A()+("end"===r?e.N(t)+e.C(t)-e.j():"center"===r?e.N(t)+(e.C(t)-e.j())/2:e.N(t))),o)},te:e=>{if(r){if(a){a=!1;const e=r.style,t=e[f];e[f]="hidden",i((()=>{e[f]=t}))}r[u]+=d(e,!0)}}}})(T,O),C=t.ref(T.I()),J=T.V(3,(()=>{C.value=T.I()})),M=T.V(4,(()=>{m("scroll",T.M())})),R=T.V(8,(()=>{m("scrollEnd")}));return t.onMounted((()=>{const e=q.value;e&&(B.X(e),N.G(e))})),t.onUnmounted((()=>{J(),M(),R(),B.F(),N.F()})),t.watch((()=>_.data.length),(e=>{T.W(3,[e,_.shift])})),t.watch([C,T.P],(([,e],[,t])=>{if(e===t)return;const r=T.U();r&&N.te(r)}),{flush:"post"}),t.watch([C,T.q],(([,[e,t]],[,[r,o]])=>{r===e&&o===t||m("rangeChange",e,t)}),{flush:"post"}),v({get scrollOffset(){return T.M()},get scrollSize(){return(e=>o(e.D(),e.j()))(T)},get viewportSize(){return T.j()},scrollToIndex:N.ee,scrollTo:N.Z,scrollBy:N.$}),()=>{C.value;const t=_.data.length,[n,s]=T.q(),i=T.H(),l=T.D(),a=(e=>o(e.D(),e.j()-e.A()-e.L()))(T),u=[];for(let l=((e,t,r)=>o(e-(1===r?1:o(1,t)),0))(n,_.overscan,i),a=((e,t,n,s)=>r(e+(2===n?1:o(1,t)),s-1))(s,_.overscan,i,t);l<=a;l++){const t=k.default(_.data[l])[0],r=t.key;u.push(e.jsx(x,{_:B.Y,p:l,m:T.N(l),v:T.T(l),k:"div",h:t,S:O},c(r)?r:"_"+l))}return e.jsx("div",{ref:q,style:{display:O?"inline-block":"block",[O?"overflowX":"overflowY"]:"auto",overflowAnchor:"none",contain:"strict",width:"100%",height:"100%"},children:e.jsx("div",{style:{contain:"content",overflowAnchor:"none",flex:"none",position:"relative",visibility:"hidden",width:O?l+"px":"100%",height:O?"100%":l+"px",[O?"minWidth":"minHeight"]:a,pointerEvents:0!==i?"none":"auto"},children:u})})}}});exports.VList=I;
2
2
  //# sourceMappingURL=index.js.map