react-native-divkit 1.6.5 → 1.7.0
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/README.md +3 -1
- package/dist/DivKit.d.ts.map +1 -1
- package/dist/DivKit.js +6 -3
- package/dist/DivKit.js.map +1 -1
- package/dist/components/DivComponent.d.ts.map +1 -1
- package/dist/components/DivComponent.js +6 -2
- package/dist/components/DivComponent.js.map +1 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/indicator/DivIndicator.d.ts +19 -0
- package/dist/components/indicator/DivIndicator.d.ts.map +1 -0
- package/dist/components/indicator/DivIndicator.js +112 -0
- package/dist/components/indicator/DivIndicator.js.map +1 -0
- package/dist/components/indicator/index.d.ts +3 -0
- package/dist/components/indicator/index.d.ts.map +1 -0
- package/dist/components/indicator/index.js +2 -0
- package/dist/components/indicator/index.js.map +1 -0
- package/dist/components/indicator/utils.d.ts +61 -0
- package/dist/components/indicator/utils.d.ts.map +1 -0
- package/dist/components/indicator/utils.js +104 -0
- package/dist/components/indicator/utils.js.map +1 -0
- package/dist/components/pager/DivPager.d.ts +22 -0
- package/dist/components/pager/DivPager.d.ts.map +1 -0
- package/dist/components/pager/DivPager.js +269 -0
- package/dist/components/pager/DivPager.js.map +1 -0
- package/dist/components/pager/index.d.ts +3 -0
- package/dist/components/pager/index.d.ts.map +1 -0
- package/dist/components/pager/index.js +2 -0
- package/dist/components/pager/index.js.map +1 -0
- package/dist/components/pager/utils.d.ts +96 -0
- package/dist/components/pager/utils.d.ts.map +1 -0
- package/dist/components/pager/utils.js +142 -0
- package/dist/components/pager/utils.js.map +1 -0
- package/dist/components/utilities/Outer.d.ts.map +1 -1
- package/dist/components/utilities/Outer.js +4 -3
- package/dist/components/utilities/Outer.js.map +1 -1
- package/dist/context/PagerContext.d.ts +30 -0
- package/dist/context/PagerContext.d.ts.map +1 -0
- package/dist/context/PagerContext.js +76 -0
- package/dist/context/PagerContext.js.map +1 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -0
- package/dist/context/index.js.map +1 -1
- package/package.json +2 -1
- package/src/DivKit.tsx +6 -3
- package/src/components/DivComponent.tsx +8 -2
- package/src/components/README.md +59 -5
- package/src/components/index.ts +4 -0
- package/src/components/indicator/DivIndicator.tsx +175 -0
- package/src/components/indicator/index.ts +2 -0
- package/src/components/indicator/utils.ts +149 -0
- package/src/components/pager/DivPager.tsx +393 -0
- package/src/components/pager/index.ts +2 -0
- package/src/components/pager/utils.ts +214 -0
- package/src/components/utilities/Outer.tsx +4 -2
- package/src/context/PagerContext.tsx +108 -0
- package/src/context/index.ts +8 -0
- package/src/types/indicator.d.ts +32 -0
- package/src/types/pager.d.ts +36 -0
- package/src/types/shape.d.ts +26 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useRef, useState, useCallback } from 'react';
|
|
2
|
+
import { View, ScrollView, StyleSheet } from 'react-native';
|
|
3
|
+
import { Outer } from '../utilities/Outer';
|
|
4
|
+
import { DivComponent } from '../DivComponent';
|
|
5
|
+
import { useDerivedFromVarsSimple } from '../../hooks/useDerivedFromVars';
|
|
6
|
+
import { useDivKitContext } from '../../context/DivKitContext';
|
|
7
|
+
import { usePagerContextOptional } from '../../context/PagerContext';
|
|
8
|
+
import { wrapError } from '../../utils/wrapError';
|
|
9
|
+
import { DUPLICATES_IN_INFINITE, buildRenderedItems, computeContentPad, computePageSize, isInDuplicateRegion as isInDuplicateRegionFn, isInfiniteEnabled, offsetToPosition, positionToReal as positionToRealFn, realToPosition as realToPositionFn } from './utils';
|
|
10
|
+
const DUPLICATES = DUPLICATES_IN_INFINITE;
|
|
11
|
+
/**
|
|
12
|
+
* DivPager — horizontal/vertical pager with snap-to-page scrolling.
|
|
13
|
+
*
|
|
14
|
+
* Based on Web Pager.svelte. Adapted for React Native:
|
|
15
|
+
* - Uses ScrollView with snapToInterval for paging behaviour.
|
|
16
|
+
* - Computes per-page size from layout_mode (fixed neighbour, percentage,
|
|
17
|
+
* wrap_content) once container size is known.
|
|
18
|
+
* - infinite_scroll: renders DUPLICATES extra items at each end; when the user
|
|
19
|
+
* lands on a duplicate the scroll position is silently snapped to the
|
|
20
|
+
* matching real item (no animation), giving a seamless loop.
|
|
21
|
+
* - Exposes its current page/size to indicators via PagerContext using the
|
|
22
|
+
* same registerPager/listenPager contract as Web. The "currentItem" reported
|
|
23
|
+
* to indicators is always the real index in [0, items.length).
|
|
24
|
+
*/
|
|
25
|
+
export function DivPager({ componentContext }) {
|
|
26
|
+
const { genId } = useDivKitContext();
|
|
27
|
+
const pagerCtx = usePagerContextOptional();
|
|
28
|
+
const { json, variables } = componentContext;
|
|
29
|
+
const orientation = useDerivedFromVarsSimple(json.orientation || 'horizontal', variables || new Map());
|
|
30
|
+
const layoutMode = useDerivedFromVarsSimple(json.layout_mode, variables || new Map());
|
|
31
|
+
const itemSpacingObj = useDerivedFromVarsSimple(json.item_spacing, variables || new Map());
|
|
32
|
+
const paddings = useDerivedFromVarsSimple(json.paddings, variables || new Map());
|
|
33
|
+
const scrollAxisAlignment = useDerivedFromVarsSimple(json.scroll_axis_alignment || 'center', variables || new Map());
|
|
34
|
+
const defaultItem = useDerivedFromVarsSimple(typeof json.default_item === 'number' ? json.default_item : 0, variables || new Map());
|
|
35
|
+
const infiniteScroll = useDerivedFromVarsSimple(json.infinite_scroll, variables || new Map());
|
|
36
|
+
const isHorizontal = orientation !== 'vertical';
|
|
37
|
+
const itemSpacing = itemSpacingObj?.value ?? 0;
|
|
38
|
+
const items = useMemo(() => {
|
|
39
|
+
return Array.isArray(json.items) ? json.items : [];
|
|
40
|
+
}, [json.items]);
|
|
41
|
+
const isInfinite = useMemo(() => isInfiniteEnabled(infiniteScroll, items.length), [infiniteScroll, items.length]);
|
|
42
|
+
// Pager paddings — applied on the inner ScrollView so we can also use them
|
|
43
|
+
// for snap math. Outer should NOT also apply them, so we strip them from
|
|
44
|
+
// the json passed into Outer below.
|
|
45
|
+
const innerPadStart = useMemo(() => {
|
|
46
|
+
const p = paddings || {};
|
|
47
|
+
if (isHorizontal) {
|
|
48
|
+
return Number(p.start ?? p.left ?? 0) || 0;
|
|
49
|
+
}
|
|
50
|
+
return Number(p.top ?? 0) || 0;
|
|
51
|
+
}, [paddings, isHorizontal]);
|
|
52
|
+
const innerPadEnd = useMemo(() => {
|
|
53
|
+
const p = paddings || {};
|
|
54
|
+
if (isHorizontal) {
|
|
55
|
+
return Number(p.end ?? p.right ?? 0) || 0;
|
|
56
|
+
}
|
|
57
|
+
return Number(p.bottom ?? 0) || 0;
|
|
58
|
+
}, [paddings, isHorizontal]);
|
|
59
|
+
const [containerSize, setContainerSize] = useState(0);
|
|
60
|
+
const scrollRef = useRef(null);
|
|
61
|
+
const currentItemRef = useRef(0); // real index, always in [0, items.length)
|
|
62
|
+
const initialScrollDone = useRef(false);
|
|
63
|
+
const registerDataRef = useRef(null);
|
|
64
|
+
const pagerInstId = useRef(genId('pager'));
|
|
65
|
+
const scrollToItemRef = useRef(null);
|
|
66
|
+
const pageSize = useMemo(() => computePageSize({
|
|
67
|
+
containerSize,
|
|
68
|
+
layoutMode,
|
|
69
|
+
scrollAxisAlignment: scrollAxisAlignment,
|
|
70
|
+
itemSpacing,
|
|
71
|
+
innerPadStart,
|
|
72
|
+
innerPadEnd
|
|
73
|
+
}), [containerSize, innerPadStart, innerPadEnd, layoutMode, scrollAxisAlignment, itemSpacing]);
|
|
74
|
+
const snapInterval = pageSize > 0 ? pageSize + itemSpacing : 0;
|
|
75
|
+
const contentPad = useMemo(() => computeContentPad({
|
|
76
|
+
containerSize,
|
|
77
|
+
pageSize,
|
|
78
|
+
innerPadStart,
|
|
79
|
+
innerPadEnd,
|
|
80
|
+
layoutMode,
|
|
81
|
+
scrollAxisAlignment: scrollAxisAlignment,
|
|
82
|
+
itemSpacing,
|
|
83
|
+
isInfinite
|
|
84
|
+
}), [
|
|
85
|
+
containerSize,
|
|
86
|
+
pageSize,
|
|
87
|
+
innerPadStart,
|
|
88
|
+
innerPadEnd,
|
|
89
|
+
layoutMode,
|
|
90
|
+
scrollAxisAlignment,
|
|
91
|
+
itemSpacing,
|
|
92
|
+
isInfinite
|
|
93
|
+
]);
|
|
94
|
+
const realToPosition = useCallback((realIdx) => realToPositionFn(realIdx, isInfinite, DUPLICATES), [isInfinite]);
|
|
95
|
+
const positionToReal = useCallback((pos) => positionToRealFn(pos, isInfinite, items.length, DUPLICATES), [isInfinite, items.length]);
|
|
96
|
+
const isInDuplicateRegion = useCallback((pos) => isInDuplicateRegionFn(pos, isInfinite, items.length, DUPLICATES), [isInfinite, items.length]);
|
|
97
|
+
const runSelectedActions = useCallback((index) => {
|
|
98
|
+
const item = items[index];
|
|
99
|
+
const actions = item?.selected_actions;
|
|
100
|
+
if (Array.isArray(actions) && actions.length > 0) {
|
|
101
|
+
componentContext.execAnyActions(actions);
|
|
102
|
+
}
|
|
103
|
+
}, [items, componentContext]);
|
|
104
|
+
const pushPagerState = useCallback((item) => {
|
|
105
|
+
const reg = registerDataRef.current;
|
|
106
|
+
if (!reg)
|
|
107
|
+
return;
|
|
108
|
+
const data = {
|
|
109
|
+
instId: pagerInstId.current,
|
|
110
|
+
size: items.length,
|
|
111
|
+
currentItem: item,
|
|
112
|
+
scrollToPagerItem: (index) => scrollToItemRef.current?.(index, true)
|
|
113
|
+
};
|
|
114
|
+
reg.update(data);
|
|
115
|
+
}, [items.length]);
|
|
116
|
+
const scrollToItem = useCallback((realIndex, animated) => {
|
|
117
|
+
const node = scrollRef.current;
|
|
118
|
+
if (!node || snapInterval <= 0 || items.length === 0)
|
|
119
|
+
return;
|
|
120
|
+
const clampedReal = isInfinite
|
|
121
|
+
? ((realIndex % items.length) + items.length) % items.length
|
|
122
|
+
: Math.max(0, Math.min(items.length - 1, realIndex));
|
|
123
|
+
const pos = realToPosition(clampedReal);
|
|
124
|
+
const offset = pos * snapInterval;
|
|
125
|
+
if (isHorizontal) {
|
|
126
|
+
node.scrollTo({ x: offset, y: 0, animated });
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
node.scrollTo({ x: 0, y: offset, animated });
|
|
130
|
+
}
|
|
131
|
+
if (clampedReal !== currentItemRef.current) {
|
|
132
|
+
currentItemRef.current = clampedReal;
|
|
133
|
+
pushPagerState(clampedReal);
|
|
134
|
+
runSelectedActions(clampedReal);
|
|
135
|
+
}
|
|
136
|
+
}, [
|
|
137
|
+
items.length,
|
|
138
|
+
snapInterval,
|
|
139
|
+
isHorizontal,
|
|
140
|
+
isInfinite,
|
|
141
|
+
realToPosition,
|
|
142
|
+
pushPagerState,
|
|
143
|
+
runSelectedActions
|
|
144
|
+
]);
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
scrollToItemRef.current = scrollToItem;
|
|
147
|
+
}, [scrollToItem]);
|
|
148
|
+
// Register pager in context (so indicators can find it)
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
if (!pagerCtx)
|
|
151
|
+
return;
|
|
152
|
+
const pagerId = json.id;
|
|
153
|
+
const reg = pagerCtx.registerPager(pagerId);
|
|
154
|
+
registerDataRef.current = reg;
|
|
155
|
+
pushPagerState(currentItemRef.current);
|
|
156
|
+
return () => {
|
|
157
|
+
reg.destroy();
|
|
158
|
+
registerDataRef.current = null;
|
|
159
|
+
};
|
|
160
|
+
}, [pagerCtx, json.id, pushPagerState]);
|
|
161
|
+
// Re-broadcast on items length / scrollToItem changes
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
pushPagerState(currentItemRef.current);
|
|
164
|
+
}, [pushPagerState]);
|
|
165
|
+
// Initial scroll to default_item once we know page size
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
if (initialScrollDone.current)
|
|
168
|
+
return;
|
|
169
|
+
if (snapInterval <= 0)
|
|
170
|
+
return;
|
|
171
|
+
const initial = Math.max(0, Math.min(items.length - 1, defaultItem ?? 0));
|
|
172
|
+
currentItemRef.current = initial;
|
|
173
|
+
const id = setTimeout(() => {
|
|
174
|
+
scrollToItem(initial, false);
|
|
175
|
+
initialScrollDone.current = true;
|
|
176
|
+
pushPagerState(initial);
|
|
177
|
+
}, 0);
|
|
178
|
+
return () => clearTimeout(id);
|
|
179
|
+
}, [snapInterval, defaultItem, items.length, scrollToItem, pushPagerState]);
|
|
180
|
+
const onScrollEnd = useCallback((event) => {
|
|
181
|
+
if (snapInterval <= 0)
|
|
182
|
+
return;
|
|
183
|
+
const { contentOffset } = event.nativeEvent;
|
|
184
|
+
const offset = isHorizontal ? contentOffset.x : contentOffset.y;
|
|
185
|
+
const pos = offsetToPosition(offset, snapInterval);
|
|
186
|
+
const realIdx = positionToReal(pos);
|
|
187
|
+
// In infinite mode: silently snap from a duplicate back to the
|
|
188
|
+
// matching real item without animation.
|
|
189
|
+
if (isInfinite && isInDuplicateRegion(pos)) {
|
|
190
|
+
const realPos = realToPosition(realIdx);
|
|
191
|
+
const node = scrollRef.current;
|
|
192
|
+
if (node) {
|
|
193
|
+
const realOffset = realPos * snapInterval;
|
|
194
|
+
if (isHorizontal) {
|
|
195
|
+
node.scrollTo({ x: realOffset, y: 0, animated: false });
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
node.scrollTo({ x: 0, y: realOffset, animated: false });
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (realIdx !== currentItemRef.current) {
|
|
203
|
+
currentItemRef.current = realIdx;
|
|
204
|
+
pushPagerState(realIdx);
|
|
205
|
+
runSelectedActions(realIdx);
|
|
206
|
+
}
|
|
207
|
+
}, [
|
|
208
|
+
snapInterval,
|
|
209
|
+
isHorizontal,
|
|
210
|
+
positionToReal,
|
|
211
|
+
isInDuplicateRegion,
|
|
212
|
+
isInfinite,
|
|
213
|
+
realToPosition,
|
|
214
|
+
pushPagerState,
|
|
215
|
+
runSelectedActions
|
|
216
|
+
]);
|
|
217
|
+
const onLayout = useCallback((e) => {
|
|
218
|
+
const size = isHorizontal ? e.nativeEvent.layout.width : e.nativeEvent.layout.height;
|
|
219
|
+
if (size && Math.abs(size - containerSize) > 0.5) {
|
|
220
|
+
setContainerSize(size);
|
|
221
|
+
}
|
|
222
|
+
}, [containerSize, isHorizontal]);
|
|
223
|
+
// Strip paddings from Outer — we apply them on the ScrollView ourselves.
|
|
224
|
+
const outerContext = useMemo(() => {
|
|
225
|
+
const restJson = { ...json };
|
|
226
|
+
delete restJson.paddings;
|
|
227
|
+
return { ...componentContext, json: restJson };
|
|
228
|
+
}, [componentContext, json]);
|
|
229
|
+
const renderedItems = useMemo(() => buildRenderedItems(items, isInfinite, DUPLICATES), [items, isInfinite]);
|
|
230
|
+
if (!json.layout_mode) {
|
|
231
|
+
componentContext.logError(wrapError(new Error('Empty "layout_mode" prop for div "pager"')));
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
const renderItems = () => {
|
|
235
|
+
if (!renderedItems.length || pageSize <= 0)
|
|
236
|
+
return null;
|
|
237
|
+
return renderedItems.map((entry, posIndex) => {
|
|
238
|
+
const childContext = componentContext.produceChildContext(entry.item, {
|
|
239
|
+
path: posIndex
|
|
240
|
+
});
|
|
241
|
+
const isLast = posIndex === renderedItems.length - 1;
|
|
242
|
+
const itemStyle = isHorizontal
|
|
243
|
+
? { width: pageSize, marginRight: isLast ? 0 : itemSpacing }
|
|
244
|
+
: { height: pageSize, marginBottom: isLast ? 0 : itemSpacing };
|
|
245
|
+
return (<View key={entry.key} style={[styles.itemWrapper, itemStyle]}>
|
|
246
|
+
<DivComponent componentContext={childContext}/>
|
|
247
|
+
</View>);
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
return (<Outer componentContext={outerContext}>
|
|
251
|
+
<View style={styles.fill} onLayout={onLayout}>
|
|
252
|
+
{pageSize > 0 ? (<ScrollView ref={scrollRef} horizontal={isHorizontal} showsHorizontalScrollIndicator={false} showsVerticalScrollIndicator={false} decelerationRate="fast" snapToInterval={snapInterval} snapToAlignment="start" disableIntervalMomentum onMomentumScrollEnd={onScrollEnd} onScrollEndDrag={onScrollEnd} scrollEventThrottle={16} contentContainerStyle={isHorizontal
|
|
253
|
+
? { paddingLeft: contentPad.start, paddingRight: contentPad.end }
|
|
254
|
+
: { paddingTop: contentPad.start, paddingBottom: contentPad.end }} style={styles.fill}>
|
|
255
|
+
{renderItems()}
|
|
256
|
+
</ScrollView>) : null}
|
|
257
|
+
</View>
|
|
258
|
+
</Outer>);
|
|
259
|
+
}
|
|
260
|
+
const styles = StyleSheet.create({
|
|
261
|
+
fill: {
|
|
262
|
+
flex: 1,
|
|
263
|
+
alignSelf: 'stretch'
|
|
264
|
+
},
|
|
265
|
+
itemWrapper: {
|
|
266
|
+
overflow: 'hidden'
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
//# sourceMappingURL=DivPager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DivPager.js","sourceRoot":"","sources":["../../../src/components/pager/DivPager.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,EACH,IAAI,EACJ,UAAU,EAIV,UAAU,EACb,MAAM,cAAc,CAAC;AAKtB,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EACH,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,mBA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ACP,SAAS,EAAE,SAAS;KACvB;IACD,WAAW,EAAE;QACT,QAAQ,EAAE,QAAQ;KACrB;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/pager/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/pager/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for DivPager. Extracted so they can be unit-tested without
|
|
3
|
+
* having to render the React tree.
|
|
4
|
+
*/
|
|
5
|
+
export type ScrollAxisAlignment = 'start' | 'center' | 'end';
|
|
6
|
+
export interface LayoutModeFixed {
|
|
7
|
+
type: 'fixed';
|
|
8
|
+
neighbour_page_width?: {
|
|
9
|
+
value?: number;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface LayoutModePercentage {
|
|
13
|
+
type: 'percentage';
|
|
14
|
+
page_width?: {
|
|
15
|
+
value?: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface LayoutModeWrap {
|
|
19
|
+
type: 'wrap_content';
|
|
20
|
+
}
|
|
21
|
+
export type AnyLayoutMode = LayoutModeFixed | LayoutModePercentage | LayoutModeWrap | {
|
|
22
|
+
type?: string;
|
|
23
|
+
[k: string]: unknown;
|
|
24
|
+
} | null | undefined;
|
|
25
|
+
export interface ComputePageSizeArgs {
|
|
26
|
+
containerSize: number;
|
|
27
|
+
layoutMode: AnyLayoutMode;
|
|
28
|
+
scrollAxisAlignment: ScrollAxisAlignment;
|
|
29
|
+
itemSpacing: number;
|
|
30
|
+
innerPadStart: number;
|
|
31
|
+
innerPadEnd: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Compute the size of a single page along the main axis. Mirrors the Web
|
|
35
|
+
* Pager.svelte autoSizeVal calculation:
|
|
36
|
+
* - fixed + center: containerSize − 2·neighbour − 2·spacing
|
|
37
|
+
* - fixed + start/end: containerSize − neighbour − spacing
|
|
38
|
+
* - percentage: containerSize · page_width / 100
|
|
39
|
+
* - wrap_content / unknown: usable area (containerSize − paddings)
|
|
40
|
+
*/
|
|
41
|
+
export declare function computePageSize(args: ComputePageSizeArgs): number;
|
|
42
|
+
export interface ComputeContentPadArgs extends ComputePageSizeArgs {
|
|
43
|
+
pageSize: number;
|
|
44
|
+
isInfinite: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Compute the contentContainer paddings the inner ScrollView needs so that the
|
|
48
|
+
* first/last items snap to the right visual position (centre/start/end). In
|
|
49
|
+
* infinite mode the duplicates take that role and we use zero padding.
|
|
50
|
+
*/
|
|
51
|
+
export declare function computeContentPad(args: ComputeContentPadArgs): {
|
|
52
|
+
start: number;
|
|
53
|
+
end: number;
|
|
54
|
+
};
|
|
55
|
+
export declare const DUPLICATES_IN_INFINITE = 2;
|
|
56
|
+
/**
|
|
57
|
+
* Map a "real" item index (0..size-1) to its rendered position.
|
|
58
|
+
* In infinite mode the real items live in [DUPLICATES, DUPLICATES + size).
|
|
59
|
+
*/
|
|
60
|
+
export declare function realToPosition(realIdx: number, isInfinite: boolean, duplicates?: number): number;
|
|
61
|
+
/**
|
|
62
|
+
* Map a rendered position back to the real index. Wraps modulo `size` when
|
|
63
|
+
* the position lands inside the duplicate region.
|
|
64
|
+
*/
|
|
65
|
+
export declare function positionToReal(pos: number, isInfinite: boolean, size: number, duplicates?: number): number;
|
|
66
|
+
/**
|
|
67
|
+
* True when `pos` corresponds to one of the duplicate entries (only meaningful
|
|
68
|
+
* in infinite mode).
|
|
69
|
+
*/
|
|
70
|
+
export declare function isInDuplicateRegion(pos: number, isInfinite: boolean, size: number, duplicates?: number): boolean;
|
|
71
|
+
export interface RenderedItemEntry<T> {
|
|
72
|
+
item: T;
|
|
73
|
+
realIndex: number;
|
|
74
|
+
key: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Build the list of items to render. In infinite mode this prefixes the array
|
|
78
|
+
* with `duplicates` copies of the last items and suffixes it with `duplicates`
|
|
79
|
+
* copies of the first items, so the user can swipe past either edge and land
|
|
80
|
+
* on something visually identical to the wrap-around target.
|
|
81
|
+
*/
|
|
82
|
+
export declare function buildRenderedItems<T extends {
|
|
83
|
+
id?: string;
|
|
84
|
+
}>(items: T[], isInfinite: boolean, duplicates?: number): RenderedItemEntry<T>[];
|
|
85
|
+
/**
|
|
86
|
+
* Decide whether infinite_scroll should actually be active.
|
|
87
|
+
* Mirrors Web's correctBooleanInt + the `items.length >= DUPLICATES_IN_INFINITE`
|
|
88
|
+
* gate.
|
|
89
|
+
*/
|
|
90
|
+
export declare function isInfiniteEnabled(infiniteValue: unknown, itemsLength: number): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Convert a scroll offset (in px) into a snap position (rounded). Returns 0
|
|
93
|
+
* when snapInterval <= 0.
|
|
94
|
+
*/
|
|
95
|
+
export declare function offsetToPosition(offset: number, snapInterval: number): number;
|
|
96
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/pager/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE7D,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,oBAAoB,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C;AACD,MAAM,WAAW,oBAAoB;IACjC,IAAI,EA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AC/B,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,OAAO,EACnB,IAAI,EAAE,MAAM,EACZ,UAAU,SAAyB,GACpC,OAAO,CAGT;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC;IACR,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,EACxD,KAAK,EAAE,CAAC,EAAE,EACV,UAAU,EAAE,OAAO,EACnB,UAAU,SAAyB,GACpC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAsBxB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAOtF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAG7E"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for DivPager. Extracted so they can be unit-tested without
|
|
3
|
+
* having to render the React tree.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Compute the size of a single page along the main axis. Mirrors the Web
|
|
7
|
+
* Pager.svelte autoSizeVal calculation:
|
|
8
|
+
* - fixed + center: containerSize − 2·neighbour − 2·spacing
|
|
9
|
+
* - fixed + start/end: containerSize − neighbour − spacing
|
|
10
|
+
* - percentage: containerSize · page_width / 100
|
|
11
|
+
* - wrap_content / unknown: usable area (containerSize − paddings)
|
|
12
|
+
*/
|
|
13
|
+
export function computePageSize(args) {
|
|
14
|
+
const { containerSize, layoutMode, scrollAxisAlignment, itemSpacing, innerPadStart, innerPadEnd } = args;
|
|
15
|
+
if (containerSize <= 0)
|
|
16
|
+
return 0;
|
|
17
|
+
const usable = containerSize - innerPadStart - innerPadEnd;
|
|
18
|
+
const lm = layoutMode;
|
|
19
|
+
if (lm && lm.type === 'fixed') {
|
|
20
|
+
const neighbourW = lm.neighbour_page_width?.value ?? 0;
|
|
21
|
+
if (scrollAxisAlignment === 'center') {
|
|
22
|
+
return Math.max(0, containerSize - 2 * neighbourW - 2 * itemSpacing);
|
|
23
|
+
}
|
|
24
|
+
return Math.max(0, containerSize - neighbourW - itemSpacing);
|
|
25
|
+
}
|
|
26
|
+
if (lm && lm.type === 'percentage') {
|
|
27
|
+
const pageW = lm.page_width?.value ?? 100;
|
|
28
|
+
return Math.max(0, (containerSize * pageW) / 100);
|
|
29
|
+
}
|
|
30
|
+
return Math.max(0, usable);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Compute the contentContainer paddings the inner ScrollView needs so that the
|
|
34
|
+
* first/last items snap to the right visual position (centre/start/end). In
|
|
35
|
+
* infinite mode the duplicates take that role and we use zero padding.
|
|
36
|
+
*/
|
|
37
|
+
export function computeContentPad(args) {
|
|
38
|
+
const { containerSize, pageSize, innerPadStart, innerPadEnd, layoutMode, scrollAxisAlignment, itemSpacing, isInfinite } = args;
|
|
39
|
+
if (containerSize <= 0 || pageSize <= 0) {
|
|
40
|
+
return { start: innerPadStart, end: innerPadEnd };
|
|
41
|
+
}
|
|
42
|
+
if (isInfinite) {
|
|
43
|
+
return { start: 0, end: 0 };
|
|
44
|
+
}
|
|
45
|
+
const lm = layoutMode;
|
|
46
|
+
if (lm && lm.type === 'fixed') {
|
|
47
|
+
const neighbourW = lm.neighbour_page_width?.value ?? 0;
|
|
48
|
+
if (scrollAxisAlignment === 'center') {
|
|
49
|
+
const pad = neighbourW + itemSpacing;
|
|
50
|
+
return { start: pad, end: pad };
|
|
51
|
+
}
|
|
52
|
+
if (scrollAxisAlignment === 'start') {
|
|
53
|
+
return { start: innerPadStart, end: neighbourW + itemSpacing + innerPadEnd };
|
|
54
|
+
}
|
|
55
|
+
if (scrollAxisAlignment === 'end') {
|
|
56
|
+
return { start: neighbourW + itemSpacing + innerPadStart, end: innerPadEnd };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return { start: innerPadStart, end: innerPadEnd };
|
|
60
|
+
}
|
|
61
|
+
export const DUPLICATES_IN_INFINITE = 2;
|
|
62
|
+
/**
|
|
63
|
+
* Map a "real" item index (0..size-1) to its rendered position.
|
|
64
|
+
* In infinite mode the real items live in [DUPLICATES, DUPLICATES + size).
|
|
65
|
+
*/
|
|
66
|
+
export function realToPosition(realIdx, isInfinite, duplicates = DUPLICATES_IN_INFINITE) {
|
|
67
|
+
return isInfinite ? duplicates + realIdx : realIdx;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Map a rendered position back to the real index. Wraps modulo `size` when
|
|
71
|
+
* the position lands inside the duplicate region.
|
|
72
|
+
*/
|
|
73
|
+
export function positionToReal(pos, isInfinite, size, duplicates = DUPLICATES_IN_INFINITE) {
|
|
74
|
+
if (size <= 0)
|
|
75
|
+
return 0;
|
|
76
|
+
if (!isInfinite) {
|
|
77
|
+
return Math.max(0, Math.min(size - 1, pos));
|
|
78
|
+
}
|
|
79
|
+
const inner = pos - duplicates;
|
|
80
|
+
return ((inner % size) + size) % size;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* True when `pos` corresponds to one of the duplicate entries (only meaningful
|
|
84
|
+
* in infinite mode).
|
|
85
|
+
*/
|
|
86
|
+
export function isInDuplicateRegion(pos, isInfinite, size, duplicates = DUPLICATES_IN_INFINITE) {
|
|
87
|
+
if (!isInfinite)
|
|
88
|
+
return false;
|
|
89
|
+
return pos < duplicates || pos >= duplicates + size;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Build the list of items to render. In infinite mode this prefixes the array
|
|
93
|
+
* with `duplicates` copies of the last items and suffixes it with `duplicates`
|
|
94
|
+
* copies of the first items, so the user can swipe past either edge and land
|
|
95
|
+
* on something visually identical to the wrap-around target.
|
|
96
|
+
*/
|
|
97
|
+
export function buildRenderedItems(items, isInfinite, duplicates = DUPLICATES_IN_INFINITE) {
|
|
98
|
+
if (!items.length)
|
|
99
|
+
return [];
|
|
100
|
+
if (!isInfinite) {
|
|
101
|
+
return items.map((item, index) => ({ item, realIndex: index, key: `r-${index}` }));
|
|
102
|
+
}
|
|
103
|
+
const size = items.length;
|
|
104
|
+
const head = [];
|
|
105
|
+
const tail = [];
|
|
106
|
+
for (let i = 0; i < duplicates; i++) {
|
|
107
|
+
const realIdx = (size - duplicates + i + size) % size;
|
|
108
|
+
head.push({ item: items[realIdx], realIndex: realIdx, key: `dup-h-${i}` });
|
|
109
|
+
}
|
|
110
|
+
for (let i = 0; i < duplicates; i++) {
|
|
111
|
+
const realIdx = i % size;
|
|
112
|
+
tail.push({ item: items[realIdx], realIndex: realIdx, key: `dup-t-${i}` });
|
|
113
|
+
}
|
|
114
|
+
const real = items.map((item, index) => ({
|
|
115
|
+
item,
|
|
116
|
+
realIndex: index,
|
|
117
|
+
key: `r-${index}`
|
|
118
|
+
}));
|
|
119
|
+
return [...head, ...real, ...tail];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Decide whether infinite_scroll should actually be active.
|
|
123
|
+
* Mirrors Web's correctBooleanInt + the `items.length >= DUPLICATES_IN_INFINITE`
|
|
124
|
+
* gate.
|
|
125
|
+
*/
|
|
126
|
+
export function isInfiniteEnabled(infiniteValue, itemsLength) {
|
|
127
|
+
const truthy = infiniteValue === true ||
|
|
128
|
+
infiniteValue === 1 ||
|
|
129
|
+
infiniteValue === '1' ||
|
|
130
|
+
infiniteValue === 'true';
|
|
131
|
+
return truthy && itemsLength >= DUPLICATES_IN_INFINITE;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Convert a scroll offset (in px) into a snap position (rounded). Returns 0
|
|
135
|
+
* when snapInterval <= 0.
|
|
136
|
+
*/
|
|
137
|
+
export function offsetToPosition(offset, snapInterval) {
|
|
138
|
+
if (snapInterval <= 0)
|
|
139
|
+
return 0;
|
|
140
|
+
return Math.round(offset / snapInterval);
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/pager/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgCH;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,IAAyB;IACrD,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,mBAAmB,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,GAC7F,IAAI,CAAC;IACT,IAAI,aAAa,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,aAAa,GAAG,aAAa,GAAG,WAAW,CAAC;IAE3D,MAAM,EAAE,GAAG,UAA8H,CAAC;IAE1I,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,MAAM,UAAU,GAAG,EAAE,CAAC,oBAAoB,EAAE,KAAK,IAAI,CAAC,CAAC;QACvD,IAAI,mBAAmB,KAAK,QAAQ,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,aAAa,GAAG,CAAC,GAAG,UAAU,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC;QACzE,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,aAAa,GAAG,UAAU,GAAG,WAAW,CAAC,CAAC;IACjE,CAAC;IACD,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,EAAE,CAAC,UAAU,EAAE,KAAK,IAAI,GAAG,CAAC;QAC1C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,aAAa,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,C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,MAAM,MAAM,GACR,aAAa,KAAK,IAAI;QACtB,aAAa,KAAK,CAAC;QACnB,aAAa,KAAK,GAAG;QACrB,aAAa,KAAK,MAAM,CAAC;IAC7B,OAAO,MAAM,IAAI,WAAW,IAAI,sBAAsB,CAAC;AAC3D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc,EAAE,YAAoB;IACjE,IAAI,YAAY,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAChC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,YAAY,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Outer.d.ts","sourceRoot":"","sources":["../../../src/components/utilities/Outer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAgC,MAAM,OAAO,CAAC;AACvE,OAAO,EAA6B,SAAS,EAAsC,MAAM,cAAc,CAAC;AACxG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAqGpD,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW;IAC3D,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;IACtC,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAAE,EACvD,gBAAgB,EAChB,QAAQ,EACR,KAAK,EAAE,WAAW,EACrB,EAAE,UAAU,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"Outer.d.ts","sourceRoot":"","sources":["../../../src/components/utilities/Outer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAgC,MAAM,OAAO,CAAC;AACvE,OAAO,EAA6B,SAAS,EAAsC,MAAM,cAAc,CAAC;AACxG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAqGpD,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW;IAC3D,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;IACtC,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAAE,EACvD,gBAAgB,EAChB,QAAQ,EACR,KAAK,EAAE,WAAW,EACrB,EAAE,UAAU,CAAC,CAAC,CAAC,4BAyaf"}
|
|
@@ -85,6 +85,7 @@ export function Outer({ componentContext, children, style: customStyle }) {
|
|
|
85
85
|
const { direction } = useDivKitContext();
|
|
86
86
|
const layoutParams = useLayoutParams();
|
|
87
87
|
const { json, variables } = componentContext;
|
|
88
|
+
const testID = json.id;
|
|
88
89
|
// Only use reactive hooks for truly dynamic properties (visibility, alpha)
|
|
89
90
|
const visibility = useDerivedFromVarsSimple(json.visibility || 'visible', variables || new Map());
|
|
90
91
|
const alpha = useDerivedFromVarsSimple(json.alpha !== undefined ? json.alpha : 1, variables || new Map());
|
|
@@ -469,19 +470,19 @@ export function Outer({ componentContext, children, style: customStyle }) {
|
|
|
469
470
|
const existingTransform = animatedStyle.transform || [];
|
|
470
471
|
animatedStyle.transform = [...existingTransform, { scale: animScale }];
|
|
471
472
|
}
|
|
472
|
-
return (<Pressable onPress={handlePress} onPressIn={onPressIn} onPressOut={onPressOut} style={outerStyle}>
|
|
473
|
+
return (<Pressable onPress={handlePress} onPressIn={onPressIn} onPressOut={onPressOut} style={outerStyle} testID={testID}>
|
|
473
474
|
<Animated.View style={animatedStyle}>
|
|
474
475
|
<Background layers={background} style={borderStyle}/>
|
|
475
476
|
{children}
|
|
476
477
|
</Animated.View>
|
|
477
478
|
</Pressable>);
|
|
478
479
|
}
|
|
479
|
-
return (<Pressable onPress={handlePress} style={finalStyle}>
|
|
480
|
+
return (<Pressable onPress={handlePress} style={finalStyle} testID={testID}>
|
|
480
481
|
<Background layers={background} style={borderStyle}/>
|
|
481
482
|
{children}
|
|
482
483
|
</Pressable>);
|
|
483
484
|
}
|
|
484
|
-
return (<View style={finalStyle}>
|
|
485
|
+
return (<View style={finalStyle} testID={testID}>
|
|
485
486
|
<Background layers={background} style={borderStyle}/>
|
|
486
487
|
{children}
|
|
487
488
|
</View>);
|