@legendapp/list 1.0.0-beta.42 → 1.0.0-beta.44
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.mts +1 -1
- package/animated.d.ts +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +112 -84
- package/index.mjs +112 -84
- package/keyboard-controller.js +5 -2
- package/keyboard-controller.mjs +5 -2
- package/package.json +1 -1
package/animated.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _legendapp_list from '@legendapp/list';
|
|
|
3
3
|
import * as react_native from 'react-native';
|
|
4
4
|
import { Animated } from 'react-native';
|
|
5
5
|
|
|
6
|
-
declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<react_native.ScrollViewProps, "
|
|
6
|
+
declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<react_native.ScrollViewProps, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
7
7
|
alignItemsAtEnd?: boolean;
|
|
8
8
|
columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
|
|
9
9
|
data: readonly T[];
|
package/animated.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _legendapp_list from '@legendapp/list';
|
|
|
3
3
|
import * as react_native from 'react-native';
|
|
4
4
|
import { Animated } from 'react-native';
|
|
5
5
|
|
|
6
|
-
declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<react_native.ScrollViewProps, "
|
|
6
|
+
declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<react_native.ScrollViewProps, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
7
7
|
alignItemsAtEnd?: boolean;
|
|
8
8
|
columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
|
|
9
9
|
data: readonly T[];
|
package/index.d.mts
CHANGED
|
@@ -453,7 +453,7 @@ type TypedMemo = <T extends React.ComponentType<any>>(Component: T, propsAreEqua
|
|
|
453
453
|
};
|
|
454
454
|
declare const typedMemo: TypedMemo;
|
|
455
455
|
|
|
456
|
-
declare const LegendList: <T>(props: Omit<react_native.ScrollViewProps, "
|
|
456
|
+
declare const LegendList: <T>(props: Omit<react_native.ScrollViewProps, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
457
457
|
alignItemsAtEnd?: boolean;
|
|
458
458
|
columnWrapperStyle?: ColumnWrapperStyle;
|
|
459
459
|
data: readonly T[];
|
|
@@ -505,7 +505,7 @@ declare const LegendList: <T>(props: Omit<react_native.ScrollViewProps, "maintai
|
|
|
505
505
|
waitForInitialLayout?: boolean;
|
|
506
506
|
} & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode;
|
|
507
507
|
|
|
508
|
-
declare function useViewability(
|
|
508
|
+
declare function useViewability(callback: ViewabilityCallback, configId?: string): void;
|
|
509
509
|
declare function useViewabilityAmount(callback: ViewabilityAmountCallback): void;
|
|
510
510
|
declare function useRecyclingEffect(effect: (info: LegendListRecyclingState<unknown>) => void | (() => void)): void;
|
|
511
511
|
declare function useRecyclingState(valueOrFun: ((info: LegendListRecyclingState<unknown>) => any) | any): [any, React$1.Dispatch<any>];
|
package/index.d.ts
CHANGED
|
@@ -453,7 +453,7 @@ type TypedMemo = <T extends React.ComponentType<any>>(Component: T, propsAreEqua
|
|
|
453
453
|
};
|
|
454
454
|
declare const typedMemo: TypedMemo;
|
|
455
455
|
|
|
456
|
-
declare const LegendList: <T>(props: Omit<react_native.ScrollViewProps, "
|
|
456
|
+
declare const LegendList: <T>(props: Omit<react_native.ScrollViewProps, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
457
457
|
alignItemsAtEnd?: boolean;
|
|
458
458
|
columnWrapperStyle?: ColumnWrapperStyle;
|
|
459
459
|
data: readonly T[];
|
|
@@ -505,7 +505,7 @@ declare const LegendList: <T>(props: Omit<react_native.ScrollViewProps, "maintai
|
|
|
505
505
|
waitForInitialLayout?: boolean;
|
|
506
506
|
} & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode;
|
|
507
507
|
|
|
508
|
-
declare function useViewability(
|
|
508
|
+
declare function useViewability(callback: ViewabilityCallback, configId?: string): void;
|
|
509
509
|
declare function useViewabilityAmount(callback: ViewabilityAmountCallback): void;
|
|
510
510
|
declare function useRecyclingEffect(effect: (info: LegendListRecyclingState<unknown>) => void | (() => void)): void;
|
|
511
511
|
declare function useRecyclingState(valueOrFun: ((info: LegendListRecyclingState<unknown>) => any) | any): [any, React$1.Dispatch<any>];
|
package/index.js
CHANGED
|
@@ -28,7 +28,12 @@ var ContextState = React6__namespace.createContext(null);
|
|
|
28
28
|
function StateProvider({ children }) {
|
|
29
29
|
const [value] = React6__namespace.useState(() => ({
|
|
30
30
|
listeners: /* @__PURE__ */ new Map(),
|
|
31
|
-
values: /* @__PURE__ */ new Map(
|
|
31
|
+
values: /* @__PURE__ */ new Map([
|
|
32
|
+
["paddingTop", 0],
|
|
33
|
+
["alignItemsPaddingTop", 0],
|
|
34
|
+
["stylePaddingTop", 0],
|
|
35
|
+
["headerSize", 0]
|
|
36
|
+
]),
|
|
32
37
|
mapViewabilityCallbacks: /* @__PURE__ */ new Map(),
|
|
33
38
|
mapViewabilityValues: /* @__PURE__ */ new Map(),
|
|
34
39
|
mapViewabilityAmountCallbacks: /* @__PURE__ */ new Map(),
|
|
@@ -149,10 +154,10 @@ function useInit(cb) {
|
|
|
149
154
|
|
|
150
155
|
// src/ContextContainer.ts
|
|
151
156
|
var ContextContainer = React6.createContext(null);
|
|
152
|
-
function useViewability(
|
|
157
|
+
function useViewability(callback, configId) {
|
|
153
158
|
const ctx = useStateContext();
|
|
154
159
|
const { containerId } = React6.useContext(ContextContainer);
|
|
155
|
-
const key = containerId + configId;
|
|
160
|
+
const key = containerId + (configId != null ? configId : "");
|
|
156
161
|
useInit(() => {
|
|
157
162
|
const value = ctx.mapViewabilityValues.get(key);
|
|
158
163
|
if (value) {
|
|
@@ -262,13 +267,20 @@ var Container = ({
|
|
|
262
267
|
const refLastSize = React6.useRef();
|
|
263
268
|
const otherAxisPos = numColumns > 1 ? `${(column - 1) / numColumns * 100}%` : 0;
|
|
264
269
|
const otherAxisSize = numColumns > 1 ? `${1 / numColumns * 100}%` : void 0;
|
|
265
|
-
let
|
|
270
|
+
let paddingStyles;
|
|
266
271
|
if (columnWrapperStyle) {
|
|
267
272
|
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
273
|
+
if (horizontal) {
|
|
274
|
+
paddingStyles = {
|
|
275
|
+
paddingRight: !lastItemKeys.includes(itemKey) ? columnGap || gap || void 0 : void 0,
|
|
276
|
+
paddingVertical: (rowGap || gap || 0) / 2
|
|
277
|
+
};
|
|
278
|
+
} else {
|
|
279
|
+
paddingStyles = {
|
|
280
|
+
paddingBottom: !lastItemKeys.includes(itemKey) ? rowGap || gap || void 0 : void 0,
|
|
281
|
+
paddingHorizontal: (columnGap || gap || 0) / 2
|
|
282
|
+
};
|
|
283
|
+
}
|
|
272
284
|
}
|
|
273
285
|
const style = horizontal ? {
|
|
274
286
|
flexDirection: ItemSeparatorComponent ? "row" : void 0,
|
|
@@ -276,14 +288,15 @@ var Container = ({
|
|
|
276
288
|
top: otherAxisPos,
|
|
277
289
|
bottom: numColumns > 1 ? null : 0,
|
|
278
290
|
height: otherAxisSize,
|
|
279
|
-
left: position.relativeCoordinate
|
|
291
|
+
left: position.relativeCoordinate,
|
|
292
|
+
...paddingStyles || {}
|
|
280
293
|
} : {
|
|
281
294
|
position: "absolute",
|
|
282
295
|
left: otherAxisPos,
|
|
283
296
|
right: numColumns > 1 ? null : 0,
|
|
284
297
|
width: otherAxisSize,
|
|
285
298
|
top: position.relativeCoordinate,
|
|
286
|
-
...
|
|
299
|
+
...paddingStyles || {}
|
|
287
300
|
};
|
|
288
301
|
const renderedItemInfo = React6.useMemo(
|
|
289
302
|
() => itemKey !== void 0 ? getRenderedItem(itemKey) : null,
|
|
@@ -381,7 +394,7 @@ var Containers = typedMemo(function Containers2({
|
|
|
381
394
|
}) {
|
|
382
395
|
const ctx = useStateContext();
|
|
383
396
|
const columnWrapperStyle = ctx.columnWrapperStyle;
|
|
384
|
-
|
|
397
|
+
use$("numColumns");
|
|
385
398
|
const numContainers = use$("numContainersPooled");
|
|
386
399
|
const animSize = useValue$(
|
|
387
400
|
"totalSizeWithScrollAdjust",
|
|
@@ -408,11 +421,18 @@ var Containers = typedMemo(function Containers2({
|
|
|
408
421
|
);
|
|
409
422
|
}
|
|
410
423
|
const style = horizontal ? { width: animSize, opacity: animOpacity } : { height: animSize, opacity: animOpacity };
|
|
411
|
-
if (columnWrapperStyle
|
|
424
|
+
if (columnWrapperStyle) {
|
|
412
425
|
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
426
|
+
if (horizontal) {
|
|
427
|
+
const my = (rowGap || gap || 0) / 2;
|
|
428
|
+
if (my) {
|
|
429
|
+
style.marginVertical = -my;
|
|
430
|
+
}
|
|
431
|
+
} else {
|
|
432
|
+
const mx = (columnGap || gap || 0) / 2;
|
|
433
|
+
if (mx) {
|
|
434
|
+
style.marginHorizontal = -mx;
|
|
435
|
+
}
|
|
416
436
|
}
|
|
417
437
|
}
|
|
418
438
|
return /* @__PURE__ */ React6__namespace.createElement(reactNative.Animated.View, { style }, containers);
|
|
@@ -837,7 +857,6 @@ var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
|
|
|
837
857
|
return /* @__PURE__ */ React6__namespace.createElement(StateProvider, null, /* @__PURE__ */ React6__namespace.createElement(LegendListInner, { ...props, ref: forwardedRef }));
|
|
838
858
|
});
|
|
839
859
|
var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
|
|
840
|
-
var _a, _b, _c, _d;
|
|
841
860
|
const {
|
|
842
861
|
data: dataProp = [],
|
|
843
862
|
initialScrollIndex,
|
|
@@ -884,9 +903,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
884
903
|
});
|
|
885
904
|
callbacks.current.onStartReached = rest.onStartReached;
|
|
886
905
|
callbacks.current.onEndReached = rest.onEndReached;
|
|
887
|
-
const contentContainerStyle = reactNative.StyleSheet.flatten(contentContainerStyleProp);
|
|
888
|
-
const style = reactNative.StyleSheet.flatten(styleProp);
|
|
889
|
-
const
|
|
906
|
+
const contentContainerStyle = { ...reactNative.StyleSheet.flatten(contentContainerStyleProp) };
|
|
907
|
+
const style = { ...reactNative.StyleSheet.flatten(styleProp) };
|
|
908
|
+
const stylePaddingTopState = ((style == null ? void 0 : style.paddingTop) || 0) + ((contentContainerStyle == null ? void 0 : contentContainerStyle.paddingTop) || 0);
|
|
890
909
|
if (style == null ? void 0 : style.paddingTop) {
|
|
891
910
|
style.paddingTop = void 0;
|
|
892
911
|
}
|
|
@@ -901,8 +920,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
901
920
|
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (item, index) => index.toString();
|
|
902
921
|
const refState = React6.useRef();
|
|
903
922
|
const getId = (index) => {
|
|
904
|
-
var
|
|
905
|
-
const data = (
|
|
923
|
+
var _a;
|
|
924
|
+
const data = (_a = refState.current) == null ? void 0 : _a.data;
|
|
906
925
|
if (!data) {
|
|
907
926
|
return "";
|
|
908
927
|
}
|
|
@@ -910,17 +929,17 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
910
929
|
return `${ret}`;
|
|
911
930
|
};
|
|
912
931
|
const getItemSize = (key, index, data) => {
|
|
913
|
-
var
|
|
932
|
+
var _a;
|
|
914
933
|
const sizeKnown = refState.current.sizes.get(key);
|
|
915
934
|
if (sizeKnown !== void 0) {
|
|
916
935
|
return sizeKnown;
|
|
917
936
|
}
|
|
918
|
-
const size = (
|
|
937
|
+
const size = (_a = getEstimatedItemSize ? getEstimatedItemSize(index, data) : estimatedItemSize) != null ? _a : DEFAULT_ITEM_SIZE;
|
|
919
938
|
refState.current.sizes.set(key, size);
|
|
920
939
|
return size;
|
|
921
940
|
};
|
|
922
941
|
const calculateOffsetForIndex = (index = initialScrollIndex) => {
|
|
923
|
-
var
|
|
942
|
+
var _a;
|
|
924
943
|
const data = dataProp;
|
|
925
944
|
if (index !== void 0) {
|
|
926
945
|
let offset = 0;
|
|
@@ -938,7 +957,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
938
957
|
} else if (estimatedItemSize) {
|
|
939
958
|
offset = index * estimatedItemSize;
|
|
940
959
|
}
|
|
941
|
-
return offset / numColumnsProp - (((
|
|
960
|
+
return offset / numColumnsProp - (((_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.getAppliedAdjust()) || 0);
|
|
942
961
|
}
|
|
943
962
|
return 0;
|
|
944
963
|
};
|
|
@@ -1021,18 +1040,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1021
1040
|
return void 0;
|
|
1022
1041
|
};
|
|
1023
1042
|
const setDidLayout = () => {
|
|
1024
|
-
var
|
|
1043
|
+
var _a;
|
|
1025
1044
|
refState.current.queuedInitialLayout = true;
|
|
1026
1045
|
checkAtBottom();
|
|
1027
1046
|
if (initialScrollIndex) {
|
|
1028
1047
|
const updatedOffset = calculateOffsetForIndex(initialScrollIndex);
|
|
1029
|
-
(
|
|
1048
|
+
(_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.setDisableAdjust(true);
|
|
1030
1049
|
queueMicrotask(() => {
|
|
1031
1050
|
scrollTo(updatedOffset, false);
|
|
1032
1051
|
requestAnimationFrame(() => {
|
|
1033
|
-
var
|
|
1052
|
+
var _a2;
|
|
1034
1053
|
set$(ctx, "containersDidLayout", true);
|
|
1035
|
-
(
|
|
1054
|
+
(_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustHandler.setDisableAdjust(false);
|
|
1036
1055
|
});
|
|
1037
1056
|
});
|
|
1038
1057
|
} else {
|
|
@@ -1077,7 +1096,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1077
1096
|
set$(ctx, "totalSize", state.totalSize);
|
|
1078
1097
|
set$(ctx, "totalSizeWithScrollAdjust", resultSize);
|
|
1079
1098
|
if (alignItemsAtEnd) {
|
|
1080
|
-
|
|
1099
|
+
updateAlignItemsPaddingTop();
|
|
1081
1100
|
}
|
|
1082
1101
|
}, []);
|
|
1083
1102
|
const getRowHeight = (n) => {
|
|
@@ -1105,13 +1124,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1105
1124
|
if (!state.anchorElement) {
|
|
1106
1125
|
return /* @__PURE__ */ new Map();
|
|
1107
1126
|
}
|
|
1108
|
-
let top = state.anchorElement.coordinate;
|
|
1109
1127
|
const anchorIndex = state.indexByKey.get(state.anchorElement.id);
|
|
1110
1128
|
if (anchorIndex === 0) {
|
|
1111
1129
|
return /* @__PURE__ */ new Map();
|
|
1112
1130
|
}
|
|
1113
1131
|
const map = state.belowAnchorElementPositions || /* @__PURE__ */ new Map();
|
|
1114
1132
|
const numColumns = peek$(ctx, "numColumns");
|
|
1133
|
+
let top = state.anchorElement.coordinate;
|
|
1115
1134
|
for (let i = anchorIndex - 1; i >= 0; i--) {
|
|
1116
1135
|
const id = getId(i);
|
|
1117
1136
|
const rowNumber = Math.floor(i / numColumns);
|
|
@@ -1123,20 +1142,20 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1123
1142
|
return map;
|
|
1124
1143
|
};
|
|
1125
1144
|
const getElementPositionBelowAchor = (id) => {
|
|
1126
|
-
var
|
|
1145
|
+
var _a;
|
|
1127
1146
|
const state = refState.current;
|
|
1128
1147
|
if (!refState.current.belowAnchorElementPositions) {
|
|
1129
1148
|
state.belowAnchorElementPositions = buildElementPositionsBelowAnchor();
|
|
1130
1149
|
}
|
|
1131
1150
|
const res = state.belowAnchorElementPositions.get(id);
|
|
1132
1151
|
if (res === void 0) {
|
|
1133
|
-
console.warn(`Undefined position below
|
|
1152
|
+
console.warn(`Undefined position below anchor ${id} ${(_a = state.anchorElement) == null ? void 0 : _a.id}`);
|
|
1134
1153
|
return 0;
|
|
1135
1154
|
}
|
|
1136
1155
|
return res;
|
|
1137
1156
|
};
|
|
1138
1157
|
const calculateItemsInView = React6.useCallback(() => {
|
|
1139
|
-
var
|
|
1158
|
+
var _a;
|
|
1140
1159
|
const state = refState.current;
|
|
1141
1160
|
const {
|
|
1142
1161
|
data,
|
|
@@ -1151,7 +1170,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1151
1170
|
return;
|
|
1152
1171
|
}
|
|
1153
1172
|
const totalSize = peek$(ctx, "totalSizeWithScrollAdjust");
|
|
1154
|
-
const topPad =
|
|
1173
|
+
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
1155
1174
|
const numColumns = peek$(ctx, "numColumns");
|
|
1156
1175
|
const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
|
|
1157
1176
|
const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
|
|
@@ -1224,22 +1243,22 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1224
1243
|
let column = 1;
|
|
1225
1244
|
let maxSizeInRow = 0;
|
|
1226
1245
|
const getInitialTop = (i) => {
|
|
1227
|
-
var
|
|
1246
|
+
var _a2;
|
|
1228
1247
|
const id = getId(i);
|
|
1229
1248
|
let topOffset = 0;
|
|
1230
1249
|
if (positions.get(id)) {
|
|
1231
1250
|
topOffset = positions.get(id);
|
|
1232
1251
|
}
|
|
1233
|
-
if (id === ((
|
|
1252
|
+
if (id === ((_a2 = state.anchorElement) == null ? void 0 : _a2.id)) {
|
|
1234
1253
|
topOffset = state.anchorElement.coordinate;
|
|
1235
1254
|
}
|
|
1236
1255
|
return topOffset;
|
|
1237
1256
|
};
|
|
1238
|
-
for (let i = loopStart; i < data.length; i++) {
|
|
1257
|
+
for (let i = Math.max(0, loopStart); i < data.length; i++) {
|
|
1239
1258
|
const id = getId(i);
|
|
1240
1259
|
const size = getItemSize(id, i, data[i]);
|
|
1241
1260
|
maxSizeInRow = Math.max(maxSizeInRow, size);
|
|
1242
|
-
if (top === void 0 || id === ((
|
|
1261
|
+
if (top === void 0 || id === ((_a = state.anchorElement) == null ? void 0 : _a.id)) {
|
|
1243
1262
|
top = getInitialTop(i);
|
|
1244
1263
|
}
|
|
1245
1264
|
if (positions.get(id) !== top) {
|
|
@@ -1420,17 +1439,33 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1420
1439
|
);
|
|
1421
1440
|
}
|
|
1422
1441
|
}, []);
|
|
1423
|
-
const
|
|
1442
|
+
const setPaddingTop = ({
|
|
1443
|
+
stylePaddingTop,
|
|
1444
|
+
alignItemsPaddingTop
|
|
1445
|
+
}) => {
|
|
1446
|
+
if (stylePaddingTop !== void 0) {
|
|
1447
|
+
set$(ctx, "stylePaddingTop", stylePaddingTop);
|
|
1448
|
+
}
|
|
1449
|
+
if (alignItemsPaddingTop !== void 0) {
|
|
1450
|
+
set$(ctx, "alignItemsPaddingTop", alignItemsPaddingTop);
|
|
1451
|
+
}
|
|
1452
|
+
set$(
|
|
1453
|
+
ctx,
|
|
1454
|
+
"paddingTop",
|
|
1455
|
+
(stylePaddingTop != null ? stylePaddingTop : peek$(ctx, "stylePaddingTop")) + (alignItemsPaddingTop != null ? alignItemsPaddingTop : peek$(ctx, "alignItemsPaddingTop"))
|
|
1456
|
+
);
|
|
1457
|
+
};
|
|
1458
|
+
const updateAlignItemsPaddingTop = () => {
|
|
1424
1459
|
if (alignItemsAtEnd) {
|
|
1425
1460
|
const { scrollLength } = refState.current;
|
|
1426
1461
|
const contentSize = getContentSize(ctx);
|
|
1427
1462
|
const paddingTop = Math.max(0, Math.floor(scrollLength - contentSize));
|
|
1428
|
-
|
|
1463
|
+
setPaddingTop({ alignItemsPaddingTop: paddingTop });
|
|
1429
1464
|
}
|
|
1430
1465
|
};
|
|
1431
1466
|
const scrollTo = (offset, animated) => {
|
|
1432
|
-
var
|
|
1433
|
-
(
|
|
1467
|
+
var _a;
|
|
1468
|
+
(_a = refScroller.current) == null ? void 0 : _a.scrollTo({
|
|
1434
1469
|
x: horizontal ? offset : 0,
|
|
1435
1470
|
y: horizontal ? 0 : offset,
|
|
1436
1471
|
animated: !!animated
|
|
@@ -1439,13 +1474,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1439
1474
|
const doMaintainScrollAtEnd = (animated) => {
|
|
1440
1475
|
const state = refState.current;
|
|
1441
1476
|
if ((state == null ? void 0 : state.isAtBottom) && maintainScrollAtEnd && peek$(ctx, "containersDidLayout")) {
|
|
1442
|
-
const paddingTop = peek$(ctx, "
|
|
1477
|
+
const paddingTop = peek$(ctx, "alignItemsPaddingTop");
|
|
1443
1478
|
if (paddingTop > 0) {
|
|
1444
1479
|
state.scroll = 0;
|
|
1445
1480
|
}
|
|
1446
1481
|
requestAnimationFrame(() => {
|
|
1447
|
-
var
|
|
1448
|
-
(
|
|
1482
|
+
var _a;
|
|
1483
|
+
(_a = refScroller.current) == null ? void 0 : _a.scrollToEnd({
|
|
1449
1484
|
animated
|
|
1450
1485
|
});
|
|
1451
1486
|
});
|
|
@@ -1489,8 +1524,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1489
1524
|
refState.current.isEndReached,
|
|
1490
1525
|
refState.current.endReachedBlockedByTimer,
|
|
1491
1526
|
(distance) => {
|
|
1492
|
-
var
|
|
1493
|
-
return (
|
|
1527
|
+
var _a, _b;
|
|
1528
|
+
return (_b = (_a = callbacks.current).onEndReached) == null ? void 0 : _b.call(_a, { distanceFromEnd: distance });
|
|
1494
1529
|
},
|
|
1495
1530
|
(block) => {
|
|
1496
1531
|
refState.current.endReachedBlockedByTimer = block;
|
|
@@ -1513,8 +1548,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1513
1548
|
refState.current.isStartReached,
|
|
1514
1549
|
refState.current.startReachedBlockedByTimer,
|
|
1515
1550
|
(distance) => {
|
|
1516
|
-
var
|
|
1517
|
-
return (
|
|
1551
|
+
var _a, _b;
|
|
1552
|
+
return (_b = (_a = callbacks.current).onStartReached) == null ? void 0 : _b.call(_a, { distanceFromStart: distance });
|
|
1518
1553
|
},
|
|
1519
1554
|
(block) => {
|
|
1520
1555
|
refState.current.startReachedBlockedByTimer = block;
|
|
@@ -1551,14 +1586,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1551
1586
|
}
|
|
1552
1587
|
};
|
|
1553
1588
|
const calcTotalSizesAndPositions = ({ forgetPositions = false }) => {
|
|
1554
|
-
var
|
|
1589
|
+
var _a, _b;
|
|
1555
1590
|
let totalSize = 0;
|
|
1556
1591
|
let totalSizeBelowIndex = 0;
|
|
1557
1592
|
const indexByKey = /* @__PURE__ */ new Map();
|
|
1558
1593
|
const newPositions = /* @__PURE__ */ new Map();
|
|
1559
1594
|
let column = 1;
|
|
1560
1595
|
let maxSizeInRow = 0;
|
|
1561
|
-
const numColumns = (
|
|
1596
|
+
const numColumns = (_a = peek$(ctx, "numColumns")) != null ? _a : numColumnsProp;
|
|
1562
1597
|
if (!refState.current) {
|
|
1563
1598
|
return;
|
|
1564
1599
|
}
|
|
@@ -1587,7 +1622,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1587
1622
|
id: getId(0)
|
|
1588
1623
|
};
|
|
1589
1624
|
refState.current.anchorElement = newAnchorElement;
|
|
1590
|
-
(
|
|
1625
|
+
(_b = refState.current.belowAnchorElementPositions) == null ? void 0 : _b.clear();
|
|
1591
1626
|
scrollTo(0, false);
|
|
1592
1627
|
setTimeout(() => {
|
|
1593
1628
|
calculateItemsInView();
|
|
@@ -1646,20 +1681,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1646
1681
|
const initalizeStateVars = () => {
|
|
1647
1682
|
set$(ctx, "lastItemKeys", memoizedLastItemKeys);
|
|
1648
1683
|
set$(ctx, "numColumns", numColumnsProp);
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
if (reactNative.Platform.OS === "ios") {
|
|
1657
|
-
queueMicrotask(() => {
|
|
1658
|
-
scrollTo(refState.current.scroll + paddingDiff, false);
|
|
1659
|
-
});
|
|
1660
|
-
}
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1684
|
+
const prevPaddingTop = peek$(ctx, "stylePaddingTop");
|
|
1685
|
+
setPaddingTop({ stylePaddingTop: stylePaddingTopState });
|
|
1686
|
+
const paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
1687
|
+
if (paddingDiff && prevPaddingTop !== void 0 && reactNative.Platform.OS === "ios") {
|
|
1688
|
+
queueMicrotask(() => {
|
|
1689
|
+
scrollTo(refState.current.scroll + paddingDiff, false);
|
|
1690
|
+
});
|
|
1663
1691
|
}
|
|
1664
1692
|
};
|
|
1665
1693
|
if (isFirst) {
|
|
@@ -1686,9 +1714,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1686
1714
|
set$(ctx, "extraData", extraData);
|
|
1687
1715
|
}, [extraData]);
|
|
1688
1716
|
refState.current.renderItem = renderItem;
|
|
1689
|
-
React6.useEffect(initalizeStateVars, [memoizedLastItemKeys.join(","), numColumnsProp,
|
|
1717
|
+
React6.useEffect(initalizeStateVars, [memoizedLastItemKeys.join(","), numColumnsProp, stylePaddingTopState]);
|
|
1690
1718
|
const getRenderedItem = React6.useCallback((key) => {
|
|
1691
|
-
var
|
|
1719
|
+
var _a, _b;
|
|
1692
1720
|
const state = refState.current;
|
|
1693
1721
|
if (!state) {
|
|
1694
1722
|
return null;
|
|
@@ -1718,7 +1746,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1718
1746
|
`[legend-list] useRecyclingState has been moved from a render prop to a regular import: import { useRecyclingState } from "@legendapp/list";`
|
|
1719
1747
|
);
|
|
1720
1748
|
} : void 0;
|
|
1721
|
-
const renderedItem = (
|
|
1749
|
+
const renderedItem = (_b = (_a = refState.current).renderItem) == null ? void 0 : _b.call(_a, {
|
|
1722
1750
|
item: data[index],
|
|
1723
1751
|
index,
|
|
1724
1752
|
extraData: peek$(ctx, "extraData"),
|
|
@@ -1731,11 +1759,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1731
1759
|
return { index, item: data[index], renderedItem };
|
|
1732
1760
|
}, []);
|
|
1733
1761
|
const doInitialAllocateContainers = () => {
|
|
1734
|
-
var
|
|
1762
|
+
var _a;
|
|
1735
1763
|
const state = refState.current;
|
|
1736
1764
|
const { scrollLength, data } = state;
|
|
1737
1765
|
if (scrollLength > 0 && data.length > 0 && !peek$(ctx, "numContainers")) {
|
|
1738
|
-
const averageItemSize = (
|
|
1766
|
+
const averageItemSize = (_a = estimatedItemSize != null ? estimatedItemSize : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(0, data[0])) != null ? _a : DEFAULT_ITEM_SIZE;
|
|
1739
1767
|
const numContainers = Math.ceil((scrollLength + scrollBuffer * 2) / averageItemSize) * numColumnsProp;
|
|
1740
1768
|
for (let i = 0; i < numContainers; i++) {
|
|
1741
1769
|
set$(ctx, `containerPosition${i}`, ANCHORED_POSITION_OUT_OF_VIEW);
|
|
@@ -1855,7 +1883,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1855
1883
|
state.scrollForNextCalculateItemsInView = void 0;
|
|
1856
1884
|
doInitialAllocateContainers();
|
|
1857
1885
|
doMaintainScrollAtEnd(false);
|
|
1858
|
-
|
|
1886
|
+
updateAlignItemsPaddingTop();
|
|
1859
1887
|
checkAtBottom();
|
|
1860
1888
|
checkAtTop();
|
|
1861
1889
|
if (didChange) {
|
|
@@ -1876,8 +1904,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1876
1904
|
}, []);
|
|
1877
1905
|
const handleScroll = React6.useCallback(
|
|
1878
1906
|
(event, fromSelf) => {
|
|
1879
|
-
var
|
|
1880
|
-
if (((
|
|
1907
|
+
var _a, _b, _c, _d;
|
|
1908
|
+
if (((_b = (_a = event.nativeEvent) == null ? void 0 : _a.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
|
|
1881
1909
|
return;
|
|
1882
1910
|
}
|
|
1883
1911
|
const state = refState.current;
|
|
@@ -1917,7 +1945,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1917
1945
|
checkAtBottom();
|
|
1918
1946
|
checkAtTop();
|
|
1919
1947
|
if (!fromSelf) {
|
|
1920
|
-
(
|
|
1948
|
+
(_d = state.onScroll) == null ? void 0 : _d.call(state, event);
|
|
1921
1949
|
}
|
|
1922
1950
|
},
|
|
1923
1951
|
[]
|
|
@@ -1931,7 +1959,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1931
1959
|
animated = true,
|
|
1932
1960
|
viewPosition = 0
|
|
1933
1961
|
}) => {
|
|
1934
|
-
var
|
|
1962
|
+
var _a;
|
|
1935
1963
|
const state = refState.current;
|
|
1936
1964
|
const firstIndexOffset = calculateOffsetForIndex(index);
|
|
1937
1965
|
let firstIndexScrollPostion = firstIndexOffset - viewOffset;
|
|
@@ -1941,7 +1969,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1941
1969
|
if (needsReanchoring) {
|
|
1942
1970
|
const id = getId(index);
|
|
1943
1971
|
state.anchorElement = { id, coordinate: firstIndexOffset };
|
|
1944
|
-
(
|
|
1972
|
+
(_a = state.belowAnchorElementPositions) == null ? void 0 : _a.clear();
|
|
1945
1973
|
state.positions.clear();
|
|
1946
1974
|
calcTotalSizesAndPositions({ forgetPositions: true });
|
|
1947
1975
|
state.startBufferedId = id;
|
|
@@ -2014,13 +2042,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2014
2042
|
);
|
|
2015
2043
|
if (reactNative.Platform.OS === "web") {
|
|
2016
2044
|
React6.useEffect(() => {
|
|
2017
|
-
var
|
|
2045
|
+
var _a;
|
|
2018
2046
|
if (initialContentOffset) {
|
|
2019
|
-
(
|
|
2047
|
+
(_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.setDisableAdjust(true);
|
|
2020
2048
|
scrollTo(initialContentOffset, false);
|
|
2021
2049
|
setTimeout(() => {
|
|
2022
|
-
var
|
|
2023
|
-
(
|
|
2050
|
+
var _a2;
|
|
2051
|
+
(_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustHandler.setDisableAdjust(false);
|
|
2024
2052
|
}, 0);
|
|
2025
2053
|
}
|
|
2026
2054
|
}, []);
|
|
@@ -2036,8 +2064,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2036
2064
|
updateItemSize,
|
|
2037
2065
|
handleScroll,
|
|
2038
2066
|
onMomentumScrollEnd: (event) => {
|
|
2039
|
-
var
|
|
2040
|
-
const scrollingToOffset = (
|
|
2067
|
+
var _a;
|
|
2068
|
+
const scrollingToOffset = (_a = refState.current) == null ? void 0 : _a.scrollingToOffset;
|
|
2041
2069
|
if (scrollingToOffset !== void 0) {
|
|
2042
2070
|
requestAnimationFrame(() => {
|
|
2043
2071
|
scrollTo(scrollingToOffset, false);
|
package/index.mjs
CHANGED
|
@@ -7,7 +7,12 @@ var ContextState = React6.createContext(null);
|
|
|
7
7
|
function StateProvider({ children }) {
|
|
8
8
|
const [value] = React6.useState(() => ({
|
|
9
9
|
listeners: /* @__PURE__ */ new Map(),
|
|
10
|
-
values: /* @__PURE__ */ new Map(
|
|
10
|
+
values: /* @__PURE__ */ new Map([
|
|
11
|
+
["paddingTop", 0],
|
|
12
|
+
["alignItemsPaddingTop", 0],
|
|
13
|
+
["stylePaddingTop", 0],
|
|
14
|
+
["headerSize", 0]
|
|
15
|
+
]),
|
|
11
16
|
mapViewabilityCallbacks: /* @__PURE__ */ new Map(),
|
|
12
17
|
mapViewabilityValues: /* @__PURE__ */ new Map(),
|
|
13
18
|
mapViewabilityAmountCallbacks: /* @__PURE__ */ new Map(),
|
|
@@ -128,10 +133,10 @@ function useInit(cb) {
|
|
|
128
133
|
|
|
129
134
|
// src/ContextContainer.ts
|
|
130
135
|
var ContextContainer = createContext(null);
|
|
131
|
-
function useViewability(
|
|
136
|
+
function useViewability(callback, configId) {
|
|
132
137
|
const ctx = useStateContext();
|
|
133
138
|
const { containerId } = useContext(ContextContainer);
|
|
134
|
-
const key = containerId + configId;
|
|
139
|
+
const key = containerId + (configId != null ? configId : "");
|
|
135
140
|
useInit(() => {
|
|
136
141
|
const value = ctx.mapViewabilityValues.get(key);
|
|
137
142
|
if (value) {
|
|
@@ -241,13 +246,20 @@ var Container = ({
|
|
|
241
246
|
const refLastSize = useRef();
|
|
242
247
|
const otherAxisPos = numColumns > 1 ? `${(column - 1) / numColumns * 100}%` : 0;
|
|
243
248
|
const otherAxisSize = numColumns > 1 ? `${1 / numColumns * 100}%` : void 0;
|
|
244
|
-
let
|
|
249
|
+
let paddingStyles;
|
|
245
250
|
if (columnWrapperStyle) {
|
|
246
251
|
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
252
|
+
if (horizontal) {
|
|
253
|
+
paddingStyles = {
|
|
254
|
+
paddingRight: !lastItemKeys.includes(itemKey) ? columnGap || gap || void 0 : void 0,
|
|
255
|
+
paddingVertical: (rowGap || gap || 0) / 2
|
|
256
|
+
};
|
|
257
|
+
} else {
|
|
258
|
+
paddingStyles = {
|
|
259
|
+
paddingBottom: !lastItemKeys.includes(itemKey) ? rowGap || gap || void 0 : void 0,
|
|
260
|
+
paddingHorizontal: (columnGap || gap || 0) / 2
|
|
261
|
+
};
|
|
262
|
+
}
|
|
251
263
|
}
|
|
252
264
|
const style = horizontal ? {
|
|
253
265
|
flexDirection: ItemSeparatorComponent ? "row" : void 0,
|
|
@@ -255,14 +267,15 @@ var Container = ({
|
|
|
255
267
|
top: otherAxisPos,
|
|
256
268
|
bottom: numColumns > 1 ? null : 0,
|
|
257
269
|
height: otherAxisSize,
|
|
258
|
-
left: position.relativeCoordinate
|
|
270
|
+
left: position.relativeCoordinate,
|
|
271
|
+
...paddingStyles || {}
|
|
259
272
|
} : {
|
|
260
273
|
position: "absolute",
|
|
261
274
|
left: otherAxisPos,
|
|
262
275
|
right: numColumns > 1 ? null : 0,
|
|
263
276
|
width: otherAxisSize,
|
|
264
277
|
top: position.relativeCoordinate,
|
|
265
|
-
...
|
|
278
|
+
...paddingStyles || {}
|
|
266
279
|
};
|
|
267
280
|
const renderedItemInfo = useMemo(
|
|
268
281
|
() => itemKey !== void 0 ? getRenderedItem(itemKey) : null,
|
|
@@ -360,7 +373,7 @@ var Containers = typedMemo(function Containers2({
|
|
|
360
373
|
}) {
|
|
361
374
|
const ctx = useStateContext();
|
|
362
375
|
const columnWrapperStyle = ctx.columnWrapperStyle;
|
|
363
|
-
|
|
376
|
+
use$("numColumns");
|
|
364
377
|
const numContainers = use$("numContainersPooled");
|
|
365
378
|
const animSize = useValue$(
|
|
366
379
|
"totalSizeWithScrollAdjust",
|
|
@@ -387,11 +400,18 @@ var Containers = typedMemo(function Containers2({
|
|
|
387
400
|
);
|
|
388
401
|
}
|
|
389
402
|
const style = horizontal ? { width: animSize, opacity: animOpacity } : { height: animSize, opacity: animOpacity };
|
|
390
|
-
if (columnWrapperStyle
|
|
403
|
+
if (columnWrapperStyle) {
|
|
391
404
|
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
405
|
+
if (horizontal) {
|
|
406
|
+
const my = (rowGap || gap || 0) / 2;
|
|
407
|
+
if (my) {
|
|
408
|
+
style.marginVertical = -my;
|
|
409
|
+
}
|
|
410
|
+
} else {
|
|
411
|
+
const mx = (columnGap || gap || 0) / 2;
|
|
412
|
+
if (mx) {
|
|
413
|
+
style.marginHorizontal = -mx;
|
|
414
|
+
}
|
|
395
415
|
}
|
|
396
416
|
}
|
|
397
417
|
return /* @__PURE__ */ React6.createElement(Animated.View, { style }, containers);
|
|
@@ -816,7 +836,6 @@ var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
|
|
|
816
836
|
return /* @__PURE__ */ React6.createElement(StateProvider, null, /* @__PURE__ */ React6.createElement(LegendListInner, { ...props, ref: forwardedRef }));
|
|
817
837
|
});
|
|
818
838
|
var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
|
|
819
|
-
var _a, _b, _c, _d;
|
|
820
839
|
const {
|
|
821
840
|
data: dataProp = [],
|
|
822
841
|
initialScrollIndex,
|
|
@@ -863,9 +882,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
863
882
|
});
|
|
864
883
|
callbacks.current.onStartReached = rest.onStartReached;
|
|
865
884
|
callbacks.current.onEndReached = rest.onEndReached;
|
|
866
|
-
const contentContainerStyle = StyleSheet.flatten(contentContainerStyleProp);
|
|
867
|
-
const style = StyleSheet.flatten(styleProp);
|
|
868
|
-
const
|
|
885
|
+
const contentContainerStyle = { ...StyleSheet.flatten(contentContainerStyleProp) };
|
|
886
|
+
const style = { ...StyleSheet.flatten(styleProp) };
|
|
887
|
+
const stylePaddingTopState = ((style == null ? void 0 : style.paddingTop) || 0) + ((contentContainerStyle == null ? void 0 : contentContainerStyle.paddingTop) || 0);
|
|
869
888
|
if (style == null ? void 0 : style.paddingTop) {
|
|
870
889
|
style.paddingTop = void 0;
|
|
871
890
|
}
|
|
@@ -880,8 +899,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
880
899
|
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (item, index) => index.toString();
|
|
881
900
|
const refState = useRef();
|
|
882
901
|
const getId = (index) => {
|
|
883
|
-
var
|
|
884
|
-
const data = (
|
|
902
|
+
var _a;
|
|
903
|
+
const data = (_a = refState.current) == null ? void 0 : _a.data;
|
|
885
904
|
if (!data) {
|
|
886
905
|
return "";
|
|
887
906
|
}
|
|
@@ -889,17 +908,17 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
889
908
|
return `${ret}`;
|
|
890
909
|
};
|
|
891
910
|
const getItemSize = (key, index, data) => {
|
|
892
|
-
var
|
|
911
|
+
var _a;
|
|
893
912
|
const sizeKnown = refState.current.sizes.get(key);
|
|
894
913
|
if (sizeKnown !== void 0) {
|
|
895
914
|
return sizeKnown;
|
|
896
915
|
}
|
|
897
|
-
const size = (
|
|
916
|
+
const size = (_a = getEstimatedItemSize ? getEstimatedItemSize(index, data) : estimatedItemSize) != null ? _a : DEFAULT_ITEM_SIZE;
|
|
898
917
|
refState.current.sizes.set(key, size);
|
|
899
918
|
return size;
|
|
900
919
|
};
|
|
901
920
|
const calculateOffsetForIndex = (index = initialScrollIndex) => {
|
|
902
|
-
var
|
|
921
|
+
var _a;
|
|
903
922
|
const data = dataProp;
|
|
904
923
|
if (index !== void 0) {
|
|
905
924
|
let offset = 0;
|
|
@@ -917,7 +936,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
917
936
|
} else if (estimatedItemSize) {
|
|
918
937
|
offset = index * estimatedItemSize;
|
|
919
938
|
}
|
|
920
|
-
return offset / numColumnsProp - (((
|
|
939
|
+
return offset / numColumnsProp - (((_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.getAppliedAdjust()) || 0);
|
|
921
940
|
}
|
|
922
941
|
return 0;
|
|
923
942
|
};
|
|
@@ -1000,18 +1019,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1000
1019
|
return void 0;
|
|
1001
1020
|
};
|
|
1002
1021
|
const setDidLayout = () => {
|
|
1003
|
-
var
|
|
1022
|
+
var _a;
|
|
1004
1023
|
refState.current.queuedInitialLayout = true;
|
|
1005
1024
|
checkAtBottom();
|
|
1006
1025
|
if (initialScrollIndex) {
|
|
1007
1026
|
const updatedOffset = calculateOffsetForIndex(initialScrollIndex);
|
|
1008
|
-
(
|
|
1027
|
+
(_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.setDisableAdjust(true);
|
|
1009
1028
|
queueMicrotask(() => {
|
|
1010
1029
|
scrollTo(updatedOffset, false);
|
|
1011
1030
|
requestAnimationFrame(() => {
|
|
1012
|
-
var
|
|
1031
|
+
var _a2;
|
|
1013
1032
|
set$(ctx, "containersDidLayout", true);
|
|
1014
|
-
(
|
|
1033
|
+
(_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustHandler.setDisableAdjust(false);
|
|
1015
1034
|
});
|
|
1016
1035
|
});
|
|
1017
1036
|
} else {
|
|
@@ -1056,7 +1075,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1056
1075
|
set$(ctx, "totalSize", state.totalSize);
|
|
1057
1076
|
set$(ctx, "totalSizeWithScrollAdjust", resultSize);
|
|
1058
1077
|
if (alignItemsAtEnd) {
|
|
1059
|
-
|
|
1078
|
+
updateAlignItemsPaddingTop();
|
|
1060
1079
|
}
|
|
1061
1080
|
}, []);
|
|
1062
1081
|
const getRowHeight = (n) => {
|
|
@@ -1084,13 +1103,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1084
1103
|
if (!state.anchorElement) {
|
|
1085
1104
|
return /* @__PURE__ */ new Map();
|
|
1086
1105
|
}
|
|
1087
|
-
let top = state.anchorElement.coordinate;
|
|
1088
1106
|
const anchorIndex = state.indexByKey.get(state.anchorElement.id);
|
|
1089
1107
|
if (anchorIndex === 0) {
|
|
1090
1108
|
return /* @__PURE__ */ new Map();
|
|
1091
1109
|
}
|
|
1092
1110
|
const map = state.belowAnchorElementPositions || /* @__PURE__ */ new Map();
|
|
1093
1111
|
const numColumns = peek$(ctx, "numColumns");
|
|
1112
|
+
let top = state.anchorElement.coordinate;
|
|
1094
1113
|
for (let i = anchorIndex - 1; i >= 0; i--) {
|
|
1095
1114
|
const id = getId(i);
|
|
1096
1115
|
const rowNumber = Math.floor(i / numColumns);
|
|
@@ -1102,20 +1121,20 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1102
1121
|
return map;
|
|
1103
1122
|
};
|
|
1104
1123
|
const getElementPositionBelowAchor = (id) => {
|
|
1105
|
-
var
|
|
1124
|
+
var _a;
|
|
1106
1125
|
const state = refState.current;
|
|
1107
1126
|
if (!refState.current.belowAnchorElementPositions) {
|
|
1108
1127
|
state.belowAnchorElementPositions = buildElementPositionsBelowAnchor();
|
|
1109
1128
|
}
|
|
1110
1129
|
const res = state.belowAnchorElementPositions.get(id);
|
|
1111
1130
|
if (res === void 0) {
|
|
1112
|
-
console.warn(`Undefined position below
|
|
1131
|
+
console.warn(`Undefined position below anchor ${id} ${(_a = state.anchorElement) == null ? void 0 : _a.id}`);
|
|
1113
1132
|
return 0;
|
|
1114
1133
|
}
|
|
1115
1134
|
return res;
|
|
1116
1135
|
};
|
|
1117
1136
|
const calculateItemsInView = useCallback(() => {
|
|
1118
|
-
var
|
|
1137
|
+
var _a;
|
|
1119
1138
|
const state = refState.current;
|
|
1120
1139
|
const {
|
|
1121
1140
|
data,
|
|
@@ -1130,7 +1149,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1130
1149
|
return;
|
|
1131
1150
|
}
|
|
1132
1151
|
const totalSize = peek$(ctx, "totalSizeWithScrollAdjust");
|
|
1133
|
-
const topPad =
|
|
1152
|
+
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
1134
1153
|
const numColumns = peek$(ctx, "numColumns");
|
|
1135
1154
|
const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
|
|
1136
1155
|
const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
|
|
@@ -1203,22 +1222,22 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1203
1222
|
let column = 1;
|
|
1204
1223
|
let maxSizeInRow = 0;
|
|
1205
1224
|
const getInitialTop = (i) => {
|
|
1206
|
-
var
|
|
1225
|
+
var _a2;
|
|
1207
1226
|
const id = getId(i);
|
|
1208
1227
|
let topOffset = 0;
|
|
1209
1228
|
if (positions.get(id)) {
|
|
1210
1229
|
topOffset = positions.get(id);
|
|
1211
1230
|
}
|
|
1212
|
-
if (id === ((
|
|
1231
|
+
if (id === ((_a2 = state.anchorElement) == null ? void 0 : _a2.id)) {
|
|
1213
1232
|
topOffset = state.anchorElement.coordinate;
|
|
1214
1233
|
}
|
|
1215
1234
|
return topOffset;
|
|
1216
1235
|
};
|
|
1217
|
-
for (let i = loopStart; i < data.length; i++) {
|
|
1236
|
+
for (let i = Math.max(0, loopStart); i < data.length; i++) {
|
|
1218
1237
|
const id = getId(i);
|
|
1219
1238
|
const size = getItemSize(id, i, data[i]);
|
|
1220
1239
|
maxSizeInRow = Math.max(maxSizeInRow, size);
|
|
1221
|
-
if (top === void 0 || id === ((
|
|
1240
|
+
if (top === void 0 || id === ((_a = state.anchorElement) == null ? void 0 : _a.id)) {
|
|
1222
1241
|
top = getInitialTop(i);
|
|
1223
1242
|
}
|
|
1224
1243
|
if (positions.get(id) !== top) {
|
|
@@ -1399,17 +1418,33 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1399
1418
|
);
|
|
1400
1419
|
}
|
|
1401
1420
|
}, []);
|
|
1402
|
-
const
|
|
1421
|
+
const setPaddingTop = ({
|
|
1422
|
+
stylePaddingTop,
|
|
1423
|
+
alignItemsPaddingTop
|
|
1424
|
+
}) => {
|
|
1425
|
+
if (stylePaddingTop !== void 0) {
|
|
1426
|
+
set$(ctx, "stylePaddingTop", stylePaddingTop);
|
|
1427
|
+
}
|
|
1428
|
+
if (alignItemsPaddingTop !== void 0) {
|
|
1429
|
+
set$(ctx, "alignItemsPaddingTop", alignItemsPaddingTop);
|
|
1430
|
+
}
|
|
1431
|
+
set$(
|
|
1432
|
+
ctx,
|
|
1433
|
+
"paddingTop",
|
|
1434
|
+
(stylePaddingTop != null ? stylePaddingTop : peek$(ctx, "stylePaddingTop")) + (alignItemsPaddingTop != null ? alignItemsPaddingTop : peek$(ctx, "alignItemsPaddingTop"))
|
|
1435
|
+
);
|
|
1436
|
+
};
|
|
1437
|
+
const updateAlignItemsPaddingTop = () => {
|
|
1403
1438
|
if (alignItemsAtEnd) {
|
|
1404
1439
|
const { scrollLength } = refState.current;
|
|
1405
1440
|
const contentSize = getContentSize(ctx);
|
|
1406
1441
|
const paddingTop = Math.max(0, Math.floor(scrollLength - contentSize));
|
|
1407
|
-
|
|
1442
|
+
setPaddingTop({ alignItemsPaddingTop: paddingTop });
|
|
1408
1443
|
}
|
|
1409
1444
|
};
|
|
1410
1445
|
const scrollTo = (offset, animated) => {
|
|
1411
|
-
var
|
|
1412
|
-
(
|
|
1446
|
+
var _a;
|
|
1447
|
+
(_a = refScroller.current) == null ? void 0 : _a.scrollTo({
|
|
1413
1448
|
x: horizontal ? offset : 0,
|
|
1414
1449
|
y: horizontal ? 0 : offset,
|
|
1415
1450
|
animated: !!animated
|
|
@@ -1418,13 +1453,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1418
1453
|
const doMaintainScrollAtEnd = (animated) => {
|
|
1419
1454
|
const state = refState.current;
|
|
1420
1455
|
if ((state == null ? void 0 : state.isAtBottom) && maintainScrollAtEnd && peek$(ctx, "containersDidLayout")) {
|
|
1421
|
-
const paddingTop = peek$(ctx, "
|
|
1456
|
+
const paddingTop = peek$(ctx, "alignItemsPaddingTop");
|
|
1422
1457
|
if (paddingTop > 0) {
|
|
1423
1458
|
state.scroll = 0;
|
|
1424
1459
|
}
|
|
1425
1460
|
requestAnimationFrame(() => {
|
|
1426
|
-
var
|
|
1427
|
-
(
|
|
1461
|
+
var _a;
|
|
1462
|
+
(_a = refScroller.current) == null ? void 0 : _a.scrollToEnd({
|
|
1428
1463
|
animated
|
|
1429
1464
|
});
|
|
1430
1465
|
});
|
|
@@ -1468,8 +1503,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1468
1503
|
refState.current.isEndReached,
|
|
1469
1504
|
refState.current.endReachedBlockedByTimer,
|
|
1470
1505
|
(distance) => {
|
|
1471
|
-
var
|
|
1472
|
-
return (
|
|
1506
|
+
var _a, _b;
|
|
1507
|
+
return (_b = (_a = callbacks.current).onEndReached) == null ? void 0 : _b.call(_a, { distanceFromEnd: distance });
|
|
1473
1508
|
},
|
|
1474
1509
|
(block) => {
|
|
1475
1510
|
refState.current.endReachedBlockedByTimer = block;
|
|
@@ -1492,8 +1527,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1492
1527
|
refState.current.isStartReached,
|
|
1493
1528
|
refState.current.startReachedBlockedByTimer,
|
|
1494
1529
|
(distance) => {
|
|
1495
|
-
var
|
|
1496
|
-
return (
|
|
1530
|
+
var _a, _b;
|
|
1531
|
+
return (_b = (_a = callbacks.current).onStartReached) == null ? void 0 : _b.call(_a, { distanceFromStart: distance });
|
|
1497
1532
|
},
|
|
1498
1533
|
(block) => {
|
|
1499
1534
|
refState.current.startReachedBlockedByTimer = block;
|
|
@@ -1530,14 +1565,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1530
1565
|
}
|
|
1531
1566
|
};
|
|
1532
1567
|
const calcTotalSizesAndPositions = ({ forgetPositions = false }) => {
|
|
1533
|
-
var
|
|
1568
|
+
var _a, _b;
|
|
1534
1569
|
let totalSize = 0;
|
|
1535
1570
|
let totalSizeBelowIndex = 0;
|
|
1536
1571
|
const indexByKey = /* @__PURE__ */ new Map();
|
|
1537
1572
|
const newPositions = /* @__PURE__ */ new Map();
|
|
1538
1573
|
let column = 1;
|
|
1539
1574
|
let maxSizeInRow = 0;
|
|
1540
|
-
const numColumns = (
|
|
1575
|
+
const numColumns = (_a = peek$(ctx, "numColumns")) != null ? _a : numColumnsProp;
|
|
1541
1576
|
if (!refState.current) {
|
|
1542
1577
|
return;
|
|
1543
1578
|
}
|
|
@@ -1566,7 +1601,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1566
1601
|
id: getId(0)
|
|
1567
1602
|
};
|
|
1568
1603
|
refState.current.anchorElement = newAnchorElement;
|
|
1569
|
-
(
|
|
1604
|
+
(_b = refState.current.belowAnchorElementPositions) == null ? void 0 : _b.clear();
|
|
1570
1605
|
scrollTo(0, false);
|
|
1571
1606
|
setTimeout(() => {
|
|
1572
1607
|
calculateItemsInView();
|
|
@@ -1625,20 +1660,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1625
1660
|
const initalizeStateVars = () => {
|
|
1626
1661
|
set$(ctx, "lastItemKeys", memoizedLastItemKeys);
|
|
1627
1662
|
set$(ctx, "numColumns", numColumnsProp);
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
if (Platform.OS === "ios") {
|
|
1636
|
-
queueMicrotask(() => {
|
|
1637
|
-
scrollTo(refState.current.scroll + paddingDiff, false);
|
|
1638
|
-
});
|
|
1639
|
-
}
|
|
1640
|
-
}
|
|
1641
|
-
}
|
|
1663
|
+
const prevPaddingTop = peek$(ctx, "stylePaddingTop");
|
|
1664
|
+
setPaddingTop({ stylePaddingTop: stylePaddingTopState });
|
|
1665
|
+
const paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
1666
|
+
if (paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
1667
|
+
queueMicrotask(() => {
|
|
1668
|
+
scrollTo(refState.current.scroll + paddingDiff, false);
|
|
1669
|
+
});
|
|
1642
1670
|
}
|
|
1643
1671
|
};
|
|
1644
1672
|
if (isFirst) {
|
|
@@ -1665,9 +1693,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1665
1693
|
set$(ctx, "extraData", extraData);
|
|
1666
1694
|
}, [extraData]);
|
|
1667
1695
|
refState.current.renderItem = renderItem;
|
|
1668
|
-
useEffect(initalizeStateVars, [memoizedLastItemKeys.join(","), numColumnsProp,
|
|
1696
|
+
useEffect(initalizeStateVars, [memoizedLastItemKeys.join(","), numColumnsProp, stylePaddingTopState]);
|
|
1669
1697
|
const getRenderedItem = useCallback((key) => {
|
|
1670
|
-
var
|
|
1698
|
+
var _a, _b;
|
|
1671
1699
|
const state = refState.current;
|
|
1672
1700
|
if (!state) {
|
|
1673
1701
|
return null;
|
|
@@ -1697,7 +1725,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1697
1725
|
`[legend-list] useRecyclingState has been moved from a render prop to a regular import: import { useRecyclingState } from "@legendapp/list";`
|
|
1698
1726
|
);
|
|
1699
1727
|
} : void 0;
|
|
1700
|
-
const renderedItem = (
|
|
1728
|
+
const renderedItem = (_b = (_a = refState.current).renderItem) == null ? void 0 : _b.call(_a, {
|
|
1701
1729
|
item: data[index],
|
|
1702
1730
|
index,
|
|
1703
1731
|
extraData: peek$(ctx, "extraData"),
|
|
@@ -1710,11 +1738,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1710
1738
|
return { index, item: data[index], renderedItem };
|
|
1711
1739
|
}, []);
|
|
1712
1740
|
const doInitialAllocateContainers = () => {
|
|
1713
|
-
var
|
|
1741
|
+
var _a;
|
|
1714
1742
|
const state = refState.current;
|
|
1715
1743
|
const { scrollLength, data } = state;
|
|
1716
1744
|
if (scrollLength > 0 && data.length > 0 && !peek$(ctx, "numContainers")) {
|
|
1717
|
-
const averageItemSize = (
|
|
1745
|
+
const averageItemSize = (_a = estimatedItemSize != null ? estimatedItemSize : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(0, data[0])) != null ? _a : DEFAULT_ITEM_SIZE;
|
|
1718
1746
|
const numContainers = Math.ceil((scrollLength + scrollBuffer * 2) / averageItemSize) * numColumnsProp;
|
|
1719
1747
|
for (let i = 0; i < numContainers; i++) {
|
|
1720
1748
|
set$(ctx, `containerPosition${i}`, ANCHORED_POSITION_OUT_OF_VIEW);
|
|
@@ -1834,7 +1862,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1834
1862
|
state.scrollForNextCalculateItemsInView = void 0;
|
|
1835
1863
|
doInitialAllocateContainers();
|
|
1836
1864
|
doMaintainScrollAtEnd(false);
|
|
1837
|
-
|
|
1865
|
+
updateAlignItemsPaddingTop();
|
|
1838
1866
|
checkAtBottom();
|
|
1839
1867
|
checkAtTop();
|
|
1840
1868
|
if (didChange) {
|
|
@@ -1855,8 +1883,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1855
1883
|
}, []);
|
|
1856
1884
|
const handleScroll = useCallback(
|
|
1857
1885
|
(event, fromSelf) => {
|
|
1858
|
-
var
|
|
1859
|
-
if (((
|
|
1886
|
+
var _a, _b, _c, _d;
|
|
1887
|
+
if (((_b = (_a = event.nativeEvent) == null ? void 0 : _a.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
|
|
1860
1888
|
return;
|
|
1861
1889
|
}
|
|
1862
1890
|
const state = refState.current;
|
|
@@ -1896,7 +1924,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1896
1924
|
checkAtBottom();
|
|
1897
1925
|
checkAtTop();
|
|
1898
1926
|
if (!fromSelf) {
|
|
1899
|
-
(
|
|
1927
|
+
(_d = state.onScroll) == null ? void 0 : _d.call(state, event);
|
|
1900
1928
|
}
|
|
1901
1929
|
},
|
|
1902
1930
|
[]
|
|
@@ -1910,7 +1938,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1910
1938
|
animated = true,
|
|
1911
1939
|
viewPosition = 0
|
|
1912
1940
|
}) => {
|
|
1913
|
-
var
|
|
1941
|
+
var _a;
|
|
1914
1942
|
const state = refState.current;
|
|
1915
1943
|
const firstIndexOffset = calculateOffsetForIndex(index);
|
|
1916
1944
|
let firstIndexScrollPostion = firstIndexOffset - viewOffset;
|
|
@@ -1920,7 +1948,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1920
1948
|
if (needsReanchoring) {
|
|
1921
1949
|
const id = getId(index);
|
|
1922
1950
|
state.anchorElement = { id, coordinate: firstIndexOffset };
|
|
1923
|
-
(
|
|
1951
|
+
(_a = state.belowAnchorElementPositions) == null ? void 0 : _a.clear();
|
|
1924
1952
|
state.positions.clear();
|
|
1925
1953
|
calcTotalSizesAndPositions({ forgetPositions: true });
|
|
1926
1954
|
state.startBufferedId = id;
|
|
@@ -1993,13 +2021,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1993
2021
|
);
|
|
1994
2022
|
if (Platform.OS === "web") {
|
|
1995
2023
|
useEffect(() => {
|
|
1996
|
-
var
|
|
2024
|
+
var _a;
|
|
1997
2025
|
if (initialContentOffset) {
|
|
1998
|
-
(
|
|
2026
|
+
(_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.setDisableAdjust(true);
|
|
1999
2027
|
scrollTo(initialContentOffset, false);
|
|
2000
2028
|
setTimeout(() => {
|
|
2001
|
-
var
|
|
2002
|
-
(
|
|
2029
|
+
var _a2;
|
|
2030
|
+
(_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustHandler.setDisableAdjust(false);
|
|
2003
2031
|
}, 0);
|
|
2004
2032
|
}
|
|
2005
2033
|
}, []);
|
|
@@ -2015,8 +2043,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2015
2043
|
updateItemSize,
|
|
2016
2044
|
handleScroll,
|
|
2017
2045
|
onMomentumScrollEnd: (event) => {
|
|
2018
|
-
var
|
|
2019
|
-
const scrollingToOffset = (
|
|
2046
|
+
var _a;
|
|
2047
|
+
const scrollingToOffset = (_a = refState.current) == null ? void 0 : _a.scrollingToOffset;
|
|
2020
2048
|
if (scrollingToOffset !== void 0) {
|
|
2021
2049
|
requestAnimationFrame(() => {
|
|
2022
2050
|
scrollTo(scrollingToOffset, false);
|
package/keyboard-controller.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var list = require('@legendapp/list');
|
|
4
4
|
var React = require('react');
|
|
5
|
+
var reactNative = require('react-native');
|
|
5
6
|
var reactNativeKeyboardController = require('react-native-keyboard-controller');
|
|
6
7
|
var reactNativeReanimated = require('react-native-reanimated');
|
|
7
8
|
|
|
@@ -28,7 +29,7 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
28
29
|
// src/keyboard-controller.tsx
|
|
29
30
|
var typedForwardRef = React.forwardRef;
|
|
30
31
|
var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
|
|
31
|
-
const { LegendList: LegendListProp, ...rest } = props;
|
|
32
|
+
const { LegendList: LegendListProp, style: styleProp, ...rest } = props;
|
|
32
33
|
const [padding, setPadding] = React.useState(0);
|
|
33
34
|
const updatePadding = (height) => {
|
|
34
35
|
setPadding(height);
|
|
@@ -40,7 +41,9 @@ var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
|
|
|
40
41
|
}
|
|
41
42
|
});
|
|
42
43
|
const LegendListComponent = LegendListProp != null ? LegendListProp : list.LegendList;
|
|
43
|
-
|
|
44
|
+
const styleFlattened = reactNative.StyleSheet.flatten(styleProp) || {};
|
|
45
|
+
const style = { ...styleFlattened, paddingTop: padding + (styleFlattened.paddingTop || 0) };
|
|
46
|
+
return /* @__PURE__ */ React__namespace.createElement(LegendListComponent, { ...rest, style, ref: forwardedRef });
|
|
44
47
|
});
|
|
45
48
|
|
|
46
49
|
exports.LegendList = LegendList;
|
package/keyboard-controller.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { LegendList as LegendList$1 } from '@legendapp/list';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useState, forwardRef } from 'react';
|
|
4
|
+
import { StyleSheet } from 'react-native';
|
|
4
5
|
import { useKeyboardHandler } from 'react-native-keyboard-controller';
|
|
5
6
|
import { runOnJS } from 'react-native-reanimated';
|
|
6
7
|
|
|
7
8
|
// src/keyboard-controller.tsx
|
|
8
9
|
var typedForwardRef = forwardRef;
|
|
9
10
|
var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
|
|
10
|
-
const { LegendList: LegendListProp, ...rest } = props;
|
|
11
|
+
const { LegendList: LegendListProp, style: styleProp, ...rest } = props;
|
|
11
12
|
const [padding, setPadding] = useState(0);
|
|
12
13
|
const updatePadding = (height) => {
|
|
13
14
|
setPadding(height);
|
|
@@ -19,7 +20,9 @@ var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
|
|
|
19
20
|
}
|
|
20
21
|
});
|
|
21
22
|
const LegendListComponent = LegendListProp != null ? LegendListProp : LegendList$1;
|
|
22
|
-
|
|
23
|
+
const styleFlattened = StyleSheet.flatten(styleProp) || {};
|
|
24
|
+
const style = { ...styleFlattened, paddingTop: padding + (styleFlattened.paddingTop || 0) };
|
|
25
|
+
return /* @__PURE__ */ React.createElement(LegendListComponent, { ...rest, style, ref: forwardedRef });
|
|
23
26
|
});
|
|
24
27
|
|
|
25
28
|
export { LegendList };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/list",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.44",
|
|
4
4
|
"description": "Legend List aims to be a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"private": false,
|