@legendapp/list 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.DS_Store +0 -0
- package/CHANGELOG.md +6 -0
- package/index.js +8 -8
- package/index.mjs +8 -8
- package/package.json +1 -1
package/.DS_Store
ADDED
|
Binary file
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## 1.1.3
|
|
2
|
+
- Fix: scrollToEnd was not always setting `viewPosition: 1` correctly
|
|
3
|
+
|
|
4
|
+
## 1.1.2
|
|
5
|
+
- Fix: Adding items in a list with item separators had a small layout jump as the previously last item re-rendered with a separator
|
|
6
|
+
|
|
1
7
|
## 1.1.1
|
|
2
8
|
- Fix: scrollTo accuracy when paddingTop changes
|
|
3
9
|
|
package/index.js
CHANGED
|
@@ -376,17 +376,18 @@ var Container = ({
|
|
|
376
376
|
const [layoutRenderCount, forceLayoutRender] = React2.useState(0);
|
|
377
377
|
const otherAxisPos = numColumns > 1 ? `${(column - 1) / numColumns * 100}%` : 0;
|
|
378
378
|
const otherAxisSize = numColumns > 1 ? `${1 / numColumns * 100}%` : void 0;
|
|
379
|
+
const isALastItem = lastItemKeys.includes(itemKey);
|
|
379
380
|
let paddingStyles;
|
|
380
381
|
if (columnWrapperStyle) {
|
|
381
382
|
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
382
383
|
if (horizontal) {
|
|
383
384
|
paddingStyles = {
|
|
384
|
-
paddingRight: !
|
|
385
|
+
paddingRight: !isALastItem ? columnGap || gap || void 0 : void 0,
|
|
385
386
|
paddingVertical: numColumns > 1 ? (rowGap || gap || 0) / 2 : void 0
|
|
386
387
|
};
|
|
387
388
|
} else {
|
|
388
389
|
paddingStyles = {
|
|
389
|
-
paddingBottom: !
|
|
390
|
+
paddingBottom: !isALastItem ? rowGap || gap || void 0 : void 0,
|
|
390
391
|
paddingHorizontal: numColumns > 1 ? (columnGap || gap || 0) / 2 : void 0
|
|
391
392
|
};
|
|
392
393
|
}
|
|
@@ -445,7 +446,7 @@ var Container = ({
|
|
|
445
446
|
}
|
|
446
447
|
}
|
|
447
448
|
}
|
|
448
|
-
}, [itemKey, layoutRenderCount]);
|
|
449
|
+
}, [itemKey, layoutRenderCount, isALastItem]);
|
|
449
450
|
} else {
|
|
450
451
|
React2.useEffect(() => {
|
|
451
452
|
if (!isNullOrUndefined(itemKey)) {
|
|
@@ -464,7 +465,7 @@ var Container = ({
|
|
|
464
465
|
ctx.viewRefs.set(id, ref);
|
|
465
466
|
return { containerId: id, itemKey, index, value: data, triggerLayout };
|
|
466
467
|
}, [id, itemKey, index, data]);
|
|
467
|
-
const contentFragment = /* @__PURE__ */ React2__namespace.default.createElement(React2__namespace.default.Fragment, { key: recycleItems ? void 0 : itemKey }, /* @__PURE__ */ React2__namespace.default.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && !
|
|
468
|
+
const contentFragment = /* @__PURE__ */ React2__namespace.default.createElement(React2__namespace.default.Fragment, { key: recycleItems ? void 0 : itemKey }, /* @__PURE__ */ React2__namespace.default.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && !isALastItem && /* @__PURE__ */ React2__namespace.default.createElement(ItemSeparatorComponent, { leadingItem: renderedItemInfo.item })));
|
|
468
469
|
if (maintainVisibleContentPosition) {
|
|
469
470
|
const anchorStyle = horizontal ? position.type === "top" ? { position: "absolute", left: 0, top: 0, bottom: 0, flexDirection: "row", alignItems: "stretch" } : { position: "absolute", right: 0, top: 0, bottom: 0, flexDirection: "row", alignItems: "stretch" } : position.type === "top" ? { position: "absolute", top: 0, left: 0, right: 0 } : { position: "absolute", bottom: 0, left: 0, right: 0 };
|
|
470
471
|
if (__DEV__ && ENABLE_DEVMODE) {
|
|
@@ -1226,7 +1227,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1226
1227
|
index,
|
|
1227
1228
|
viewOffset = 0,
|
|
1228
1229
|
animated = true,
|
|
1229
|
-
viewPosition
|
|
1230
|
+
viewPosition
|
|
1230
1231
|
}) => {
|
|
1231
1232
|
var _a;
|
|
1232
1233
|
const state = refState.current;
|
|
@@ -1255,7 +1256,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1255
1256
|
state.minIndexSizeChanged = index;
|
|
1256
1257
|
firstIndexScrollPostion = firstIndexOffset - viewOffset + state.scrollAdjustHandler.getAppliedAdjust();
|
|
1257
1258
|
}
|
|
1258
|
-
scrollTo({ offset: firstIndexScrollPostion, animated, index, viewPosition, viewOffset });
|
|
1259
|
+
scrollTo({ offset: firstIndexScrollPostion, animated, index, viewPosition: viewPosition != null ? viewPosition : 0, viewOffset });
|
|
1259
1260
|
};
|
|
1260
1261
|
const setDidLayout = () => {
|
|
1261
1262
|
refState.current.queuedInitialLayout = true;
|
|
@@ -2511,7 +2512,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2511
2512
|
if (index !== -1) {
|
|
2512
2513
|
const paddingBottom = stylePaddingBottom || 0;
|
|
2513
2514
|
const footerSize = peek$(ctx, "footerSize") || 0;
|
|
2514
|
-
scrollToIndex({ index, viewOffset: -paddingBottom - footerSize, ...options });
|
|
2515
|
+
scrollToIndex({ index, viewPosition: 1, viewOffset: -paddingBottom - footerSize, ...options });
|
|
2515
2516
|
}
|
|
2516
2517
|
}
|
|
2517
2518
|
};
|
|
@@ -2592,7 +2593,6 @@ var LazyLegendList = typedForwardRef2(function LazyLegendList2(props, forwardedR
|
|
|
2592
2593
|
const { LegendList: LegendListProp, children, ...rest } = props;
|
|
2593
2594
|
const LegendListComponent = LegendListProp != null ? LegendListProp : list.LegendList;
|
|
2594
2595
|
const data = (isArray(children) ? children : React2__namespace.Children.toArray(children)).flat(1);
|
|
2595
|
-
console.log({ data });
|
|
2596
2596
|
return (
|
|
2597
2597
|
// @ts-expect-error TODO: Fix this type
|
|
2598
2598
|
/* @__PURE__ */ React2__namespace.createElement(LegendListComponent, { ...rest, data, renderItem, ref: forwardedRef })
|
package/index.mjs
CHANGED
|
@@ -355,17 +355,18 @@ var Container = ({
|
|
|
355
355
|
const [layoutRenderCount, forceLayoutRender] = useState(0);
|
|
356
356
|
const otherAxisPos = numColumns > 1 ? `${(column - 1) / numColumns * 100}%` : 0;
|
|
357
357
|
const otherAxisSize = numColumns > 1 ? `${1 / numColumns * 100}%` : void 0;
|
|
358
|
+
const isALastItem = lastItemKeys.includes(itemKey);
|
|
358
359
|
let paddingStyles;
|
|
359
360
|
if (columnWrapperStyle) {
|
|
360
361
|
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
361
362
|
if (horizontal) {
|
|
362
363
|
paddingStyles = {
|
|
363
|
-
paddingRight: !
|
|
364
|
+
paddingRight: !isALastItem ? columnGap || gap || void 0 : void 0,
|
|
364
365
|
paddingVertical: numColumns > 1 ? (rowGap || gap || 0) / 2 : void 0
|
|
365
366
|
};
|
|
366
367
|
} else {
|
|
367
368
|
paddingStyles = {
|
|
368
|
-
paddingBottom: !
|
|
369
|
+
paddingBottom: !isALastItem ? rowGap || gap || void 0 : void 0,
|
|
369
370
|
paddingHorizontal: numColumns > 1 ? (columnGap || gap || 0) / 2 : void 0
|
|
370
371
|
};
|
|
371
372
|
}
|
|
@@ -424,7 +425,7 @@ var Container = ({
|
|
|
424
425
|
}
|
|
425
426
|
}
|
|
426
427
|
}
|
|
427
|
-
}, [itemKey, layoutRenderCount]);
|
|
428
|
+
}, [itemKey, layoutRenderCount, isALastItem]);
|
|
428
429
|
} else {
|
|
429
430
|
useEffect(() => {
|
|
430
431
|
if (!isNullOrUndefined(itemKey)) {
|
|
@@ -443,7 +444,7 @@ var Container = ({
|
|
|
443
444
|
ctx.viewRefs.set(id, ref);
|
|
444
445
|
return { containerId: id, itemKey, index, value: data, triggerLayout };
|
|
445
446
|
}, [id, itemKey, index, data]);
|
|
446
|
-
const contentFragment = /* @__PURE__ */ React2__default.createElement(React2__default.Fragment, { key: recycleItems ? void 0 : itemKey }, /* @__PURE__ */ React2__default.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && !
|
|
447
|
+
const contentFragment = /* @__PURE__ */ React2__default.createElement(React2__default.Fragment, { key: recycleItems ? void 0 : itemKey }, /* @__PURE__ */ React2__default.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && !isALastItem && /* @__PURE__ */ React2__default.createElement(ItemSeparatorComponent, { leadingItem: renderedItemInfo.item })));
|
|
447
448
|
if (maintainVisibleContentPosition) {
|
|
448
449
|
const anchorStyle = horizontal ? position.type === "top" ? { position: "absolute", left: 0, top: 0, bottom: 0, flexDirection: "row", alignItems: "stretch" } : { position: "absolute", right: 0, top: 0, bottom: 0, flexDirection: "row", alignItems: "stretch" } : position.type === "top" ? { position: "absolute", top: 0, left: 0, right: 0 } : { position: "absolute", bottom: 0, left: 0, right: 0 };
|
|
449
450
|
if (__DEV__ && ENABLE_DEVMODE) {
|
|
@@ -1205,7 +1206,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1205
1206
|
index,
|
|
1206
1207
|
viewOffset = 0,
|
|
1207
1208
|
animated = true,
|
|
1208
|
-
viewPosition
|
|
1209
|
+
viewPosition
|
|
1209
1210
|
}) => {
|
|
1210
1211
|
var _a;
|
|
1211
1212
|
const state = refState.current;
|
|
@@ -1234,7 +1235,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1234
1235
|
state.minIndexSizeChanged = index;
|
|
1235
1236
|
firstIndexScrollPostion = firstIndexOffset - viewOffset + state.scrollAdjustHandler.getAppliedAdjust();
|
|
1236
1237
|
}
|
|
1237
|
-
scrollTo({ offset: firstIndexScrollPostion, animated, index, viewPosition, viewOffset });
|
|
1238
|
+
scrollTo({ offset: firstIndexScrollPostion, animated, index, viewPosition: viewPosition != null ? viewPosition : 0, viewOffset });
|
|
1238
1239
|
};
|
|
1239
1240
|
const setDidLayout = () => {
|
|
1240
1241
|
refState.current.queuedInitialLayout = true;
|
|
@@ -2490,7 +2491,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2490
2491
|
if (index !== -1) {
|
|
2491
2492
|
const paddingBottom = stylePaddingBottom || 0;
|
|
2492
2493
|
const footerSize = peek$(ctx, "footerSize") || 0;
|
|
2493
|
-
scrollToIndex({ index, viewOffset: -paddingBottom - footerSize, ...options });
|
|
2494
|
+
scrollToIndex({ index, viewPosition: 1, viewOffset: -paddingBottom - footerSize, ...options });
|
|
2494
2495
|
}
|
|
2495
2496
|
}
|
|
2496
2497
|
};
|
|
@@ -2571,7 +2572,6 @@ var LazyLegendList = typedForwardRef2(function LazyLegendList2(props, forwardedR
|
|
|
2571
2572
|
const { LegendList: LegendListProp, children, ...rest } = props;
|
|
2572
2573
|
const LegendListComponent = LegendListProp != null ? LegendListProp : LegendList$1;
|
|
2573
2574
|
const data = (isArray(children) ? children : React2.Children.toArray(children)).flat(1);
|
|
2574
|
-
console.log({ data });
|
|
2575
2575
|
return (
|
|
2576
2576
|
// @ts-expect-error TODO: Fix this type
|
|
2577
2577
|
/* @__PURE__ */ React2.createElement(LegendListComponent, { ...rest, data, renderItem, ref: forwardedRef })
|
package/package.json
CHANGED