@legendapp/list 3.0.0-beta.9 → 3.0.1

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 (48) hide show
  1. package/.DS_Store +0 -0
  2. package/CHANGELOG.md +27 -1
  3. package/README.md +8 -2
  4. package/animated.d.ts +659 -5
  5. package/animated.js +2 -2
  6. package/animated.mjs +1 -1
  7. package/keyboard-legacy.d.ts +226 -0
  8. package/keyboard-legacy.js +456 -0
  9. package/keyboard-legacy.mjs +435 -0
  10. package/keyboard.d.ts +261 -9
  11. package/keyboard.js +114 -135
  12. package/keyboard.mjs +115 -137
  13. package/package.json +55 -5
  14. package/{types-1Hgg1rTO.d.mts → react-native.d.ts} +269 -284
  15. package/react-native.js +6471 -0
  16. package/react-native.mjs +6442 -0
  17. package/{types-1Hgg1rTO.d.ts → react-native.web.d.ts} +330 -283
  18. package/react-native.web.js +7125 -0
  19. package/react-native.web.mjs +7096 -0
  20. package/react.d.ts +771 -0
  21. package/react.js +7125 -0
  22. package/react.mjs +7096 -0
  23. package/reanimated.d.ts +681 -8
  24. package/reanimated.js +225 -38
  25. package/reanimated.mjs +227 -40
  26. package/section-list.d.ts +682 -7
  27. package/section-list.js +85 -3854
  28. package/section-list.mjs +83 -3853
  29. package/animated.d.mts +0 -9
  30. package/index.d.mts +0 -23
  31. package/index.d.ts +0 -23
  32. package/index.js +0 -3935
  33. package/index.mjs +0 -3907
  34. package/index.native.d.mts +0 -23
  35. package/index.native.d.ts +0 -23
  36. package/index.native.js +0 -3739
  37. package/index.native.mjs +0 -3711
  38. package/keyboard-controller.d.mts +0 -12
  39. package/keyboard-controller.d.ts +0 -12
  40. package/keyboard-controller.js +0 -69
  41. package/keyboard-controller.mjs +0 -48
  42. package/keyboard.d.mts +0 -13
  43. package/reanimated.d.mts +0 -18
  44. package/section-list.d.mts +0 -113
  45. package/section-list.native.d.mts +0 -113
  46. package/section-list.native.d.ts +0 -113
  47. package/section-list.native.js +0 -3897
  48. package/section-list.native.mjs +0 -3876
package/keyboard.d.ts CHANGED
@@ -1,13 +1,265 @@
1
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';
2
+ import { ScrollViewComponent, ScrollResponderMixin, Insets as Insets$1, ScrollViewProps, View, LayoutChangeEvent } from 'react-native';
3
+ import { KeyboardChatScrollViewProps } from 'react-native-keyboard-controller';
4
+ import { SharedValue } from 'react-native-reanimated';
5
5
  import { AnimatedLegendListProps } from '@legendapp/list/reanimated';
6
6
 
7
- declare const KeyboardAvoidingLegendList: <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "onScroll" | "contentInset"> & {
8
- onScroll?: (event: ReanimatedScrollEvent) => void;
9
- contentInset?: Insets | undefined;
10
- safeAreaInsetBottom?: number;
11
- } & React.RefAttributes<LegendListRef>) => React.ReactNode;
7
+ interface MaintainVisibleContentPositionNormalized<ItemT = any> {
8
+ data: boolean;
9
+ size: boolean;
10
+ shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
11
+ }
12
12
 
13
- export { KeyboardAvoidingLegendList, KeyboardAvoidingLegendList as LegendList };
13
+ 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}`;
14
+ type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
15
+ type ListenerTypeValueMap = {
16
+ activeStickyIndex: number;
17
+ anchoredEndSpaceSize: number;
18
+ animatedScrollY: any;
19
+ debugComputedScroll: number;
20
+ debugRawScroll: number;
21
+ extraData: any;
22
+ footerSize: number;
23
+ headerSize: number;
24
+ isAtEnd: boolean;
25
+ isAtStart: boolean;
26
+ isNearEnd: boolean;
27
+ isNearStart: boolean;
28
+ isWithinMaintainScrollAtEndThreshold: boolean;
29
+ lastItemKeys: string[];
30
+ lastPositionUpdate: number;
31
+ maintainVisibleContentPosition: MaintainVisibleContentPositionNormalized;
32
+ numColumns: number;
33
+ numContainers: number;
34
+ numContainersPooled: number;
35
+ otherAxisSize: number;
36
+ readyToRender: boolean;
37
+ scrollAdjust: number;
38
+ scrollAdjustPending: number;
39
+ scrollAdjustUserOffset: number;
40
+ scrollSize: {
41
+ width: number;
42
+ height: number;
43
+ };
44
+ snapToOffsets: number[];
45
+ stylePaddingTop: number;
46
+ totalSize: number;
47
+ } & {
48
+ [K in ListenerType as K extends `containerItemKey${number}` ? K : never]: string;
49
+ } & {
50
+ [K in ListenerType as K extends `containerItemData${number}` ? K : never]: any;
51
+ } & {
52
+ [K in ListenerType as K extends `containerPosition${number}` ? K : never]: number;
53
+ } & {
54
+ [K in ListenerType as K extends `containerColumn${number}` ? K : never]: number;
55
+ } & {
56
+ [K in ListenerType as K extends `containerSpan${number}` ? K : never]: number;
57
+ } & {
58
+ [K in ListenerType as K extends `containerSticky${number}` ? K : never]: boolean;
59
+ };
60
+
61
+ interface Insets {
62
+ top: number;
63
+ left: number;
64
+ bottom: number;
65
+ right: number;
66
+ }
67
+ interface AnchoredEndSpaceConfig$1 {
68
+ anchorIndex: number;
69
+ anchorOffset?: number;
70
+ anchorMaxSize?: number;
71
+ includeInEndInset?: boolean;
72
+ onSizeChanged?: (size: number) => void;
73
+ }
74
+ interface LegendListAverageItemSize {
75
+ average: number;
76
+ count: number;
77
+ }
78
+ type LegendListState = {
79
+ activeStickyIndex: number;
80
+ contentLength: number;
81
+ data: readonly any[];
82
+ elementAtIndex: (index: number) => any;
83
+ end: number;
84
+ endBuffered: number;
85
+ isAtEnd: boolean;
86
+ isAtStart: boolean;
87
+ isNearEnd: boolean;
88
+ isNearStart: boolean;
89
+ isEndReached: boolean;
90
+ isStartReached: boolean;
91
+ isWithinMaintainScrollAtEndThreshold: boolean;
92
+ getAverageItemSizes: () => Record<string, LegendListAverageItemSize>;
93
+ listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
94
+ listenToPosition: (key: string, callback: (value: number) => void) => () => void;
95
+ positionAtIndex: (index: number) => number;
96
+ positionByKey: (key: string) => number | undefined;
97
+ scroll: number;
98
+ scrollLength: number;
99
+ scrollVelocity: number;
100
+ sizeAtIndex: (index: number) => number;
101
+ sizes: Map<string, number>;
102
+ start: number;
103
+ startBuffered: number;
104
+ };
105
+ type LegendListRef$1 = {
106
+ /**
107
+ * Displays the scroll indicators momentarily.
108
+ */
109
+ flashScrollIndicators(): void;
110
+ /**
111
+ * Returns the native ScrollView component reference.
112
+ */
113
+ getNativeScrollRef(): any;
114
+ /**
115
+ * Returns the scroll responder instance for handling scroll events.
116
+ */
117
+ getScrollableNode(): any;
118
+ /**
119
+ * Returns the ScrollResponderMixin for advanced scroll handling.
120
+ */
121
+ getScrollResponder(): any;
122
+ /**
123
+ * Returns the internal state of the scroll virtualization.
124
+ */
125
+ getState(): LegendListState;
126
+ /**
127
+ * Scrolls a specific index into view.
128
+ * @param params - Parameters for scrolling.
129
+ * @param params.animated - If true, animates the scroll. Default: true.
130
+ * @param params.index - The index to scroll to.
131
+ */
132
+ scrollIndexIntoView(params: {
133
+ animated?: boolean | undefined;
134
+ index: number;
135
+ }): Promise<void>;
136
+ /**
137
+ * Scrolls a specific index into view.
138
+ * @param params - Parameters for scrolling.
139
+ * @param params.animated - If true, animates the scroll. Default: true.
140
+ * @param params.item - The item to scroll to.
141
+ */
142
+ scrollItemIntoView(params: {
143
+ animated?: boolean | undefined;
144
+ item: any;
145
+ }): Promise<void>;
146
+ /**
147
+ * Scrolls to the end of the list.
148
+ * @param options - Options for scrolling.
149
+ * @param options.animated - If true, animates the scroll. Default: true.
150
+ * @param options.viewOffset - Offset from the target position.
151
+ */
152
+ scrollToEnd(options?: {
153
+ animated?: boolean | undefined;
154
+ viewOffset?: number | undefined;
155
+ }): Promise<void>;
156
+ /**
157
+ * Scrolls to a specific index in the list.
158
+ * @param params - Parameters for scrolling.
159
+ * @param params.animated - If true, animates the scroll. Default: true.
160
+ * @param params.index - The index to scroll to.
161
+ * @param params.viewOffset - Offset from the target position.
162
+ * @param params.viewPosition - Position of the item in the viewport (0 to 1).
163
+ */
164
+ scrollToIndex(params: {
165
+ animated?: boolean | undefined;
166
+ index: number;
167
+ viewOffset?: number | undefined;
168
+ viewPosition?: number | undefined;
169
+ }): Promise<void>;
170
+ /**
171
+ * Scrolls to a specific item in the list.
172
+ * @param params - Parameters for scrolling.
173
+ * @param params.animated - If true, animates the scroll. Default: true.
174
+ * @param params.item - The item to scroll to.
175
+ * @param params.viewOffset - Offset from the target position.
176
+ * @param params.viewPosition - Position of the item in the viewport (0 to 1).
177
+ */
178
+ scrollToItem(params: {
179
+ animated?: boolean | undefined;
180
+ item: any;
181
+ viewOffset?: number | undefined;
182
+ viewPosition?: number | undefined;
183
+ }): Promise<void>;
184
+ /**
185
+ * Scrolls to a specific offset in pixels.
186
+ * @param params - Parameters for scrolling.
187
+ * @param params.offset - The pixel offset to scroll to.
188
+ * @param params.animated - If true, animates the scroll. Default: true.
189
+ */
190
+ scrollToOffset(params: {
191
+ offset: number;
192
+ animated?: boolean | undefined;
193
+ }): Promise<void>;
194
+ /**
195
+ * Sets or adds to the offset of the visible content anchor.
196
+ * @param value - The offset to set or add.
197
+ * @param animated - If true, uses Animated to animate the change.
198
+ */
199
+ setVisibleContentAnchorOffset(value: number | ((val: number) => number)): void;
200
+ /**
201
+ * Sets whether scroll processing is enabled.
202
+ * @param enabled - If true, scroll processing is enabled.
203
+ */
204
+ setScrollProcessingEnabled(enabled: boolean): void;
205
+ /**
206
+ * Clears internal virtualization caches.
207
+ * @param options - Cache clearing options.
208
+ * @param options.mode - `sizes` clears measurement caches. `full` also clears key/position caches.
209
+ */
210
+ clearCaches(options?: {
211
+ mode?: "sizes" | "full";
212
+ }): void;
213
+ /**
214
+ * Reports an externally measured content inset. Pass null/undefined to clear.
215
+ * Values are merged on top of props/animated/native insets.
216
+ */
217
+ reportContentInset(inset?: Partial<Insets> | null): void;
218
+ };
219
+
220
+ interface AnchoredEndSpaceConfig extends Omit<AnchoredEndSpaceConfig$1, "includeInEndInset"> {
221
+ }
222
+
223
+ type LegendListRef = Omit<LegendListRef$1, "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
224
+ getNativeScrollRef(): React.ElementRef<typeof ScrollViewComponent>;
225
+ getScrollResponder(): ScrollResponderMixin;
226
+ reportContentInset(inset?: Partial<Insets$1> | null): void;
227
+ };
228
+
229
+ type KeyboardChatScrollViewPropsUnique = Omit<KeyboardChatScrollViewProps, keyof ScrollViewProps | "inverted" | "ScrollViewComponent" | "blankSpace" | "extraContentPadding" | "onContentInsetChange" | "offset">;
230
+ type ScrollMessageToEndOptions = {
231
+ animated: boolean;
232
+ closeKeyboard: boolean;
233
+ };
234
+ type KeyboardScrollToEndListRef = {
235
+ current: {
236
+ scrollToEnd(params?: {
237
+ animated?: boolean;
238
+ }): Promise<void>;
239
+ } | null;
240
+ };
241
+ type UseKeyboardScrollToEndOptions = {
242
+ freeze?: SharedValue<boolean>;
243
+ listRef: KeyboardScrollToEndListRef;
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
+ };
255
+ declare function useKeyboardScrollToEnd({ freeze: freezeProp, listRef }: UseKeyboardScrollToEndOptions): {
256
+ freeze: SharedValue<boolean>;
257
+ scrollMessageToEnd: ({ animated, closeKeyboard }: ScrollMessageToEndOptions) => Promise<void>;
258
+ };
259
+ declare const KeyboardAwareLegendList: <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "anchoredEndSpace" | "contentInsetEndAdjustment" | "renderScrollComponent"> & KeyboardChatScrollViewPropsUnique & {
260
+ anchoredEndSpace?: AnchoredEndSpaceConfig;
261
+ contentInsetEndAdjustment?: SharedValue<number>;
262
+ keyboardOffset?: number;
263
+ } & React.RefAttributes<LegendListRef>) => React.ReactElement | null;
264
+
265
+ export { KeyboardAwareLegendList, useKeyboardChatComposerInset, useKeyboardScrollToEnd };
package/keyboard.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
- var reactNative = require('react-native');
5
4
  var reactNativeKeyboardController = require('react-native-keyboard-controller');
6
5
  var reactNativeReanimated = require('react-native-reanimated');
6
+ var reactNative = require('@legendapp/list/react-native');
7
7
  var reanimated = require('@legendapp/list/reanimated');
8
8
 
9
9
  function _interopNamespace(e) {
@@ -27,156 +27,135 @@ function _interopNamespace(e) {
27
27
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
28
28
 
29
29
  // src/integrations/keyboard.tsx
30
-
31
- // src/utils/helpers.ts
32
- function isFunction(obj) {
33
- return typeof obj === "function";
30
+ var { typedForwardRef, useCombinedRef } = reactNative.internal;
31
+ if (typeof __DEV__ !== "undefined" && __DEV__ && !reactNativeKeyboardController.KeyboardChatScrollView) {
32
+ console.warn(
33
+ "[legend-list] KeyboardAwareLegendList requires a recent react-native-keyboard-controller with KeyboardChatScrollView. Please upgrade react-native-keyboard-controller to at least 1.21.7."
34
+ );
34
35
  }
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;
36
+ function useKeyboardChatComposerInset(listRef, composerRef, initialHeight = 0) {
37
+ const contentInsetEndAdjustment = reactNativeReanimated.useSharedValue(initialHeight);
38
+ const lastHeightRef = React.useRef(void 0);
39
+ const reportHeight = React.useCallback(
40
+ (height) => {
41
+ var _a;
42
+ if (Number.isFinite(height) && height !== lastHeightRef.current) {
43
+ lastHeightRef.current = height;
44
+ contentInsetEndAdjustment.value = height;
45
+ (_a = listRef.current) == null ? void 0 : _a.reportContentInset({ bottom: height });
42
46
  }
43
- if (isFunction(ref)) {
44
- ref(element);
45
- } else {
46
- ref.current = element;
47
+ },
48
+ [contentInsetEndAdjustment, listRef]
49
+ );
50
+ React.useLayoutEffect(() => {
51
+ var _a;
52
+ (_a = composerRef.current) == null ? void 0 : _a.measure((_x, _y, _width, height) => {
53
+ reportHeight(height);
54
+ });
55
+ }, [composerRef, reportHeight]);
56
+ const onComposerLayout = React.useCallback(
57
+ (event) => {
58
+ reportHeight(event.nativeEvent.layout.height);
59
+ },
60
+ [reportHeight]
61
+ );
62
+ return { contentInsetEndAdjustment, onComposerLayout };
63
+ }
64
+ function useKeyboardScrollToEnd({ freeze: freezeProp, listRef }) {
65
+ const internalFreeze = reactNativeReanimated.useSharedValue(false);
66
+ const freeze = freezeProp != null ? freezeProp : internalFreeze;
67
+ const scrollMessageToEnd = React.useCallback(
68
+ async ({ animated, closeKeyboard }) => {
69
+ const listRefCurrent = listRef.current;
70
+ if (listRefCurrent) {
71
+ freeze.set(true);
72
+ const dismissPromise = closeKeyboard && reactNativeKeyboardController.KeyboardController.dismiss();
73
+ const scrollPromise = listRefCurrent.scrollToEnd({ animated });
74
+ await Promise.all([scrollPromise, dismissPromise]);
75
+ freeze.set(false);
47
76
  }
48
- }
49
- }, refs);
50
- return callback;
51
- };
52
-
53
- // src/integrations/keyboard.tsx
54
- var KeyboardAvoidingLegendList = React.forwardRef(function KeyboardAvoidingLegendList2(props, forwardedRef) {
77
+ },
78
+ [freeze, listRef]
79
+ );
80
+ return {
81
+ freeze,
82
+ scrollMessageToEnd
83
+ };
84
+ }
85
+ var KeyboardAwareLegendList = typedForwardRef(function KeyboardAwareLegendList2(props, forwardedRef) {
55
86
  const {
56
- contentInset: contentInsetProp,
57
- horizontal,
58
- onScroll: onScrollProp,
59
- safeAreaInsetBottom = 0,
87
+ anchoredEndSpace,
88
+ applyWorkaroundForContentInsetHitTestBug,
89
+ contentInsetEndAdjustment,
90
+ freeze,
91
+ keyboardLiftBehavior,
92
+ keyboardOffset,
60
93
  ...rest
61
94
  } = props;
62
95
  const refLegendList = React.useRef(null);
63
96
  const combinedRef = useCombinedRef(forwardedRef, refLegendList);
64
- const scrollViewRef = reactNativeReanimated.useAnimatedRef();
65
- const scrollOffsetY = reactNativeReanimated.useSharedValue(0);
66
- const animatedOffsetY = reactNativeReanimated.useSharedValue(null);
67
- const scrollOffsetAtKeyboardStart = reactNativeReanimated.useSharedValue(0);
68
- const keyboardInset = reactNativeReanimated.useSharedValue(0);
69
- const keyboardHeight = reactNativeReanimated.useSharedValue(0);
70
- const isOpening = reactNativeReanimated.useSharedValue(false);
71
- const didInteractive = reactNativeReanimated.useSharedValue(false);
72
- const scrollHandler = reactNativeReanimated.useAnimatedScrollHandler(
73
- (event) => {
74
- scrollOffsetY.value = event.contentOffset[horizontal ? "x" : "y"];
75
- if (onScrollProp) {
76
- reactNativeReanimated.runOnJS(onScrollProp)(event);
97
+ const blankSpace = reactNativeReanimated.useSharedValue(0);
98
+ React.useEffect(() => {
99
+ if (!anchoredEndSpace) {
100
+ blankSpace.value = 0;
101
+ }
102
+ }, [anchoredEndSpace, blankSpace]);
103
+ const anchoredEndSpaceWithBlankSpace = React.useMemo(() => {
104
+ if (!anchoredEndSpace) {
105
+ return void 0;
106
+ }
107
+ return {
108
+ ...anchoredEndSpace,
109
+ includeInEndInset: true,
110
+ onSizeChanged: (size) => {
111
+ var _a;
112
+ blankSpace.value = size;
113
+ (_a = anchoredEndSpace.onSizeChanged) == null ? void 0 : _a.call(anchoredEndSpace, size);
77
114
  }
78
- },
79
- [onScrollProp, horizontal]
80
- );
81
- const setScrollProcessingEnabled = React.useCallback(
82
- (enabled) => {
83
- var _a;
84
- (_a = refLegendList.current) == null ? void 0 : _a.setScrollProcessingEnabled(enabled);
85
- },
86
- [refLegendList]
87
- );
88
- reactNativeKeyboardController.useKeyboardHandler(
89
- // biome-ignore assist/source/useSortedKeys: prefer start/move/end
90
- {
91
- onStart: (event) => {
92
- "worklet";
93
- if (!didInteractive.get()) {
94
- if (event.height > 0) {
95
- keyboardHeight.set(event.height - safeAreaInsetBottom);
96
- }
97
- isOpening.set(event.progress > 0);
98
- scrollOffsetAtKeyboardStart.value = scrollOffsetY.value;
99
- animatedOffsetY.set(scrollOffsetY.value);
100
- reactNativeReanimated.runOnJS(setScrollProcessingEnabled)(false);
101
- }
102
- },
103
- onInteractive: () => {
104
- "worklet";
105
- if (!didInteractive.get()) {
106
- didInteractive.set(true);
107
- }
108
- },
109
- onMove: (event) => {
110
- "worklet";
111
- if (!didInteractive.get()) {
112
- const vIsOpening = isOpening.get();
113
- const vKeyboardHeight = keyboardHeight.get();
114
- const vProgress = vIsOpening ? event.progress : 1 - event.progress;
115
- const targetOffset = scrollOffsetAtKeyboardStart.value + (vIsOpening ? vKeyboardHeight : -vKeyboardHeight) * vProgress;
116
- scrollOffsetY.value = targetOffset;
117
- animatedOffsetY.set(targetOffset);
118
- if (!horizontal) {
119
- keyboardInset.value = Math.max(0, event.height - safeAreaInsetBottom);
120
- }
121
- }
122
- },
123
- onEnd: (event) => {
124
- "worklet";
125
- const wasInteractive = didInteractive.get();
126
- if (wasInteractive && event.progress === 0 && event.target > 0) {
127
- return;
128
- }
129
- if (!wasInteractive) {
130
- const vIsOpening = isOpening.get();
131
- const vKeyboardHeight = keyboardHeight.get();
132
- const targetOffset = scrollOffsetAtKeyboardStart.value + (vIsOpening ? vKeyboardHeight : -vKeyboardHeight) * (vIsOpening ? event.progress : 1 - event.progress);
133
- scrollOffsetY.value = targetOffset;
134
- animatedOffsetY.set(targetOffset);
135
- reactNativeReanimated.runOnJS(setScrollProcessingEnabled)(true);
136
- }
137
- didInteractive.set(false);
138
- if (!horizontal) {
139
- keyboardInset.value = Math.max(0, event.height - safeAreaInsetBottom);
115
+ };
116
+ }, [anchoredEndSpace, blankSpace]);
117
+ const onContentInsetChange = React.useCallback((insets) => {
118
+ var _a;
119
+ (_a = refLegendList.current) == null ? void 0 : _a.reportContentInset(insets);
120
+ }, []);
121
+ const memoList = React.useCallback(
122
+ (scrollProps) => {
123
+ return /* @__PURE__ */ React__namespace.createElement(
124
+ reactNativeKeyboardController.KeyboardChatScrollView,
125
+ {
126
+ ...scrollProps,
127
+ applyWorkaroundForContentInsetHitTestBug,
128
+ blankSpace,
129
+ extraContentPadding: contentInsetEndAdjustment,
130
+ freeze,
131
+ keyboardLiftBehavior,
132
+ offset: keyboardOffset,
133
+ onContentInsetChange
140
134
  }
141
- }
135
+ );
142
136
  },
143
- [scrollViewRef, safeAreaInsetBottom]
137
+ [
138
+ applyWorkaroundForContentInsetHitTestBug,
139
+ blankSpace,
140
+ contentInsetEndAdjustment,
141
+ freeze,
142
+ keyboardLiftBehavior,
143
+ keyboardOffset,
144
+ onContentInsetChange
145
+ ]
144
146
  );
145
- const animatedProps = reactNativeReanimated.useAnimatedProps(() => {
146
- "worklet";
147
- var _a, _b, _c, _d;
148
- const baseProps = {
149
- contentOffset: animatedOffsetY.value === null ? void 0 : {
150
- x: 0,
151
- y: animatedOffsetY.value
152
- }
153
- };
154
- return reactNative.Platform.OS === "ios" ? Object.assign(baseProps, {
155
- contentInset: {
156
- bottom: ((_a = contentInsetProp == null ? void 0 : contentInsetProp.bottom) != null ? _a : 0) + (horizontal ? 0 : keyboardInset.value),
157
- left: (_b = contentInsetProp == null ? void 0 : contentInsetProp.left) != null ? _b : 0,
158
- right: (_c = contentInsetProp == null ? void 0 : contentInsetProp.right) != null ? _c : 0,
159
- top: (_d = contentInsetProp == null ? void 0 : contentInsetProp.top) != null ? _d : 0
160
- }
161
- }) : baseProps;
162
- });
163
- const style = reactNative.Platform.OS !== "ios" ? reactNativeReanimated.useAnimatedStyle(() => ({
164
- marginBottom: keyboardInset.value
165
- })) : void 0;
147
+ const AnimatedLegendListInternal = reanimated.AnimatedLegendList;
166
148
  return /* @__PURE__ */ React__namespace.createElement(
167
- reanimated.AnimatedLegendList,
149
+ AnimatedLegendListInternal,
168
150
  {
169
- ...rest,
170
- animatedProps,
171
- keyboardDismissMode: "interactive",
172
- onScroll: scrollHandler,
151
+ anchoredEndSpace: anchoredEndSpaceWithBlankSpace,
173
152
  ref: combinedRef,
174
- refScrollView: scrollViewRef,
175
- scrollIndicatorInsets: { bottom: 0, top: 0 },
176
- style
153
+ renderScrollComponent: memoList,
154
+ ...rest
177
155
  }
178
156
  );
179
157
  });
180
158
 
181
- exports.KeyboardAvoidingLegendList = KeyboardAvoidingLegendList;
182
- exports.LegendList = KeyboardAvoidingLegendList;
159
+ exports.KeyboardAwareLegendList = KeyboardAwareLegendList;
160
+ exports.useKeyboardChatComposerInset = useKeyboardChatComposerInset;
161
+ exports.useKeyboardScrollToEnd = useKeyboardScrollToEnd;