rc-virtual-list
Advanced tools
Comparing version 0.0.0-alpha.25 to 0.0.0-alpha.26
import * as React from 'react'; | ||
import { Key } from './utils/itemUtil'; | ||
declare type ScrollAlign = 'top' | 'bottom' | 'auto'; | ||
declare type ScrollConfig = { | ||
index: number; | ||
align?: ScrollAlign; | ||
} | { | ||
key: Key; | ||
align?: ScrollAlign; | ||
}; | ||
export declare type RenderFunc<T> = (item: T, index: number, props: { | ||
@@ -22,3 +31,3 @@ style: React.CSSProperties; | ||
fullHeight?: boolean; | ||
itemKey: string | ((item: T) => string); | ||
itemKey: Key | ((item: T) => Key); | ||
component?: string | React.FC<any> | React.ComponentClass<any>; | ||
@@ -120,4 +129,4 @@ disabled?: boolean; | ||
triggerOnScroll: React.UIEventHandler<HTMLElement>; | ||
getIndexKey: (index: number, props?: Partial<ListProps<T>>) => string; | ||
getItemKey: (item: T, props?: Partial<ListProps<T>>) => string; | ||
getIndexKey: (index: number, props?: Partial<ListProps<T>>) => string | number; | ||
getItemKey: (item: T, props?: Partial<ListProps<T>>) => string | number; | ||
/** | ||
@@ -131,6 +140,3 @@ * Collect current rendered dom element item heights | ||
scrollTo(scrollTop: number): void; | ||
scrollTo(config: { | ||
index: number; | ||
align?: 'top' | 'bottom' | 'auto'; | ||
}): void; | ||
scrollTo(config: ScrollConfig): void; | ||
internalScrollTo(relativeScroll: RelativeScroll): void; | ||
@@ -137,0 +143,0 @@ /** |
@@ -443,5 +443,15 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
data = _this$props3.data; | ||
var index = arg0.index, | ||
_arg0$align = arg0.align, | ||
var _arg0$align = arg0.align, | ||
align = _arg0$align === void 0 ? 'auto' : _arg0$align; | ||
var index = 0; | ||
if ('index' in arg0) { | ||
index = arg0.index; | ||
} else if ('key' in arg0) { | ||
var key = arg0.key; | ||
index = data.findIndex(function (item) { | ||
return _this3.getItemKey(item) === key; | ||
}); | ||
} | ||
var visibleCount = Math.ceil(height / itemHeight); | ||
@@ -448,0 +458,0 @@ var item = data[index]; |
@@ -0,1 +1,2 @@ | ||
import { Key } from './itemUtil'; | ||
/** | ||
@@ -19,5 +20,5 @@ * Get index with specific start index one by one. e.g. | ||
*/ | ||
export declare function findListDiffIndex<T>(originList: T[], targetList: T[], getKey: (item: T) => string): { | ||
export declare function findListDiffIndex<T>(originList: T[], targetList: T[], getKey: (item: T) => Key): { | ||
index: number; | ||
multiple: boolean; | ||
} | null; |
@@ -6,2 +6,3 @@ /** | ||
export declare const GHOST_ITEM_KEY = "__rc_ghost_item__"; | ||
export declare type Key = string | number; | ||
/** | ||
@@ -41,3 +42,3 @@ * Safari has the elasticity effect which provides negative `scrollTop` value. | ||
clientHeight: number; | ||
getItemKey: (index: number) => string; | ||
getItemKey: (index: number) => Key; | ||
} | ||
@@ -56,3 +57,3 @@ /** | ||
compareItemIndex: number; | ||
getItemKey: (index: number) => string; | ||
getItemKey: (index: number) => Key; | ||
startIndex: number; | ||
@@ -59,0 +60,0 @@ endIndex: number; |
import * as React from 'react'; | ||
import { Key } from './utils/itemUtil'; | ||
declare type ScrollAlign = 'top' | 'bottom' | 'auto'; | ||
declare type ScrollConfig = { | ||
index: number; | ||
align?: ScrollAlign; | ||
} | { | ||
key: Key; | ||
align?: ScrollAlign; | ||
}; | ||
export declare type RenderFunc<T> = (item: T, index: number, props: { | ||
@@ -22,3 +31,3 @@ style: React.CSSProperties; | ||
fullHeight?: boolean; | ||
itemKey: string | ((item: T) => string); | ||
itemKey: Key | ((item: T) => Key); | ||
component?: string | React.FC<any> | React.ComponentClass<any>; | ||
@@ -120,4 +129,4 @@ disabled?: boolean; | ||
triggerOnScroll: React.UIEventHandler<HTMLElement>; | ||
getIndexKey: (index: number, props?: Partial<ListProps<T>>) => string; | ||
getItemKey: (item: T, props?: Partial<ListProps<T>>) => string; | ||
getIndexKey: (index: number, props?: Partial<ListProps<T>>) => string | number; | ||
getItemKey: (item: T, props?: Partial<ListProps<T>>) => string | number; | ||
/** | ||
@@ -131,6 +140,3 @@ * Collect current rendered dom element item heights | ||
scrollTo(scrollTop: number): void; | ||
scrollTo(config: { | ||
index: number; | ||
align?: 'top' | 'bottom' | 'auto'; | ||
}): void; | ||
scrollTo(config: ScrollConfig): void; | ||
internalScrollTo(relativeScroll: RelativeScroll): void; | ||
@@ -137,0 +143,0 @@ /** |
@@ -459,5 +459,15 @@ "use strict"; | ||
data = _this$props3.data; | ||
var index = arg0.index, | ||
_arg0$align = arg0.align, | ||
var _arg0$align = arg0.align, | ||
align = _arg0$align === void 0 ? 'auto' : _arg0$align; | ||
var index = 0; | ||
if ('index' in arg0) { | ||
index = arg0.index; | ||
} else if ('key' in arg0) { | ||
var key = arg0.key; | ||
index = data.findIndex(function (item) { | ||
return _this3.getItemKey(item) === key; | ||
}); | ||
} | ||
var visibleCount = Math.ceil(height / itemHeight); | ||
@@ -464,0 +474,0 @@ var item = data[index]; |
@@ -0,1 +1,2 @@ | ||
import { Key } from './itemUtil'; | ||
/** | ||
@@ -19,5 +20,5 @@ * Get index with specific start index one by one. e.g. | ||
*/ | ||
export declare function findListDiffIndex<T>(originList: T[], targetList: T[], getKey: (item: T) => string): { | ||
export declare function findListDiffIndex<T>(originList: T[], targetList: T[], getKey: (item: T) => Key): { | ||
index: number; | ||
multiple: boolean; | ||
} | null; |
@@ -6,2 +6,3 @@ /** | ||
export declare const GHOST_ITEM_KEY = "__rc_ghost_item__"; | ||
export declare type Key = string | number; | ||
/** | ||
@@ -41,3 +42,3 @@ * Safari has the elasticity effect which provides negative `scrollTop` value. | ||
clientHeight: number; | ||
getItemKey: (index: number) => string; | ||
getItemKey: (index: number) => Key; | ||
} | ||
@@ -56,3 +57,3 @@ /** | ||
compareItemIndex: number; | ||
getItemKey: (index: number) => string; | ||
getItemKey: (index: number) => Key; | ||
startIndex: number; | ||
@@ -59,0 +60,0 @@ endIndex: number; |
{ | ||
"name": "rc-virtual-list", | ||
"version": "0.0.0-alpha.25", | ||
"version": "0.0.0-alpha.26", | ||
"description": "React Virtual List Component", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
116387
2522