@legendapp/list 3.0.0-beta.53 → 3.0.0-beta.54
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/animated.d.ts +12 -9
- package/index.d.ts +15 -12
- package/index.js +391 -219
- package/index.mjs +391 -219
- package/index.native.js +332 -211
- package/index.native.mjs +332 -211
- package/keyboard-chat.d.ts +17 -2
- package/keyboard-chat.js +29 -0
- package/keyboard-chat.mjs +30 -2
- package/keyboard-test.d.ts +5 -0
- package/keyboard.d.ts +5 -0
- package/package.json +1 -1
- package/react-native.d.ts +13 -10
- package/react-native.js +332 -211
- package/react-native.mjs +332 -211
- package/react-native.web.d.ts +13 -10
- package/react-native.web.js +391 -219
- package/react-native.web.mjs +391 -219
- package/react.d.ts +13 -10
- package/react.js +391 -219
- package/react.mjs +391 -219
- package/reanimated.d.ts +12 -9
- package/reanimated.js +1 -1
- package/reanimated.mjs +1 -1
- package/section-list.d.ts +12 -9
package/keyboard-chat.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { ScrollViewComponent, ScrollResponderMixin, Insets as Insets$1, ScrollViewProps } from 'react-native';
|
|
2
|
+
import { ScrollViewComponent, ScrollResponderMixin, Insets as Insets$1, ScrollViewProps, View, LayoutChangeEvent } from 'react-native';
|
|
3
3
|
import { KeyboardChatScrollViewProps } from 'react-native-keyboard-controller';
|
|
4
4
|
import { SharedValue } from 'react-native-reanimated';
|
|
5
5
|
import { AnimatedLegendListProps } from '@legendapp/list/reanimated';
|
|
@@ -71,6 +71,10 @@ interface AnchoredEndSpaceConfig$1 {
|
|
|
71
71
|
includeInEndInset?: boolean;
|
|
72
72
|
onSizeChanged?: (size: number) => void;
|
|
73
73
|
}
|
|
74
|
+
interface LegendListAverageItemSize {
|
|
75
|
+
average: number;
|
|
76
|
+
count: number;
|
|
77
|
+
}
|
|
74
78
|
type LegendListState = {
|
|
75
79
|
activeStickyIndex: number;
|
|
76
80
|
contentLength: number;
|
|
@@ -85,6 +89,7 @@ type LegendListState = {
|
|
|
85
89
|
isEndReached: boolean;
|
|
86
90
|
isStartReached: boolean;
|
|
87
91
|
isWithinMaintainScrollAtEndThreshold: boolean;
|
|
92
|
+
getAverageItemSizes: () => Record<string, LegendListAverageItemSize>;
|
|
88
93
|
listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
|
|
89
94
|
listenToPosition: (key: string, callback: (value: number) => void) => () => void;
|
|
90
95
|
positionAtIndex: (index: number) => number;
|
|
@@ -237,6 +242,16 @@ type UseKeyboardScrollToEndOptions = {
|
|
|
237
242
|
freeze?: SharedValue<boolean>;
|
|
238
243
|
listRef: KeyboardScrollToEndListRef;
|
|
239
244
|
};
|
|
245
|
+
type KeyboardChatComposerInsetListRef = {
|
|
246
|
+
current: Pick<LegendListRef, "reportContentInset"> | null;
|
|
247
|
+
};
|
|
248
|
+
type KeyboardChatComposerRef = {
|
|
249
|
+
current: Pick<View, "measure"> | null;
|
|
250
|
+
};
|
|
251
|
+
declare function useKeyboardChatComposerInset(listRef: KeyboardChatComposerInsetListRef, composerRef: KeyboardChatComposerRef, initialHeight?: number): {
|
|
252
|
+
contentInsetEndAdjustment: SharedValue<number>;
|
|
253
|
+
onComposerLayout: (event: LayoutChangeEvent) => void;
|
|
254
|
+
};
|
|
240
255
|
declare function useKeyboardScrollToEnd({ freeze: freezeProp, listRef }: UseKeyboardScrollToEndOptions): {
|
|
241
256
|
freeze: SharedValue<boolean>;
|
|
242
257
|
scrollMessageToEnd: ({ animated, closeKeyboard }: ScrollMessageToEndOptions) => Promise<void>;
|
|
@@ -246,4 +261,4 @@ declare const KeyboardChatLegendList: <ItemT>(props: Omit<AnimatedLegendListProp
|
|
|
246
261
|
contentInsetEndAdjustment?: SharedValue<number>;
|
|
247
262
|
} & React.RefAttributes<LegendListRef>) => React.ReactElement | null;
|
|
248
263
|
|
|
249
|
-
export { KeyboardChatLegendList, useKeyboardScrollToEnd };
|
|
264
|
+
export { KeyboardChatLegendList, useKeyboardChatComposerInset, useKeyboardScrollToEnd };
|
package/keyboard-chat.js
CHANGED
|
@@ -28,6 +28,34 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
28
28
|
|
|
29
29
|
// src/integrations/keyboard-chat.tsx
|
|
30
30
|
var { typedForwardRef, useCombinedRef } = reactNative.internal;
|
|
31
|
+
function useKeyboardChatComposerInset(listRef, composerRef, initialHeight = 0) {
|
|
32
|
+
const contentInsetEndAdjustment = reactNativeReanimated.useSharedValue(initialHeight);
|
|
33
|
+
const lastHeightRef = React.useRef(void 0);
|
|
34
|
+
const reportHeight = React.useCallback(
|
|
35
|
+
(height) => {
|
|
36
|
+
var _a;
|
|
37
|
+
if (Number.isFinite(height) && height !== lastHeightRef.current) {
|
|
38
|
+
lastHeightRef.current = height;
|
|
39
|
+
contentInsetEndAdjustment.value = height;
|
|
40
|
+
(_a = listRef.current) == null ? void 0 : _a.reportContentInset({ bottom: height });
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
[contentInsetEndAdjustment, listRef]
|
|
44
|
+
);
|
|
45
|
+
React.useLayoutEffect(() => {
|
|
46
|
+
var _a;
|
|
47
|
+
(_a = composerRef.current) == null ? void 0 : _a.measure((_x, _y, _width, height) => {
|
|
48
|
+
reportHeight(height);
|
|
49
|
+
});
|
|
50
|
+
}, [composerRef, reportHeight]);
|
|
51
|
+
const onComposerLayout = React.useCallback(
|
|
52
|
+
(event) => {
|
|
53
|
+
reportHeight(event.nativeEvent.layout.height);
|
|
54
|
+
},
|
|
55
|
+
[reportHeight]
|
|
56
|
+
);
|
|
57
|
+
return { contentInsetEndAdjustment, onComposerLayout };
|
|
58
|
+
}
|
|
31
59
|
function useKeyboardScrollToEnd({ freeze: freezeProp, listRef }) {
|
|
32
60
|
const internalFreeze = reactNativeReanimated.useSharedValue(false);
|
|
33
61
|
const freeze = freezeProp != null ? freezeProp : internalFreeze;
|
|
@@ -123,4 +151,5 @@ var KeyboardChatLegendList = typedForwardRef(function KeyboardChatLegendList2(pr
|
|
|
123
151
|
});
|
|
124
152
|
|
|
125
153
|
exports.KeyboardChatLegendList = KeyboardChatLegendList;
|
|
154
|
+
exports.useKeyboardChatComposerInset = useKeyboardChatComposerInset;
|
|
126
155
|
exports.useKeyboardScrollToEnd = useKeyboardScrollToEnd;
|
package/keyboard-chat.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useRef, useEffect, useMemo, useCallback } from 'react';
|
|
2
|
+
import { useRef, useEffect, useMemo, useCallback, useLayoutEffect } from 'react';
|
|
3
3
|
import { KeyboardChatScrollView, KeyboardController } from 'react-native-keyboard-controller';
|
|
4
4
|
import { useSharedValue } from 'react-native-reanimated';
|
|
5
5
|
import { internal } from '@legendapp/list/react-native';
|
|
@@ -7,6 +7,34 @@ import { AnimatedLegendList } from '@legendapp/list/reanimated';
|
|
|
7
7
|
|
|
8
8
|
// src/integrations/keyboard-chat.tsx
|
|
9
9
|
var { typedForwardRef, useCombinedRef } = internal;
|
|
10
|
+
function useKeyboardChatComposerInset(listRef, composerRef, initialHeight = 0) {
|
|
11
|
+
const contentInsetEndAdjustment = useSharedValue(initialHeight);
|
|
12
|
+
const lastHeightRef = useRef(void 0);
|
|
13
|
+
const reportHeight = useCallback(
|
|
14
|
+
(height) => {
|
|
15
|
+
var _a;
|
|
16
|
+
if (Number.isFinite(height) && height !== lastHeightRef.current) {
|
|
17
|
+
lastHeightRef.current = height;
|
|
18
|
+
contentInsetEndAdjustment.value = height;
|
|
19
|
+
(_a = listRef.current) == null ? void 0 : _a.reportContentInset({ bottom: height });
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
[contentInsetEndAdjustment, listRef]
|
|
23
|
+
);
|
|
24
|
+
useLayoutEffect(() => {
|
|
25
|
+
var _a;
|
|
26
|
+
(_a = composerRef.current) == null ? void 0 : _a.measure((_x, _y, _width, height) => {
|
|
27
|
+
reportHeight(height);
|
|
28
|
+
});
|
|
29
|
+
}, [composerRef, reportHeight]);
|
|
30
|
+
const onComposerLayout = useCallback(
|
|
31
|
+
(event) => {
|
|
32
|
+
reportHeight(event.nativeEvent.layout.height);
|
|
33
|
+
},
|
|
34
|
+
[reportHeight]
|
|
35
|
+
);
|
|
36
|
+
return { contentInsetEndAdjustment, onComposerLayout };
|
|
37
|
+
}
|
|
10
38
|
function useKeyboardScrollToEnd({ freeze: freezeProp, listRef }) {
|
|
11
39
|
const internalFreeze = useSharedValue(false);
|
|
12
40
|
const freeze = freezeProp != null ? freezeProp : internalFreeze;
|
|
@@ -101,4 +129,4 @@ var KeyboardChatLegendList = typedForwardRef(function KeyboardChatLegendList2(pr
|
|
|
101
129
|
);
|
|
102
130
|
});
|
|
103
131
|
|
|
104
|
-
export { KeyboardChatLegendList, useKeyboardScrollToEnd };
|
|
132
|
+
export { KeyboardChatLegendList, useKeyboardChatComposerInset, useKeyboardScrollToEnd };
|
package/keyboard-test.d.ts
CHANGED
|
@@ -65,6 +65,10 @@ interface Insets {
|
|
|
65
65
|
bottom: number;
|
|
66
66
|
right: number;
|
|
67
67
|
}
|
|
68
|
+
interface LegendListAverageItemSize {
|
|
69
|
+
average: number;
|
|
70
|
+
count: number;
|
|
71
|
+
}
|
|
68
72
|
type LegendListState = {
|
|
69
73
|
activeStickyIndex: number;
|
|
70
74
|
contentLength: number;
|
|
@@ -79,6 +83,7 @@ type LegendListState = {
|
|
|
79
83
|
isEndReached: boolean;
|
|
80
84
|
isStartReached: boolean;
|
|
81
85
|
isWithinMaintainScrollAtEndThreshold: boolean;
|
|
86
|
+
getAverageItemSizes: () => Record<string, LegendListAverageItemSize>;
|
|
82
87
|
listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
|
|
83
88
|
listenToPosition: (key: string, callback: (value: number) => void) => () => void;
|
|
84
89
|
positionAtIndex: (index: number) => number;
|
package/keyboard.d.ts
CHANGED
|
@@ -63,6 +63,10 @@ interface Insets {
|
|
|
63
63
|
bottom: number;
|
|
64
64
|
right: number;
|
|
65
65
|
}
|
|
66
|
+
interface LegendListAverageItemSize {
|
|
67
|
+
average: number;
|
|
68
|
+
count: number;
|
|
69
|
+
}
|
|
66
70
|
type LegendListState = {
|
|
67
71
|
activeStickyIndex: number;
|
|
68
72
|
contentLength: number;
|
|
@@ -77,6 +81,7 @@ type LegendListState = {
|
|
|
77
81
|
isEndReached: boolean;
|
|
78
82
|
isStartReached: boolean;
|
|
79
83
|
isWithinMaintainScrollAtEndThreshold: boolean;
|
|
84
|
+
getAverageItemSizes: () => Record<string, LegendListAverageItemSize>;
|
|
80
85
|
listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
|
|
81
86
|
listenToPosition: (key: string, callback: (value: number) => void) => () => void;
|
|
82
87
|
positionAtIndex: (index: number) => number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/list",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.54",
|
|
4
4
|
"description": "Legend List is a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"private": false,
|
package/react-native.d.ts
CHANGED
|
@@ -160,7 +160,10 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
|
|
|
160
160
|
*/
|
|
161
161
|
extraData?: any;
|
|
162
162
|
/**
|
|
163
|
-
*
|
|
163
|
+
* Optional per-item size estimate used before a row is measured.
|
|
164
|
+
*
|
|
165
|
+
* @deprecated Prefer a single `estimatedItemSize` for initial size hints, or `getFixedItemSize`
|
|
166
|
+
* when item sizes are known exactly.
|
|
164
167
|
*/
|
|
165
168
|
getEstimatedItemSize?: (item: ItemT, index: number, type: TItemType) => number;
|
|
166
169
|
/**
|
|
@@ -178,8 +181,9 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
|
|
|
178
181
|
leadingItem: ItemT;
|
|
179
182
|
}>;
|
|
180
183
|
/**
|
|
181
|
-
* Ratio
|
|
182
|
-
* @
|
|
184
|
+
* Ratio used to size the initial recycled container pool.
|
|
185
|
+
* @deprecated The list now manages spare container capacity automatically.
|
|
186
|
+
* @default 3
|
|
183
187
|
*/
|
|
184
188
|
initialContainerPoolRatio?: number | undefined;
|
|
185
189
|
/**
|
|
@@ -360,12 +364,6 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
|
|
|
360
364
|
* Array of item indices to use as snap points.
|
|
361
365
|
*/
|
|
362
366
|
snapToIndices?: number[];
|
|
363
|
-
/**
|
|
364
|
-
* This will log a suggested estimatedItemSize.
|
|
365
|
-
* @required
|
|
366
|
-
* @default false
|
|
367
|
-
*/
|
|
368
|
-
suggestEstimatedItemSize?: boolean;
|
|
369
367
|
/**
|
|
370
368
|
* Configuration for determining item viewability.
|
|
371
369
|
*/
|
|
@@ -454,6 +452,10 @@ interface LegendListMetrics {
|
|
|
454
452
|
headerSize: number;
|
|
455
453
|
footerSize: number;
|
|
456
454
|
}
|
|
455
|
+
interface LegendListAverageItemSize {
|
|
456
|
+
average: number;
|
|
457
|
+
count: number;
|
|
458
|
+
}
|
|
457
459
|
interface LegendListRenderItemProps<ItemT, TItemType extends string | number | undefined = string | number | undefined> {
|
|
458
460
|
data: readonly ItemT[];
|
|
459
461
|
extraData: any;
|
|
@@ -475,6 +477,7 @@ type LegendListState$1 = {
|
|
|
475
477
|
isEndReached: boolean;
|
|
476
478
|
isStartReached: boolean;
|
|
477
479
|
isWithinMaintainScrollAtEndThreshold: boolean;
|
|
480
|
+
getAverageItemSizes: () => Record<string, LegendListAverageItemSize>;
|
|
478
481
|
listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
|
|
479
482
|
listenToPosition: (key: string, callback: (value: number) => void) => () => void;
|
|
480
483
|
positionAtIndex: (index: number) => number;
|
|
@@ -715,4 +718,4 @@ declare function useSyncLayout(): () => void;
|
|
|
715
718
|
|
|
716
719
|
declare const LegendList: LegendListComponent;
|
|
717
720
|
|
|
718
|
-
export { type AlwaysRenderConfig, type ColumnWrapperStyle, type InitialScrollAnchor, type Insets, type LayoutRectangle, LegendList, type LegendListComponent, type LegendListMetrics, type LegendListProps, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type LegendListState, type MaintainScrollAtEndOnOptions, type MaintainScrollAtEndOptions, type MaintainVisibleContentPositionConfig, type NativeScrollEvent, type NativeSyntheticEvent, type OnViewableItemsChanged, type OnViewableItemsChangedInfo, type ScrollIndexWithOffset, type ScrollIndexWithOffsetAndContentOffset, type ScrollIndexWithOffsetPosition, type StickyHeaderConfig, type StyleProp, type ViewAmountToken, type ViewStyle, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };
|
|
721
|
+
export { type AlwaysRenderConfig, type ColumnWrapperStyle, type InitialScrollAnchor, type Insets, type LayoutRectangle, LegendList, type LegendListAverageItemSize, type LegendListComponent, type LegendListMetrics, type LegendListProps, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type LegendListState, type MaintainScrollAtEndOnOptions, type MaintainScrollAtEndOptions, type MaintainVisibleContentPositionConfig, type NativeScrollEvent, type NativeSyntheticEvent, type OnViewableItemsChanged, type OnViewableItemsChangedInfo, type ScrollIndexWithOffset, type ScrollIndexWithOffsetAndContentOffset, type ScrollIndexWithOffsetPosition, type StickyHeaderConfig, type StyleProp, type ViewAmountToken, type ViewStyle, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };
|