@skyscanner/backpack-web 38.18.0 → 38.19.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.
|
@@ -66,14 +66,19 @@ const BpkCardListCarousel = props => {
|
|
|
66
66
|
const shownIndicatorCount = Math.min(totalPages, PAGINATION_INDICATOR_MAX_SHOWN_COUNT);
|
|
67
67
|
return Math.max(RENDER_BUFFER_SIZE, (shownIndicatorCount - 1) * initiallyShownCards);
|
|
68
68
|
}, [childrenLength, initiallyShownCards, isMobile]);
|
|
69
|
-
const renderList = useMemo(() => visibilityList.map((_, index) =>
|
|
69
|
+
const renderList = useMemo(() => visibilityList.map((_, index) => {
|
|
70
|
+
const isIndexVisible = index >= firstVisibleIndex - dynamicRenderBufferSize && index <= lastVisibleIndex + dynamicRenderBufferSize;
|
|
71
|
+
if (isIndexVisible) {
|
|
72
|
+
hasBeenVisibleRef.current.add(index);
|
|
73
|
+
}
|
|
74
|
+
return isIndexVisible ? 1 : 0;
|
|
75
|
+
}), [visibilityList, firstVisibleIndex, lastVisibleIndex, dynamicRenderBufferSize]);
|
|
70
76
|
const cardRefFns = useMemo(() => Array(childrenLength).fill(null).map((_, i) => el => {
|
|
71
77
|
cardRefs.current[i] = el;
|
|
72
78
|
observerVisibility(el, i);
|
|
73
79
|
setA11yTabIndex(el, i, visibilityList);
|
|
74
80
|
// record the first card's width and height when it becomes visible
|
|
75
81
|
if (el && visibilityList[i] === 0) {
|
|
76
|
-
hasBeenVisibleRef.current.add(i);
|
|
77
82
|
if (firstCardWidthRef.current == null && el.offsetWidth) {
|
|
78
83
|
firstCardWidthRef.current = el.offsetWidth;
|
|
79
84
|
}
|
|
@@ -81,7 +86,7 @@ const BpkCardListCarousel = props => {
|
|
|
81
86
|
firstCardHeightRef.current = el.offsetHeight;
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
|
-
}), [childrenLength, observerVisibility, visibilityList,
|
|
89
|
+
}), [childrenLength, observerVisibility, visibilityList, firstCardWidthRef, firstCardHeightRef]);
|
|
85
90
|
useEffect(() => {
|
|
86
91
|
const container = root;
|
|
87
92
|
if (isMobile || !container) return undefined;
|
|
@@ -143,30 +148,36 @@ const BpkCardListCarousel = props => {
|
|
|
143
148
|
if (firstCardHeightRef.current) {
|
|
144
149
|
cardDimensionStyle.height = `${firstCardHeightRef.current}px`;
|
|
145
150
|
}
|
|
151
|
+
const commonProps = {
|
|
152
|
+
className: getClassName(`bpk-card-list-row-rail__${layout}__card`),
|
|
153
|
+
style: {
|
|
154
|
+
...shownNumberStyle,
|
|
155
|
+
...cardDimensionStyle
|
|
156
|
+
},
|
|
157
|
+
key: `carousel-card-${index.toString()}`,
|
|
158
|
+
role: "group"
|
|
159
|
+
};
|
|
146
160
|
|
|
147
161
|
// Only render cards that are within the renderList range or have been visible before
|
|
148
|
-
|
|
162
|
+
const shouldRenderCard = renderList[index] === 1 || hasBeenVisibleRef.current.has(index);
|
|
163
|
+
if (!shouldRenderCard) {
|
|
149
164
|
return /*#__PURE__*/_jsx("div", {
|
|
165
|
+
...commonProps,
|
|
150
166
|
style: {
|
|
151
|
-
...
|
|
152
|
-
|
|
153
|
-
flexShrink: 0,
|
|
154
|
-
visibility: 'hidden'
|
|
167
|
+
...commonProps.style,
|
|
168
|
+
contain: 'paint'
|
|
155
169
|
},
|
|
156
|
-
"
|
|
157
|
-
|
|
170
|
+
"data-testid": "bpk-card-list-carousel--placeholder",
|
|
171
|
+
"aria-hidden": "true",
|
|
172
|
+
children: card
|
|
173
|
+
});
|
|
158
174
|
}
|
|
159
175
|
return /*#__PURE__*/_jsx("div", {
|
|
160
|
-
|
|
176
|
+
...commonProps,
|
|
161
177
|
ref: cardRefFns[index],
|
|
162
|
-
style: {
|
|
163
|
-
...shownNumberStyle,
|
|
164
|
-
...cardDimensionStyle
|
|
165
|
-
},
|
|
166
|
-
role: "group",
|
|
167
178
|
"aria-label": slideLabel(index, childrenLength),
|
|
168
179
|
children: card
|
|
169
|
-
}
|
|
180
|
+
});
|
|
170
181
|
})
|
|
171
182
|
});
|
|
172
183
|
};
|
|
@@ -28,8 +28,10 @@ const setPageProperties = ({
|
|
|
28
28
|
isDialogOpen
|
|
29
29
|
}) => {
|
|
30
30
|
document.body.style.overflowY = isDialogOpen ? 'hidden' : 'visible';
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
if (!dialogSupported) {
|
|
32
|
+
document.body.style.position = isDialogOpen ? 'fixed' : 'relative';
|
|
33
|
+
document.body.style.width = isDialogOpen ? '100%' : 'auto';
|
|
34
|
+
}
|
|
33
35
|
};
|
|
34
36
|
export const BpkDialogWrapper = ({
|
|
35
37
|
children,
|