@legendapp/list 3.0.0-beta.43 → 3.0.0-beta.45
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 +84 -47
- package/index.d.ts +383 -294
- package/index.js +2262 -1186
- package/index.mjs +2262 -1186
- package/index.native.js +2348 -1362
- package/index.native.mjs +2348 -1362
- package/keyboard-chat.d.ts +228 -0
- package/keyboard-chat.js +97 -0
- package/keyboard-chat.mjs +76 -0
- package/keyboard-test.d.ts +18 -8
- package/keyboard-test.js +8 -3
- package/keyboard-test.mjs +9 -4
- package/keyboard.d.ts +17 -7
- package/keyboard.js +5 -4
- package/keyboard.mjs +5 -4
- package/package.json +7 -1
- package/react-native.d.ts +84 -318
- package/react-native.js +2350 -1363
- package/react-native.mjs +2351 -1362
- package/react-native.web.d.ts +91 -319
- package/react-native.web.js +2274 -1173
- package/react-native.web.mjs +2275 -1172
- package/react.d.ts +91 -319
- package/react.js +2274 -1173
- package/react.mjs +2275 -1172
- package/reanimated.d.ts +96 -49
- package/reanimated.js +94 -19
- package/reanimated.mjs +95 -20
- package/section-list.d.ts +88 -47
- package/section-list.js +16 -4
- package/section-list.mjs +15 -3
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ScrollViewComponent, ScrollResponderMixin, Insets as Insets$1, ScrollViewProps } from 'react-native';
|
|
3
|
+
import { KeyboardChatScrollViewProps } from 'react-native-keyboard-controller';
|
|
4
|
+
import { AnimatedLegendListProps } from '@legendapp/list/reanimated';
|
|
5
|
+
|
|
6
|
+
interface MaintainVisibleContentPositionNormalized<ItemT = any> {
|
|
7
|
+
data: boolean;
|
|
8
|
+
size: boolean;
|
|
9
|
+
shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type ListenerType = "activeStickyIndex" | "anchoredEndSpaceSize" | "debugComputedScroll" | "debugRawScroll" | "extraData" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "maintainVisibleContentPosition" | "numColumns" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "scrollAdjust" | "scrollAdjustPending" | "scrollAdjustUserOffset" | "scrollSize" | "snapToOffsets" | "stylePaddingTop" | "totalSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
|
|
13
|
+
type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
|
|
14
|
+
type ListenerTypeValueMap = {
|
|
15
|
+
activeStickyIndex: number;
|
|
16
|
+
anchoredEndSpaceSize: number;
|
|
17
|
+
animatedScrollY: any;
|
|
18
|
+
debugComputedScroll: number;
|
|
19
|
+
debugRawScroll: number;
|
|
20
|
+
extraData: any;
|
|
21
|
+
footerSize: number;
|
|
22
|
+
headerSize: number;
|
|
23
|
+
isAtEnd: boolean;
|
|
24
|
+
isAtStart: boolean;
|
|
25
|
+
isNearEnd: boolean;
|
|
26
|
+
isNearStart: boolean;
|
|
27
|
+
isWithinMaintainScrollAtEndThreshold: boolean;
|
|
28
|
+
lastItemKeys: string[];
|
|
29
|
+
lastPositionUpdate: number;
|
|
30
|
+
maintainVisibleContentPosition: MaintainVisibleContentPositionNormalized;
|
|
31
|
+
numColumns: number;
|
|
32
|
+
numContainers: number;
|
|
33
|
+
numContainersPooled: number;
|
|
34
|
+
otherAxisSize: number;
|
|
35
|
+
readyToRender: boolean;
|
|
36
|
+
scrollAdjust: number;
|
|
37
|
+
scrollAdjustPending: number;
|
|
38
|
+
scrollAdjustUserOffset: number;
|
|
39
|
+
scrollSize: {
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
};
|
|
43
|
+
snapToOffsets: number[];
|
|
44
|
+
stylePaddingTop: number;
|
|
45
|
+
totalSize: number;
|
|
46
|
+
} & {
|
|
47
|
+
[K in ListenerType as K extends `containerItemKey${number}` ? K : never]: string;
|
|
48
|
+
} & {
|
|
49
|
+
[K in ListenerType as K extends `containerItemData${number}` ? K : never]: any;
|
|
50
|
+
} & {
|
|
51
|
+
[K in ListenerType as K extends `containerPosition${number}` ? K : never]: number;
|
|
52
|
+
} & {
|
|
53
|
+
[K in ListenerType as K extends `containerColumn${number}` ? K : never]: number;
|
|
54
|
+
} & {
|
|
55
|
+
[K in ListenerType as K extends `containerSpan${number}` ? K : never]: number;
|
|
56
|
+
} & {
|
|
57
|
+
[K in ListenerType as K extends `containerSticky${number}` ? K : never]: boolean;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
interface Insets {
|
|
61
|
+
top: number;
|
|
62
|
+
left: number;
|
|
63
|
+
bottom: number;
|
|
64
|
+
right: number;
|
|
65
|
+
}
|
|
66
|
+
interface AnchoredEndSpaceConfig$1 {
|
|
67
|
+
anchorIndex: number;
|
|
68
|
+
anchorOffset?: number;
|
|
69
|
+
anchorMaxSize?: number;
|
|
70
|
+
includeInEndInset?: boolean;
|
|
71
|
+
onSizeChanged?: (size: number) => void;
|
|
72
|
+
}
|
|
73
|
+
type LegendListState = {
|
|
74
|
+
activeStickyIndex: number;
|
|
75
|
+
contentLength: number;
|
|
76
|
+
data: readonly any[];
|
|
77
|
+
elementAtIndex: (index: number) => any;
|
|
78
|
+
end: number;
|
|
79
|
+
endBuffered: number;
|
|
80
|
+
isAtEnd: boolean;
|
|
81
|
+
isAtStart: boolean;
|
|
82
|
+
isNearEnd: boolean;
|
|
83
|
+
isNearStart: boolean;
|
|
84
|
+
isEndReached: boolean;
|
|
85
|
+
isStartReached: boolean;
|
|
86
|
+
isWithinMaintainScrollAtEndThreshold: boolean;
|
|
87
|
+
listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
|
|
88
|
+
listenToPosition: (key: string, callback: (value: number) => void) => () => void;
|
|
89
|
+
positionAtIndex: (index: number) => number;
|
|
90
|
+
positionByKey: (key: string) => number | undefined;
|
|
91
|
+
scroll: number;
|
|
92
|
+
scrollLength: number;
|
|
93
|
+
scrollVelocity: number;
|
|
94
|
+
sizeAtIndex: (index: number) => number;
|
|
95
|
+
sizes: Map<string, number>;
|
|
96
|
+
start: number;
|
|
97
|
+
startBuffered: number;
|
|
98
|
+
};
|
|
99
|
+
type LegendListRef$1 = {
|
|
100
|
+
/**
|
|
101
|
+
* Displays the scroll indicators momentarily.
|
|
102
|
+
*/
|
|
103
|
+
flashScrollIndicators(): void;
|
|
104
|
+
/**
|
|
105
|
+
* Returns the native ScrollView component reference.
|
|
106
|
+
*/
|
|
107
|
+
getNativeScrollRef(): any;
|
|
108
|
+
/**
|
|
109
|
+
* Returns the scroll responder instance for handling scroll events.
|
|
110
|
+
*/
|
|
111
|
+
getScrollableNode(): any;
|
|
112
|
+
/**
|
|
113
|
+
* Returns the ScrollResponderMixin for advanced scroll handling.
|
|
114
|
+
*/
|
|
115
|
+
getScrollResponder(): any;
|
|
116
|
+
/**
|
|
117
|
+
* Returns the internal state of the scroll virtualization.
|
|
118
|
+
*/
|
|
119
|
+
getState(): LegendListState;
|
|
120
|
+
/**
|
|
121
|
+
* Scrolls a specific index into view.
|
|
122
|
+
* @param params - Parameters for scrolling.
|
|
123
|
+
* @param params.animated - If true, animates the scroll. Default: true.
|
|
124
|
+
* @param params.index - The index to scroll to.
|
|
125
|
+
*/
|
|
126
|
+
scrollIndexIntoView(params: {
|
|
127
|
+
animated?: boolean | undefined;
|
|
128
|
+
index: number;
|
|
129
|
+
}): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Scrolls a specific index into view.
|
|
132
|
+
* @param params - Parameters for scrolling.
|
|
133
|
+
* @param params.animated - If true, animates the scroll. Default: true.
|
|
134
|
+
* @param params.item - The item to scroll to.
|
|
135
|
+
*/
|
|
136
|
+
scrollItemIntoView(params: {
|
|
137
|
+
animated?: boolean | undefined;
|
|
138
|
+
item: any;
|
|
139
|
+
}): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Scrolls to the end of the list.
|
|
142
|
+
* @param options - Options for scrolling.
|
|
143
|
+
* @param options.animated - If true, animates the scroll. Default: true.
|
|
144
|
+
* @param options.viewOffset - Offset from the target position.
|
|
145
|
+
*/
|
|
146
|
+
scrollToEnd(options?: {
|
|
147
|
+
animated?: boolean | undefined;
|
|
148
|
+
viewOffset?: number | undefined;
|
|
149
|
+
}): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Scrolls to a specific index in the list.
|
|
152
|
+
* @param params - Parameters for scrolling.
|
|
153
|
+
* @param params.animated - If true, animates the scroll. Default: true.
|
|
154
|
+
* @param params.index - The index to scroll to.
|
|
155
|
+
* @param params.viewOffset - Offset from the target position.
|
|
156
|
+
* @param params.viewPosition - Position of the item in the viewport (0 to 1).
|
|
157
|
+
*/
|
|
158
|
+
scrollToIndex(params: {
|
|
159
|
+
animated?: boolean | undefined;
|
|
160
|
+
index: number;
|
|
161
|
+
viewOffset?: number | undefined;
|
|
162
|
+
viewPosition?: number | undefined;
|
|
163
|
+
}): Promise<void>;
|
|
164
|
+
/**
|
|
165
|
+
* Scrolls to a specific item in the list.
|
|
166
|
+
* @param params - Parameters for scrolling.
|
|
167
|
+
* @param params.animated - If true, animates the scroll. Default: true.
|
|
168
|
+
* @param params.item - The item to scroll to.
|
|
169
|
+
* @param params.viewOffset - Offset from the target position.
|
|
170
|
+
* @param params.viewPosition - Position of the item in the viewport (0 to 1).
|
|
171
|
+
*/
|
|
172
|
+
scrollToItem(params: {
|
|
173
|
+
animated?: boolean | undefined;
|
|
174
|
+
item: any;
|
|
175
|
+
viewOffset?: number | undefined;
|
|
176
|
+
viewPosition?: number | undefined;
|
|
177
|
+
}): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* Scrolls to a specific offset in pixels.
|
|
180
|
+
* @param params - Parameters for scrolling.
|
|
181
|
+
* @param params.offset - The pixel offset to scroll to.
|
|
182
|
+
* @param params.animated - If true, animates the scroll. Default: true.
|
|
183
|
+
*/
|
|
184
|
+
scrollToOffset(params: {
|
|
185
|
+
offset: number;
|
|
186
|
+
animated?: boolean | undefined;
|
|
187
|
+
}): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Sets or adds to the offset of the visible content anchor.
|
|
190
|
+
* @param value - The offset to set or add.
|
|
191
|
+
* @param animated - If true, uses Animated to animate the change.
|
|
192
|
+
*/
|
|
193
|
+
setVisibleContentAnchorOffset(value: number | ((val: number) => number)): void;
|
|
194
|
+
/**
|
|
195
|
+
* Sets whether scroll processing is enabled.
|
|
196
|
+
* @param enabled - If true, scroll processing is enabled.
|
|
197
|
+
*/
|
|
198
|
+
setScrollProcessingEnabled(enabled: boolean): void;
|
|
199
|
+
/**
|
|
200
|
+
* Clears internal virtualization caches.
|
|
201
|
+
* @param options - Cache clearing options.
|
|
202
|
+
* @param options.mode - `sizes` clears measurement caches. `full` also clears key/position caches.
|
|
203
|
+
*/
|
|
204
|
+
clearCaches(options?: {
|
|
205
|
+
mode?: "sizes" | "full";
|
|
206
|
+
}): void;
|
|
207
|
+
/**
|
|
208
|
+
* Reports an externally measured content inset. Pass null/undefined to clear.
|
|
209
|
+
* Values are merged on top of props/animated/native insets.
|
|
210
|
+
*/
|
|
211
|
+
reportContentInset(inset?: Partial<Insets> | null): void;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
interface AnchoredEndSpaceConfig extends Omit<AnchoredEndSpaceConfig$1, "includeInEndInset"> {
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
type LegendListRef = Omit<LegendListRef$1, "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
|
|
218
|
+
getNativeScrollRef(): React.ElementRef<typeof ScrollViewComponent>;
|
|
219
|
+
getScrollResponder(): ScrollResponderMixin;
|
|
220
|
+
reportContentInset(inset?: Partial<Insets$1> | null): void;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
type KeyboardChatScrollViewPropsUnique = Omit<KeyboardChatScrollViewProps, keyof ScrollViewProps | "inverted" | "ScrollViewComponent" | "blankSpace">;
|
|
224
|
+
declare const KeyboardChatLegendList: <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "anchoredEndSpace" | "renderScrollComponent"> & KeyboardChatScrollViewPropsUnique & {
|
|
225
|
+
anchoredEndSpace?: AnchoredEndSpaceConfig;
|
|
226
|
+
} & React.RefAttributes<LegendListRef>) => React.ReactElement | null;
|
|
227
|
+
|
|
228
|
+
export { KeyboardChatLegendList };
|
package/keyboard-chat.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var reactNativeKeyboardController = require('react-native-keyboard-controller');
|
|
5
|
+
var reactNativeReanimated = require('react-native-reanimated');
|
|
6
|
+
var reactNative = require('@legendapp/list/react-native');
|
|
7
|
+
var reanimated = require('@legendapp/list/reanimated');
|
|
8
|
+
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
|
+
|
|
29
|
+
// src/integrations/keyboard-chat.tsx
|
|
30
|
+
var { typedForwardRef } = reactNative.internal;
|
|
31
|
+
var KeyboardChatLegendList = typedForwardRef(function KeyboardChatLegendList2(props, forwardedRef) {
|
|
32
|
+
const {
|
|
33
|
+
anchoredEndSpace,
|
|
34
|
+
applyWorkaroundForContentInsetHitTestBug,
|
|
35
|
+
extraContentPadding,
|
|
36
|
+
freeze,
|
|
37
|
+
keyboardLiftBehavior,
|
|
38
|
+
offset,
|
|
39
|
+
...rest
|
|
40
|
+
} = props;
|
|
41
|
+
const blankSpace = reactNativeReanimated.useSharedValue(0);
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
if (!anchoredEndSpace) {
|
|
44
|
+
blankSpace.value = 0;
|
|
45
|
+
}
|
|
46
|
+
}, [anchoredEndSpace, blankSpace]);
|
|
47
|
+
const anchoredEndSpaceWithBlankSpace = React.useMemo(() => {
|
|
48
|
+
if (!anchoredEndSpace) {
|
|
49
|
+
return void 0;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
...anchoredEndSpace,
|
|
53
|
+
includeInEndInset: true,
|
|
54
|
+
onSizeChanged: (size) => {
|
|
55
|
+
var _a;
|
|
56
|
+
blankSpace.value = size;
|
|
57
|
+
(_a = anchoredEndSpace.onSizeChanged) == null ? void 0 : _a.call(anchoredEndSpace, size);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}, [anchoredEndSpace, blankSpace]);
|
|
61
|
+
const memoList = React.useCallback(
|
|
62
|
+
(scrollProps) => {
|
|
63
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
64
|
+
reactNativeKeyboardController.KeyboardChatScrollView,
|
|
65
|
+
{
|
|
66
|
+
...scrollProps,
|
|
67
|
+
applyWorkaroundForContentInsetHitTestBug,
|
|
68
|
+
blankSpace,
|
|
69
|
+
extraContentPadding,
|
|
70
|
+
freeze,
|
|
71
|
+
keyboardLiftBehavior,
|
|
72
|
+
offset
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
},
|
|
76
|
+
[
|
|
77
|
+
applyWorkaroundForContentInsetHitTestBug,
|
|
78
|
+
blankSpace,
|
|
79
|
+
extraContentPadding,
|
|
80
|
+
freeze,
|
|
81
|
+
keyboardLiftBehavior,
|
|
82
|
+
offset
|
|
83
|
+
]
|
|
84
|
+
);
|
|
85
|
+
const AnimatedLegendListInternal = reanimated.AnimatedLegendList;
|
|
86
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
87
|
+
AnimatedLegendListInternal,
|
|
88
|
+
{
|
|
89
|
+
anchoredEndSpace: anchoredEndSpaceWithBlankSpace,
|
|
90
|
+
ref: forwardedRef,
|
|
91
|
+
renderScrollComponent: memoList,
|
|
92
|
+
...rest
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
exports.KeyboardChatLegendList = KeyboardChatLegendList;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useEffect, useMemo, useCallback } from 'react';
|
|
3
|
+
import { KeyboardChatScrollView } from 'react-native-keyboard-controller';
|
|
4
|
+
import { useSharedValue } from 'react-native-reanimated';
|
|
5
|
+
import { internal } from '@legendapp/list/react-native';
|
|
6
|
+
import { AnimatedLegendList } from '@legendapp/list/reanimated';
|
|
7
|
+
|
|
8
|
+
// src/integrations/keyboard-chat.tsx
|
|
9
|
+
var { typedForwardRef } = internal;
|
|
10
|
+
var KeyboardChatLegendList = typedForwardRef(function KeyboardChatLegendList2(props, forwardedRef) {
|
|
11
|
+
const {
|
|
12
|
+
anchoredEndSpace,
|
|
13
|
+
applyWorkaroundForContentInsetHitTestBug,
|
|
14
|
+
extraContentPadding,
|
|
15
|
+
freeze,
|
|
16
|
+
keyboardLiftBehavior,
|
|
17
|
+
offset,
|
|
18
|
+
...rest
|
|
19
|
+
} = props;
|
|
20
|
+
const blankSpace = useSharedValue(0);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!anchoredEndSpace) {
|
|
23
|
+
blankSpace.value = 0;
|
|
24
|
+
}
|
|
25
|
+
}, [anchoredEndSpace, blankSpace]);
|
|
26
|
+
const anchoredEndSpaceWithBlankSpace = useMemo(() => {
|
|
27
|
+
if (!anchoredEndSpace) {
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
...anchoredEndSpace,
|
|
32
|
+
includeInEndInset: true,
|
|
33
|
+
onSizeChanged: (size) => {
|
|
34
|
+
var _a;
|
|
35
|
+
blankSpace.value = size;
|
|
36
|
+
(_a = anchoredEndSpace.onSizeChanged) == null ? void 0 : _a.call(anchoredEndSpace, size);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}, [anchoredEndSpace, blankSpace]);
|
|
40
|
+
const memoList = useCallback(
|
|
41
|
+
(scrollProps) => {
|
|
42
|
+
return /* @__PURE__ */ React.createElement(
|
|
43
|
+
KeyboardChatScrollView,
|
|
44
|
+
{
|
|
45
|
+
...scrollProps,
|
|
46
|
+
applyWorkaroundForContentInsetHitTestBug,
|
|
47
|
+
blankSpace,
|
|
48
|
+
extraContentPadding,
|
|
49
|
+
freeze,
|
|
50
|
+
keyboardLiftBehavior,
|
|
51
|
+
offset
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
},
|
|
55
|
+
[
|
|
56
|
+
applyWorkaroundForContentInsetHitTestBug,
|
|
57
|
+
blankSpace,
|
|
58
|
+
extraContentPadding,
|
|
59
|
+
freeze,
|
|
60
|
+
keyboardLiftBehavior,
|
|
61
|
+
offset
|
|
62
|
+
]
|
|
63
|
+
);
|
|
64
|
+
const AnimatedLegendListInternal = AnimatedLegendList;
|
|
65
|
+
return /* @__PURE__ */ React.createElement(
|
|
66
|
+
AnimatedLegendListInternal,
|
|
67
|
+
{
|
|
68
|
+
anchoredEndSpace: anchoredEndSpaceWithBlankSpace,
|
|
69
|
+
ref: forwardedRef,
|
|
70
|
+
renderScrollComponent: memoList,
|
|
71
|
+
...rest
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export { KeyboardChatLegendList };
|
package/keyboard-test.d.ts
CHANGED
|
@@ -3,16 +3,28 @@ import { ScrollViewComponent, ScrollResponderMixin, Insets as Insets$1, ScrollVi
|
|
|
3
3
|
import { KeyboardChatScrollViewProps } from 'react-native-keyboard-controller';
|
|
4
4
|
import { AnimatedLegendListProps } from '@legendapp/list/reanimated';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
interface MaintainVisibleContentPositionNormalized<ItemT = any> {
|
|
7
|
+
data: boolean;
|
|
8
|
+
size: boolean;
|
|
9
|
+
shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type ListenerType = "activeStickyIndex" | "anchoredEndSpaceSize" | "debugComputedScroll" | "debugRawScroll" | "extraData" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "maintainVisibleContentPosition" | "numColumns" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "scrollAdjust" | "scrollAdjustPending" | "scrollAdjustUserOffset" | "scrollSize" | "snapToOffsets" | "stylePaddingTop" | "totalSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
|
|
13
|
+
type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
|
|
8
14
|
type ListenerTypeValueMap = {
|
|
9
15
|
activeStickyIndex: number;
|
|
16
|
+
anchoredEndSpaceSize: number;
|
|
10
17
|
animatedScrollY: any;
|
|
11
18
|
debugComputedScroll: number;
|
|
12
19
|
debugRawScroll: number;
|
|
13
20
|
extraData: any;
|
|
14
21
|
footerSize: number;
|
|
15
22
|
headerSize: number;
|
|
23
|
+
isAtEnd: boolean;
|
|
24
|
+
isAtStart: boolean;
|
|
25
|
+
isNearEnd: boolean;
|
|
26
|
+
isNearStart: boolean;
|
|
27
|
+
isWithinMaintainScrollAtEndThreshold: boolean;
|
|
16
28
|
lastItemKeys: string[];
|
|
17
29
|
lastPositionUpdate: number;
|
|
18
30
|
maintainVisibleContentPosition: MaintainVisibleContentPositionNormalized;
|
|
@@ -51,11 +63,6 @@ interface Insets {
|
|
|
51
63
|
bottom: number;
|
|
52
64
|
right: number;
|
|
53
65
|
}
|
|
54
|
-
interface MaintainVisibleContentPositionNormalized<ItemT = any> {
|
|
55
|
-
data: boolean;
|
|
56
|
-
size: boolean;
|
|
57
|
-
shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
|
|
58
|
-
}
|
|
59
66
|
type LegendListState = {
|
|
60
67
|
activeStickyIndex: number;
|
|
61
68
|
contentLength: number;
|
|
@@ -65,8 +72,11 @@ type LegendListState = {
|
|
|
65
72
|
endBuffered: number;
|
|
66
73
|
isAtEnd: boolean;
|
|
67
74
|
isAtStart: boolean;
|
|
75
|
+
isNearEnd: boolean;
|
|
76
|
+
isNearStart: boolean;
|
|
68
77
|
isEndReached: boolean;
|
|
69
78
|
isStartReached: boolean;
|
|
79
|
+
isWithinMaintainScrollAtEndThreshold: boolean;
|
|
70
80
|
listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
|
|
71
81
|
listenToPosition: (key: string, callback: (value: number) => void) => () => void;
|
|
72
82
|
positionAtIndex: (index: number) => number;
|
|
@@ -201,6 +211,6 @@ type LegendListRef = Omit<LegendListRef$1, "getNativeScrollRef" | "getScrollResp
|
|
|
201
211
|
};
|
|
202
212
|
|
|
203
213
|
type KeyboardChatScrollViewPropsUnique = Omit<KeyboardChatScrollViewProps, keyof ScrollViewProps | "inverted" | "ScrollViewComponent">;
|
|
204
|
-
declare const KeyboardAvoidingLegendList: <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "renderScrollComponent"> & KeyboardChatScrollViewPropsUnique & React.RefAttributes<LegendListRef>) => React.
|
|
214
|
+
declare const KeyboardAvoidingLegendList: <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "renderScrollComponent"> & KeyboardChatScrollViewPropsUnique & React.RefAttributes<LegendListRef>) => React.ReactElement | null;
|
|
205
215
|
|
|
206
216
|
export { KeyboardAvoidingLegendList };
|
package/keyboard-test.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var reactNativeKeyboardController = require('react-native-keyboard-controller');
|
|
5
|
+
var reactNative = require('@legendapp/list/react-native');
|
|
5
6
|
var reanimated = require('@legendapp/list/reanimated');
|
|
6
7
|
|
|
7
8
|
function _interopNamespace(e) {
|
|
@@ -25,10 +26,14 @@ function _interopNamespace(e) {
|
|
|
25
26
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
26
27
|
|
|
27
28
|
// src/integrations/keyboard-test.tsx
|
|
28
|
-
var typedForwardRef =
|
|
29
|
+
var { typedForwardRef } = reactNative.internal;
|
|
29
30
|
var KeyboardAvoidingLegendList = typedForwardRef(function KeyboardAvoidingLegendList2(props, forwardedRef) {
|
|
30
|
-
const
|
|
31
|
-
|
|
31
|
+
const { extraContentPadding, ...rest } = props;
|
|
32
|
+
const memoList = React.useCallback(
|
|
33
|
+
(listProps) => /* @__PURE__ */ React__namespace.createElement(reactNativeKeyboardController.KeyboardChatScrollView, { ...listProps, extraContentPadding }),
|
|
34
|
+
[extraContentPadding]
|
|
35
|
+
);
|
|
36
|
+
return /* @__PURE__ */ React__namespace.createElement(reanimated.AnimatedLegendList, { ref: forwardedRef, renderScrollComponent: memoList, ...rest });
|
|
32
37
|
});
|
|
33
38
|
|
|
34
39
|
exports.KeyboardAvoidingLegendList = KeyboardAvoidingLegendList;
|
package/keyboard-test.mjs
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useCallback
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
3
|
import { KeyboardChatScrollView } from 'react-native-keyboard-controller';
|
|
4
|
+
import { internal } from '@legendapp/list/react-native';
|
|
4
5
|
import { AnimatedLegendList } from '@legendapp/list/reanimated';
|
|
5
6
|
|
|
6
7
|
// src/integrations/keyboard-test.tsx
|
|
7
|
-
var typedForwardRef =
|
|
8
|
+
var { typedForwardRef } = internal;
|
|
8
9
|
var KeyboardAvoidingLegendList = typedForwardRef(function KeyboardAvoidingLegendList2(props, forwardedRef) {
|
|
9
|
-
const
|
|
10
|
-
|
|
10
|
+
const { extraContentPadding, ...rest } = props;
|
|
11
|
+
const memoList = useCallback(
|
|
12
|
+
(listProps) => /* @__PURE__ */ React.createElement(KeyboardChatScrollView, { ...listProps, extraContentPadding }),
|
|
13
|
+
[extraContentPadding]
|
|
14
|
+
);
|
|
15
|
+
return /* @__PURE__ */ React.createElement(AnimatedLegendList, { ref: forwardedRef, renderScrollComponent: memoList, ...rest });
|
|
11
16
|
});
|
|
12
17
|
|
|
13
18
|
export { KeyboardAvoidingLegendList };
|
package/keyboard.d.ts
CHANGED
|
@@ -3,16 +3,28 @@ import { ScrollViewComponent, ScrollResponderMixin, Insets as Insets$1 } from 'r
|
|
|
3
3
|
import { ScrollEvent, ScrollHandlerProcessed } from 'react-native-reanimated';
|
|
4
4
|
import { AnimatedLegendListProps } from '@legendapp/list/reanimated';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
interface MaintainVisibleContentPositionNormalized<ItemT = any> {
|
|
7
|
+
data: boolean;
|
|
8
|
+
size: boolean;
|
|
9
|
+
shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type ListenerType = "activeStickyIndex" | "anchoredEndSpaceSize" | "debugComputedScroll" | "debugRawScroll" | "extraData" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "maintainVisibleContentPosition" | "numColumns" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "scrollAdjust" | "scrollAdjustPending" | "scrollAdjustUserOffset" | "scrollSize" | "snapToOffsets" | "stylePaddingTop" | "totalSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
|
|
13
|
+
type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
|
|
8
14
|
type ListenerTypeValueMap = {
|
|
9
15
|
activeStickyIndex: number;
|
|
16
|
+
anchoredEndSpaceSize: number;
|
|
10
17
|
animatedScrollY: any;
|
|
11
18
|
debugComputedScroll: number;
|
|
12
19
|
debugRawScroll: number;
|
|
13
20
|
extraData: any;
|
|
14
21
|
footerSize: number;
|
|
15
22
|
headerSize: number;
|
|
23
|
+
isAtEnd: boolean;
|
|
24
|
+
isAtStart: boolean;
|
|
25
|
+
isNearEnd: boolean;
|
|
26
|
+
isNearStart: boolean;
|
|
27
|
+
isWithinMaintainScrollAtEndThreshold: boolean;
|
|
16
28
|
lastItemKeys: string[];
|
|
17
29
|
lastPositionUpdate: number;
|
|
18
30
|
maintainVisibleContentPosition: MaintainVisibleContentPositionNormalized;
|
|
@@ -51,11 +63,6 @@ interface Insets {
|
|
|
51
63
|
bottom: number;
|
|
52
64
|
right: number;
|
|
53
65
|
}
|
|
54
|
-
interface MaintainVisibleContentPositionNormalized<ItemT = any> {
|
|
55
|
-
data: boolean;
|
|
56
|
-
size: boolean;
|
|
57
|
-
shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
|
|
58
|
-
}
|
|
59
66
|
type LegendListState = {
|
|
60
67
|
activeStickyIndex: number;
|
|
61
68
|
contentLength: number;
|
|
@@ -65,8 +72,11 @@ type LegendListState = {
|
|
|
65
72
|
endBuffered: number;
|
|
66
73
|
isAtEnd: boolean;
|
|
67
74
|
isAtStart: boolean;
|
|
75
|
+
isNearEnd: boolean;
|
|
76
|
+
isNearStart: boolean;
|
|
68
77
|
isEndReached: boolean;
|
|
69
78
|
isStartReached: boolean;
|
|
79
|
+
isWithinMaintainScrollAtEndThreshold: boolean;
|
|
70
80
|
listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
|
|
71
81
|
listenToPosition: (key: string, callback: (value: number) => void) => () => void;
|
|
72
82
|
positionAtIndex: (index: number) => number;
|
package/keyboard.js
CHANGED
|
@@ -28,7 +28,7 @@ function _interopNamespace(e) {
|
|
|
28
28
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
29
29
|
|
|
30
30
|
// src/integrations/keyboard.tsx
|
|
31
|
-
var { useCombinedRef } = reactNative.internal;
|
|
31
|
+
var { typedForwardRef, useCombinedRef } = reactNative.internal;
|
|
32
32
|
var clampProgress = (progress) => {
|
|
33
33
|
"worklet";
|
|
34
34
|
return Math.min(1, Math.max(0, progress));
|
|
@@ -52,7 +52,7 @@ var calculateKeyboardTargetOffset = (startOffset, keyboardHeight, isOpening, pro
|
|
|
52
52
|
const delta = (isOpening ? keyboardHeight : -keyboardHeight) * normalizedProgress;
|
|
53
53
|
return Math.max(0, startOffset + delta);
|
|
54
54
|
};
|
|
55
|
-
var KeyboardAvoidingLegendList =
|
|
55
|
+
var KeyboardAvoidingLegendList = typedForwardRef(function KeyboardAvoidingLegendList2(props, forwardedRef) {
|
|
56
56
|
const {
|
|
57
57
|
contentContainerStyle: contentContainerStyleProp,
|
|
58
58
|
contentInset: contentInsetProp,
|
|
@@ -417,13 +417,14 @@ var KeyboardAvoidingLegendList = reactNative.typedForwardRef(function KeyboardAv
|
|
|
417
417
|
return baseProps;
|
|
418
418
|
}
|
|
419
419
|
});
|
|
420
|
-
const
|
|
420
|
+
const androidAnimatedStyle = reactNativeReanimated.useAnimatedStyle(
|
|
421
421
|
() => ({
|
|
422
422
|
...styleFlattened || {},
|
|
423
423
|
marginBottom: keyboardInset.get()
|
|
424
424
|
}),
|
|
425
425
|
[styleProp, keyboardInset]
|
|
426
|
-
)
|
|
426
|
+
);
|
|
427
|
+
const style = isAndroid ? androidAnimatedStyle : styleProp;
|
|
427
428
|
const contentContainerStyle = React.useMemo(() => {
|
|
428
429
|
if (alignItemsAtEndMinSize === void 0) {
|
|
429
430
|
return contentContainerStyleProp;
|
package/keyboard.mjs
CHANGED
|
@@ -3,11 +3,11 @@ import { useRef, useState, useMemo, useCallback, useEffect } from 'react';
|
|
|
3
3
|
import { StyleSheet, Platform } from 'react-native';
|
|
4
4
|
import { useKeyboardHandler } from 'react-native-keyboard-controller';
|
|
5
5
|
import { useAnimatedRef, useSharedValue, isWorkletFunction, useAnimatedScrollHandler, runOnJS, useComposedEventHandler, useAnimatedProps, useAnimatedStyle } from 'react-native-reanimated';
|
|
6
|
-
import { internal
|
|
6
|
+
import { internal } from '@legendapp/list/react-native';
|
|
7
7
|
import { AnimatedLegendList } from '@legendapp/list/reanimated';
|
|
8
8
|
|
|
9
9
|
// src/integrations/keyboard.tsx
|
|
10
|
-
var { useCombinedRef } = internal;
|
|
10
|
+
var { typedForwardRef, useCombinedRef } = internal;
|
|
11
11
|
var clampProgress = (progress) => {
|
|
12
12
|
"worklet";
|
|
13
13
|
return Math.min(1, Math.max(0, progress));
|
|
@@ -396,13 +396,14 @@ var KeyboardAvoidingLegendList = typedForwardRef(function KeyboardAvoidingLegend
|
|
|
396
396
|
return baseProps;
|
|
397
397
|
}
|
|
398
398
|
});
|
|
399
|
-
const
|
|
399
|
+
const androidAnimatedStyle = useAnimatedStyle(
|
|
400
400
|
() => ({
|
|
401
401
|
...styleFlattened || {},
|
|
402
402
|
marginBottom: keyboardInset.get()
|
|
403
403
|
}),
|
|
404
404
|
[styleProp, keyboardInset]
|
|
405
|
-
)
|
|
405
|
+
);
|
|
406
|
+
const style = isAndroid ? androidAnimatedStyle : styleProp;
|
|
406
407
|
const contentContainerStyle = useMemo(() => {
|
|
407
408
|
if (alignItemsAtEndMinSize === void 0) {
|
|
408
409
|
return contentContainerStyleProp;
|
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.45",
|
|
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,
|
|
@@ -28,6 +28,12 @@
|
|
|
28
28
|
"require": "./keyboard.js",
|
|
29
29
|
"default": "./keyboard.js"
|
|
30
30
|
},
|
|
31
|
+
"./keyboard-chat": {
|
|
32
|
+
"types": "./keyboard-chat.d.ts",
|
|
33
|
+
"import": "./keyboard-chat.mjs",
|
|
34
|
+
"require": "./keyboard-chat.js",
|
|
35
|
+
"default": "./keyboard-chat.js"
|
|
36
|
+
},
|
|
31
37
|
"./keyboard-test": {
|
|
32
38
|
"types": "./keyboard-test.d.ts",
|
|
33
39
|
"import": "./keyboard-test.mjs",
|