@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,71 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CarouselScrollableRef } from './CarouselScrollableRef';
|
|
3
|
+
import { CarouselSimpleProps } from './CarouselSimpleProps';
|
|
4
|
+
/**
|
|
5
|
+
* Type alias for a `CarouselScrollable` reference, since both versions of the list
|
|
6
|
+
* should support the same user API.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link CarouselScrollableRef}
|
|
9
|
+
*/
|
|
10
|
+
export type CarouselSimpleRef = CarouselScrollableRef;
|
|
11
|
+
/**
|
|
12
|
+
* The internal implementation of the {@link CarouselSimple} component.
|
|
13
|
+
*
|
|
14
|
+
* This implementation basically wraps a {@link CarouselScrollable} component for using
|
|
15
|
+
* it with a simple array of `ItemT` items.
|
|
16
|
+
*
|
|
17
|
+
* @see {@link CarouselSimple}
|
|
18
|
+
* @see {@link CarouselScrollable}
|
|
19
|
+
* @see {@link CarouselScrollableRef}
|
|
20
|
+
*/
|
|
21
|
+
declare function CarouselSimpleInner<ItemT, KeyT = React.Key>(props: CarouselSimpleProps<ItemT, KeyT>, ref?: React.Ref<CarouselSimpleRef>): React.JSX.Element;
|
|
22
|
+
/**
|
|
23
|
+
* `CarouselSimple` is a wrapper around the {@link CarouselScrollable} component that
|
|
24
|
+
* focuses on simplicity over control.
|
|
25
|
+
*
|
|
26
|
+
* The goal of `CarouselSimple` is to define some opinionated and simple
|
|
27
|
+
* defaults for the {@link CarouselScrollable}.
|
|
28
|
+
*
|
|
29
|
+
* To start, the `CarouselSimple` requires a mandatory array of items
|
|
30
|
+
* (`ItemT[]`), and it will use it as a static data provider.
|
|
31
|
+
*
|
|
32
|
+
* You can certainly update the items in this component and achieve most of the
|
|
33
|
+
* behavior from {@link CarouselScrollable}, but if you realize that you're having to
|
|
34
|
+
* write a significant amount of code to do so, consider using {@link CarouselScrollable}
|
|
35
|
+
* directly.
|
|
36
|
+
*
|
|
37
|
+
* The next significant default used by `CarouselSimple`, is how it handles
|
|
38
|
+
* item's unique identifiers (or _keys_).
|
|
39
|
+
*
|
|
40
|
+
* By default, it will be a number equal to the item's index in the data array,
|
|
41
|
+
* but you can customize it to some special behavior that would give the
|
|
42
|
+
* component the stable IDs it needs.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* The following snippet represents the `CarouselSimple` usage in its basic
|
|
46
|
+
* form:
|
|
47
|
+
* ```tsx
|
|
48
|
+
* function MyComponent(dataArray: MyDataItem[]) {
|
|
49
|
+
* const renderItem = React.useCallback(
|
|
50
|
+
* (item: MyDataItem) => <View>{item.render()}</View>
|
|
51
|
+
* []
|
|
52
|
+
* )
|
|
53
|
+
* return (
|
|
54
|
+
* <CarouselSimple
|
|
55
|
+
* data={dataArray}
|
|
56
|
+
* renderItem={renderItem} />
|
|
57
|
+
* )
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* If you need to use a different type of _key_ with the component, make sure
|
|
62
|
+
* you provide the proper implementation of the `getItemKey` function.
|
|
63
|
+
*
|
|
64
|
+
* For details on those, check their documentation.
|
|
65
|
+
*
|
|
66
|
+
* @see {@link CarouselSimpleInner}
|
|
67
|
+
* @see {@link CarouselSimpleProps}
|
|
68
|
+
* @see {@link CarouselSimpleRef}
|
|
69
|
+
*/
|
|
70
|
+
export declare const CarouselSimple: <ItemT, KeyT = string>(props: CarouselSimpleProps<ItemT, KeyT>, ref?: React.Ref<CarouselSimpleRef>) => React.JSX.Element;
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.CarouselSimple = void 0;
|
|
12
|
+
const react_1 = __importDefault(require("react"));
|
|
13
|
+
const CarouselScrollable_1 = require("./CarouselScrollable");
|
|
14
|
+
/**
|
|
15
|
+
* The internal implementation of the {@link CarouselSimple} component.
|
|
16
|
+
*
|
|
17
|
+
* This implementation basically wraps a {@link CarouselScrollable} component for using
|
|
18
|
+
* it with a simple array of `ItemT` items.
|
|
19
|
+
*
|
|
20
|
+
* @see {@link CarouselSimple}
|
|
21
|
+
* @see {@link CarouselScrollable}
|
|
22
|
+
* @see {@link CarouselScrollableRef}
|
|
23
|
+
*/
|
|
24
|
+
function CarouselSimpleInner(props, ref) {
|
|
25
|
+
const { data, getItemKey: getItemKeyProp } = props;
|
|
26
|
+
const hostRef = react_1.default.useRef(null);
|
|
27
|
+
react_1.default.useImperativeHandle(ref, () => {
|
|
28
|
+
// noinspection JSUnusedGlobalSymbols
|
|
29
|
+
return {
|
|
30
|
+
enableInputEvents(enable) {
|
|
31
|
+
if (hostRef.current) {
|
|
32
|
+
hostRef.current.enableInputEvents(enable);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
reset() {
|
|
36
|
+
if (hostRef.current) {
|
|
37
|
+
hostRef.current.reset();
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
setSelectedItem(index, animated) {
|
|
41
|
+
if (hostRef.current) {
|
|
42
|
+
hostRef.current.setSelectedItem(index, animated);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
setOverflowItemsVisible(visible, animated) {
|
|
46
|
+
if (hostRef.current) {
|
|
47
|
+
hostRef.current.setOverflowItemsVisible(visible, animated === true);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
notifyDataChange(changes, animated) {
|
|
51
|
+
if (hostRef.current) {
|
|
52
|
+
hostRef.current.notifyDataChange(changes, animated === true);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
const getItem = react_1.default.useCallback((index) => data[index], [data]);
|
|
58
|
+
const getItemCount = react_1.default.useCallback(() => data.length, [data]);
|
|
59
|
+
const getItemKey = react_1.default.useCallback((item, index) => getItemKeyProp?.(item, index) ?? index, [getItemKeyProp]);
|
|
60
|
+
const notifyDataError = react_1.default.useCallback(() => false, []);
|
|
61
|
+
return (react_1.default.createElement(CarouselScrollable_1.CarouselScrollable, { ...props, getItem: getItem, getItemCount: getItemCount, getItemKey: getItemKey, notifyDataError: notifyDataError, ref: hostRef }));
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* `CarouselSimple` is a wrapper around the {@link CarouselScrollable} component that
|
|
65
|
+
* focuses on simplicity over control.
|
|
66
|
+
*
|
|
67
|
+
* The goal of `CarouselSimple` is to define some opinionated and simple
|
|
68
|
+
* defaults for the {@link CarouselScrollable}.
|
|
69
|
+
*
|
|
70
|
+
* To start, the `CarouselSimple` requires a mandatory array of items
|
|
71
|
+
* (`ItemT[]`), and it will use it as a static data provider.
|
|
72
|
+
*
|
|
73
|
+
* You can certainly update the items in this component and achieve most of the
|
|
74
|
+
* behavior from {@link CarouselScrollable}, but if you realize that you're having to
|
|
75
|
+
* write a significant amount of code to do so, consider using {@link CarouselScrollable}
|
|
76
|
+
* directly.
|
|
77
|
+
*
|
|
78
|
+
* The next significant default used by `CarouselSimple`, is how it handles
|
|
79
|
+
* item's unique identifiers (or _keys_).
|
|
80
|
+
*
|
|
81
|
+
* By default, it will be a number equal to the item's index in the data array,
|
|
82
|
+
* but you can customize it to some special behavior that would give the
|
|
83
|
+
* component the stable IDs it needs.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* The following snippet represents the `CarouselSimple` usage in its basic
|
|
87
|
+
* form:
|
|
88
|
+
* ```tsx
|
|
89
|
+
* function MyComponent(dataArray: MyDataItem[]) {
|
|
90
|
+
* const renderItem = React.useCallback(
|
|
91
|
+
* (item: MyDataItem) => <View>{item.render()}</View>
|
|
92
|
+
* []
|
|
93
|
+
* )
|
|
94
|
+
* return (
|
|
95
|
+
* <CarouselSimple
|
|
96
|
+
* data={dataArray}
|
|
97
|
+
* renderItem={renderItem} />
|
|
98
|
+
* )
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* If you need to use a different type of _key_ with the component, make sure
|
|
103
|
+
* you provide the proper implementation of the `getItemKey` function.
|
|
104
|
+
*
|
|
105
|
+
* For details on those, check their documentation.
|
|
106
|
+
*
|
|
107
|
+
* @see {@link CarouselSimpleInner}
|
|
108
|
+
* @see {@link CarouselSimpleProps}
|
|
109
|
+
* @see {@link CarouselSimpleRef}
|
|
110
|
+
*/
|
|
111
|
+
exports.CarouselSimple = react_1.default.forwardRef(CarouselSimpleInner);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CarouselScrollableProps } from './CarouselScrollableProps';
|
|
3
|
+
import { GetItemKeyFunc } from '../CarouselData';
|
|
4
|
+
/**
|
|
5
|
+
* Configurable properties of a {@link CarouselSimple}.
|
|
6
|
+
*
|
|
7
|
+
* Any change in the attributes of this interface will result in a visual or
|
|
8
|
+
* behavioral change of the affected list.
|
|
9
|
+
*
|
|
10
|
+
* These properties are a subset of the `CarouselScrollableProps` that allow us to
|
|
11
|
+
* have the minimal number of mandatory properties for the user.
|
|
12
|
+
*
|
|
13
|
+
* @template ItemT The type of data items the list will use to render its items.
|
|
14
|
+
* @template KeyT The type used as items unique identifiers (also called _keys_,
|
|
15
|
+
* or _stable IDs_) in the list;
|
|
16
|
+
*
|
|
17
|
+
* @see {@link CarouselSimple}
|
|
18
|
+
*/
|
|
19
|
+
export interface CarouselSimpleProps<ItemT, KeyT = React.Key> extends Omit<CarouselScrollableProps<ItemT, KeyT>, 'getItem' | 'getItemKey' | 'notifyDataError' | 'registerDataObserver' | 'dataAdapter'> {
|
|
20
|
+
data: Array<ItemT>;
|
|
21
|
+
/**
|
|
22
|
+
* Optional function that takes an item and its index, and returns its key.
|
|
23
|
+
*
|
|
24
|
+
* @function
|
|
25
|
+
* @default (item: ItemT, index: number) => index as KeyT
|
|
26
|
+
* @see {@link GetItemKeyFunc}
|
|
27
|
+
*/
|
|
28
|
+
getItemKey?: GetItemKeyFunc<ItemT, KeyT>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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("./CarouselScrollableTypes"), exports);
|
|
23
|
+
__exportStar(require("./CarouselScrollableProps"), exports);
|
|
24
|
+
__exportStar(require("./CarouselScrollableRef"), exports);
|
|
25
|
+
__exportStar(require("./CarouselScrollable"), exports);
|
|
26
|
+
__exportStar(require("./CarouselSimple"), exports);
|
|
27
|
+
__exportStar(require("./CarouselSimpleProps"), exports);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { HostComponent, ViewProps, NativeSyntheticEvent } from 'react-native';
|
|
2
|
+
import { CarouselDataChange } from '../../CarouselData';
|
|
3
|
+
import { CarouselScrollableConfigProps, CarouselScrollableInfoProps } from '../CarouselScrollableProps';
|
|
4
|
+
/**
|
|
5
|
+
* Type representing a native "Selection Changed" event that is emitted from the
|
|
6
|
+
* native layer.
|
|
7
|
+
*/
|
|
8
|
+
export type CarouselNativeHostComponentInternalSelectionChangedEvent = {
|
|
9
|
+
/**
|
|
10
|
+
* The current index of the first item mounted on the native {@link CarouselScrollable}
|
|
11
|
+
* component.
|
|
12
|
+
*/
|
|
13
|
+
renderFirstIndex: number;
|
|
14
|
+
/**
|
|
15
|
+
* The current index of the last item mounted on the native {@link CarouselScrollable}
|
|
16
|
+
* component.
|
|
17
|
+
*/
|
|
18
|
+
renderLastIndex: number;
|
|
19
|
+
/**
|
|
20
|
+
* The data index for the item that just got selected in the native layer.
|
|
21
|
+
*/
|
|
22
|
+
selectedIndex: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The "selection changed" event emitted by the native layer.
|
|
26
|
+
*
|
|
27
|
+
* Check the internal type documentation
|
|
28
|
+
* ({@link CarouselNativeHostComponentInternalSelectionChangedEvent}) for
|
|
29
|
+
* details.
|
|
30
|
+
*
|
|
31
|
+
* @see {@link CarouselNativeHostComponentInternalSelectionChangedEvent}
|
|
32
|
+
*/
|
|
33
|
+
export type CarouselNativeHostComponentSelectionChangedEvent = NativeSyntheticEvent<CarouselNativeHostComponentInternalSelectionChangedEvent>;
|
|
34
|
+
/**
|
|
35
|
+
* This type represents the native "Selection Change" event callback function
|
|
36
|
+
* the framework call when it receives the "Selection Change" event from the
|
|
37
|
+
* native layer.
|
|
38
|
+
*
|
|
39
|
+
* @param {CarouselNativeHostComponentSelectionChangedEvent} nativeEvent The
|
|
40
|
+
* framework native component event that wraps our "Selection Change"
|
|
41
|
+
* event before delivering it to the callback function.
|
|
42
|
+
*
|
|
43
|
+
* @see {@link CarouselNativeHostComponentSelectionChangedEvent}
|
|
44
|
+
*/
|
|
45
|
+
export type OnCarouselNativeHostComponentSelectionChangedCallback = (nativeEvent: CarouselNativeHostComponentSelectionChangedEvent) => void;
|
|
46
|
+
/**
|
|
47
|
+
* This type represents all values that can be passed to the native component on
|
|
48
|
+
* a JSX declaration.
|
|
49
|
+
*
|
|
50
|
+
* Note, though, that these properties will not all be passed down to the native
|
|
51
|
+
* layer. Only properties with `true` values from the `validAttributes` object,
|
|
52
|
+
* passed to the {@link registerGeneratedViewConfig} will be attempted to be
|
|
53
|
+
* passed down. React Native might still decide to not forward a property if it
|
|
54
|
+
* uses some of the reserved names (e.g.; "id").
|
|
55
|
+
*
|
|
56
|
+
* @see {@link ViewProps}
|
|
57
|
+
* @see {@link CarouselScrollableConfigProps}
|
|
58
|
+
*/
|
|
59
|
+
export type CarouselNativeHostComponentProps = Omit<ViewProps, 'id'> & CarouselScrollableInfoProps & Omit<CarouselScrollableConfigProps, 'focusedItemScaleFactor' | 'shiftItemsOnSelection' | 'scaleOnPress'> & {
|
|
60
|
+
relativeInitialStartIndex: number;
|
|
61
|
+
dataStartIndex: number;
|
|
62
|
+
dataLimitIndex: number;
|
|
63
|
+
scaleItemOnPress: boolean;
|
|
64
|
+
scaleItemOnSelection: boolean;
|
|
65
|
+
shiftItemsOnSelection: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Callback function called whenever the Native Component emits the
|
|
68
|
+
* `selectionChanged` event.
|
|
69
|
+
*
|
|
70
|
+
* @see {@link OnCarouselNativeHostComponentSelectionChangedCallback}
|
|
71
|
+
*
|
|
72
|
+
*/
|
|
73
|
+
onSelectionChanged: OnCarouselNativeHostComponentSelectionChangedCallback;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Helper constant to be used as the JSX component for the Native List Component
|
|
77
|
+
* in this package.
|
|
78
|
+
*/
|
|
79
|
+
export declare const CarouselNativeHostComponent: HostComponent<CarouselNativeHostComponentProps>;
|
|
80
|
+
/**
|
|
81
|
+
* Contract type for the Native Component accepted commands.
|
|
82
|
+
*
|
|
83
|
+
* For details on what each function her do, check the {@link CarouselScrollableRef}
|
|
84
|
+
* documentation.
|
|
85
|
+
*
|
|
86
|
+
* @see {@link CarouselNativeHostComponentCommandsDefaults}
|
|
87
|
+
* @see {@link CarouselScrollableRef}
|
|
88
|
+
*/
|
|
89
|
+
export type CarouselNativeHostComponentCommandsContract = {
|
|
90
|
+
enableInputEvents: (hostComponent: HostComponent<CarouselNativeHostComponentProps>, enable: boolean) => void;
|
|
91
|
+
setSelectedItem: (hostComponent: HostComponent<CarouselNativeHostComponentProps>, index: number, animated: boolean) => void;
|
|
92
|
+
setOverflowItemsVisible: (hostComponent: HostComponent<CarouselNativeHostComponentProps>, visible: boolean, animated?: boolean) => void;
|
|
93
|
+
notifyDataChange: (hostComponent: HostComponent<CarouselNativeHostComponentProps>, changes: Array<CarouselDataChange>, animated?: boolean) => void;
|
|
94
|
+
reset: (hostComponent: HostComponent<CarouselNativeHostComponentProps>) => void;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Helper constant to register the
|
|
98
|
+
* {@link CarouselNativeHostComponentCommandsContract} as native functions.
|
|
99
|
+
*
|
|
100
|
+
* This has no use during run-time, but it exists to strongly type our commands
|
|
101
|
+
* function, since any modern IDE would highlight an error if one adds or
|
|
102
|
+
* removes a function from the contract.
|
|
103
|
+
*/
|
|
104
|
+
export declare const CarouselNativeHostComponentCommandsDefaults: CarouselNativeHostComponentCommandsContract;
|
|
105
|
+
/**
|
|
106
|
+
* This constant holds the Native Turbo Module RPC interface for the available
|
|
107
|
+
* commands on the {@link CarouselNativeHostComponent}.
|
|
108
|
+
*/
|
|
109
|
+
export declare const CarouselNativeHostComponentCommands: CarouselNativeHostComponentCommandsContract;
|
|
@@ -0,0 +1,82 @@
|
|
|
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.CarouselNativeHostComponentCommands = exports.CarouselNativeHostComponentCommandsDefaults = exports.CarouselNativeHostComponent = void 0;
|
|
9
|
+
const utils_1 = require("../../utils");
|
|
10
|
+
/**
|
|
11
|
+
* Constant holding the Native Carousel component to be used in JSX
|
|
12
|
+
* declarations.
|
|
13
|
+
*/
|
|
14
|
+
const nativeComponentName = 'CarouselNative';
|
|
15
|
+
const validAttributes = {
|
|
16
|
+
uniqueId: true,
|
|
17
|
+
orientation: true,
|
|
18
|
+
renderedItemsCount: true,
|
|
19
|
+
navigableScrollOffset: true,
|
|
20
|
+
itemPadding: true,
|
|
21
|
+
itemPaddingOnFocus: true,
|
|
22
|
+
initialStartIndex: true,
|
|
23
|
+
relativeInitialStartIndex: true,
|
|
24
|
+
numOffsetItems: true,
|
|
25
|
+
showSelectionBorder: true,
|
|
26
|
+
selectionBorderStyle: true,
|
|
27
|
+
selectionBorderStrategy: true,
|
|
28
|
+
trapFocusOnOrientation: true,
|
|
29
|
+
offsetNestedSelectionShift: true,
|
|
30
|
+
scaleItemOnPress: true,
|
|
31
|
+
scaleItemOnSelection: true,
|
|
32
|
+
shiftItemsOnSelection: true,
|
|
33
|
+
selectionStrategy: true,
|
|
34
|
+
pinnedFocusOffset: true,
|
|
35
|
+
hideItemsBeforeSelection: true,
|
|
36
|
+
discardLastFocus: true,
|
|
37
|
+
scaleOrigin: true,
|
|
38
|
+
shouldSelectedOverlap: true,
|
|
39
|
+
itemPressedDuration: true,
|
|
40
|
+
itemScrollDuration: true,
|
|
41
|
+
containerFocusChangeDuration: true,
|
|
42
|
+
dataStartIndex: true,
|
|
43
|
+
dataLimitIndex: true,
|
|
44
|
+
hasPreferredFocus: true,
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Helper constant to be used as the JSX component for the Native List Component
|
|
48
|
+
* in this package.
|
|
49
|
+
*/
|
|
50
|
+
exports.CarouselNativeHostComponent = nativeComponentName;
|
|
51
|
+
/**
|
|
52
|
+
* Helper constant to register the
|
|
53
|
+
* {@link CarouselNativeHostComponentCommandsContract} as native functions.
|
|
54
|
+
*
|
|
55
|
+
* This has no use during run-time, but it exists to strongly type our commands
|
|
56
|
+
* function, since any modern IDE would highlight an error if one adds or
|
|
57
|
+
* removes a function from the contract.
|
|
58
|
+
*/
|
|
59
|
+
exports.CarouselNativeHostComponentCommandsDefaults = {
|
|
60
|
+
enableInputEvents: () => { },
|
|
61
|
+
notifyDataChange: () => { },
|
|
62
|
+
setOverflowItemsVisible: () => { },
|
|
63
|
+
setSelectedItem: () => { },
|
|
64
|
+
reset: () => { },
|
|
65
|
+
};
|
|
66
|
+
// With our properties and component name defined, we can register it as a
|
|
67
|
+
// native component on the React Native framework.
|
|
68
|
+
(0, utils_1.registerGeneratedViewConfig)(nativeComponentName, {
|
|
69
|
+
uiViewClassName: nativeComponentName,
|
|
70
|
+
validAttributes,
|
|
71
|
+
directEventTypes: (0, utils_1.buildDirectEvents)({
|
|
72
|
+
selectionChanged: 'top',
|
|
73
|
+
pivotChanged: 'top',
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* This constant holds the Native Turbo Module RPC interface for the available
|
|
78
|
+
* commands on the {@link CarouselNativeHostComponent}.
|
|
79
|
+
*/
|
|
80
|
+
exports.CarouselNativeHostComponentCommands = (0, utils_1.codegenNativeCommands)({
|
|
81
|
+
supportedCommands: Object.keys(exports.CarouselNativeHostComponentCommandsDefaults),
|
|
82
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { HostComponent, ViewProps, NativeSyntheticEvent } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* Type representing a native "Bind" event that is emitted from the native
|
|
4
|
+
* layer.
|
|
5
|
+
*/
|
|
6
|
+
export type CarouselNativeItemHostComponentInternalBindEvent = {
|
|
7
|
+
/**
|
|
8
|
+
* The target index for the bind.
|
|
9
|
+
*/
|
|
10
|
+
index: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Type representing a native "Refresh" event that is emitted from the native
|
|
14
|
+
* layer.
|
|
15
|
+
*/
|
|
16
|
+
export type CarouselNativeItemHostComponentInternalRefreshEvent = {
|
|
17
|
+
/**
|
|
18
|
+
* Optional target index for the refresh.
|
|
19
|
+
*/
|
|
20
|
+
index?: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The "Bind" event emitted by the native layer.
|
|
24
|
+
*
|
|
25
|
+
* Check the internal type documentation
|
|
26
|
+
* ({@link CarouselNativeItemHostComponentInternalBindEvent}) for details.
|
|
27
|
+
*
|
|
28
|
+
* @see {@link CarouselNativeItemHostComponentInternalBindEvent}
|
|
29
|
+
*/
|
|
30
|
+
export type CarouselNativeItemHostComponentBindEvent = NativeSyntheticEvent<CarouselNativeItemHostComponentInternalBindEvent>;
|
|
31
|
+
/**
|
|
32
|
+
* The "Refresh" event emitted by the native layer.
|
|
33
|
+
*
|
|
34
|
+
* Check the internal type documentation
|
|
35
|
+
* ({@link CarouselNativeItemHostComponentInternalRefreshEvent}) for details.
|
|
36
|
+
*
|
|
37
|
+
* @see {@link CarouselNativeItemHostComponentInternalRefreshEvent}
|
|
38
|
+
*/
|
|
39
|
+
export type CarouselNativeItemHostComponentRefreshEvent = NativeSyntheticEvent<CarouselNativeItemHostComponentInternalRefreshEvent>;
|
|
40
|
+
/**
|
|
41
|
+
* This type represents all values that can be passed to the native component on
|
|
42
|
+
* a JSX declaration.
|
|
43
|
+
*
|
|
44
|
+
* Note, though, that these properties will not all be passed down to the native
|
|
45
|
+
* layer. Only properties with `true` values from the `validAttributes` object,
|
|
46
|
+
* passed to the {@link registerGeneratedViewConfig} will be attempted to be
|
|
47
|
+
* passed down. React Native might still decide to not forward a property if it
|
|
48
|
+
* uses some of the reserved names (e.g.; "id").
|
|
49
|
+
*
|
|
50
|
+
* @see {@link ViewProps}
|
|
51
|
+
*/
|
|
52
|
+
export interface CarouselNativeItemHostComponentProps extends Omit<ViewProps, 'id'> {
|
|
53
|
+
parentId?: string;
|
|
54
|
+
/**
|
|
55
|
+
* The data index associated with this item component.
|
|
56
|
+
*/
|
|
57
|
+
dataIndex?: number;
|
|
58
|
+
showSelectionBorder: boolean;
|
|
59
|
+
selectionBorderWidth: number;
|
|
60
|
+
selectionBorderRadius: number;
|
|
61
|
+
selectionBorderColor: number;
|
|
62
|
+
selectionBorderStrokeWidth: number;
|
|
63
|
+
selectionBorderStrokeRadius: number;
|
|
64
|
+
selectionBorderStrokeColor: number;
|
|
65
|
+
selectionBorderStrategy: number;
|
|
66
|
+
/**
|
|
67
|
+
* A scale multiplier to be applied to this item component when it gets
|
|
68
|
+
* activated (e.g., the user presses down the select button on the device's
|
|
69
|
+
* remote control).
|
|
70
|
+
*/
|
|
71
|
+
pressedItemScaleFactor: number;
|
|
72
|
+
/**
|
|
73
|
+
* A scale multiplier to be applied to this item component when it gets
|
|
74
|
+
* selected.
|
|
75
|
+
*/
|
|
76
|
+
focusedItemScaleFactor: number;
|
|
77
|
+
shiftItemsWidthScaleFactor: number;
|
|
78
|
+
shiftItemsHeightScaleFactor: number;
|
|
79
|
+
/**
|
|
80
|
+
* Callback called by the native layer whenever it needs to request this item
|
|
81
|
+
* to be bound to a different index.
|
|
82
|
+
*
|
|
83
|
+
* @param {CarouselNativeItemHostComponentBindEvent} nativeEvent The native
|
|
84
|
+
* event object.
|
|
85
|
+
*
|
|
86
|
+
* @see {@link CarouselNativeItemHostComponentBindEvent}
|
|
87
|
+
*/
|
|
88
|
+
onBind: (nativeEvent: CarouselNativeItemHostComponentBindEvent) => void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Helper constant to be used as the JSX component for a Native List Component
|
|
92
|
+
* Item in this package.
|
|
93
|
+
*/
|
|
94
|
+
export declare const CarouselNativeItemHost: HostComponent<CarouselNativeItemHostComponentProps>;
|
|
@@ -0,0 +1,42 @@
|
|
|
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.CarouselNativeItemHost = void 0;
|
|
9
|
+
const utils_1 = require("../../utils");
|
|
10
|
+
/**
|
|
11
|
+
* Constant holding the Native Carousel component to be used in JSX
|
|
12
|
+
* declarations.
|
|
13
|
+
*/
|
|
14
|
+
const nativeComponentName = 'CarouselNativeItem';
|
|
15
|
+
const validAttributes = {
|
|
16
|
+
parentId: true,
|
|
17
|
+
dataIndex: true,
|
|
18
|
+
showSelectionBorder: true,
|
|
19
|
+
selectionBorderWidth: true,
|
|
20
|
+
selectionBorderRadius: true,
|
|
21
|
+
selectionBorderColor: true,
|
|
22
|
+
selectionBorderStrokeWidth: true,
|
|
23
|
+
selectionBorderStrokeRadius: true,
|
|
24
|
+
selectionBorderStrokeColor: true,
|
|
25
|
+
selectionBorderStrategy: true,
|
|
26
|
+
pressedItemScaleFactor: true,
|
|
27
|
+
focusedItemScaleFactor: true,
|
|
28
|
+
shiftItemsWidthScaleFactor: true,
|
|
29
|
+
shiftItemsHeightScaleFactor: true,
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Helper constant to be used as the JSX component for a Native List Component
|
|
33
|
+
* Item in this package.
|
|
34
|
+
*/
|
|
35
|
+
exports.CarouselNativeItemHost = nativeComponentName;
|
|
36
|
+
// With our properties and component name defined, we can register it as a
|
|
37
|
+
// native component on the React Native framework.
|
|
38
|
+
(0, utils_1.registerGeneratedViewConfig)(nativeComponentName, {
|
|
39
|
+
uiViewClassName: nativeComponentName,
|
|
40
|
+
validAttributes,
|
|
41
|
+
directEventTypes: (0, utils_1.buildDirectEvents)({ bind: 'top' }),
|
|
42
|
+
});
|