@amazon-devices/vega-carousel 0.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/LICENSE +7 -0
- package/README.md +0 -0
- package/dist/Carousel/Carousel.d.ts +16 -0
- package/dist/Carousel/Carousel.js +102 -0
- package/dist/Carousel/Utils.d.ts +4 -0
- package/dist/Carousel/Utils.js +35 -0
- package/dist/Carousel/index.d.ts +7 -0
- package/dist/Carousel/index.js +23 -0
- package/dist/Carousel/types.d.ts +406 -0
- package/dist/Carousel/types.js +2 -0
- package/dist/CarouselData/CarouselDataAdapter.d.ts +141 -0
- package/dist/CarouselData/CarouselDataAdapter.js +67 -0
- package/dist/CarouselData/CarouselDataResolver.d.ts +100 -0
- package/dist/CarouselData/CarouselDataResolver.js +224 -0
- package/dist/CarouselData/CarouselDataTypes.d.ts +280 -0
- package/dist/CarouselData/CarouselDataTypes.js +84 -0
- package/dist/CarouselData/index.d.ts +3 -0
- package/dist/CarouselData/index.js +24 -0
- package/dist/CarouselScrollable/CarouselScrollable.d.ts +67 -0
- package/dist/CarouselScrollable/CarouselScrollable.js +77 -0
- package/dist/CarouselScrollable/CarouselScrollableProps.d.ts +499 -0
- package/dist/CarouselScrollable/CarouselScrollableProps.js +211 -0
- package/dist/CarouselScrollable/CarouselScrollableRef.d.ts +80 -0
- package/dist/CarouselScrollable/CarouselScrollableRef.js +7 -0
- package/dist/CarouselScrollable/CarouselScrollableTypes.d.ts +224 -0
- package/dist/CarouselScrollable/CarouselScrollableTypes.js +116 -0
- package/dist/CarouselScrollable/CarouselSimple.d.ts +71 -0
- package/dist/CarouselScrollable/CarouselSimple.js +111 -0
- package/dist/CarouselScrollable/CarouselSimpleProps.d.ts +29 -0
- package/dist/CarouselScrollable/CarouselSimpleProps.js +7 -0
- package/dist/CarouselScrollable/index.d.ts +6 -0
- package/dist/CarouselScrollable/index.js +27 -0
- package/dist/CarouselScrollable/native/CarouselNativeHostComponent.d.ts +109 -0
- package/dist/CarouselScrollable/native/CarouselNativeHostComponent.js +82 -0
- package/dist/CarouselScrollable/native/CarouselNativeItemHostComponent.d.ts +94 -0
- package/dist/CarouselScrollable/native/CarouselNativeItemHostComponent.js +42 -0
- package/dist/CarouselScrollable/native/CarouselNativeItemWrapper.d.ts +255 -0
- package/dist/CarouselScrollable/native/CarouselNativeItemWrapper.js +276 -0
- package/dist/CarouselScrollable/native/CarouselNativeLogic.d.ts +209 -0
- package/dist/CarouselScrollable/native/CarouselNativeLogic.js +349 -0
- package/dist/CarouselScrollable/native/CarouselNativeWrapper.d.ts +68 -0
- package/dist/CarouselScrollable/native/CarouselNativeWrapper.js +164 -0
- package/dist/CarouselScrollable/native/index.d.ts +5 -0
- package/dist/CarouselScrollable/native/index.js +26 -0
- package/dist/CarouselScrollable/recyclerview/JSRecyclerViewList.d.ts +25 -0
- package/dist/CarouselScrollable/recyclerview/JSRecyclerViewList.js +150 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +24 -0
- package/dist/kepler/aarch64-debug/lib/com.amazon.keplerscript.carousel.so +0 -0
- package/dist/kepler/aarch64-debug/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
- package/dist/kepler/aarch64-release/lib/com.amazon.keplerscript.carousel.so +0 -0
- package/dist/kepler/aarch64-release/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
- package/dist/kepler/armv7-debug/lib/com.amazon.keplerscript.carousel.so +0 -0
- package/dist/kepler/armv7-debug/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
- package/dist/kepler/armv7-release/lib/com.amazon.keplerscript.carousel.so +0 -0
- package/dist/kepler/armv7-release/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
- package/dist/kepler/tm-manifest.json +1 -0
- package/dist/kepler/x86_64-debug/lib/com.amazon.keplerscript.carousel.so +0 -0
- package/dist/kepler/x86_64-debug/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
- package/dist/kepler/x86_64-release/lib/com.amazon.keplerscript.carousel.so +0 -0
- package/dist/kepler/x86_64-release/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
- package/dist/utils/CarouselLogger.d.ts +295 -0
- package/dist/utils/CarouselLogger.js +370 -0
- package/dist/utils/CarouselReactNativeUtilities.d.ts +108 -0
- package/dist/utils/CarouselReactNativeUtilities.js +150 -0
- package/dist/utils/HelperTypes.d.ts +5 -0
- package/dist/utils/HelperTypes.js +7 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +24 -0
- package/package.json +1 -0
- package/react-native.config.js +22 -0
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ListOrientation, ListSelectionStrategy, OnItemBindFunc, OnItemUnbindFunc, OnSelectionChangedCallback, ScaleFactor, ScaleOriginStrategy, SelectionBorderStrategy, SelectionBorderStyle } from './CarouselScrollableTypes';
|
|
4
|
+
import { CarouselDataAdapter, RenderItemFunc } from '../CarouselData';
|
|
5
|
+
/**
|
|
6
|
+
* This type contains properties that relate to how {@link CarouselScrollable}
|
|
7
|
+
* is identified.
|
|
8
|
+
*
|
|
9
|
+
* @see {@link CarouselScrollable}
|
|
10
|
+
* @see {@link CarouselScrollableProps}
|
|
11
|
+
*/
|
|
12
|
+
export type CarouselScrollableInfoProps = {
|
|
13
|
+
/**
|
|
14
|
+
* An arbitrary and unique identifier for this list that will be used
|
|
15
|
+
* to determine when to recycle the list and its items.
|
|
16
|
+
*
|
|
17
|
+
* @default undefined
|
|
18
|
+
*/
|
|
19
|
+
uniqueId?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* This type represents the group of properties for the {@link CarouselScrollable}
|
|
23
|
+
* component that will change how it is displayed and how it behaves.
|
|
24
|
+
*
|
|
25
|
+
* These properties are not intended to change during the component's lifecycle.
|
|
26
|
+
* If you require changing them, you will need to force a re-render on the list
|
|
27
|
+
* component.
|
|
28
|
+
*
|
|
29
|
+
* @see {@link CarouselScrollable}
|
|
30
|
+
* @see {@link CarouselScrollableProps}
|
|
31
|
+
*/
|
|
32
|
+
export type CarouselScrollableConfigProps = {
|
|
33
|
+
/**
|
|
34
|
+
* Indicates if the list is horizontal or vertical.
|
|
35
|
+
*
|
|
36
|
+
* @default listOrientation.HORIZONTAL
|
|
37
|
+
* @see {@link ListOrientation}
|
|
38
|
+
*/
|
|
39
|
+
orientation?: ListOrientation;
|
|
40
|
+
/**
|
|
41
|
+
* The number of items to be rendered at a given time.
|
|
42
|
+
*
|
|
43
|
+
* Always set this value to a number bigger than the number of items that fit
|
|
44
|
+
* in the screen.
|
|
45
|
+
*
|
|
46
|
+
* When a selection change triggers a scroll, the last item in the opposite
|
|
47
|
+
* direction will be _"recycled"_ so the next one, in the same direction as
|
|
48
|
+
* the selection, can use that recycled frame to render.
|
|
49
|
+
*
|
|
50
|
+
* @default 10
|
|
51
|
+
*/
|
|
52
|
+
renderedItemsCount?: number;
|
|
53
|
+
/**
|
|
54
|
+
* A secondary margin that exists only on the orientation axis of the
|
|
55
|
+
* component (left and right for {@link ListOrientation.HORIZONTAL} lists, and
|
|
56
|
+
* top and bottom for {@link ListOrientation.VERTICAL} lists).
|
|
57
|
+
*
|
|
58
|
+
* This secondary margin is mostly used to restrict the “navigable” range of
|
|
59
|
+
* the list’s selection, but other features of the component use this margin
|
|
60
|
+
* as reference for their behavior.
|
|
61
|
+
*
|
|
62
|
+
* Since the “scroll offset margin” exists on both ends of the component, when
|
|
63
|
+
* an item is rendered there, we say the item is _outside the scroll offset
|
|
64
|
+
* area_, or that the item is an “_overflown item_” in the list.
|
|
65
|
+
*
|
|
66
|
+
* @default 100
|
|
67
|
+
* @see {@link ListOrientation}
|
|
68
|
+
*/
|
|
69
|
+
navigableScrollOffset?: number;
|
|
70
|
+
/**
|
|
71
|
+
* The screen distance that each item on the list will have between its
|
|
72
|
+
* neighbor items.
|
|
73
|
+
*
|
|
74
|
+
* @default 0
|
|
75
|
+
*/
|
|
76
|
+
itemPadding?: number;
|
|
77
|
+
/**
|
|
78
|
+
* The extra screen distance that each item on the list will have between its
|
|
79
|
+
* neighbor items when list is focused.
|
|
80
|
+
*
|
|
81
|
+
* @default 0
|
|
82
|
+
*/
|
|
83
|
+
itemPaddingOnFocus?: number;
|
|
84
|
+
/**
|
|
85
|
+
* Allow us to have the list component start its lifecycle with a different
|
|
86
|
+
* item selected instead of the item in the first available position.
|
|
87
|
+
*
|
|
88
|
+
* When omitted (set to `undefined`), the item in the first available position
|
|
89
|
+
* will be used as the initial selection.
|
|
90
|
+
*
|
|
91
|
+
* @default 0
|
|
92
|
+
*/
|
|
93
|
+
initialStartIndex?: number;
|
|
94
|
+
/**
|
|
95
|
+
* When laying out its items, depending on the selection index, the scrollable
|
|
96
|
+
* might need to render items before the selected item.
|
|
97
|
+
*
|
|
98
|
+
* This option defines how many items to place “before” the left “Scroll
|
|
99
|
+
* Offset” margin ({@link navigableScrollOffset}), and together with the “max number
|
|
100
|
+
* of mounted items” ({@link renderedItemsCount}) one, allows you to control the
|
|
101
|
+
* recycling “buffer” of the list.
|
|
102
|
+
*
|
|
103
|
+
* @default 2
|
|
104
|
+
* @see {@link navigableScrollOffset}
|
|
105
|
+
* @see {@link renderedItemsCount}
|
|
106
|
+
*/
|
|
107
|
+
numOffsetItems?: number;
|
|
108
|
+
/**
|
|
109
|
+
* When this flag is set to `true`, the selected item will have a styleable
|
|
110
|
+
* border enveloping the selected item.
|
|
111
|
+
*
|
|
112
|
+
* The look-and-feel of the selection border can be configured by the
|
|
113
|
+
* {@link selectionBorderStyle} property.
|
|
114
|
+
*
|
|
115
|
+
* @default false
|
|
116
|
+
* @see {@link selectionBorderStyle}
|
|
117
|
+
*/
|
|
118
|
+
showSelectionBorder?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* This property defines the look-and-feel of the border surrounding the
|
|
121
|
+
* selected item when it is enabled.
|
|
122
|
+
*/
|
|
123
|
+
selectionBorderStyle?: SelectionBorderStyle;
|
|
124
|
+
/**
|
|
125
|
+
* This property defines the strategy used for rendering the selection border
|
|
126
|
+
* relative to the content area.
|
|
127
|
+
*
|
|
128
|
+
* @default 'outset'
|
|
129
|
+
* @see {@link SelectionBorderStrategy}
|
|
130
|
+
*/
|
|
131
|
+
selectionBorderStrategy?: SelectionBorderStrategy;
|
|
132
|
+
/**
|
|
133
|
+
* This flag will prevent the focus from progressing to the nearest component
|
|
134
|
+
* outside the list, alongside its orientation axis.
|
|
135
|
+
*
|
|
136
|
+
* Meaning, if the list is horizontal and the selected item is:
|
|
137
|
+
*
|
|
138
|
+
* 1. The first item and the user presses left;
|
|
139
|
+
* 2. The last item and the user presses right;
|
|
140
|
+
*
|
|
141
|
+
* Then this flag will prevent the focus from escaping the list.
|
|
142
|
+
*
|
|
143
|
+
* @default false
|
|
144
|
+
*/
|
|
145
|
+
trapFocusOnOrientation?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* This flag will force the scrollable list to check its items for a nested
|
|
148
|
+
* scrollable list.
|
|
149
|
+
*
|
|
150
|
+
* When found, it will make the component to counter-offset its child
|
|
151
|
+
* selection shift so the nested items won't move on the orientation of the
|
|
152
|
+
* parent scrollable.
|
|
153
|
+
*
|
|
154
|
+
* @default false
|
|
155
|
+
*/
|
|
156
|
+
offsetNestedSelectionShift?: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* A scale multiplier to be applied to the item when it is being activated by
|
|
159
|
+
* the user (e.g., the user pressed down the select button on the device's
|
|
160
|
+
* remote control).
|
|
161
|
+
*
|
|
162
|
+
* NOTE : This value should be based on the selected dimensions of a card.
|
|
163
|
+
*
|
|
164
|
+
* @default 0.8
|
|
165
|
+
*/
|
|
166
|
+
pressedItemScaleFactor?: number;
|
|
167
|
+
/**
|
|
168
|
+
* A scale multiplier to be applied to the selected item.
|
|
169
|
+
*
|
|
170
|
+
* When this value is `1.0`, it means there will be no scaling happening to
|
|
171
|
+
* the selected item while the user scrolls through the list.
|
|
172
|
+
*
|
|
173
|
+
* @default 1.0
|
|
174
|
+
*/
|
|
175
|
+
focusedItemScaleFactor?: number;
|
|
176
|
+
/**
|
|
177
|
+
* This flag indicates to the scrollable list the scaling strategy of the items when
|
|
178
|
+
* selected.
|
|
179
|
+
* *Currently on scaling from top-left corner of item or center scaling is supported*
|
|
180
|
+
* top-left - scale from top-left
|
|
181
|
+
* center - scale from center
|
|
182
|
+
*
|
|
183
|
+
* @default ScaleOriginStrategy.TOP_LEFT
|
|
184
|
+
*/
|
|
185
|
+
scaleOrigin?: ScaleOriginStrategy;
|
|
186
|
+
/**
|
|
187
|
+
* This flag indicates to the scrollable list the enabling of overlapping the items
|
|
188
|
+
* when scaling while the items are selected
|
|
189
|
+
* By default the shift will be turned off
|
|
190
|
+
*
|
|
191
|
+
* @default false
|
|
192
|
+
*/
|
|
193
|
+
shouldSelectedOverlap?: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* This property defines a *scale factor* that will be used to calculate an
|
|
196
|
+
* *orientation shift* of the selected item and its predecessors, whenever the
|
|
197
|
+
* list selection changes.
|
|
198
|
+
*
|
|
199
|
+
* You can pass a {@link ScaleFactor} object to define different shifts on
|
|
200
|
+
* each component's axes, a _single number_ that will be used on all axes, or
|
|
201
|
+
* a _`boolean`_ flag that, when `true`, will force the component to use the
|
|
202
|
+
* {@link focusedItemScaleFactor} value as its shift factor on all axes.
|
|
203
|
+
*
|
|
204
|
+
* The base dimension used to calculate the shift distance, it is always the
|
|
205
|
+
* selected item's full size, without any scale factor applied to it.
|
|
206
|
+
*
|
|
207
|
+
* It's important to notice that the shift of items on selection is
|
|
208
|
+
* independent of the {@link focusedItemScaleFactor} property, and can always
|
|
209
|
+
* be applied even if the selected item is not being scaled-up.
|
|
210
|
+
*
|
|
211
|
+
* @default false
|
|
212
|
+
* @see {@link focusedItemScaleFactor}
|
|
213
|
+
*/
|
|
214
|
+
shiftItemsOnSelection?: boolean | number | ScaleFactor;
|
|
215
|
+
/**
|
|
216
|
+
* This option defines the relation between item selection change and
|
|
217
|
+
* scrolling.
|
|
218
|
+
*
|
|
219
|
+
* For details on how this property affects the list component, check the
|
|
220
|
+
* {@link ListSelectionStrategy} documentation.
|
|
221
|
+
*
|
|
222
|
+
* @default ScrollSelectionStrategy.ANCHORED
|
|
223
|
+
* @see {@link ListSelectionStrategy}
|
|
224
|
+
*/
|
|
225
|
+
selectionStrategy?: ListSelectionStrategy;
|
|
226
|
+
/**
|
|
227
|
+
* Defines the component's size fraction used as the pinned selected position
|
|
228
|
+
* value.
|
|
229
|
+
*
|
|
230
|
+
* This property must be a value between `0.0` and `1.0` and only has any
|
|
231
|
+
* effect when the {@link selectionStrategy} property is set to
|
|
232
|
+
* {@link ListSelectionStrategy.PINNED}.
|
|
233
|
+
*
|
|
234
|
+
* Alternatively, you can set this property to one of the three pre-defined
|
|
235
|
+
* positions strings: `'start'` (will set this property to `0.0`), `'center'`
|
|
236
|
+
* (will set this property to `0.5`), and `'end'` (will set this property to
|
|
237
|
+
* `0.1`).
|
|
238
|
+
*
|
|
239
|
+
* @default 'center'
|
|
240
|
+
* @see {@link selectionStrategy}
|
|
241
|
+
* @see {@link ListSelectionStrategy}
|
|
242
|
+
*/
|
|
243
|
+
pinnedFocusOffset?: number | 'start' | 'center' | 'end';
|
|
244
|
+
/**
|
|
245
|
+
* This flag indicates to the scrollable list that it can “over-optimize” its
|
|
246
|
+
* render stack by detaching items from the view tree, as soon as they cross
|
|
247
|
+
* the “Scroll Offset” margin.
|
|
248
|
+
*
|
|
249
|
+
* Be careful with this property; although it can improve performance, it
|
|
250
|
+
* might cause the list component to “vanish” items before they're fully
|
|
251
|
+
* positioned outside the visible area.
|
|
252
|
+
*
|
|
253
|
+
* @default false
|
|
254
|
+
*/
|
|
255
|
+
hideItemsBeforeSelection?: boolean;
|
|
256
|
+
/**
|
|
257
|
+
* This flag indicates to the scrollable list that it can “discard the last focused item”,
|
|
258
|
+
* to override the default behavior of retaining the last focused item.
|
|
259
|
+
*
|
|
260
|
+
*
|
|
261
|
+
* @default false
|
|
262
|
+
*/
|
|
263
|
+
discardLastFocus?: boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Number of seconds that the item activation animation takes to complete.
|
|
266
|
+
*
|
|
267
|
+
* @default 0.15 seconds
|
|
268
|
+
*/
|
|
269
|
+
itemPressedDuration?: number;
|
|
270
|
+
/**
|
|
271
|
+
* Number of seconds that a selection change animation takes to complete.
|
|
272
|
+
*
|
|
273
|
+
* @default 0.2 seconds
|
|
274
|
+
*/
|
|
275
|
+
itemScrollDuration?: number;
|
|
276
|
+
/**
|
|
277
|
+
* Number of seconds that a selection change animation takes to complete when
|
|
278
|
+
* the component is gaining or losing focus.
|
|
279
|
+
*
|
|
280
|
+
* The animation that this option controls is the same animation used by the
|
|
281
|
+
* “Selection Change” but this option is only used if the list itself gains
|
|
282
|
+
* or loses focus.
|
|
283
|
+
*
|
|
284
|
+
* @default CarouselScrollableConfigProps.itemScrollDuration
|
|
285
|
+
*/
|
|
286
|
+
containerFocusChangeDuration?: number;
|
|
287
|
+
/**
|
|
288
|
+
* Determines whether this component should automatically receive focus when rendered.
|
|
289
|
+
* When true, the component will attempt to gain focus during the initial mount or when the prop value changes.
|
|
290
|
+
*
|
|
291
|
+
* @default false
|
|
292
|
+
*/
|
|
293
|
+
hasPreferredFocus?: boolean;
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* This type encapsulates the function used by the {@link CarouselScrollable} to resolve
|
|
297
|
+
* its child items.
|
|
298
|
+
*
|
|
299
|
+
* @see {@link CarouselScrollable}
|
|
300
|
+
* @see {@link CarouselScrollableProps}
|
|
301
|
+
*/
|
|
302
|
+
export type CarouselScrollableResolverProps<ItemT> = {
|
|
303
|
+
/**
|
|
304
|
+
* This function is called whenever the scrollable component needs to get the
|
|
305
|
+
* item’s declaration.
|
|
306
|
+
*
|
|
307
|
+
* If the item is not ready to be displayed when this function is invoked, it
|
|
308
|
+
* should return a **placeholder** component to allow the list to display
|
|
309
|
+
* something for the item.
|
|
310
|
+
*
|
|
311
|
+
* Returning an `undefined` value from this function will indicate to the
|
|
312
|
+
* component that the item cannot be used in the list during the current
|
|
313
|
+
* component's lifecycle.
|
|
314
|
+
*
|
|
315
|
+
* When that happens, the component will notify the caller that this
|
|
316
|
+
* particular data item failed by calling the {@link notifyDataError}
|
|
317
|
+
* function.
|
|
318
|
+
*
|
|
319
|
+
* @function
|
|
320
|
+
* @see {@link getItem}
|
|
321
|
+
* @see {@link CarouselDataAdapterReader.notifyDataError}
|
|
322
|
+
* @see {@link RenderItemFunc}
|
|
323
|
+
*/
|
|
324
|
+
renderItem: RenderItemFunc<ItemT>;
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* This type wrap all of the {@link CarouselDataAdapter} functions into a single
|
|
328
|
+
* property.
|
|
329
|
+
*
|
|
330
|
+
* @see {@link CarouselScrollable}
|
|
331
|
+
* @see {@link CarouselScrollableProps}
|
|
332
|
+
* @see {@link CarouselDataAdapter}
|
|
333
|
+
*/
|
|
334
|
+
export type CarouselScrollableDataAdapterProps<ItemT, KeyT = React.Key> = {
|
|
335
|
+
/**
|
|
336
|
+
* The object used to retrieve items and other information about them.
|
|
337
|
+
*
|
|
338
|
+
* For details on the {@link CarouselDataAdapter} object, check its
|
|
339
|
+
* documentation.
|
|
340
|
+
*
|
|
341
|
+
* @see {@link CarouselDataAdapter}
|
|
342
|
+
*/
|
|
343
|
+
dataAdapter: CarouselDataAdapter<ItemT, KeyT>;
|
|
344
|
+
};
|
|
345
|
+
/**
|
|
346
|
+
* The functions in this type, when present, will be called when an internal
|
|
347
|
+
* important event happened, to give the opportunity to the caller to act on
|
|
348
|
+
* those scenarios.
|
|
349
|
+
*
|
|
350
|
+
* @see {@link CarouselScrollable}
|
|
351
|
+
* @see {@link CarouselScrollableProps}
|
|
352
|
+
*/
|
|
353
|
+
export type CarouselScrollableCallbackProps<ItemT> = {
|
|
354
|
+
/**
|
|
355
|
+
* Function called when the Scrollable List is binding an item to a new native
|
|
356
|
+
* frame.
|
|
357
|
+
*
|
|
358
|
+
* The argument `savedStateData` is whatever the user passed to the
|
|
359
|
+
* `saveStateData` function on the {@link onItemUnbind} when it was previously
|
|
360
|
+
* unbound, or undefined if there is no known data for the item.
|
|
361
|
+
*
|
|
362
|
+
* @function
|
|
363
|
+
* @default undefined
|
|
364
|
+
* @see {@link OnItemBindFunc}
|
|
365
|
+
*/
|
|
366
|
+
onItemBind?: OnItemBindFunc<ItemT>;
|
|
367
|
+
/**
|
|
368
|
+
* Function called when the list is not rendering an item anymore,
|
|
369
|
+
* and is ready to re-use the item's view with some other item.
|
|
370
|
+
*
|
|
371
|
+
* This happens **before** a component item is recycled during a scroll.
|
|
372
|
+
*
|
|
373
|
+
* @function
|
|
374
|
+
* @default undefined
|
|
375
|
+
* @see {@link OnItemUnbindFunc}
|
|
376
|
+
*/
|
|
377
|
+
onItemUnbind?: OnItemUnbindFunc<ItemT>;
|
|
378
|
+
/**
|
|
379
|
+
* Function called whenever the current selected item on the list changes
|
|
380
|
+
* (it's not called when the list gains or loses focus).
|
|
381
|
+
*
|
|
382
|
+
* If the user needs that information, the {@link initialStartIndex}
|
|
383
|
+
* should be stored in a {@link React.Ref}, and updated whenever the
|
|
384
|
+
* `onSelectionChange` is called, then, the user can use the standard
|
|
385
|
+
* `onFocus` and `onBlur` callbacks on the scrollable list to trigger some
|
|
386
|
+
* special behavior.
|
|
387
|
+
*
|
|
388
|
+
* @function
|
|
389
|
+
* @default undefined
|
|
390
|
+
* @see {@link initialStartIndex}
|
|
391
|
+
* @see {@link OnSelectionChangedCallback}
|
|
392
|
+
* @see {@link SelectionChangeEvent}
|
|
393
|
+
*/
|
|
394
|
+
onSelectionChanged?: OnSelectionChangedCallback;
|
|
395
|
+
};
|
|
396
|
+
/**
|
|
397
|
+
* Configurable properties of a {@link CarouselScrollable} component.
|
|
398
|
+
*
|
|
399
|
+
* This type groups all the `CarouselScrollable*` property types, with a special behavior
|
|
400
|
+
* for the Data Adapter properties.
|
|
401
|
+
*
|
|
402
|
+
* The user can choose between a functional API style or a Data Adapter object
|
|
403
|
+
*
|
|
404
|
+
* @template ItemT The type of data items the list will use to render its items.
|
|
405
|
+
* @template KeyT The type used as items unique identifiers (also called _keys_,
|
|
406
|
+
* or _stable IDs_) in the list;
|
|
407
|
+
*
|
|
408
|
+
* @see {@link ViewProps}
|
|
409
|
+
* @see {@link CarouselScrollableInfoProps}
|
|
410
|
+
* @see {@link CarouselScrollableResolverProps}
|
|
411
|
+
* @see {@link CarouselScrollableCallbackProps}
|
|
412
|
+
* @see {@link CarouselScrollableDataAdapterProps}
|
|
413
|
+
* @see {@link CarouselDataAdapter}
|
|
414
|
+
*/
|
|
415
|
+
export type CarouselScrollableProps<ItemT, KeyT = React.Key> = ViewProps & CarouselScrollableInfoProps & CarouselScrollableConfigProps & (CarouselDataAdapter<ItemT, KeyT> | CarouselScrollableDataAdapterProps<ItemT, KeyT>) & CarouselScrollableResolverProps<ItemT> & CarouselScrollableCallbackProps<ItemT>;
|
|
416
|
+
/**
|
|
417
|
+
* Helper type to hold the fields of a {@link CarouselScrollableProps} with its config
|
|
418
|
+
* props set to their default value when not present.
|
|
419
|
+
*
|
|
420
|
+
* @template ItemT The type of data items the list will use to render its items.
|
|
421
|
+
* @template KeyT The type used as items unique identifiers (also called _keys_,
|
|
422
|
+
* or _stable IDs_) in the list;
|
|
423
|
+
*
|
|
424
|
+
* @see {@link CarouselScrollableProps}
|
|
425
|
+
* @see {@link Required}
|
|
426
|
+
*/
|
|
427
|
+
export type RequiredCarouselScrollableProps<ItemT, KeyT = React.Key> = ViewProps & CarouselScrollableInfoProps & Omit<Required<CarouselScrollableConfigProps>, 'pinnedFocusOffset' | 'shiftItemsOnSelection'> & (CarouselDataAdapter<ItemT, KeyT> | CarouselScrollableDataAdapterProps<ItemT, KeyT>) & CarouselScrollableResolverProps<ItemT> & CarouselScrollableCallbackProps<ItemT> & {
|
|
428
|
+
pinnedFocusOffset: number;
|
|
429
|
+
shiftItemsOnSelection: ScaleFactor;
|
|
430
|
+
};
|
|
431
|
+
/**
|
|
432
|
+
* This is a helper constant that holds all the _default values_ defined by the
|
|
433
|
+
* list.
|
|
434
|
+
*
|
|
435
|
+
* The values in this object will be updated whenever the documentation of the
|
|
436
|
+
* associated value changes, and vice versa.
|
|
437
|
+
*
|
|
438
|
+
* Refer to the documentation of the {@link CarouselScrollableConfigProps} type for
|
|
439
|
+
* details about each one of these fields.
|
|
440
|
+
*
|
|
441
|
+
* @see {@link CarouselScrollableConfigProps}
|
|
442
|
+
* @see {@link CarouselScrollableProps}
|
|
443
|
+
*/
|
|
444
|
+
export declare const CarouselScrollableDefaults: Required<CarouselScrollableConfigProps>;
|
|
445
|
+
/**
|
|
446
|
+
* Helper function to normalize a
|
|
447
|
+
* {@link CarouselScrollableConfigProps.pinnedFocusOffset} value to a number with
|
|
448
|
+
* value between the accepted range.
|
|
449
|
+
*
|
|
450
|
+
* @param {number | 'start' | 'center' | 'end'} value The
|
|
451
|
+
* {@link CarouselScrollableConfigProps.pinnedFocusOffset} value to be
|
|
452
|
+
* normalized.
|
|
453
|
+
*
|
|
454
|
+
* @return {number} - Returns the normalized number value for the
|
|
455
|
+
* {@link CarouselScrollableConfigProps.pinnedFocusOffset} field.
|
|
456
|
+
*
|
|
457
|
+
* @see {@link CarouselScrollableConfigProps.pinnedFocusOffset}
|
|
458
|
+
*/
|
|
459
|
+
export declare function pinnedFocusOffsetValue(value: number | 'start' | 'center' | 'end'): number;
|
|
460
|
+
export declare function shiftItemsOnSelectionValue(value: boolean | number | ScaleFactor | undefined, focusedItemScaleFactor: number | undefined): ScaleFactor;
|
|
461
|
+
/**
|
|
462
|
+
* Helper function that returns a {@link CarouselScrollableProps} with any missing value
|
|
463
|
+
* set to their defined default.
|
|
464
|
+
*
|
|
465
|
+
* @template ItemT The type of data items the list will use to render its items.
|
|
466
|
+
* @template KeyT The type used as items unique identifiers (also called _keys_,
|
|
467
|
+
* or _stable IDs_) in the list;
|
|
468
|
+
*
|
|
469
|
+
* @param {CarouselScrollableProps<ItemT, KeyT>} props The {@link CarouselScrollableProps} to fill
|
|
470
|
+
* out default values.
|
|
471
|
+
*
|
|
472
|
+
* @return {RequiredCarouselScrollableProps<ItemT, KeyT>} Returns a "_properties_" object
|
|
473
|
+
* where all the fields from the {@link CarouselScrollableConfigProps} are not
|
|
474
|
+
* optionals, and have default values where the given `props` did not
|
|
475
|
+
* have anything.
|
|
476
|
+
*
|
|
477
|
+
* @see {@link CarouselScrollableProps}
|
|
478
|
+
* @see {@link CarouselScrollableConfigProps}
|
|
479
|
+
*/
|
|
480
|
+
export declare function useDefaults<ItemT, KeyT = React.Key>(props: CarouselScrollableProps<ItemT, KeyT>): RequiredCarouselScrollableProps<ItemT, KeyT>;
|
|
481
|
+
/**
|
|
482
|
+
* Helper function to retrieve a {@link CarouselDataAdapter} from a
|
|
483
|
+
* {@link CarouselScrollableProps}.
|
|
484
|
+
*
|
|
485
|
+
* This function will use either the `dataAdapter` field if it is present, or
|
|
486
|
+
* the functions from the functional API to return an adapter.
|
|
487
|
+
*
|
|
488
|
+
* It allows you to not have to check which API style the user decides to use.
|
|
489
|
+
*
|
|
490
|
+
* @param {CarouselScrollableProps} props The property object used to extract a
|
|
491
|
+
* {@link CarouselDataAdapter} from.
|
|
492
|
+
*
|
|
493
|
+
* @return {CarouselDataAdapter} Returns a data adapter object driving the data
|
|
494
|
+
* used on the list component.
|
|
495
|
+
*
|
|
496
|
+
* @see {@link CarouselDataAdapter}
|
|
497
|
+
* @see {@link CarouselScrollableProps}
|
|
498
|
+
*/
|
|
499
|
+
export declare function getDataAdapter<ItemT, KeyT = React.Key>(props: CarouselScrollableProps<ItemT, KeyT>): CarouselDataAdapter<ItemT, KeyT>;
|