virtual-scroller 1.9.0 → 1.10.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.
- package/CHANGELOG.md +7 -0
- package/README.md +6 -4
- package/bundle/virtual-scroller-dom.js.map +1 -1
- package/bundle/virtual-scroller-react.js +1 -1
- package/bundle/virtual-scroller-react.js.map +1 -1
- package/bundle/virtual-scroller.js.map +1 -1
- package/commonjs/VirtualScroller.js +1 -1
- package/commonjs/VirtualScroller.js.map +1 -1
- package/commonjs/react/VirtualScroller.js +17 -4
- package/commonjs/react/VirtualScroller.js.map +1 -1
- package/commonjs/react/useHandleItemsChange.js.map +1 -1
- package/dom/index.d.ts +1 -1
- package/index.d.ts +3 -3
- package/modules/VirtualScroller.js +1 -1
- package/modules/VirtualScroller.js.map +1 -1
- package/modules/react/VirtualScroller.js +10 -3
- package/modules/react/VirtualScroller.js.map +1 -1
- package/modules/react/useHandleItemsChange.js +1 -1
- package/modules/react/useHandleItemsChange.js.map +1 -1
- package/package.json +1 -1
- package/react/index.d.ts +53 -15
- package/source/VirtualScroller.js +1 -1
- package/source/react/VirtualScroller.js +7 -1
- package/source/react/useHandleItemsChange.js +1 -1
- package/website/index-bypass.html +2 -2
- package/website/index-grid.html +2 -2
- package/website/index-scrollableContainer.html +2 -2
- package/website/index.html +2 -2
package/react/index.d.ts
CHANGED
|
@@ -4,25 +4,63 @@ export { State, ItemState } from '../index.d.ts';
|
|
|
4
4
|
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
// Taken from https://www.benmvp.com/blog/polymorphic-react-components-typescript/
|
|
8
|
+
|
|
9
|
+
// A more precise version of just React.ComponentPropsWithoutRef on its own
|
|
10
|
+
export type PropsOf<
|
|
11
|
+
C extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>
|
|
12
|
+
> = JSX.LibraryManagedAttributes<C, React.ComponentPropsWithoutRef<C>>
|
|
13
|
+
|
|
14
|
+
type AsProp<C extends React.ElementType> = {
|
|
15
|
+
/**
|
|
16
|
+
* An override of the default HTML tag.
|
|
17
|
+
* Can also be another React component.
|
|
18
|
+
*/
|
|
19
|
+
as?: C
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Allows for extending a set of props (`ExtendedProps`) by an overriding set of props
|
|
24
|
+
* (`OverrideProps`), ensuring that any duplicates are overridden by the overriding
|
|
25
|
+
* set of props.
|
|
26
|
+
*/
|
|
27
|
+
export type ExtendableProps<
|
|
28
|
+
ExtendedProps = {},
|
|
29
|
+
OverrideProps = {}
|
|
30
|
+
> = OverrideProps & Omit<ExtendedProps, keyof OverrideProps>
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Allows for inheriting the props from the specified element type so that
|
|
34
|
+
* props like children, className & style work, as well as element-specific
|
|
35
|
+
* attributes like aria roles. The component (`C`) must be passed in.
|
|
36
|
+
*/
|
|
37
|
+
export type InheritableElementProps<
|
|
38
|
+
C extends React.ElementType,
|
|
39
|
+
Props = {}
|
|
40
|
+
> = ExtendableProps<PropsOf<C>, Props>
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A more sophisticated version of `InheritableElementProps` where
|
|
44
|
+
* the passed in `as` prop will determine which props can be included
|
|
45
|
+
*/
|
|
46
|
+
export type PolymorphicComponentProps<
|
|
47
|
+
C extends React.ElementType,
|
|
48
|
+
Props = {}
|
|
49
|
+
> = InheritableElementProps<C, Props & AsProp<C>>
|
|
50
|
+
|
|
51
|
+
interface Props<Item, ItemComponentProps extends object>
|
|
52
|
+
extends VirtualScrollerCommonOptions<Item>{
|
|
9
53
|
items: Item[];
|
|
10
|
-
itemComponent: React.ElementType
|
|
11
|
-
itemComponentProps?:
|
|
54
|
+
itemComponent: React.ElementType<ItemComponentProps & { item: Item, itemIndex: number }>;
|
|
55
|
+
itemComponentProps?: ItemComponentProps;
|
|
12
56
|
initialState?: State<Item>;
|
|
13
57
|
preserveScrollPositionOnPrependItems?: boolean;
|
|
58
|
+
|
|
14
59
|
getScrollableContainer?(): HTMLElement;
|
|
15
60
|
}
|
|
16
61
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// declare const VirtualScroller<Item>: ReactVirtualScroller<Item>;
|
|
21
|
-
//
|
|
22
|
-
// Uses `<any>` instead.
|
|
23
|
-
//
|
|
24
|
-
// If someone finds a fix for this, create an issue.
|
|
25
|
-
//
|
|
26
|
-
declare const VirtualScroller: ReactVirtualScroller<any>;
|
|
62
|
+
declare function VirtualScroller<Item = any, ItemComponentProps extends object={}, AsElement extends React.ElementType = 'div'>(
|
|
63
|
+
props: PolymorphicComponentProps<AsElement, Props<Item, ItemComponentProps>>
|
|
64
|
+
): JSX.Element;
|
|
27
65
|
|
|
28
|
-
export default VirtualScroller;
|
|
66
|
+
export default VirtualScroller;
|
|
@@ -35,7 +35,7 @@ export default class VirtualScroller {
|
|
|
35
35
|
const isRestart = this._isActive === false
|
|
36
36
|
|
|
37
37
|
if (!isRestart) {
|
|
38
|
-
// If no custom
|
|
38
|
+
// If no custom state storage has been configured, use the default one.
|
|
39
39
|
// Also sets the initial state.
|
|
40
40
|
if (!this._usesCustomStateStorage) {
|
|
41
41
|
this.useDefaultStateStorage()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useRef, useMemo, useLayoutEffect } from 'react'
|
|
1
|
+
import React, { useRef, useMemo, useLayoutEffect } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
4
|
import useState from './useState.js'
|
|
@@ -184,8 +184,14 @@ function VirtualScroller({
|
|
|
184
184
|
style={style}>
|
|
185
185
|
{renderedItems.map((item, i) => {
|
|
186
186
|
if (i >= firstShownItemIndex && i <= lastShownItemIndex) {
|
|
187
|
+
// Passing `item` as `children` property is legacy and is deprecated.
|
|
188
|
+
// If version `2.x` is published in some hypothetical future,
|
|
189
|
+
// the `item` and `itemIndex` properties should be moved below
|
|
190
|
+
// `{...itemComponentProps}`.
|
|
187
191
|
return (
|
|
188
192
|
<Component
|
|
193
|
+
item={item}
|
|
194
|
+
itemIndex={i}
|
|
189
195
|
{...itemComponentProps}
|
|
190
196
|
key={getItemKey(item, i)}
|
|
191
197
|
state={itemStates && itemStates[i]}
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
function Message(props) {
|
|
138
|
-
const {
|
|
138
|
+
const { item: message } = props
|
|
139
139
|
const {
|
|
140
140
|
username,
|
|
141
141
|
date,
|
|
@@ -157,7 +157,7 @@
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
Message.propTypes = {
|
|
160
|
-
|
|
160
|
+
item: message.isRequired
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
class Feed extends React.Component {
|
package/website/index-grid.html
CHANGED
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
function Message(props) {
|
|
159
|
-
const {
|
|
159
|
+
const { item: message } = props
|
|
160
160
|
const {
|
|
161
161
|
username,
|
|
162
162
|
date,
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
Message.propTypes = {
|
|
181
|
-
|
|
181
|
+
item: message.isRequired
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
class Feed extends React.Component {
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
function Message(props) {
|
|
151
|
-
const {
|
|
151
|
+
const { item: message } = props
|
|
152
152
|
const {
|
|
153
153
|
username,
|
|
154
154
|
date,
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
Message.propTypes = {
|
|
173
|
-
|
|
173
|
+
item: message.isRequired
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
class Feed extends React.Component {
|
package/website/index.html
CHANGED
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
function Message(props) {
|
|
127
|
-
const {
|
|
127
|
+
const { item: message } = props
|
|
128
128
|
const {
|
|
129
129
|
username,
|
|
130
130
|
date,
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
Message.propTypes = {
|
|
149
|
-
|
|
149
|
+
item: message.isRequired
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
class Feed extends React.Component {
|