@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.
Files changed (71) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +0 -0
  3. package/dist/Carousel/Carousel.d.ts +16 -0
  4. package/dist/Carousel/Carousel.js +102 -0
  5. package/dist/Carousel/Utils.d.ts +4 -0
  6. package/dist/Carousel/Utils.js +35 -0
  7. package/dist/Carousel/index.d.ts +7 -0
  8. package/dist/Carousel/index.js +23 -0
  9. package/dist/Carousel/types.d.ts +406 -0
  10. package/dist/Carousel/types.js +2 -0
  11. package/dist/CarouselData/CarouselDataAdapter.d.ts +141 -0
  12. package/dist/CarouselData/CarouselDataAdapter.js +67 -0
  13. package/dist/CarouselData/CarouselDataResolver.d.ts +100 -0
  14. package/dist/CarouselData/CarouselDataResolver.js +224 -0
  15. package/dist/CarouselData/CarouselDataTypes.d.ts +280 -0
  16. package/dist/CarouselData/CarouselDataTypes.js +84 -0
  17. package/dist/CarouselData/index.d.ts +3 -0
  18. package/dist/CarouselData/index.js +24 -0
  19. package/dist/CarouselScrollable/CarouselScrollable.d.ts +67 -0
  20. package/dist/CarouselScrollable/CarouselScrollable.js +77 -0
  21. package/dist/CarouselScrollable/CarouselScrollableProps.d.ts +499 -0
  22. package/dist/CarouselScrollable/CarouselScrollableProps.js +211 -0
  23. package/dist/CarouselScrollable/CarouselScrollableRef.d.ts +80 -0
  24. package/dist/CarouselScrollable/CarouselScrollableRef.js +7 -0
  25. package/dist/CarouselScrollable/CarouselScrollableTypes.d.ts +224 -0
  26. package/dist/CarouselScrollable/CarouselScrollableTypes.js +116 -0
  27. package/dist/CarouselScrollable/CarouselSimple.d.ts +71 -0
  28. package/dist/CarouselScrollable/CarouselSimple.js +111 -0
  29. package/dist/CarouselScrollable/CarouselSimpleProps.d.ts +29 -0
  30. package/dist/CarouselScrollable/CarouselSimpleProps.js +7 -0
  31. package/dist/CarouselScrollable/index.d.ts +6 -0
  32. package/dist/CarouselScrollable/index.js +27 -0
  33. package/dist/CarouselScrollable/native/CarouselNativeHostComponent.d.ts +109 -0
  34. package/dist/CarouselScrollable/native/CarouselNativeHostComponent.js +82 -0
  35. package/dist/CarouselScrollable/native/CarouselNativeItemHostComponent.d.ts +94 -0
  36. package/dist/CarouselScrollable/native/CarouselNativeItemHostComponent.js +42 -0
  37. package/dist/CarouselScrollable/native/CarouselNativeItemWrapper.d.ts +255 -0
  38. package/dist/CarouselScrollable/native/CarouselNativeItemWrapper.js +276 -0
  39. package/dist/CarouselScrollable/native/CarouselNativeLogic.d.ts +209 -0
  40. package/dist/CarouselScrollable/native/CarouselNativeLogic.js +349 -0
  41. package/dist/CarouselScrollable/native/CarouselNativeWrapper.d.ts +68 -0
  42. package/dist/CarouselScrollable/native/CarouselNativeWrapper.js +164 -0
  43. package/dist/CarouselScrollable/native/index.d.ts +5 -0
  44. package/dist/CarouselScrollable/native/index.js +26 -0
  45. package/dist/CarouselScrollable/recyclerview/JSRecyclerViewList.d.ts +25 -0
  46. package/dist/CarouselScrollable/recyclerview/JSRecyclerViewList.js +150 -0
  47. package/dist/index.d.ts +3 -0
  48. package/dist/index.js +24 -0
  49. package/dist/kepler/aarch64-debug/lib/com.amazon.keplerscript.carousel.so +0 -0
  50. package/dist/kepler/aarch64-debug/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
  51. package/dist/kepler/aarch64-release/lib/com.amazon.keplerscript.carousel.so +0 -0
  52. package/dist/kepler/aarch64-release/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
  53. package/dist/kepler/armv7-debug/lib/com.amazon.keplerscript.carousel.so +0 -0
  54. package/dist/kepler/armv7-debug/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
  55. package/dist/kepler/armv7-release/lib/com.amazon.keplerscript.carousel.so +0 -0
  56. package/dist/kepler/armv7-release/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
  57. package/dist/kepler/tm-manifest.json +1 -0
  58. package/dist/kepler/x86_64-debug/lib/com.amazon.keplerscript.carousel.so +0 -0
  59. package/dist/kepler/x86_64-debug/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
  60. package/dist/kepler/x86_64-release/lib/com.amazon.keplerscript.carousel.so +0 -0
  61. package/dist/kepler/x86_64-release/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
  62. package/dist/utils/CarouselLogger.d.ts +295 -0
  63. package/dist/utils/CarouselLogger.js +370 -0
  64. package/dist/utils/CarouselReactNativeUtilities.d.ts +108 -0
  65. package/dist/utils/CarouselReactNativeUtilities.js +150 -0
  66. package/dist/utils/HelperTypes.d.ts +5 -0
  67. package/dist/utils/HelperTypes.js +7 -0
  68. package/dist/utils/index.d.ts +3 -0
  69. package/dist/utils/index.js +24 -0
  70. package/package.json +1 -0
  71. package/react-native.config.js +22 -0
@@ -0,0 +1,211 @@
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.getDataAdapter = exports.useDefaults = exports.shiftItemsOnSelectionValue = exports.pinnedFocusOffsetValue = exports.CarouselScrollableDefaults = void 0;
9
+ const CarouselScrollableTypes_1 = require("./CarouselScrollableTypes");
10
+ /**
11
+ * This is a helper constant that holds all the _default values_ defined by the
12
+ * list.
13
+ *
14
+ * The values in this object will be updated whenever the documentation of the
15
+ * associated value changes, and vice versa.
16
+ *
17
+ * Refer to the documentation of the {@link CarouselScrollableConfigProps} type for
18
+ * details about each one of these fields.
19
+ *
20
+ * @see {@link CarouselScrollableConfigProps}
21
+ * @see {@link CarouselScrollableProps}
22
+ */
23
+ exports.CarouselScrollableDefaults = {
24
+ orientation: CarouselScrollableTypes_1.ListOrientation.HORIZONTAL,
25
+ renderedItemsCount: 8,
26
+ numOffsetItems: 2,
27
+ navigableScrollOffset: 100,
28
+ initialStartIndex: 0,
29
+ itemPadding: 0,
30
+ itemPaddingOnFocus: 0,
31
+ showSelectionBorder: false,
32
+ selectionBorderStyle: {},
33
+ selectionBorderStrategy: 'outset',
34
+ trapFocusOnOrientation: false,
35
+ offsetNestedSelectionShift: false,
36
+ pressedItemScaleFactor: 0.8,
37
+ focusedItemScaleFactor: 1.0,
38
+ shiftItemsOnSelection: false,
39
+ selectionStrategy: CarouselScrollableTypes_1.ListSelectionStrategy.ANCHORED,
40
+ pinnedFocusOffset: 'center',
41
+ hideItemsBeforeSelection: false,
42
+ discardLastFocus: false,
43
+ scaleOrigin: CarouselScrollableTypes_1.ScaleOriginStrategy.TOP_LEFT,
44
+ shouldSelectedOverlap: false,
45
+ itemPressedDuration: 0.15,
46
+ itemScrollDuration: 0.2,
47
+ containerFocusChangeDuration: 0.2,
48
+ hasPreferredFocus: false,
49
+ };
50
+ /**
51
+ * Helper function to normalize a
52
+ * {@link CarouselScrollableConfigProps.pinnedFocusOffset} value to a number with
53
+ * value between the accepted range.
54
+ *
55
+ * @param {number | 'start' | 'center' | 'end'} value The
56
+ * {@link CarouselScrollableConfigProps.pinnedFocusOffset} value to be
57
+ * normalized.
58
+ *
59
+ * @return {number} - Returns the normalized number value for the
60
+ * {@link CarouselScrollableConfigProps.pinnedFocusOffset} field.
61
+ *
62
+ * @see {@link CarouselScrollableConfigProps.pinnedFocusOffset}
63
+ */
64
+ function pinnedFocusOffsetValue(value) {
65
+ if (typeof value === 'number') {
66
+ return Math.min(Math.max(value, 0), 1);
67
+ }
68
+ switch (value) {
69
+ case 'start':
70
+ return 0;
71
+ case 'center':
72
+ return 0.5;
73
+ case 'end':
74
+ return 1;
75
+ }
76
+ }
77
+ exports.pinnedFocusOffsetValue = pinnedFocusOffsetValue;
78
+ function makeScaleFactor(value) {
79
+ return { width: value, height: value };
80
+ }
81
+ function shiftItemsOnSelectionValue(value, focusedItemScaleFactor) {
82
+ if (typeof value === 'boolean') {
83
+ if (value) {
84
+ return makeScaleFactor(focusedItemScaleFactor ??
85
+ exports.CarouselScrollableDefaults.focusedItemScaleFactor);
86
+ }
87
+ return makeScaleFactor(1);
88
+ }
89
+ else if (typeof value === 'number') {
90
+ return makeScaleFactor(value);
91
+ }
92
+ else if (typeof value === 'undefined') {
93
+ return makeScaleFactor(1);
94
+ }
95
+ return { width: value.width ?? 1, height: value.height ?? 1 };
96
+ }
97
+ exports.shiftItemsOnSelectionValue = shiftItemsOnSelectionValue;
98
+ /**
99
+ * Helper function that returns a {@link CarouselScrollableProps} with any missing value
100
+ * set to their defined default.
101
+ *
102
+ * @template ItemT The type of data items the list will use to render its items.
103
+ * @template KeyT The type used as items unique identifiers (also called _keys_,
104
+ * or _stable IDs_) in the list;
105
+ *
106
+ * @param {CarouselScrollableProps<ItemT, KeyT>} props The {@link CarouselScrollableProps} to fill
107
+ * out default values.
108
+ *
109
+ * @return {RequiredCarouselScrollableProps<ItemT, KeyT>} Returns a "_properties_" object
110
+ * where all the fields from the {@link CarouselScrollableConfigProps} are not
111
+ * optionals, and have default values where the given `props` did not
112
+ * have anything.
113
+ *
114
+ * @see {@link CarouselScrollableProps}
115
+ * @see {@link CarouselScrollableConfigProps}
116
+ */
117
+ function useDefaults(props) {
118
+ return {
119
+ // Start with the given props;
120
+ ...props,
121
+ // Get default values for undefined props;
122
+ orientation: props.orientation ?? exports.CarouselScrollableDefaults.orientation,
123
+ navigableScrollOffset: props.navigableScrollOffset ??
124
+ exports.CarouselScrollableDefaults.navigableScrollOffset,
125
+ itemPadding: props.itemPadding ?? exports.CarouselScrollableDefaults.itemPadding,
126
+ itemPaddingOnFocus: props.itemPaddingOnFocus ?? exports.CarouselScrollableDefaults.itemPaddingOnFocus,
127
+ showSelectionBorder: props.showSelectionBorder ??
128
+ exports.CarouselScrollableDefaults.showSelectionBorder,
129
+ selectionBorderStyle: props.selectionBorderStyle ??
130
+ exports.CarouselScrollableDefaults.selectionBorderStyle,
131
+ selectionBorderStrategy: props.selectionBorderStrategy ??
132
+ exports.CarouselScrollableDefaults.selectionBorderStrategy,
133
+ trapFocusOnOrientation: props.trapFocusOnOrientation !== undefined
134
+ ? props.trapFocusOnOrientation
135
+ : exports.CarouselScrollableDefaults.trapFocusOnOrientation,
136
+ offsetNestedSelectionShift: props.offsetNestedSelectionShift !== undefined
137
+ ? props.offsetNestedSelectionShift
138
+ : exports.CarouselScrollableDefaults.offsetNestedSelectionShift,
139
+ pressedItemScaleFactor: props.pressedItemScaleFactor ??
140
+ exports.CarouselScrollableDefaults.pressedItemScaleFactor,
141
+ focusedItemScaleFactor: props.focusedItemScaleFactor ??
142
+ exports.CarouselScrollableDefaults.focusedItemScaleFactor,
143
+ selectionStrategy: props.selectionStrategy ?? exports.CarouselScrollableDefaults.selectionStrategy,
144
+ hideItemsBeforeSelection: props.hideItemsBeforeSelection !== undefined
145
+ ? props.hideItemsBeforeSelection
146
+ : exports.CarouselScrollableDefaults.hideItemsBeforeSelection,
147
+ discardLastFocus: props.discardLastFocus ?? exports.CarouselScrollableDefaults.discardLastFocus,
148
+ itemPressedDuration: props.itemPressedDuration ??
149
+ exports.CarouselScrollableDefaults.itemPressedDuration,
150
+ itemScrollDuration: props.itemScrollDuration ?? exports.CarouselScrollableDefaults.itemScrollDuration,
151
+ // Overlay any special trim or transform as the last action:
152
+ // -------------------------------------------------------------------------
153
+ // renderedItemsCount should have at least one element;
154
+ renderedItemsCount: Math.max(1, props.renderedItemsCount ?? exports.CarouselScrollableDefaults.renderedItemsCount),
155
+ // numOffsetItems shouldn't be a negative number and should be less than renderedItemsCount
156
+ numOffsetItems: props.numOffsetItems !== undefined &&
157
+ props.numOffsetItems >= 0 &&
158
+ props.numOffsetItems <
159
+ (props.renderedItemsCount ??
160
+ exports.CarouselScrollableDefaults.renderedItemsCount)
161
+ ? props.numOffsetItems
162
+ : 0,
163
+ // initialStartIndex shouldn't be a negative number
164
+ initialStartIndex: Math.max(0, props.initialStartIndex ?? exports.CarouselScrollableDefaults.initialStartIndex),
165
+ // shiftItemsOnSelectionRatio should always be represented as a full
166
+ // ScaleFactor object;
167
+ shiftItemsOnSelection: shiftItemsOnSelectionValue(props.shiftItemsOnSelection ??
168
+ exports.CarouselScrollableDefaults.shiftItemsOnSelection, props.focusedItemScaleFactor),
169
+ // pinnedFocusOffset should be a number, even when one of the alias
170
+ // strings is given;
171
+ pinnedFocusOffset: pinnedFocusOffsetValue(props.pinnedFocusOffset ?? exports.CarouselScrollableDefaults.pinnedFocusOffset),
172
+ // scaleOrigin top-left or center;
173
+ scaleOrigin: props.scaleOrigin ?? exports.CarouselScrollableDefaults.scaleOrigin,
174
+ // shouldSelectedOverlap;
175
+ shouldSelectedOverlap: props.shouldSelectedOverlap ??
176
+ exports.CarouselScrollableDefaults.shouldSelectedOverlap,
177
+ // containerFocusChangeDuration, when not provided, should use the
178
+ // value set to the itemScrollDuration property, but only if it's not
179
+ // `undefined`, if it is, use the `itemScrollDuration` default value;
180
+ containerFocusChangeDuration: props.containerFocusChangeDuration ??
181
+ props.itemScrollDuration ??
182
+ exports.CarouselScrollableDefaults.itemScrollDuration,
183
+ hasPreferredFocus: props.hasPreferredFocus ?? exports.CarouselScrollableDefaults.hasPreferredFocus,
184
+ };
185
+ }
186
+ exports.useDefaults = useDefaults;
187
+ /**
188
+ * Helper function to retrieve a {@link CarouselDataAdapter} from a
189
+ * {@link CarouselScrollableProps}.
190
+ *
191
+ * This function will use either the `dataAdapter` field if it is present, or
192
+ * the functions from the functional API to return an adapter.
193
+ *
194
+ * It allows you to not have to check which API style the user decides to use.
195
+ *
196
+ * @param {CarouselScrollableProps} props The property object used to extract a
197
+ * {@link CarouselDataAdapter} from.
198
+ *
199
+ * @return {CarouselDataAdapter} Returns a data adapter object driving the data
200
+ * used on the list component.
201
+ *
202
+ * @see {@link CarouselDataAdapter}
203
+ * @see {@link CarouselScrollableProps}
204
+ */
205
+ function getDataAdapter(props) {
206
+ if (Object.keys(props).includes('getItem')) {
207
+ return props;
208
+ }
209
+ return props.dataAdapter;
210
+ }
211
+ exports.getDataAdapter = getDataAdapter;
@@ -0,0 +1,80 @@
1
+ import { CarouselDataChange } from '../CarouselData';
2
+ /**
3
+ * Contract for imperative operations allowed by the Carousel components.
4
+ *
5
+ * @template KeyT The type used on data items unique identifiers (also called
6
+ * _stable IDs_, or _keys_) in the list;
7
+ */
8
+ export interface CarouselScrollableRef {
9
+ /**
10
+ * When this function is called, it will change the list ability to handle
11
+ * input events.
12
+ *
13
+ * When the scrollable is set to not handle input events, it will _swallow_
14
+ * all the input events directed to it; therefore, preventing any object in
15
+ * the ancestry hierarchy to handle the input.
16
+ *
17
+ * If an object not related to the direct list's hierarchy is defined before
18
+ * the list, it still can consume input events normally.
19
+ *
20
+ * @param {boolean} enable Flag indicating if the list should handle input
21
+ * events or not.
22
+ */
23
+ enableInputEvents(enable: boolean): void;
24
+ /**
25
+ * When this function is called, it will force the list to select the item on
26
+ * the given `index` position. Depending on the `ListSelectionStrategy`
27
+ * configured in the list, this function call may trigger a component scroll
28
+ * as the result of the selection.
29
+ *
30
+ * If the given `index` is outside the available data range, nothing will
31
+ * happen, and the list will log a warning message.
32
+ *
33
+ * If the selection operation finished successfully, a
34
+ * {@link SelectionChangeEvent} event will be emitted by the list at the end
35
+ * of the operation.
36
+ *
37
+ * @param {number} index The data index of the item that should be selected
38
+ * after the scroll ends.
39
+ * @param {boolean} animated Optional flag indicating if the requested
40
+ * selection should be animated or not. It defaults to `false`.
41
+ *
42
+ * @see {@link SelectionChangeEvent}
43
+ */
44
+ setSelectedItem(index: number, animated?: boolean): void;
45
+ /**
46
+ * This function allows one to hide or show items (depending on the value of
47
+ * the `visible` argument) that are positioned outside the “Scroll Offset”
48
+ * area, optionally, animating the process.
49
+ *
50
+ * When animating, the hide will be done with a _fade-out_ animation, and the
51
+ * "show" will use a _fade-in_; both animations will use the focus gain/lose
52
+ * duration property ({@link containerFocusChangeDuration}) for
53
+ * their duration.
54
+ *
55
+ * @param {boolean} visible Flag indicating if the _outer items_ should be
56
+ * hidden (`false`), or shown (`true`).
57
+ * @param {boolean} animated Indicates if the show/hide action should be
58
+ * animated or not.
59
+ *
60
+ * @see {@link CarouselScrollableConfigProps.containerFocusChangeDuration}
61
+ */
62
+ setOverflowItemsVisible(visible: boolean, animated?: boolean): void;
63
+ /**
64
+ * This function should be called be the user whenever the backing data for
65
+ * the list component changed somehow (one or more items were added, removed,
66
+ * or updated).
67
+ *
68
+ * This will allow the native layout to adjust its internal state to match the
69
+ * expectations about the data.
70
+ *
71
+ * @param {Array<CarouselDataChange>} changes A list of all
72
+ * changes that happened to the backing data.
73
+ * @param {boolean} animated Flag indicating if the change operation should be
74
+ * animated or not.
75
+ *
76
+ * @see {@link CarouselDataChange}
77
+ */
78
+ notifyDataChange(changes: Array<CarouselDataChange>, animated?: boolean): void;
79
+ reset(): void;
80
+ }
@@ -0,0 +1,7 @@
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 });
@@ -0,0 +1,224 @@
1
+ import { ColorValue } from 'react-native';
2
+ import { AnyValue } from '../utils';
3
+ /**
4
+ * A callback called whenever a list item needs to update its content with a new
5
+ * data item. This function can be called as the result of an item recycle, or a
6
+ * new item added to the list after the first list render, but never during the
7
+ * initial list mounting.
8
+ *
9
+ * @template ItemT The type of the data items the list is using to back its
10
+ * data.
11
+ *
12
+ * @param {ItemT} item The data item that is about to be bound to a new frame;
13
+ * @param {number} index The positional index where this item is found in the
14
+ * data set used in the list;
15
+ * @param {any} storedData An optional data stored by the item when it was
16
+ * previously unbound. If this callback is invoked during the first
17
+ * render of an item, this value will be `null`. In all other cases, this
18
+ * value will be whatever the item passed to the `storeData` function
19
+ * given to the `OnItemUnbindFunc` callback.
20
+ */
21
+ export type OnItemBindFunc<ItemT> = (item: ItemT, index: number, storedData?: AnyValue) => void;
22
+ /**
23
+ * A callback that will be called whenever an item in the list is about to be
24
+ * unbound, and will have its UI component released for recycle.
25
+ *
26
+ * This callback is always called **before** the _actual_ component recycle.
27
+ *
28
+ * @template ItemT The type of the data items the list is using to back its
29
+ * data.
30
+ *
31
+ * @param {ItemT} item The data item that is about to be unbound from its frame;
32
+ * @param {number} index The positional index where this item is found in the
33
+ * data set used in the list;
34
+ * @param {(dataValue: AnyValue) => void} storeData A function that the item should
35
+ * call to store important information about its current state that will
36
+ * be relevant the next time it is bound to a component.
37
+ */
38
+ export type OnItemUnbindFunc<ItemT> = (item: ItemT, index: number, storeData: (dataValue: AnyValue) => void) => void;
39
+ /**
40
+ * Callback called whenever the selected item changes in the list.
41
+ *
42
+ * The _selected item_ in the list is always the same as the _focused item_.
43
+ * Selection and Focus can be used interchangeably.
44
+ *
45
+ * @param {SelectionChangeEvent} event The current list selection state.
46
+ *
47
+ * @see {@link SelectionChangeEvent}
48
+ */
49
+ export type OnSelectionChangedCallback = (event: SelectionChangeEvent) => void;
50
+ /**
51
+ * Callback called whenever the selected item is activated by the user.
52
+ *
53
+ * An item activation happens when the user presses the selected button on the
54
+ * device's remote control, or when the user taps on the item on a touch-based
55
+ * device.
56
+ *
57
+ * @param {number} index The data index for the item that was just activated.
58
+ */
59
+ export type OnItemActivatedCallback = (index: number) => void;
60
+ /**
61
+ * Enumeration used to represent a list orientation.
62
+ *
63
+ * @enum {number}
64
+ */
65
+ export declare enum ListOrientation {
66
+ VERTICAL = 0,
67
+ HORIZONTAL = 1
68
+ }
69
+ /**
70
+ * Enumeration used to represent the type of selection change supported by the
71
+ * list.
72
+ */
73
+ export declare enum ListSelectionStrategy {
74
+ /**
75
+ * Represents the FlexList _no strategy_.
76
+ *
77
+ * Without selection strategy, changing the selected item will not cause the
78
+ * component to scroll unless the newly selected item is outside the _scroll
79
+ * offset_ area.
80
+ *
81
+ * Every time the next item about to be selected is outside the _scroll
82
+ * offset_ area, the selection change will cause the list component to scroll.
83
+ */
84
+ NATURAL = 0,
85
+ /**
86
+ * In this strategy, the selected item will always be positioned at the
87
+ * beginning of the _scroll offset_ area.
88
+ */
89
+ ANCHORED = 1,
90
+ /**
91
+ * This strategy will force the list component to scroll if the next selected
92
+ * item crosses the pinned position defined in the configuration. Differently
93
+ * from the {@link ANCHORED} strategy though, the `PINNED` strategy will not
94
+ * make the list scroll its contents if the last (or first) item in the list
95
+ * is already positioned at the scroll offset position.
96
+ *
97
+ * The `PINNED` behavior can be defined by the following:
98
+ *
99
+ * - If the list is rendering its start, and the selected itm is _before_ the
100
+ * configured pinned position, selecting the next item will simply **move**
101
+ * the selection to the next item without making the component scroll its
102
+ * contents;
103
+ *
104
+ * - If the list is rendering its end, and the selected item is _after_ the
105
+ * configured pinned position, selecting the previous item will simply
106
+ * **move** the selection to the previous item without making the component
107
+ * scroll its contents;
108
+ *
109
+ * - If selecting the _next_ or _previous_ item, makes the selection cross the
110
+ * configured pinned position, the selection will move to the target item.
111
+ * The list will scroll its contents, so the selected item is centralized
112
+ * in the configured pinned position.
113
+ *
114
+ * - If the selected item is centralized at the configured pinned position,
115
+ * and the first or last items are not positioned on the _edge_ of the
116
+ * scroll offset area, any selection change will cause the list to scroll
117
+ * its contents to keep the selected item centralized at the configured
118
+ * pinned position;
119
+ *
120
+ * - When the last (or first) item in the list is positioned at the edge of
121
+ * the scroll-offset area, changing the selection towards that edge will
122
+ * make the selection to move and not the contents to scroll;
123
+ */
124
+ PINNED = 2
125
+ }
126
+ /**
127
+ * Enumeration used to represent the type of scale origin strategy supported by the
128
+ * list. Currently only scaling from top-left and center is supported
129
+ */
130
+ export declare enum ScaleOriginStrategy {
131
+ TOP_LEFT = 0,
132
+ CENTER = 1
133
+ }
134
+ /**
135
+ * Enumeration used to represent different border rendering strategies for selection borders.
136
+ */
137
+ export declare enum CarouselBorderStrategy {
138
+ /**
139
+ * Border is outside original content bounds and content stays the same size.
140
+ * This increases item size to include the border and then shrinks content back to its original size.
141
+ */
142
+ OUTSET = 0,
143
+ /**
144
+ * Border within the original content bounds and content remains the same size so border overlays content.
145
+ */
146
+ INSET = 1
147
+ }
148
+ /**
149
+ * String union type used to represent the selection border rendering strategy.
150
+ */
151
+ export type SelectionBorderStrategy = 'inset' | 'outset';
152
+ /**
153
+ * Helper function to convert SelectionBorderStrategy string to CarouselBorderStrategy enum.
154
+ * @param strategy The string strategy to convert
155
+ * @returns The corresponding CarouselBorderStrategy enum value
156
+ */
157
+ export declare function selectionBorderStrategyToBorderStrategy(strategy: SelectionBorderStrategy): CarouselBorderStrategy;
158
+ /**
159
+ * Contract for an object representing an **inclusive** range of data indexes.
160
+ */
161
+ export type IndexRange = {
162
+ /**
163
+ * The first index in the range. Accessing an item at this index should give
164
+ * you the _first_ item.
165
+ */
166
+ start: number;
167
+ /**
168
+ * The last index in the range. Accessing an item at this index should give
169
+ * you the _last_ item.
170
+ */
171
+ end: number;
172
+ };
173
+ /**
174
+ * The current selection state in the list.
175
+ *
176
+ * It has information about the items being rendered at the moment, as well as
177
+ * the current selected one.
178
+ *
179
+ * @see {@link OnSelectionChangedCallback}
180
+ */
181
+ export type SelectionChangeEvent = {
182
+ /**
183
+ * After the selection is changed, this range represents the indexes of all
184
+ * items being rendered in the component.
185
+ */
186
+ renderedRange: IndexRange;
187
+ /**
188
+ * This is the index of the item selected after the selection change finished.
189
+ */
190
+ selectedIndex: number;
191
+ };
192
+ export type ScaleFactor = {
193
+ width: number;
194
+ height: number;
195
+ };
196
+ /**
197
+ * This type represents all the styling options for the native selection border
198
+ * for the List component.
199
+ */
200
+ export type SelectionBorderStyle = {
201
+ /** How thick the border surrounding the selected item should be. */
202
+ borderWidth?: number;
203
+ /**
204
+ * If the selection border should have rounded corners, this value represents
205
+ * how big the radius of those corners are.
206
+ */
207
+ borderRadius?: number;
208
+ /** What color to use on the selected item's border. */
209
+ borderColor?: ColorValue;
210
+ /**
211
+ * How thick the outline stroke that separates the border from the content
212
+ * should be.
213
+ */
214
+ borderStrokeWidth?: number;
215
+ /**
216
+ * A different radius for the rounded rect representing the outline stroke
217
+ * that separates the border from the content.
218
+ */
219
+ borderStrokeRadius?: number;
220
+ /**
221
+ * A different color to use on the selection border stroke.
222
+ */
223
+ borderStrokeColor?: ColorValue;
224
+ };
@@ -0,0 +1,116 @@
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.selectionBorderStrategyToBorderStrategy = exports.CarouselBorderStrategy = exports.ScaleOriginStrategy = exports.ListSelectionStrategy = exports.ListOrientation = void 0;
9
+ /**
10
+ * Enumeration used to represent a list orientation.
11
+ *
12
+ * @enum {number}
13
+ */
14
+ var ListOrientation;
15
+ (function (ListOrientation) {
16
+ ListOrientation[ListOrientation["VERTICAL"] = 0] = "VERTICAL";
17
+ ListOrientation[ListOrientation["HORIZONTAL"] = 1] = "HORIZONTAL";
18
+ })(ListOrientation = exports.ListOrientation || (exports.ListOrientation = {}));
19
+ /**
20
+ * Enumeration used to represent the type of selection change supported by the
21
+ * list.
22
+ */
23
+ var ListSelectionStrategy;
24
+ (function (ListSelectionStrategy) {
25
+ /**
26
+ * Represents the FlexList _no strategy_.
27
+ *
28
+ * Without selection strategy, changing the selected item will not cause the
29
+ * component to scroll unless the newly selected item is outside the _scroll
30
+ * offset_ area.
31
+ *
32
+ * Every time the next item about to be selected is outside the _scroll
33
+ * offset_ area, the selection change will cause the list component to scroll.
34
+ */
35
+ ListSelectionStrategy[ListSelectionStrategy["NATURAL"] = 0] = "NATURAL";
36
+ /**
37
+ * In this strategy, the selected item will always be positioned at the
38
+ * beginning of the _scroll offset_ area.
39
+ */
40
+ ListSelectionStrategy[ListSelectionStrategy["ANCHORED"] = 1] = "ANCHORED";
41
+ /**
42
+ * This strategy will force the list component to scroll if the next selected
43
+ * item crosses the pinned position defined in the configuration. Differently
44
+ * from the {@link ANCHORED} strategy though, the `PINNED` strategy will not
45
+ * make the list scroll its contents if the last (or first) item in the list
46
+ * is already positioned at the scroll offset position.
47
+ *
48
+ * The `PINNED` behavior can be defined by the following:
49
+ *
50
+ * - If the list is rendering its start, and the selected itm is _before_ the
51
+ * configured pinned position, selecting the next item will simply **move**
52
+ * the selection to the next item without making the component scroll its
53
+ * contents;
54
+ *
55
+ * - If the list is rendering its end, and the selected item is _after_ the
56
+ * configured pinned position, selecting the previous item will simply
57
+ * **move** the selection to the previous item without making the component
58
+ * scroll its contents;
59
+ *
60
+ * - If selecting the _next_ or _previous_ item, makes the selection cross the
61
+ * configured pinned position, the selection will move to the target item.
62
+ * The list will scroll its contents, so the selected item is centralized
63
+ * in the configured pinned position.
64
+ *
65
+ * - If the selected item is centralized at the configured pinned position,
66
+ * and the first or last items are not positioned on the _edge_ of the
67
+ * scroll offset area, any selection change will cause the list to scroll
68
+ * its contents to keep the selected item centralized at the configured
69
+ * pinned position;
70
+ *
71
+ * - When the last (or first) item in the list is positioned at the edge of
72
+ * the scroll-offset area, changing the selection towards that edge will
73
+ * make the selection to move and not the contents to scroll;
74
+ */
75
+ ListSelectionStrategy[ListSelectionStrategy["PINNED"] = 2] = "PINNED";
76
+ })(ListSelectionStrategy = exports.ListSelectionStrategy || (exports.ListSelectionStrategy = {}));
77
+ /**
78
+ * Enumeration used to represent the type of scale origin strategy supported by the
79
+ * list. Currently only scaling from top-left and center is supported
80
+ */
81
+ var ScaleOriginStrategy;
82
+ (function (ScaleOriginStrategy) {
83
+ ScaleOriginStrategy[ScaleOriginStrategy["TOP_LEFT"] = 0] = "TOP_LEFT";
84
+ ScaleOriginStrategy[ScaleOriginStrategy["CENTER"] = 1] = "CENTER";
85
+ })(ScaleOriginStrategy = exports.ScaleOriginStrategy || (exports.ScaleOriginStrategy = {}));
86
+ /**
87
+ * Enumeration used to represent different border rendering strategies for selection borders.
88
+ */
89
+ var CarouselBorderStrategy;
90
+ (function (CarouselBorderStrategy) {
91
+ /**
92
+ * Border is outside original content bounds and content stays the same size.
93
+ * This increases item size to include the border and then shrinks content back to its original size.
94
+ */
95
+ CarouselBorderStrategy[CarouselBorderStrategy["OUTSET"] = 0] = "OUTSET";
96
+ /**
97
+ * Border within the original content bounds and content remains the same size so border overlays content.
98
+ */
99
+ CarouselBorderStrategy[CarouselBorderStrategy["INSET"] = 1] = "INSET";
100
+ })(CarouselBorderStrategy = exports.CarouselBorderStrategy || (exports.CarouselBorderStrategy = {}));
101
+ /**
102
+ * Helper function to convert SelectionBorderStrategy string to CarouselBorderStrategy enum.
103
+ * @param strategy The string strategy to convert
104
+ * @returns The corresponding CarouselBorderStrategy enum value
105
+ */
106
+ function selectionBorderStrategyToBorderStrategy(strategy) {
107
+ switch (strategy) {
108
+ case 'inset':
109
+ return CarouselBorderStrategy.INSET;
110
+ case 'outset':
111
+ return CarouselBorderStrategy.OUTSET;
112
+ default:
113
+ return CarouselBorderStrategy.OUTSET; // Default fallback
114
+ }
115
+ }
116
+ exports.selectionBorderStrategyToBorderStrategy = selectionBorderStrategyToBorderStrategy;