@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,280 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScaleFactor } from '../CarouselScrollable/CarouselScrollableTypes';
|
|
3
|
+
/**
|
|
4
|
+
* Function that can retrieve an item on an arbitrary position (`index`) from
|
|
5
|
+
* the given `data`.
|
|
6
|
+
*
|
|
7
|
+
* @template ItemT The type of object returned by this function.
|
|
8
|
+
*
|
|
9
|
+
* @param {number} index The positional index where the returned item is
|
|
10
|
+
* located.
|
|
11
|
+
*
|
|
12
|
+
* @return {ItemT | undefined} Returns the item located on the given position,
|
|
13
|
+
* or `undefined`, if there are no items on the given `index`.
|
|
14
|
+
*/
|
|
15
|
+
export type GetItemFunc<ItemT> = (index: number) => ItemT | undefined;
|
|
16
|
+
export type GetItemCountFunc = () => number;
|
|
17
|
+
/**
|
|
18
|
+
* Function that can retrieve a shift value to be used for neighboring items
|
|
19
|
+
* when the given item gets focused.
|
|
20
|
+
*
|
|
21
|
+
* @template ItemT The type for the object that will have its identifier
|
|
22
|
+
* retrieved.
|
|
23
|
+
*
|
|
24
|
+
* @param {ItemT} item The item object that will have its unique identifier
|
|
25
|
+
* extracted.
|
|
26
|
+
* @param {number} index The index position of the given item.
|
|
27
|
+
*
|
|
28
|
+
* @return {number | undefined} Returns the shift value. If undefined is
|
|
29
|
+
* returned, the scrollable will use the default value passed into
|
|
30
|
+
* the scrollable component.
|
|
31
|
+
*/
|
|
32
|
+
export type GetSelectedItemOffsetFunc<ItemT> = (item: ItemT, index: number) => ScaleFactor | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Function that can retrieve a unique (sometimes also called _stable_)
|
|
35
|
+
* identifier from a given `item`.
|
|
36
|
+
*
|
|
37
|
+
* @template ItemT The type for the object that will have its identifier
|
|
38
|
+
* retrieved.
|
|
39
|
+
* @template KeyT The type used for the returned identifier. By default, this
|
|
40
|
+
* function uses {@link React.Key} as the identifier's type.
|
|
41
|
+
*
|
|
42
|
+
* @param {ItemT} item The item object that will have its unique identifier
|
|
43
|
+
* extracted.
|
|
44
|
+
* @param {number} index The index position of the given item.
|
|
45
|
+
*
|
|
46
|
+
* @return {KeyT | undefined} Returns the unique identifier for the given
|
|
47
|
+
* {@link item}. If the function cannot extract a unique identifier for
|
|
48
|
+
* the object, `undefined` should be returned.
|
|
49
|
+
*/
|
|
50
|
+
export type GetItemKeyFunc<ItemT, KeyT = React.Key> = (item: ItemT, index: number) => KeyT | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Function that can resolve the given `item` into a {@link React.ReactElement}.
|
|
53
|
+
*
|
|
54
|
+
* @template ItemT The type of the data object that will be used in the
|
|
55
|
+
* resolver.
|
|
56
|
+
*
|
|
57
|
+
* @param {ItemT} item The data item object used to create a resolved
|
|
58
|
+
* [React element]{@link React.ReactElement}.
|
|
59
|
+
* @param {number} index The data index position of the given item.
|
|
60
|
+
*
|
|
61
|
+
* @return {React.ReactElement | undefined} Returns the resolved item as a
|
|
62
|
+
* [React element]{@link React.ReactElement}, or `undefined` if it could
|
|
63
|
+
* not resolve it for any reason.
|
|
64
|
+
*/
|
|
65
|
+
export type RenderItemFunc<ItemT> = (item: ItemT, index: number) => React.ReactElement | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* This enumerator is a representation of the directions a _batch read_ of
|
|
68
|
+
* elements can follow.
|
|
69
|
+
*
|
|
70
|
+
* When retrieving data from the data adaptor, the component will always request
|
|
71
|
+
* a single item at the selected position, and a series of items from the sides
|
|
72
|
+
* of the selected one.
|
|
73
|
+
*
|
|
74
|
+
* For more details on how this enum is used, check the
|
|
75
|
+
* {@link resolveDataItems} function documentation.
|
|
76
|
+
*
|
|
77
|
+
* @see resolveDataItems
|
|
78
|
+
*/
|
|
79
|
+
export declare enum CarouselDataReadDirection {
|
|
80
|
+
/**
|
|
81
|
+
* When reading from the target position, the component won't try to get next
|
|
82
|
+
* nor previous items.
|
|
83
|
+
*/
|
|
84
|
+
AT_TARGET = 0,
|
|
85
|
+
/**
|
|
86
|
+
* When reading items backwards, after the first successful retrieval, further
|
|
87
|
+
* requests will always try to get an item from a smaller position then the
|
|
88
|
+
* previous retrieved one.
|
|
89
|
+
*/
|
|
90
|
+
BACKWARDS = 1,
|
|
91
|
+
/**
|
|
92
|
+
* When reading items forward, after the first successful retrieval, further
|
|
93
|
+
* requests will always try to get an item from a higher position then the
|
|
94
|
+
* previous retrieved one.
|
|
95
|
+
*/
|
|
96
|
+
FORWARD = 2
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* This type defines how the {@link resolveDataItems} will behave when trying to
|
|
100
|
+
* retrieve items.
|
|
101
|
+
*
|
|
102
|
+
* For details on the resolving process, check the {@link resolveDataItems}
|
|
103
|
+
* documentation.
|
|
104
|
+
*
|
|
105
|
+
* @see {@link resolveDataItems}
|
|
106
|
+
*/
|
|
107
|
+
export type CarouselDataReadConfig = {
|
|
108
|
+
/**
|
|
109
|
+
* The position where to start the reading process. Depending on the type of
|
|
110
|
+
* read executed, this might not be the last index read.
|
|
111
|
+
*
|
|
112
|
+
* @see {@link readDirection}
|
|
113
|
+
*/
|
|
114
|
+
startIndex: number;
|
|
115
|
+
/**
|
|
116
|
+
* Indicates if the reading should move forward, backwards, or stay at the
|
|
117
|
+
* given {@link startIndex} position.
|
|
118
|
+
*
|
|
119
|
+
* @see {@link startIndex}
|
|
120
|
+
*/
|
|
121
|
+
readDirection: CarouselDataReadDirection;
|
|
122
|
+
/**
|
|
123
|
+
* This function is a predicate called in a loop by the
|
|
124
|
+
* {@link resolveDataItems} function to know if it should stop requesting
|
|
125
|
+
* items.
|
|
126
|
+
*
|
|
127
|
+
* @param {number} lastIndexRead This function is called at the start of every
|
|
128
|
+
* data retrieval loop, to this index represents what is its value at
|
|
129
|
+
* the start of the process, and at every time a new loop starts.
|
|
130
|
+
*
|
|
131
|
+
* @return {boolean} This callback should return `true` if the caller wants
|
|
132
|
+
* the retrieval API to keep requesting items, and `false` otherwise.
|
|
133
|
+
*
|
|
134
|
+
* @see {@link resolveDataItems}
|
|
135
|
+
*/
|
|
136
|
+
shouldReadNext?: (lastIndexRead: number) => boolean;
|
|
137
|
+
/**
|
|
138
|
+
* The number of times the resolver can try to retrieve or resolve an item
|
|
139
|
+
* before it considers the operation a failure.
|
|
140
|
+
*
|
|
141
|
+
* @default ITEM_FAILURE_DEFAULT_MAX_RETRIES
|
|
142
|
+
*/
|
|
143
|
+
maxRetries: number;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* This enumerator represents all types of errors that can happen when handling
|
|
147
|
+
* a data item (reading it or resolving it).
|
|
148
|
+
*/
|
|
149
|
+
export declare enum CarouselDataErrorReason {
|
|
150
|
+
/**
|
|
151
|
+
* The data item could not be read. In practice, this means the adapter
|
|
152
|
+
* returned `null` or `undefined` when `getItem` was called.
|
|
153
|
+
*/
|
|
154
|
+
CANNOT_READ = 0,
|
|
155
|
+
/**
|
|
156
|
+
* The data item could not be resolved into a {@link React.ReactElement}. This
|
|
157
|
+
* also means the adapter will have to prune the item from its data set
|
|
158
|
+
* because even though the item exists and is valid, we cannot use it in our
|
|
159
|
+
* carousels.
|
|
160
|
+
*/
|
|
161
|
+
CANNOT_RENDER = 1
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* This type encapsulates all the available information available about a data
|
|
165
|
+
* error. You have the `readConfig` used while reading the item at position
|
|
166
|
+
* `index`, and if the error is a _read_ or _resolve_ problem.
|
|
167
|
+
*/
|
|
168
|
+
export type CarouselDataError = {
|
|
169
|
+
/**
|
|
170
|
+
* The data index of the item that caused the error being reported.
|
|
171
|
+
*/
|
|
172
|
+
index: number;
|
|
173
|
+
/**
|
|
174
|
+
* The read configuration used by the {@link resolveDataItems} function when
|
|
175
|
+
* the error being reported happened.
|
|
176
|
+
*/
|
|
177
|
+
readConfig: CarouselDataReadConfig;
|
|
178
|
+
/**
|
|
179
|
+
* Enumerator value indicating if this error is a _read_ or a _resolve_
|
|
180
|
+
* problem.
|
|
181
|
+
*/
|
|
182
|
+
reason: CarouselDataErrorReason;
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Type representing the function called by the list component when it
|
|
186
|
+
* encounters an error while retrieving and rendering an item.
|
|
187
|
+
*
|
|
188
|
+
* For details about this function's usage, check the {@link resolveDataItems}
|
|
189
|
+
* documentation.
|
|
190
|
+
*
|
|
191
|
+
* @param {number} index The data index of the item that caused the error.
|
|
192
|
+
* @param {CarouselDataReadDirection} readTarget The retrieve target used by
|
|
193
|
+
* the {@link resolveDataItems} function when the error happened.
|
|
194
|
+
*
|
|
195
|
+
* @return {boolean} Returns `true` if the data adapter wants the component to
|
|
196
|
+
* perform a retry, or `false` if this is unrecoverable.
|
|
197
|
+
*
|
|
198
|
+
* @function
|
|
199
|
+
* @see {@link resolveDataItems}
|
|
200
|
+
*/
|
|
201
|
+
export type CarouselDataErrorNotifyFunc = (error: CarouselDataError) => boolean;
|
|
202
|
+
/**
|
|
203
|
+
* When the data backing the {@link CarouselScrollable} component changes, there are only
|
|
204
|
+
* three possible operations that happened.
|
|
205
|
+
*
|
|
206
|
+
* This enum represents the type of operations allowed in the {@link CarouselScrollable}.
|
|
207
|
+
*
|
|
208
|
+
* @see {@link CarouselScrollable}
|
|
209
|
+
* @see {@link CarouselDataChange}
|
|
210
|
+
*/
|
|
211
|
+
export declare enum CarouselDataChangeType {
|
|
212
|
+
/**
|
|
213
|
+
* Indicates that an item was added to the data set. The item insertion could
|
|
214
|
+
* have happened in the data edge (`prepend` or `append`) or in the middle.
|
|
215
|
+
*/
|
|
216
|
+
ADD = 1,
|
|
217
|
+
/** Indicates an item was removed from the data set. */
|
|
218
|
+
REMOVE = 2,
|
|
219
|
+
/**
|
|
220
|
+
* Indicates that the item's **content** changed, and although the item itself
|
|
221
|
+
* did not change, it might render different information then before.
|
|
222
|
+
*/
|
|
223
|
+
UPDATE = 3
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* When an external entity needs to report that the data backing a
|
|
227
|
+
* {@link CarouselScrollable} changed, it must send a list of operations representing all
|
|
228
|
+
* the modifications done in the data.
|
|
229
|
+
*
|
|
230
|
+
* This type represents a single operation in this list.
|
|
231
|
+
*
|
|
232
|
+
* Notice, though, that this type does not carry any _data_ information like
|
|
233
|
+
* other data adapter implementations.
|
|
234
|
+
*
|
|
235
|
+
* Since our component core is designed to not handle with data (it does not
|
|
236
|
+
* care what is being rendered on its internal frames), we don't need to carry
|
|
237
|
+
* any information within a data change operation.
|
|
238
|
+
*
|
|
239
|
+
* @see {@link CarouselScrollable}
|
|
240
|
+
* @see {@link CarouselDataChangeType}
|
|
241
|
+
*/
|
|
242
|
+
export type CarouselDataChange = {
|
|
243
|
+
/**
|
|
244
|
+
* Indicates what type of operation was performed in the data set (check the
|
|
245
|
+
* {@link CarouselDataChangeType} documentation for details).
|
|
246
|
+
*
|
|
247
|
+
* @see {@link CarouselDataChangeType}
|
|
248
|
+
*/
|
|
249
|
+
type: CarouselDataChangeType;
|
|
250
|
+
/**
|
|
251
|
+
* Indicates the position where this operation happened.
|
|
252
|
+
*
|
|
253
|
+
* It's important to know that any data operation follows a standard array
|
|
254
|
+
* order, meaning: If the operation is an {@link ADD}, the item currently
|
|
255
|
+
* present in this position index will be moved to the right so the new item
|
|
256
|
+
* is added there;
|
|
257
|
+
*/
|
|
258
|
+
position: number;
|
|
259
|
+
/**
|
|
260
|
+
* Indicates how many **sequential** items were affected by this operation.
|
|
261
|
+
*/
|
|
262
|
+
count: number;
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* This type represents a function that will be called by the implementation of
|
|
266
|
+
* a data adapter when it notices that a change happened in its data set.
|
|
267
|
+
*
|
|
268
|
+
* @param {Array<CarouselDataChange>} changes The list of changes
|
|
269
|
+
* that will represent the data change that already happened.
|
|
270
|
+
*
|
|
271
|
+
* @function
|
|
272
|
+
* @see {@link CarouselDataChange}
|
|
273
|
+
*/
|
|
274
|
+
export type CarouselDataChangeCallback = (changes: Array<CarouselDataChange>) => void;
|
|
275
|
+
export type CarouselResolvedDataValues<KeyT = React.Key> = {
|
|
276
|
+
index: number;
|
|
277
|
+
element: React.ReactElement;
|
|
278
|
+
key?: KeyT;
|
|
279
|
+
shift?: ScaleFactor;
|
|
280
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024 - 2025 Amazon.com, Inc. or its affiliates. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* PROPRIETARY/CONFIDENTIAL. USE IS SUBJECT TO LICENSE TERMS.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.CarouselDataChangeType = exports.CarouselDataErrorReason = exports.CarouselDataReadDirection = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* This enumerator is a representation of the directions a _batch read_ of
|
|
11
|
+
* elements can follow.
|
|
12
|
+
*
|
|
13
|
+
* When retrieving data from the data adaptor, the component will always request
|
|
14
|
+
* a single item at the selected position, and a series of items from the sides
|
|
15
|
+
* of the selected one.
|
|
16
|
+
*
|
|
17
|
+
* For more details on how this enum is used, check the
|
|
18
|
+
* {@link resolveDataItems} function documentation.
|
|
19
|
+
*
|
|
20
|
+
* @see resolveDataItems
|
|
21
|
+
*/
|
|
22
|
+
var CarouselDataReadDirection;
|
|
23
|
+
(function (CarouselDataReadDirection) {
|
|
24
|
+
/**
|
|
25
|
+
* When reading from the target position, the component won't try to get next
|
|
26
|
+
* nor previous items.
|
|
27
|
+
*/
|
|
28
|
+
CarouselDataReadDirection[CarouselDataReadDirection["AT_TARGET"] = 0] = "AT_TARGET";
|
|
29
|
+
/**
|
|
30
|
+
* When reading items backwards, after the first successful retrieval, further
|
|
31
|
+
* requests will always try to get an item from a smaller position then the
|
|
32
|
+
* previous retrieved one.
|
|
33
|
+
*/
|
|
34
|
+
CarouselDataReadDirection[CarouselDataReadDirection["BACKWARDS"] = 1] = "BACKWARDS";
|
|
35
|
+
/**
|
|
36
|
+
* When reading items forward, after the first successful retrieval, further
|
|
37
|
+
* requests will always try to get an item from a higher position then the
|
|
38
|
+
* previous retrieved one.
|
|
39
|
+
*/
|
|
40
|
+
CarouselDataReadDirection[CarouselDataReadDirection["FORWARD"] = 2] = "FORWARD";
|
|
41
|
+
})(CarouselDataReadDirection = exports.CarouselDataReadDirection || (exports.CarouselDataReadDirection = {}));
|
|
42
|
+
/**
|
|
43
|
+
* This enumerator represents all types of errors that can happen when handling
|
|
44
|
+
* a data item (reading it or resolving it).
|
|
45
|
+
*/
|
|
46
|
+
var CarouselDataErrorReason;
|
|
47
|
+
(function (CarouselDataErrorReason) {
|
|
48
|
+
/**
|
|
49
|
+
* The data item could not be read. In practice, this means the adapter
|
|
50
|
+
* returned `null` or `undefined` when `getItem` was called.
|
|
51
|
+
*/
|
|
52
|
+
CarouselDataErrorReason[CarouselDataErrorReason["CANNOT_READ"] = 0] = "CANNOT_READ";
|
|
53
|
+
/**
|
|
54
|
+
* The data item could not be resolved into a {@link React.ReactElement}. This
|
|
55
|
+
* also means the adapter will have to prune the item from its data set
|
|
56
|
+
* because even though the item exists and is valid, we cannot use it in our
|
|
57
|
+
* carousels.
|
|
58
|
+
*/
|
|
59
|
+
CarouselDataErrorReason[CarouselDataErrorReason["CANNOT_RENDER"] = 1] = "CANNOT_RENDER";
|
|
60
|
+
})(CarouselDataErrorReason = exports.CarouselDataErrorReason || (exports.CarouselDataErrorReason = {}));
|
|
61
|
+
/**
|
|
62
|
+
* When the data backing the {@link CarouselScrollable} component changes, there are only
|
|
63
|
+
* three possible operations that happened.
|
|
64
|
+
*
|
|
65
|
+
* This enum represents the type of operations allowed in the {@link CarouselScrollable}.
|
|
66
|
+
*
|
|
67
|
+
* @see {@link CarouselScrollable}
|
|
68
|
+
* @see {@link CarouselDataChange}
|
|
69
|
+
*/
|
|
70
|
+
var CarouselDataChangeType;
|
|
71
|
+
(function (CarouselDataChangeType) {
|
|
72
|
+
/**
|
|
73
|
+
* Indicates that an item was added to the data set. The item insertion could
|
|
74
|
+
* have happened in the data edge (`prepend` or `append`) or in the middle.
|
|
75
|
+
*/
|
|
76
|
+
CarouselDataChangeType[CarouselDataChangeType["ADD"] = 1] = "ADD";
|
|
77
|
+
/** Indicates an item was removed from the data set. */
|
|
78
|
+
CarouselDataChangeType[CarouselDataChangeType["REMOVE"] = 2] = "REMOVE";
|
|
79
|
+
/**
|
|
80
|
+
* Indicates that the item's **content** changed, and although the item itself
|
|
81
|
+
* did not change, it might render different information then before.
|
|
82
|
+
*/
|
|
83
|
+
CarouselDataChangeType[CarouselDataChangeType["UPDATE"] = 3] = "UPDATE";
|
|
84
|
+
})(CarouselDataChangeType = exports.CarouselDataChangeType || (exports.CarouselDataChangeType = {}));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024 - 2025 Amazon.com, Inc. or its affiliates. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* PROPRIETARY/CONFIDENTIAL. USE IS SUBJECT TO LICENSE TERMS.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
__exportStar(require("./CarouselDataAdapter"), exports);
|
|
23
|
+
__exportStar(require("./CarouselDataResolver"), exports);
|
|
24
|
+
__exportStar(require("./CarouselDataTypes"), exports);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* `CarouselScrollable` is a recyclable list component that offers granular control over
|
|
4
|
+
* how its data is retrieved and rendered.
|
|
5
|
+
*
|
|
6
|
+
* It uses a minimal functional style to define how to access the data backing
|
|
7
|
+
* the list, with `4` required fields on its properties.
|
|
8
|
+
*
|
|
9
|
+
* Optionally, if you prefer to use a more object-oriented API, you can pass an
|
|
10
|
+
* object implementing the {@link CarouselDataAdapter} contract and a single
|
|
11
|
+
* function called when the list needs to render an item, making the number of
|
|
12
|
+
* required fields to be `2`.
|
|
13
|
+
*
|
|
14
|
+
* Check the {@link CarouselScrollableProps} documentation for details on the properties
|
|
15
|
+
* used by this component, and the {@link CarouselDataAdapter} for the data access
|
|
16
|
+
* documentation.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* The following is an example of a minimal `CarouselScrollable` component using the
|
|
20
|
+
* functional style API:
|
|
21
|
+
* ```tsx
|
|
22
|
+
* function MyComponent(dataAdapter: CarouselDataAdapter) {
|
|
23
|
+
* const renderItem = React.useCallback(
|
|
24
|
+
* (item: MyDataItem) => <View>{item.render()}</View>
|
|
25
|
+
* []
|
|
26
|
+
* )
|
|
27
|
+
* return (
|
|
28
|
+
* <CarouselScrollable
|
|
29
|
+
* getItem={dataAdapter.getItem}
|
|
30
|
+
* getItemKey={dataAdapter.getItemKey}
|
|
31
|
+
* notifyDataFailure={dataAdapter.notifyDataFailure}
|
|
32
|
+
* renderItem={renderItem} />
|
|
33
|
+
* )
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* If, like the sample above, have an object that can implement the Data Adapter
|
|
39
|
+
* API, then you can have an even simpler usage:
|
|
40
|
+
* ```tsx
|
|
41
|
+
* function MyComponent(dataAdapter: CarouselDataAdapter) {
|
|
42
|
+
* const renderItem = React.useCallback(
|
|
43
|
+
* (item: MyDataItem) => <View>{item.render()}</View>
|
|
44
|
+
* []
|
|
45
|
+
* )
|
|
46
|
+
* return (
|
|
47
|
+
* <CarouselScrollable dataAdapter={dataAdapter} renderItem={renderItem} />
|
|
48
|
+
* )
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* If you can guarantee that your data will be a standard `Array`, you should
|
|
53
|
+
* use the {@link CarouselSimple} component, which is a wrapper around this
|
|
54
|
+
* list with defaults targeted for data as an {@link Array} of items.
|
|
55
|
+
*
|
|
56
|
+
* Internally, we have different implementations of the `CarouselScrollable` component.
|
|
57
|
+
* One of these implementations will be selected to **be** the `CarouselScrollable` type
|
|
58
|
+
* during runtime. For internal details on these implementations, check their
|
|
59
|
+
* documentation.
|
|
60
|
+
*
|
|
61
|
+
* @see {@link CarouselScrollableProps}
|
|
62
|
+
* @see {@link CarouselDataAdapter}
|
|
63
|
+
* @see {@link CarouselSimple}
|
|
64
|
+
*/
|
|
65
|
+
export declare const CarouselScrollable: <ItemT, KeyT = import("react").Key>(props: import("./CarouselScrollableProps").CarouselScrollableProps<ItemT, KeyT> & {
|
|
66
|
+
ref?: import("react").Ref<import("./CarouselScrollableRef").CarouselScrollableRef> | undefined;
|
|
67
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024 - 2025 Amazon.com, Inc. or its affiliates. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* PROPRIETARY/CONFIDENTIAL. USE IS SUBJECT TO LICENSE TERMS.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.CarouselScrollable = void 0;
|
|
9
|
+
const react_native_1 = require("react-native");
|
|
10
|
+
const JSRecyclerViewList_1 = require("./recyclerview/JSRecyclerViewList");
|
|
11
|
+
const native_1 = require("./native");
|
|
12
|
+
/**
|
|
13
|
+
* `CarouselScrollable` is a recyclable list component that offers granular control over
|
|
14
|
+
* how its data is retrieved and rendered.
|
|
15
|
+
*
|
|
16
|
+
* It uses a minimal functional style to define how to access the data backing
|
|
17
|
+
* the list, with `4` required fields on its properties.
|
|
18
|
+
*
|
|
19
|
+
* Optionally, if you prefer to use a more object-oriented API, you can pass an
|
|
20
|
+
* object implementing the {@link CarouselDataAdapter} contract and a single
|
|
21
|
+
* function called when the list needs to render an item, making the number of
|
|
22
|
+
* required fields to be `2`.
|
|
23
|
+
*
|
|
24
|
+
* Check the {@link CarouselScrollableProps} documentation for details on the properties
|
|
25
|
+
* used by this component, and the {@link CarouselDataAdapter} for the data access
|
|
26
|
+
* documentation.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* The following is an example of a minimal `CarouselScrollable` component using the
|
|
30
|
+
* functional style API:
|
|
31
|
+
* ```tsx
|
|
32
|
+
* function MyComponent(dataAdapter: CarouselDataAdapter) {
|
|
33
|
+
* const renderItem = React.useCallback(
|
|
34
|
+
* (item: MyDataItem) => <View>{item.render()}</View>
|
|
35
|
+
* []
|
|
36
|
+
* )
|
|
37
|
+
* return (
|
|
38
|
+
* <CarouselScrollable
|
|
39
|
+
* getItem={dataAdapter.getItem}
|
|
40
|
+
* getItemKey={dataAdapter.getItemKey}
|
|
41
|
+
* notifyDataFailure={dataAdapter.notifyDataFailure}
|
|
42
|
+
* renderItem={renderItem} />
|
|
43
|
+
* )
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* If, like the sample above, have an object that can implement the Data Adapter
|
|
49
|
+
* API, then you can have an even simpler usage:
|
|
50
|
+
* ```tsx
|
|
51
|
+
* function MyComponent(dataAdapter: CarouselDataAdapter) {
|
|
52
|
+
* const renderItem = React.useCallback(
|
|
53
|
+
* (item: MyDataItem) => <View>{item.render()}</View>
|
|
54
|
+
* []
|
|
55
|
+
* )
|
|
56
|
+
* return (
|
|
57
|
+
* <CarouselScrollable dataAdapter={dataAdapter} renderItem={renderItem} />
|
|
58
|
+
* )
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* If you can guarantee that your data will be a standard `Array`, you should
|
|
63
|
+
* use the {@link CarouselSimple} component, which is a wrapper around this
|
|
64
|
+
* list with defaults targeted for data as an {@link Array} of items.
|
|
65
|
+
*
|
|
66
|
+
* Internally, we have different implementations of the `CarouselScrollable` component.
|
|
67
|
+
* One of these implementations will be selected to **be** the `CarouselScrollable` type
|
|
68
|
+
* during runtime. For internal details on these implementations, check their
|
|
69
|
+
* documentation.
|
|
70
|
+
*
|
|
71
|
+
* @see {@link CarouselScrollableProps}
|
|
72
|
+
* @see {@link CarouselDataAdapter}
|
|
73
|
+
* @see {@link CarouselSimple}
|
|
74
|
+
*/
|
|
75
|
+
exports.CarouselScrollable = react_native_1.Platform.OS === 'android' && react_native_1.Platform.isTV
|
|
76
|
+
? /* istanbul ignore next */ JSRecyclerViewList_1.JSRecyclerViewList
|
|
77
|
+
: native_1.CarouselNativeWrapper;
|