@legendapp/list 3.0.0-beta.32 → 3.0.0-beta.33

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.
Files changed (54) hide show
  1. package/README.md +7 -1
  2. package/animated.d.ts +600 -6
  3. package/animated.js +2 -2
  4. package/animated.mjs +1 -1
  5. package/index.d.ts +454 -108
  6. package/index.js +81 -32
  7. package/index.mjs +81 -32
  8. package/index.native.js +89 -44
  9. package/index.native.mjs +88 -43
  10. package/keyboard-controller.d.ts +611 -6
  11. package/keyboard-controller.js +2 -2
  12. package/keyboard-controller.mjs +1 -1
  13. package/keyboard.d.ts +204 -8
  14. package/keyboard.js +66 -52
  15. package/keyboard.mjs +69 -54
  16. package/{index.d.mts → list-react-native.d.ts} +95 -32
  17. package/list-react-native.js +4234 -0
  18. package/list-react-native.mjs +4204 -0
  19. package/{index.native.d.mts → list-react.d.ts} +355 -40
  20. package/list-react.js +4426 -0
  21. package/list-react.mjs +4396 -0
  22. package/package.json +52 -1
  23. package/reanimated.d.ts +595 -7
  24. package/reanimated.js +156 -11
  25. package/reanimated.mjs +153 -8
  26. package/section-list.d.ts +610 -14
  27. package/section-list.js +6 -6
  28. package/section-list.mjs +1 -1
  29. package/animated.d.mts +0 -9
  30. package/animated.native.d.mts +0 -9
  31. package/animated.native.d.ts +0 -9
  32. package/animated.native.js +0 -9
  33. package/animated.native.mjs +0 -7
  34. package/index.native.d.ts +0 -817
  35. package/keyboard-controller.d.mts +0 -12
  36. package/keyboard-controller.native.d.mts +0 -12
  37. package/keyboard-controller.native.d.ts +0 -12
  38. package/keyboard-controller.native.js +0 -69
  39. package/keyboard-controller.native.mjs +0 -48
  40. package/keyboard.d.mts +0 -13
  41. package/keyboard.native.d.mts +0 -13
  42. package/keyboard.native.d.ts +0 -13
  43. package/keyboard.native.js +0 -399
  44. package/keyboard.native.mjs +0 -377
  45. package/reanimated.d.mts +0 -18
  46. package/reanimated.native.d.mts +0 -18
  47. package/reanimated.native.d.ts +0 -18
  48. package/reanimated.native.js +0 -89
  49. package/reanimated.native.mjs +0 -65
  50. package/section-list.d.mts +0 -112
  51. package/section-list.native.d.mts +0 -112
  52. package/section-list.native.d.ts +0 -112
  53. package/section-list.native.js +0 -293
  54. package/section-list.native.mjs +0 -271
@@ -1,12 +0,0 @@
1
- import * as React from 'react';
2
- import { LegendList as LegendList$1, LegendListProps, LegendListRef } from '@legendapp/list';
3
- import { AnimatedLegendList } from '@legendapp/list/animated';
4
- import { AnimatedLegendList as AnimatedLegendList$1 } from '@legendapp/list/reanimated';
5
-
6
- declare const LegendList: <ItemT, ListT extends typeof LegendList$1 | typeof AnimatedLegendList | typeof AnimatedLegendList$1 = (<T>(props: LegendListProps<T> & React.RefAttributes<LegendListRef>) => React.ReactNode) & {
7
- displayName?: string;
8
- }>(props: (LegendListProps<ItemT> & {
9
- LegendList?: ListT;
10
- }) & React.RefAttributes<LegendListRef>) => React.ReactNode;
11
-
12
- export { LegendList };
@@ -1,12 +0,0 @@
1
- import * as React from 'react';
2
- import { LegendList as LegendList$1, LegendListProps, LegendListRef } from '@legendapp/list';
3
- import { AnimatedLegendList } from '@legendapp/list/animated';
4
- import { AnimatedLegendList as AnimatedLegendList$1 } from '@legendapp/list/reanimated';
5
-
6
- declare const LegendList: <ItemT, ListT extends typeof LegendList$1 | typeof AnimatedLegendList | typeof AnimatedLegendList$1 = (<T>(props: LegendListProps<T> & React.RefAttributes<LegendListRef>) => React.ReactNode) & {
7
- displayName?: string;
8
- }>(props: (LegendListProps<ItemT> & {
9
- LegendList?: ListT;
10
- }) & React.RefAttributes<LegendListRef>) => React.ReactNode;
11
-
12
- export { LegendList };
@@ -1,12 +0,0 @@
1
- import * as React from 'react';
2
- import { LegendList as LegendList$1, LegendListProps, LegendListRef } from '@legendapp/list';
3
- import { AnimatedLegendList } from '@legendapp/list/animated';
4
- import { AnimatedLegendList as AnimatedLegendList$1 } from '@legendapp/list/reanimated';
5
-
6
- declare const LegendList: <ItemT, ListT extends typeof LegendList$1 | typeof AnimatedLegendList | typeof AnimatedLegendList$1 = (<T>(props: LegendListProps<T> & React.RefAttributes<LegendListRef>) => React.ReactNode) & {
7
- displayName?: string;
8
- }>(props: (LegendListProps<ItemT> & {
9
- LegendList?: ListT;
10
- }) & React.RefAttributes<LegendListRef>) => React.ReactNode;
11
-
12
- export { LegendList };
@@ -1,69 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var reactNative = require('react-native');
5
- var reactNativeKeyboardController = require('react-native-keyboard-controller');
6
- var reactNativeReanimated = require('react-native-reanimated');
7
- var list = require('@legendapp/list');
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-controller.tsx
30
- var typedForwardRef = React.forwardRef;
31
- var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
32
- const {
33
- LegendList: LegendListProp,
34
- contentContainerStyle: contentContainerStyleProp,
35
- scrollIndicatorInsets: scrollIndicatorInsetsProp,
36
- ...rest
37
- } = props;
38
- const [padding, setPadding] = React.useState(0);
39
- const updatePadding = (height) => {
40
- setPadding(height);
41
- };
42
- reactNativeKeyboardController.useKeyboardHandler({
43
- onEnd: (e) => {
44
- "worklet";
45
- reactNativeReanimated.runOnJS(updatePadding)(e.height);
46
- }
47
- });
48
- const LegendListComponent = LegendListProp != null ? LegendListProp : list.LegendList;
49
- const contentContainerStyleFlattened = reactNative.StyleSheet.flatten(contentContainerStyleProp) || {};
50
- const contentContainerStyle = { ...contentContainerStyleFlattened, paddingTop: padding };
51
- const scrollIndicatorInsets = scrollIndicatorInsetsProp ? { ...scrollIndicatorInsetsProp } : {};
52
- if (!props.horizontal) {
53
- scrollIndicatorInsets.top = ((scrollIndicatorInsets == null ? void 0 : scrollIndicatorInsets.top) || 0) + padding;
54
- }
55
- return (
56
- // @ts-expect-error TODO: Fix this type
57
- /* @__PURE__ */ React__namespace.createElement(
58
- LegendListComponent,
59
- {
60
- ...rest,
61
- contentContainerStyle,
62
- ref: forwardedRef,
63
- scrollIndicatorInsets
64
- }
65
- )
66
- );
67
- });
68
-
69
- exports.LegendList = LegendList;
@@ -1,48 +0,0 @@
1
- import * as React from 'react';
2
- import { useState, forwardRef } from 'react';
3
- import { StyleSheet } from 'react-native';
4
- import { useKeyboardHandler } from 'react-native-keyboard-controller';
5
- import { runOnJS } from 'react-native-reanimated';
6
- import { LegendList as LegendList$1 } from '@legendapp/list';
7
-
8
- // src/integrations/keyboard-controller.tsx
9
- var typedForwardRef = forwardRef;
10
- var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
11
- const {
12
- LegendList: LegendListProp,
13
- contentContainerStyle: contentContainerStyleProp,
14
- scrollIndicatorInsets: scrollIndicatorInsetsProp,
15
- ...rest
16
- } = props;
17
- const [padding, setPadding] = useState(0);
18
- const updatePadding = (height) => {
19
- setPadding(height);
20
- };
21
- useKeyboardHandler({
22
- onEnd: (e) => {
23
- "worklet";
24
- runOnJS(updatePadding)(e.height);
25
- }
26
- });
27
- const LegendListComponent = LegendListProp != null ? LegendListProp : LegendList$1;
28
- const contentContainerStyleFlattened = StyleSheet.flatten(contentContainerStyleProp) || {};
29
- const contentContainerStyle = { ...contentContainerStyleFlattened, paddingTop: padding };
30
- const scrollIndicatorInsets = scrollIndicatorInsetsProp ? { ...scrollIndicatorInsetsProp } : {};
31
- if (!props.horizontal) {
32
- scrollIndicatorInsets.top = ((scrollIndicatorInsets == null ? void 0 : scrollIndicatorInsets.top) || 0) + padding;
33
- }
34
- return (
35
- // @ts-expect-error TODO: Fix this type
36
- /* @__PURE__ */ React.createElement(
37
- LegendListComponent,
38
- {
39
- ...rest,
40
- contentContainerStyle,
41
- ref: forwardedRef,
42
- scrollIndicatorInsets
43
- }
44
- )
45
- );
46
- });
47
-
48
- export { LegendList };
package/keyboard.d.mts DELETED
@@ -1,13 +0,0 @@
1
- import * as React from 'react';
2
- import { Insets } from 'react-native';
3
- import { ReanimatedScrollEvent } from 'react-native-reanimated/lib/typescript/hook/commonTypes';
4
- import { LegendListRef } from '@legendapp/list';
5
- import { AnimatedLegendListProps } from '@legendapp/list/reanimated';
6
-
7
- declare const KeyboardAvoidingLegendList: <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "onScroll" | "automaticallyAdjustContentInsets" | "contentInset"> & {
8
- onScroll?: (event: ReanimatedScrollEvent) => void;
9
- contentInset?: Insets | undefined;
10
- safeAreaInsetBottom?: number;
11
- } & React.RefAttributes<LegendListRef>) => React.ReactNode;
12
-
13
- export { KeyboardAvoidingLegendList, KeyboardAvoidingLegendList as LegendList };
@@ -1,13 +0,0 @@
1
- import * as React from 'react';
2
- import { Insets } from 'react-native';
3
- import { ReanimatedScrollEvent } from 'react-native-reanimated/lib/typescript/hook/commonTypes';
4
- import { LegendListRef } from '@legendapp/list';
5
- import { AnimatedLegendListProps } from '@legendapp/list/reanimated';
6
-
7
- declare const KeyboardAvoidingLegendList: <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "onScroll" | "automaticallyAdjustContentInsets" | "contentInset"> & {
8
- onScroll?: (event: ReanimatedScrollEvent) => void;
9
- contentInset?: Insets | undefined;
10
- safeAreaInsetBottom?: number;
11
- } & React.RefAttributes<LegendListRef>) => React.ReactNode;
12
-
13
- export { KeyboardAvoidingLegendList, KeyboardAvoidingLegendList as LegendList };
@@ -1,13 +0,0 @@
1
- import * as React from 'react';
2
- import { Insets } from 'react-native';
3
- import { ReanimatedScrollEvent } from 'react-native-reanimated/lib/typescript/hook/commonTypes';
4
- import { LegendListRef } from '@legendapp/list';
5
- import { AnimatedLegendListProps } from '@legendapp/list/reanimated';
6
-
7
- declare const KeyboardAvoidingLegendList: <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "onScroll" | "automaticallyAdjustContentInsets" | "contentInset"> & {
8
- onScroll?: (event: ReanimatedScrollEvent) => void;
9
- contentInset?: Insets | undefined;
10
- safeAreaInsetBottom?: number;
11
- } & React.RefAttributes<LegendListRef>) => React.ReactNode;
12
-
13
- export { KeyboardAvoidingLegendList, KeyboardAvoidingLegendList as LegendList };
@@ -1,399 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var reactNative = require('react-native');
5
- var reactNativeKeyboardController = require('react-native-keyboard-controller');
6
- var reactNativeReanimated = require('react-native-reanimated');
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.tsx
30
-
31
- // src/utils/helpers.ts
32
- function isFunction(obj) {
33
- return typeof obj === "function";
34
- }
35
-
36
- // src/hooks/useCombinedRef.ts
37
- var useCombinedRef = (...refs) => {
38
- const callback = React.useCallback((element) => {
39
- for (const ref of refs) {
40
- if (!ref) {
41
- continue;
42
- }
43
- if (isFunction(ref)) {
44
- ref(element);
45
- } else {
46
- ref.current = element;
47
- }
48
- }
49
- }, refs);
50
- return callback;
51
- };
52
-
53
- // src/integrations/keyboard.tsx
54
- var clampProgress = (progress) => {
55
- "worklet";
56
- return Math.min(1, Math.max(0, progress));
57
- };
58
- var calculateKeyboardInset = (height, safeAreaInsetBottom) => {
59
- "worklet";
60
- return Math.max(0, height - safeAreaInsetBottom);
61
- };
62
- var calculateEffectiveKeyboardHeight = (keyboardHeight, contentLength, scrollLength, alignItemsAtEnd) => {
63
- "worklet";
64
- if (alignItemsAtEnd) {
65
- return keyboardHeight;
66
- } else {
67
- const availableSpace = Math.max(0, scrollLength - contentLength);
68
- return Math.max(0, keyboardHeight - availableSpace);
69
- }
70
- };
71
- var calculateKeyboardTargetOffset = (startOffset, keyboardHeight, isOpening, progress) => {
72
- "worklet";
73
- const normalizedProgress = isOpening ? progress : 1 - progress;
74
- const delta = (isOpening ? keyboardHeight : -keyboardHeight) * normalizedProgress;
75
- return Math.max(0, startOffset + delta);
76
- };
77
- var KeyboardAvoidingLegendList = React.forwardRef(function KeyboardAvoidingLegendList2(props, forwardedRef) {
78
- const {
79
- contentContainerStyle: contentContainerStyleProp,
80
- contentInset: contentInsetProp,
81
- horizontal,
82
- onMetricsChange: onMetricsChangeProp,
83
- onScroll: onScrollProp,
84
- safeAreaInsetBottom = 0,
85
- style: styleProp,
86
- ...rest
87
- } = props;
88
- const { alignItemsAtEnd } = props;
89
- const styleFlattened = reactNative.StyleSheet.flatten(styleProp);
90
- const refLegendList = React.useRef(null);
91
- const combinedRef = useCombinedRef(forwardedRef, refLegendList);
92
- const isIos = reactNative.Platform.OS === "ios";
93
- const isAndroid = reactNative.Platform.OS === "android";
94
- const scrollViewRef = reactNativeReanimated.useAnimatedRef();
95
- const scrollOffsetY = reactNativeReanimated.useSharedValue(0);
96
- const animatedOffsetY = reactNativeReanimated.useSharedValue(null);
97
- const scrollOffsetAtKeyboardStart = reactNativeReanimated.useSharedValue(0);
98
- const mode = reactNativeReanimated.useSharedValue("idle");
99
- const keyboardInset = reactNativeReanimated.useSharedValue(0);
100
- const keyboardHeight = reactNativeReanimated.useSharedValue(0);
101
- const contentLength = reactNativeReanimated.useSharedValue(0);
102
- const scrollLength = reactNativeReanimated.useSharedValue(0);
103
- const isOpening = reactNativeReanimated.useSharedValue(false);
104
- const didInteractive = reactNativeReanimated.useSharedValue(false);
105
- const shouldUpdateAlignItemsAtEndMinSize = reactNativeReanimated.useSharedValue(false);
106
- const isKeyboardOpen = reactNativeReanimated.useSharedValue(false);
107
- const keyboardInsetRef = React.useRef(0);
108
- const [alignItemsAtEndMinSize, setAlignItemsAtEndMinSize] = React.useState(void 0);
109
- const scrollHandler = reactNativeReanimated.useAnimatedScrollHandler(
110
- (event) => {
111
- if (mode.get() !== "running" || didInteractive.get()) {
112
- scrollOffsetY.set(event.contentOffset[horizontal ? "x" : "y"]);
113
- }
114
- if (onScrollProp) {
115
- reactNativeReanimated.runOnJS(onScrollProp)(event);
116
- }
117
- },
118
- [onScrollProp, horizontal]
119
- );
120
- const setScrollProcessingEnabled = React.useCallback(
121
- (enabled) => {
122
- var _a;
123
- return (_a = refLegendList.current) == null ? void 0 : _a.setScrollProcessingEnabled(enabled);
124
- },
125
- [refLegendList]
126
- );
127
- const reportContentInset = React.useCallback(
128
- (bottom) => {
129
- var _a;
130
- return (_a = refLegendList.current) == null ? void 0 : _a.reportContentInset({ bottom });
131
- },
132
- [refLegendList]
133
- );
134
- const clearAlignItemsAtEndMinSize = React.useCallback(() => {
135
- setAlignItemsAtEndMinSize((prev) => prev === void 0 ? prev : void 0);
136
- }, []);
137
- const updateAlignItemsAtEndMinSize = React.useCallback(
138
- (nextKeyboardInset) => {
139
- var _a;
140
- if (isAndroid) {
141
- return;
142
- }
143
- if (nextKeyboardInset !== void 0) {
144
- keyboardInsetRef.current = nextKeyboardInset;
145
- }
146
- if (!alignItemsAtEnd || horizontal) {
147
- clearAlignItemsAtEndMinSize();
148
- return;
149
- }
150
- const state = (_a = refLegendList.current) == null ? void 0 : _a.getState();
151
- if (!state) {
152
- return;
153
- }
154
- const currentInset = keyboardInsetRef.current;
155
- if (currentInset <= 0) {
156
- clearAlignItemsAtEndMinSize();
157
- return;
158
- }
159
- if (state.scrollLength <= 0) {
160
- return;
161
- }
162
- const nextMinSize = Math.max(0, state.scrollLength - currentInset);
163
- setAlignItemsAtEndMinSize((prev) => prev === nextMinSize ? prev : nextMinSize);
164
- },
165
- [alignItemsAtEnd, clearAlignItemsAtEndMinSize, horizontal]
166
- );
167
- const updateScrollMetrics = React.useCallback(() => {
168
- var _a;
169
- const state = (_a = refLegendList.current) == null ? void 0 : _a.getState();
170
- if (!state) {
171
- return;
172
- }
173
- contentLength.set(state.contentLength);
174
- scrollLength.set(state.scrollLength);
175
- updateAlignItemsAtEndMinSize();
176
- }, [contentLength, scrollLength, updateAlignItemsAtEndMinSize]);
177
- const handleMetricsChange = React.useCallback(
178
- (metrics) => {
179
- updateScrollMetrics();
180
- onMetricsChangeProp == null ? void 0 : onMetricsChangeProp(metrics);
181
- },
182
- [onMetricsChangeProp, updateScrollMetrics]
183
- );
184
- React.useEffect(() => {
185
- updateAlignItemsAtEndMinSize();
186
- }, [updateAlignItemsAtEndMinSize]);
187
- reactNativeKeyboardController.useKeyboardHandler(
188
- // biome-ignore assist/source/useSortedKeys: prefer start/move/end
189
- {
190
- onStart: (event) => {
191
- "worklet";
192
- mode.set("running");
193
- const progress = clampProgress(event.progress);
194
- if (isKeyboardOpen.get() && progress >= 1 && event.height > 0) {
195
- return;
196
- }
197
- if (!didInteractive.get()) {
198
- if (event.height > 0) {
199
- keyboardHeight.set(event.height - safeAreaInsetBottom);
200
- }
201
- const vIsOpening = progress > 0;
202
- isOpening.set(vIsOpening);
203
- shouldUpdateAlignItemsAtEndMinSize.set(
204
- !!alignItemsAtEnd && !horizontal && contentLength.get() < scrollLength.get()
205
- );
206
- if (!shouldUpdateAlignItemsAtEndMinSize.get()) {
207
- reactNativeReanimated.runOnJS(clearAlignItemsAtEndMinSize)();
208
- }
209
- const vScrollOffset = scrollOffsetY.get();
210
- scrollOffsetAtKeyboardStart.set(vScrollOffset);
211
- if (isIos) {
212
- const vContentLength = contentLength.get();
213
- const vScrollLength = scrollLength.get();
214
- const vKeyboardHeight = keyboardHeight.get();
215
- const vEffectiveKeyboardHeight = calculateEffectiveKeyboardHeight(
216
- vKeyboardHeight,
217
- vContentLength,
218
- vScrollLength,
219
- alignItemsAtEnd
220
- );
221
- const targetOffset = Math.max(
222
- 0,
223
- vIsOpening ? vScrollOffset + vEffectiveKeyboardHeight : vScrollOffset - vEffectiveKeyboardHeight
224
- );
225
- scrollOffsetY.set(targetOffset);
226
- animatedOffsetY.set(targetOffset);
227
- keyboardInset.set(vEffectiveKeyboardHeight);
228
- reactNativeReanimated.runOnJS(updateAlignItemsAtEndMinSize)(vEffectiveKeyboardHeight);
229
- } else if (isAndroid) {
230
- animatedOffsetY.set(vScrollOffset);
231
- }
232
- reactNativeReanimated.runOnJS(setScrollProcessingEnabled)(false);
233
- }
234
- },
235
- onInteractive: (event) => {
236
- "worklet";
237
- if (mode.get() !== "running") {
238
- reactNativeReanimated.runOnJS(setScrollProcessingEnabled)(false);
239
- }
240
- mode.set("running");
241
- if (!didInteractive.get()) {
242
- didInteractive.set(true);
243
- }
244
- if (isAndroid && !horizontal) {
245
- const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
246
- keyboardInset.set(newInset);
247
- }
248
- if (shouldUpdateAlignItemsAtEndMinSize.get() && !horizontal && alignItemsAtEnd) {
249
- const vKeyboardHeight = calculateKeyboardInset(event.height, safeAreaInsetBottom);
250
- const vEffectiveKeyboardHeight = calculateEffectiveKeyboardHeight(
251
- vKeyboardHeight,
252
- contentLength.get(),
253
- scrollLength.get(),
254
- alignItemsAtEnd
255
- );
256
- reactNativeReanimated.runOnJS(updateAlignItemsAtEndMinSize)(vEffectiveKeyboardHeight);
257
- }
258
- },
259
- onMove: (event) => {
260
- "worklet";
261
- const vIsOpening = isOpening.get();
262
- if (isAndroid) {
263
- if (!didInteractive.get()) {
264
- const progress = clampProgress(event.progress);
265
- const vKeyboardHeight = keyboardHeight.get();
266
- const vEffectiveKeyboardHeight = calculateEffectiveKeyboardHeight(
267
- vKeyboardHeight,
268
- contentLength.get(),
269
- scrollLength.get(),
270
- alignItemsAtEnd
271
- );
272
- const targetOffset = calculateKeyboardTargetOffset(
273
- scrollOffsetAtKeyboardStart.get(),
274
- vEffectiveKeyboardHeight,
275
- vIsOpening,
276
- progress
277
- );
278
- scrollOffsetY.set(targetOffset);
279
- animatedOffsetY.set(targetOffset);
280
- }
281
- if (!horizontal) {
282
- const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
283
- keyboardInset.set(newInset);
284
- }
285
- }
286
- if (!horizontal && alignItemsAtEnd && !vIsOpening && shouldUpdateAlignItemsAtEndMinSize.get()) {
287
- const vKeyboardHeight = calculateKeyboardInset(event.height, safeAreaInsetBottom);
288
- const vEffectiveKeyboardHeight = calculateEffectiveKeyboardHeight(
289
- vKeyboardHeight,
290
- contentLength.get(),
291
- scrollLength.get(),
292
- alignItemsAtEnd
293
- );
294
- reactNativeReanimated.runOnJS(updateAlignItemsAtEndMinSize)(vEffectiveKeyboardHeight);
295
- }
296
- },
297
- onEnd: (event) => {
298
- "worklet";
299
- const wasInteractive = didInteractive.get();
300
- const vMode = mode.get();
301
- mode.set("idle");
302
- if (vMode === "running") {
303
- const progress = clampProgress(event.progress);
304
- const vKeyboardHeight = keyboardHeight.get();
305
- const vEffectiveKeyboardHeight = calculateEffectiveKeyboardHeight(
306
- vKeyboardHeight,
307
- contentLength.get(),
308
- scrollLength.get(),
309
- alignItemsAtEnd
310
- );
311
- const vIsOpening = isOpening.get();
312
- if (!wasInteractive) {
313
- const targetOffset = calculateKeyboardTargetOffset(
314
- scrollOffsetAtKeyboardStart.get(),
315
- vEffectiveKeyboardHeight,
316
- vIsOpening,
317
- progress
318
- );
319
- scrollOffsetY.set(targetOffset);
320
- animatedOffsetY.set(targetOffset);
321
- }
322
- reactNativeReanimated.runOnJS(setScrollProcessingEnabled)(true);
323
- didInteractive.set(false);
324
- isKeyboardOpen.set(event.height > 0);
325
- if (!horizontal) {
326
- const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
327
- keyboardInset.set(newInset);
328
- reactNativeReanimated.runOnJS(reportContentInset)(newInset);
329
- if (!vIsOpening) {
330
- reactNativeReanimated.runOnJS(updateAlignItemsAtEndMinSize)(newInset);
331
- }
332
- if (newInset <= 0) {
333
- animatedOffsetY.set(scrollOffsetY.get());
334
- }
335
- }
336
- }
337
- }
338
- },
339
- [alignItemsAtEnd, horizontal, safeAreaInsetBottom, scrollViewRef]
340
- );
341
- const animatedProps = reactNativeReanimated.useAnimatedProps(() => {
342
- "worklet";
343
- var _a, _b, _c, _d;
344
- const vAnimatedOffsetY = animatedOffsetY.get();
345
- const baseProps = {
346
- contentOffset: vAnimatedOffsetY === null ? void 0 : {
347
- x: 0,
348
- y: vAnimatedOffsetY
349
- }
350
- };
351
- if (isIos) {
352
- const keyboardInsetBottom = keyboardInset.get();
353
- const contentInset = {
354
- bottom: ((_a = contentInsetProp == null ? void 0 : contentInsetProp.bottom) != null ? _a : 0) + (horizontal ? 0 : keyboardInsetBottom),
355
- left: (_b = contentInsetProp == null ? void 0 : contentInsetProp.left) != null ? _b : 0,
356
- right: (_c = contentInsetProp == null ? void 0 : contentInsetProp.right) != null ? _c : 0,
357
- top: (_d = contentInsetProp == null ? void 0 : contentInsetProp.top) != null ? _d : 0
358
- };
359
- return Object.assign(baseProps, {
360
- contentInset
361
- });
362
- } else {
363
- return baseProps;
364
- }
365
- });
366
- const style = isAndroid ? reactNativeReanimated.useAnimatedStyle(
367
- () => ({
368
- ...styleFlattened || {},
369
- marginBottom: keyboardInset.get()
370
- }),
371
- [styleProp, keyboardInset]
372
- ) : void 0;
373
- const contentContainerStyle = React.useMemo(() => {
374
- if (alignItemsAtEndMinSize === void 0) {
375
- return contentContainerStyleProp;
376
- }
377
- const minSizeStyle = horizontal ? { minWidth: alignItemsAtEndMinSize } : { minHeight: alignItemsAtEndMinSize };
378
- return contentContainerStyleProp ? [contentContainerStyleProp, minSizeStyle] : minSizeStyle;
379
- }, [alignItemsAtEndMinSize, contentContainerStyleProp, horizontal]);
380
- return /* @__PURE__ */ React__namespace.createElement(
381
- reanimated.AnimatedLegendList,
382
- {
383
- ...rest,
384
- animatedProps,
385
- automaticallyAdjustContentInsets: false,
386
- contentContainerStyle,
387
- keyboardDismissMode: "interactive",
388
- onMetricsChange: handleMetricsChange,
389
- onScroll: scrollHandler,
390
- ref: combinedRef,
391
- refScrollView: scrollViewRef,
392
- scrollIndicatorInsets: { bottom: 0, top: 0 },
393
- style
394
- }
395
- );
396
- });
397
-
398
- exports.KeyboardAvoidingLegendList = KeyboardAvoidingLegendList;
399
- exports.LegendList = KeyboardAvoidingLegendList;