@legendapp/list 3.0.0-beta.9 → 3.0.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/.DS_Store +0 -0
- package/CHANGELOG.md +21 -1
- package/README.md +8 -2
- package/animated.d.ts +659 -5
- package/animated.js +2 -2
- package/animated.mjs +1 -1
- package/keyboard-legacy.d.ts +226 -0
- package/keyboard-legacy.js +456 -0
- package/keyboard-legacy.mjs +435 -0
- package/keyboard.d.ts +261 -9
- package/keyboard.js +114 -135
- package/keyboard.mjs +115 -137
- package/package.json +55 -5
- package/{types-1Hgg1rTO.d.mts → react-native.d.ts} +269 -284
- package/react-native.js +6453 -0
- package/react-native.mjs +6424 -0
- package/{types-1Hgg1rTO.d.ts → react-native.web.d.ts} +330 -283
- package/react-native.web.js +7111 -0
- package/react-native.web.mjs +7082 -0
- package/react.d.ts +771 -0
- package/react.js +7111 -0
- package/react.mjs +7082 -0
- package/reanimated.d.ts +681 -8
- package/reanimated.js +225 -38
- package/reanimated.mjs +227 -40
- package/section-list.d.ts +663 -5
- package/section-list.js +39 -3829
- package/section-list.mjs +37 -3828
- package/animated.d.mts +0 -9
- package/index.d.mts +0 -23
- package/index.d.ts +0 -23
- package/index.js +0 -3935
- package/index.mjs +0 -3907
- package/index.native.d.mts +0 -23
- package/index.native.d.ts +0 -23
- package/index.native.js +0 -3739
- package/index.native.mjs +0 -3711
- package/keyboard-controller.d.mts +0 -12
- package/keyboard-controller.d.ts +0 -12
- package/keyboard-controller.js +0 -69
- package/keyboard-controller.mjs +0 -48
- package/keyboard.d.mts +0 -13
- package/reanimated.d.mts +0 -18
- package/section-list.d.mts +0 -113
- package/section-list.native.d.mts +0 -113
- package/section-list.native.d.ts +0 -113
- package/section-list.native.js +0 -3897
- package/section-list.native.mjs +0 -3876
package/keyboard.mjs
CHANGED
|
@@ -1,160 +1,138 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { useRef, useEffect, useMemo, useCallback, useLayoutEffect } from 'react';
|
|
3
|
+
import { KeyboardChatScrollView, KeyboardController } from 'react-native-keyboard-controller';
|
|
4
|
+
import { useSharedValue } from 'react-native-reanimated';
|
|
5
|
+
import { internal } from '@legendapp/list/react-native';
|
|
6
6
|
import { AnimatedLegendList } from '@legendapp/list/reanimated';
|
|
7
7
|
|
|
8
8
|
// src/integrations/keyboard.tsx
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
var { typedForwardRef, useCombinedRef } = internal;
|
|
10
|
+
if (typeof __DEV__ !== "undefined" && __DEV__ && !KeyboardChatScrollView) {
|
|
11
|
+
console.warn(
|
|
12
|
+
"[legend-list] KeyboardAwareLegendList requires a recent react-native-keyboard-controller with KeyboardChatScrollView. Please upgrade react-native-keyboard-controller to at least 1.21.7."
|
|
13
|
+
);
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
function useKeyboardChatComposerInset(listRef, composerRef, initialHeight = 0) {
|
|
16
|
+
const contentInsetEndAdjustment = useSharedValue(initialHeight);
|
|
17
|
+
const lastHeightRef = useRef(void 0);
|
|
18
|
+
const reportHeight = useCallback(
|
|
19
|
+
(height) => {
|
|
20
|
+
var _a;
|
|
21
|
+
if (Number.isFinite(height) && height !== lastHeightRef.current) {
|
|
22
|
+
lastHeightRef.current = height;
|
|
23
|
+
contentInsetEndAdjustment.value = height;
|
|
24
|
+
(_a = listRef.current) == null ? void 0 : _a.reportContentInset({ bottom: height });
|
|
21
25
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
},
|
|
27
|
+
[contentInsetEndAdjustment, listRef]
|
|
28
|
+
);
|
|
29
|
+
useLayoutEffect(() => {
|
|
30
|
+
var _a;
|
|
31
|
+
(_a = composerRef.current) == null ? void 0 : _a.measure((_x, _y, _width, height) => {
|
|
32
|
+
reportHeight(height);
|
|
33
|
+
});
|
|
34
|
+
}, [composerRef, reportHeight]);
|
|
35
|
+
const onComposerLayout = useCallback(
|
|
36
|
+
(event) => {
|
|
37
|
+
reportHeight(event.nativeEvent.layout.height);
|
|
38
|
+
},
|
|
39
|
+
[reportHeight]
|
|
40
|
+
);
|
|
41
|
+
return { contentInsetEndAdjustment, onComposerLayout };
|
|
42
|
+
}
|
|
43
|
+
function useKeyboardScrollToEnd({ freeze: freezeProp, listRef }) {
|
|
44
|
+
const internalFreeze = useSharedValue(false);
|
|
45
|
+
const freeze = freezeProp != null ? freezeProp : internalFreeze;
|
|
46
|
+
const scrollMessageToEnd = useCallback(
|
|
47
|
+
async ({ animated, closeKeyboard }) => {
|
|
48
|
+
const listRefCurrent = listRef.current;
|
|
49
|
+
if (listRefCurrent) {
|
|
50
|
+
freeze.set(true);
|
|
51
|
+
const dismissPromise = closeKeyboard && KeyboardController.dismiss();
|
|
52
|
+
const scrollPromise = listRefCurrent.scrollToEnd({ animated });
|
|
53
|
+
await Promise.all([scrollPromise, dismissPromise]);
|
|
54
|
+
freeze.set(false);
|
|
26
55
|
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
56
|
+
},
|
|
57
|
+
[freeze, listRef]
|
|
58
|
+
);
|
|
59
|
+
return {
|
|
60
|
+
freeze,
|
|
61
|
+
scrollMessageToEnd
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
var KeyboardAwareLegendList = typedForwardRef(function KeyboardAwareLegendList2(props, forwardedRef) {
|
|
34
65
|
const {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
66
|
+
anchoredEndSpace,
|
|
67
|
+
applyWorkaroundForContentInsetHitTestBug,
|
|
68
|
+
contentInsetEndAdjustment,
|
|
69
|
+
freeze,
|
|
70
|
+
keyboardLiftBehavior,
|
|
71
|
+
keyboardOffset,
|
|
39
72
|
...rest
|
|
40
73
|
} = props;
|
|
41
74
|
const refLegendList = useRef(null);
|
|
42
75
|
const combinedRef = useCombinedRef(forwardedRef, refLegendList);
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
76
|
+
const blankSpace = useSharedValue(0);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (!anchoredEndSpace) {
|
|
79
|
+
blankSpace.value = 0;
|
|
80
|
+
}
|
|
81
|
+
}, [anchoredEndSpace, blankSpace]);
|
|
82
|
+
const anchoredEndSpaceWithBlankSpace = useMemo(() => {
|
|
83
|
+
if (!anchoredEndSpace) {
|
|
84
|
+
return void 0;
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
...anchoredEndSpace,
|
|
88
|
+
includeInEndInset: true,
|
|
89
|
+
onSizeChanged: (size) => {
|
|
90
|
+
var _a;
|
|
91
|
+
blankSpace.value = size;
|
|
92
|
+
(_a = anchoredEndSpace.onSizeChanged) == null ? void 0 : _a.call(anchoredEndSpace, size);
|
|
56
93
|
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
isOpening.set(event.progress > 0);
|
|
77
|
-
scrollOffsetAtKeyboardStart.value = scrollOffsetY.value;
|
|
78
|
-
animatedOffsetY.set(scrollOffsetY.value);
|
|
79
|
-
runOnJS(setScrollProcessingEnabled)(false);
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
onInteractive: () => {
|
|
83
|
-
"worklet";
|
|
84
|
-
if (!didInteractive.get()) {
|
|
85
|
-
didInteractive.set(true);
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
onMove: (event) => {
|
|
89
|
-
"worklet";
|
|
90
|
-
if (!didInteractive.get()) {
|
|
91
|
-
const vIsOpening = isOpening.get();
|
|
92
|
-
const vKeyboardHeight = keyboardHeight.get();
|
|
93
|
-
const vProgress = vIsOpening ? event.progress : 1 - event.progress;
|
|
94
|
-
const targetOffset = scrollOffsetAtKeyboardStart.value + (vIsOpening ? vKeyboardHeight : -vKeyboardHeight) * vProgress;
|
|
95
|
-
scrollOffsetY.value = targetOffset;
|
|
96
|
-
animatedOffsetY.set(targetOffset);
|
|
97
|
-
if (!horizontal) {
|
|
98
|
-
keyboardInset.value = Math.max(0, event.height - safeAreaInsetBottom);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
onEnd: (event) => {
|
|
103
|
-
"worklet";
|
|
104
|
-
const wasInteractive = didInteractive.get();
|
|
105
|
-
if (wasInteractive && event.progress === 0 && event.target > 0) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (!wasInteractive) {
|
|
109
|
-
const vIsOpening = isOpening.get();
|
|
110
|
-
const vKeyboardHeight = keyboardHeight.get();
|
|
111
|
-
const targetOffset = scrollOffsetAtKeyboardStart.value + (vIsOpening ? vKeyboardHeight : -vKeyboardHeight) * (vIsOpening ? event.progress : 1 - event.progress);
|
|
112
|
-
scrollOffsetY.value = targetOffset;
|
|
113
|
-
animatedOffsetY.set(targetOffset);
|
|
114
|
-
runOnJS(setScrollProcessingEnabled)(true);
|
|
115
|
-
}
|
|
116
|
-
didInteractive.set(false);
|
|
117
|
-
if (!horizontal) {
|
|
118
|
-
keyboardInset.value = Math.max(0, event.height - safeAreaInsetBottom);
|
|
94
|
+
};
|
|
95
|
+
}, [anchoredEndSpace, blankSpace]);
|
|
96
|
+
const onContentInsetChange = useCallback((insets) => {
|
|
97
|
+
var _a;
|
|
98
|
+
(_a = refLegendList.current) == null ? void 0 : _a.reportContentInset(insets);
|
|
99
|
+
}, []);
|
|
100
|
+
const memoList = useCallback(
|
|
101
|
+
(scrollProps) => {
|
|
102
|
+
return /* @__PURE__ */ React.createElement(
|
|
103
|
+
KeyboardChatScrollView,
|
|
104
|
+
{
|
|
105
|
+
...scrollProps,
|
|
106
|
+
applyWorkaroundForContentInsetHitTestBug,
|
|
107
|
+
blankSpace,
|
|
108
|
+
extraContentPadding: contentInsetEndAdjustment,
|
|
109
|
+
freeze,
|
|
110
|
+
keyboardLiftBehavior,
|
|
111
|
+
offset: keyboardOffset,
|
|
112
|
+
onContentInsetChange
|
|
119
113
|
}
|
|
120
|
-
|
|
114
|
+
);
|
|
121
115
|
},
|
|
122
|
-
[
|
|
116
|
+
[
|
|
117
|
+
applyWorkaroundForContentInsetHitTestBug,
|
|
118
|
+
blankSpace,
|
|
119
|
+
contentInsetEndAdjustment,
|
|
120
|
+
freeze,
|
|
121
|
+
keyboardLiftBehavior,
|
|
122
|
+
keyboardOffset,
|
|
123
|
+
onContentInsetChange
|
|
124
|
+
]
|
|
123
125
|
);
|
|
124
|
-
const
|
|
125
|
-
"worklet";
|
|
126
|
-
var _a, _b, _c, _d;
|
|
127
|
-
const baseProps = {
|
|
128
|
-
contentOffset: animatedOffsetY.value === null ? void 0 : {
|
|
129
|
-
x: 0,
|
|
130
|
-
y: animatedOffsetY.value
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
return Platform.OS === "ios" ? Object.assign(baseProps, {
|
|
134
|
-
contentInset: {
|
|
135
|
-
bottom: ((_a = contentInsetProp == null ? void 0 : contentInsetProp.bottom) != null ? _a : 0) + (horizontal ? 0 : keyboardInset.value),
|
|
136
|
-
left: (_b = contentInsetProp == null ? void 0 : contentInsetProp.left) != null ? _b : 0,
|
|
137
|
-
right: (_c = contentInsetProp == null ? void 0 : contentInsetProp.right) != null ? _c : 0,
|
|
138
|
-
top: (_d = contentInsetProp == null ? void 0 : contentInsetProp.top) != null ? _d : 0
|
|
139
|
-
}
|
|
140
|
-
}) : baseProps;
|
|
141
|
-
});
|
|
142
|
-
const style = Platform.OS !== "ios" ? useAnimatedStyle(() => ({
|
|
143
|
-
marginBottom: keyboardInset.value
|
|
144
|
-
})) : void 0;
|
|
126
|
+
const AnimatedLegendListInternal = AnimatedLegendList;
|
|
145
127
|
return /* @__PURE__ */ React.createElement(
|
|
146
|
-
|
|
128
|
+
AnimatedLegendListInternal,
|
|
147
129
|
{
|
|
148
|
-
|
|
149
|
-
animatedProps,
|
|
150
|
-
keyboardDismissMode: "interactive",
|
|
151
|
-
onScroll: scrollHandler,
|
|
130
|
+
anchoredEndSpace: anchoredEndSpaceWithBlankSpace,
|
|
152
131
|
ref: combinedRef,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
style
|
|
132
|
+
renderScrollComponent: memoList,
|
|
133
|
+
...rest
|
|
156
134
|
}
|
|
157
135
|
);
|
|
158
136
|
});
|
|
159
137
|
|
|
160
|
-
export {
|
|
138
|
+
export { KeyboardAwareLegendList, useKeyboardChatComposerInset, useKeyboardScrollToEnd };
|
package/package.json
CHANGED
|
@@ -1,13 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/list",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
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,
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
"exports": {
|
|
8
|
+
"./animated": {
|
|
9
|
+
"types": "./animated.d.ts",
|
|
10
|
+
"import": "./animated.mjs",
|
|
11
|
+
"require": "./animated.js",
|
|
12
|
+
"default": "./animated.js"
|
|
13
|
+
},
|
|
14
|
+
"./keyboard": {
|
|
15
|
+
"types": "./keyboard.d.ts",
|
|
16
|
+
"import": "./keyboard.mjs",
|
|
17
|
+
"require": "./keyboard.js",
|
|
18
|
+
"default": "./keyboard.js"
|
|
19
|
+
},
|
|
20
|
+
"./keyboard-legacy": {
|
|
21
|
+
"types": "./keyboard-legacy.d.ts",
|
|
22
|
+
"import": "./keyboard-legacy.mjs",
|
|
23
|
+
"require": "./keyboard-legacy.js",
|
|
24
|
+
"default": "./keyboard-legacy.js"
|
|
25
|
+
},
|
|
26
|
+
"./reanimated": {
|
|
27
|
+
"types": "./reanimated.d.ts",
|
|
28
|
+
"import": "./reanimated.mjs",
|
|
29
|
+
"require": "./reanimated.js",
|
|
30
|
+
"default": "./reanimated.js"
|
|
31
|
+
},
|
|
32
|
+
"./react-native": {
|
|
33
|
+
"types": "./react-native.d.ts",
|
|
34
|
+
"browser": {
|
|
35
|
+
"import": "./react-native.web.mjs",
|
|
36
|
+
"require": "./react-native.web.js",
|
|
37
|
+
"default": "./react-native.web.js"
|
|
38
|
+
},
|
|
39
|
+
"react-native": {
|
|
40
|
+
"import": "./react-native.mjs",
|
|
41
|
+
"require": "./react-native.js",
|
|
42
|
+
"default": "./react-native.js"
|
|
43
|
+
},
|
|
44
|
+
"import": "./react-native.web.mjs",
|
|
45
|
+
"require": "./react-native.web.js",
|
|
46
|
+
"default": "./react-native.web.js"
|
|
47
|
+
},
|
|
48
|
+
"./section-list": {
|
|
49
|
+
"types": "./section-list.d.ts",
|
|
50
|
+
"import": "./section-list.mjs",
|
|
51
|
+
"require": "./section-list.js",
|
|
52
|
+
"default": "./section-list.js"
|
|
53
|
+
},
|
|
54
|
+
"./react": {
|
|
55
|
+
"types": "./react.d.ts",
|
|
56
|
+
"import": "./react.mjs",
|
|
57
|
+
"require": "./react.js",
|
|
58
|
+
"default": "./react.js"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
11
61
|
"files": [
|
|
12
62
|
"**"
|
|
13
63
|
],
|